From 54a52c87d5ac1a246e99f2574284031d7af4a4d7 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Sun, 28 Jul 2019 13:05:31 -0400 Subject: [PATCH] Figure out if device has touch control --- src/QGCApplication.h | 2 +- src/QmlControls/ScreenToolsController.cc | 6 ++++++ src/QmlControls/ScreenToolsController.h | 7 +++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/QGCApplication.h b/src/QGCApplication.h index 7b93c54dc9..c48edcb482 100644 --- a/src/QGCApplication.h +++ b/src/QGCApplication.h @@ -79,7 +79,7 @@ public: void showMessage(const QString& message); /// @return true: Fake ui into showing mobile interface - bool fakeMobile(void) { return _fakeMobile; } + bool fakeMobile(void) const { return _fakeMobile; } // Still working on getting rid of this and using dependency injection instead for everything QGCToolbox* toolbox(void) { return _toolbox; } diff --git a/src/QmlControls/ScreenToolsController.cc b/src/QmlControls/ScreenToolsController.cc index 6a219e154e..408f967390 100644 --- a/src/QmlControls/ScreenToolsController.cc +++ b/src/QmlControls/ScreenToolsController.cc @@ -26,6 +26,12 @@ ScreenToolsController::ScreenToolsController() } +bool +ScreenToolsController::hasTouch() const +{ + return QTouchDevice::devices().count() > 0 || isMobile(); +} + QString ScreenToolsController::iOSDevice() const { diff --git a/src/QmlControls/ScreenToolsController.h b/src/QmlControls/ScreenToolsController.h index cb665870c7..71f5788df6 100644 --- a/src/QmlControls/ScreenToolsController.h +++ b/src/QmlControls/ScreenToolsController.h @@ -37,6 +37,7 @@ public: Q_PROPERTY(bool isLinux READ isLinux CONSTANT) Q_PROPERTY(bool isWindows READ isWindows CONSTANT) Q_PROPERTY(bool isSerialAvailable READ isSerialAvailable CONSTANT) + Q_PROPERTY(bool hasTouch READ hasTouch CONSTANT) Q_PROPERTY(QString iOSDevice READ iOSDevice CONSTANT) Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily CONSTANT) Q_PROPERTY(QString normalFontFamily READ normalFontFamily CONSTANT) @@ -47,9 +48,9 @@ public: Q_INVOKABLE int mouseY(void) { return QCursor::pos().y(); } #if defined(__mobile__) - bool isMobile () { return true; } + bool isMobile () const { return true; } #else - bool isMobile () { return qgcApp()->fakeMobile(); } + bool isMobile () const { return qgcApp()->fakeMobile(); } #endif #if defined (Q_OS_ANDROID) @@ -102,6 +103,8 @@ public: bool isDebug () { return false; } #endif + bool hasTouch() const; + QString iOSDevice () const; QString fixedFontFamily () const; QString normalFontFamily () const; -- GitLab