QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ScreenToolsController.cc
Go to the documentation of this file.
2#include "QGCApplication.h"
4#include "SettingsManager.h"
5#include "AppSettings.h"
6
7#include <QtGui/QCursor>
8#include <QtGui/QFontDatabase>
9#include <QtGui/QFontMetrics>
10#include <QtGui/QInputDevice>
11
12#if defined(Q_OS_IOS)
13#include <sys/utsname.h>
14#endif
15
16QGC_LOGGING_CATEGORY(ScreenToolsControllerLog, "QMLControls.ScreenToolsController")
17
19 : QObject(parent)
20{
21 // qCDebug(ScreenToolsControllerLog) << Q_FUNC_INFO << this;
22}
23
24ScreenToolsController::~ScreenToolsController()
25{
26 // qCDebug(ScreenToolsControllerLog) << Q_FUNC_INFO << this;
27}
28
29int ScreenToolsController::mouseX()
30{
31 return QCursor::pos().x();
32}
33
34int ScreenToolsController::mouseY()
35{
36 return QCursor::pos().y();
37}
38
39bool ScreenToolsController::hasTouch()
40{
41 for (const auto &inputDevice: QInputDevice::devices()) {
42 if (inputDevice->type() == QInputDevice::DeviceType::TouchScreen) {
43 return true;
44 }
45 }
46 return false;
47}
48
49QString ScreenToolsController::iOSDevice()
50{
51#if defined(Q_OS_IOS)
52 struct utsname systemInfo;
53 uname(&systemInfo);
54 return QString(systemInfo.machine);
55#else
56 return QString();
57#endif
58}
59
60QString ScreenToolsController::fixedFontFamily()
61{
62 return QFontDatabase::systemFont(QFontDatabase::FixedFont).family();
63}
64
65QString ScreenToolsController::normalFontFamily()
66{
67 //-- See App.SettinsGroup.json for index
68 const int langID = SettingsManager::instance()->appSettings()->qLocaleLanguage()->rawValue().toInt();
69 if (langID == QLocale::Korean) {
70 return QStringLiteral("NanumGothic");
71 }
72
73 return QStringLiteral("Open Sans");
74}
75
76double ScreenToolsController::defaultFontDescent(int pointSize)
77{
78 return QFontMetrics(QFont(normalFontFamily(), pointSize)).descent();
79}
80
81#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
82bool ScreenToolsController::fakeMobile()
83{
84 return qgcApp()->fakeMobile();
85}
86#endif
#define qgcApp()
#define QGC_LOGGING_CATEGORY(name, categoryStr)
Fact *qLocaleLanguage READ qLocaleLanguage CONSTANT Fact * qLocaleLanguage()
This Qml control is used to return screen parameters.