From 7024a2a838ac62a40e297ce05448d716d0499b9c Mon Sep 17 00:00:00 2001 From: Damiano Date: Tue, 19 Apr 2016 21:50:51 +0200 Subject: [PATCH 1/3] dip --- .../src/cpp/HelperClasses/ApplicationHelper.cpp | 17 ++++++++++++++++- .../src/cpp/HelperClasses/ApplicationHelper.h | 8 ++++++++ MobileClient/QtProject/src/qml/Navigator.qml | 2 ++ MobileClient/QtProject/src/qml/Panel_Home.qml | 1 - .../QtProject/src/qml/Panel_NearbySpots.qml | 1 - MobileClient/QtProject/src/qml/Panel_Upload.qml | 1 - MobileClient/QtProject/src/qml/Panel_User.qml | 1 - .../src/qml/widgets/TabWidgetBottom.qml | 4 +++- 8 files changed, 29 insertions(+), 6 deletions(-) diff --git a/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp b/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp index 8ae067c..b08c0a2 100644 --- a/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp +++ b/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp @@ -19,9 +19,10 @@ #include "../WebApi/WebApi.h" // Qt includes ----------------------------- -#include #include +#include #include +#include //----------------------------------------------------------------------------------------------------------------------------- @@ -43,6 +44,9 @@ ApplicationHelper::ApplicationHelper(Settings *settings, PlateformDetail *platef .arg(buildTimestamp()) .arg(m_PlateformDetail->name())); + // Log phisical dpi + Logger::info(QString::number(QApplication::screens().at(0)->physicalDotsPerInch())); + // Check if newer version was installed if(m_Settings->get_Application_LastVersion() != QApplication::applicationVersion()) { @@ -72,6 +76,17 @@ ApplicationHelper::~ApplicationHelper() } +int ApplicationHelper::dip() +{ + return QApplication::screens().at(0)->physicalDotsPerInch() / 108.0; +} + +void ApplicationHelper::setDip(int dip) +{ + + emit signal_Dip_Changed(); +} + //----------------------------------------------------------------------------------------------------------------------------- QString ApplicationHelper::version() const diff --git a/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.h b/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.h index 2d81ba0..c99400f 100644 --- a/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.h +++ b/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.h @@ -28,18 +28,26 @@ class ApplicationHelper : public QObject { Q_OBJECT + Q_PROPERTY(double dip READ dip WRITE setDip NOTIFY signal_Dip_Changed) + public: explicit ApplicationHelper(Settings *settings, PlateformDetail *plateformDetail, QObject *parent = 0); ~ApplicationHelper(); + int dip(); + + void setDip(int dip); + signals: void signal_NewClientVersionAvailable(); void signal_DevelopmentMode_Changed(bool developmentMode); + void signal_Dip_Changed(); + public slots: // Version diff --git a/MobileClient/QtProject/src/qml/Navigator.qml b/MobileClient/QtProject/src/qml/Navigator.qml index 45b210f..bc3309c 100644 --- a/MobileClient/QtProject/src/qml/Navigator.qml +++ b/MobileClient/QtProject/src/qml/Navigator.qml @@ -16,8 +16,10 @@ Rectangle { signal continueClicked signal menuClicked + height: text_Title.height * 2 z: 2 // so flickable doesn't draw on top + color: ( mouseBack.pressed || mouseContinue.pressed || mouseMenu.pressed ) ? Qt.lighter(hc_Application.color_BackgroundNavigator(), 1.2) diff --git a/MobileClient/QtProject/src/qml/Panel_Home.qml b/MobileClient/QtProject/src/qml/Panel_Home.qml index f99ffe4..156a539 100644 --- a/MobileClient/QtProject/src/qml/Panel_Home.qml +++ b/MobileClient/QtProject/src/qml/Panel_Home.qml @@ -29,7 +29,6 @@ Item { anchors.top: parent.top width: parent.width - height: 40 title : (stackView.currentItem != null) ? stackView.currentItem.navigation_Title : ""; backButtonVisible : stackView.depth > 1 diff --git a/MobileClient/QtProject/src/qml/Panel_NearbySpots.qml b/MobileClient/QtProject/src/qml/Panel_NearbySpots.qml index 323753a..9ca8fc4 100644 --- a/MobileClient/QtProject/src/qml/Panel_NearbySpots.qml +++ b/MobileClient/QtProject/src/qml/Panel_NearbySpots.qml @@ -67,7 +67,6 @@ Item { anchors.top: parent.top width: parent.width - height: 40 title : (stackView.currentItem != null) ? stackView.currentItem.navigation_Title : ""; backButtonVisible : stackView.depth > 1 diff --git a/MobileClient/QtProject/src/qml/Panel_Upload.qml b/MobileClient/QtProject/src/qml/Panel_Upload.qml index f7794bd..de11a0f 100644 --- a/MobileClient/QtProject/src/qml/Panel_Upload.qml +++ b/MobileClient/QtProject/src/qml/Panel_Upload.qml @@ -56,7 +56,6 @@ Item { anchors.top: parent.top width: parent.width - height: 40 title : (stackView.currentItem != null) ? stackView.currentItem.navigation_Title : ""; backButtonVisible : (stackView.currentItem != null) ? stackView.currentItem.navigation_BackButtonVisible : false; diff --git a/MobileClient/QtProject/src/qml/Panel_User.qml b/MobileClient/QtProject/src/qml/Panel_User.qml index 4e226a0..6668bcf 100644 --- a/MobileClient/QtProject/src/qml/Panel_User.qml +++ b/MobileClient/QtProject/src/qml/Panel_User.qml @@ -49,7 +49,6 @@ Item { anchors.top: parent.top width: parent.width - height: 40 title : (stackView.currentItem != null) ? stackView.currentItem.navigation_Title : ""; backButtonVisible : (stackView.currentItem != null) ? stackView.currentItem.navigation_BackButtonVisible : false; diff --git a/MobileClient/QtProject/src/qml/widgets/TabWidgetBottom.qml b/MobileClient/QtProject/src/qml/widgets/TabWidgetBottom.qml index d98f74a..666d96f 100644 --- a/MobileClient/QtProject/src/qml/widgets/TabWidgetBottom.qml +++ b/MobileClient/QtProject/src/qml/widgets/TabWidgetBottom.qml @@ -1,6 +1,7 @@ // Qt imports ------------------------------ import QtQuick 2.0 +import QtQuick.Window 2.0 // Project qml imports --------------------- import "qrc:/qml/" @@ -61,7 +62,8 @@ Item { Repeater { model: stack.children.length delegate: TabButton { - width: tabWidgetBottom.width / stack.children.length; height: 36 + width: tabWidgetBottom.width / stack.children.length; + height: 30 * hc_Application.dip iconSource: stack.children[index].tabWidget_ButtonIconSource buttonText: stack.children[index].tabWidget_ButtonText From 30db0ed2e5867118dde207200509cd75ecd121d0 Mon Sep 17 00:00:00 2001 From: Damiano Date: Wed, 20 Apr 2016 08:16:13 +0200 Subject: [PATCH 2/3] dip dip --- .../cpp/HelperClasses/ApplicationHelper.cpp | 34 +++++++++++++++++-- .../src/cpp/HelperClasses/ApplicationHelper.h | 3 ++ .../src/cpp/HelperClasses/PlateformDetail.cpp | 6 ++-- .../src/cpp/HelperClasses/PlateformDetail.h | 2 +- MobileClient/QtProject/src/qml/Navigator.qml | 1 - MobileClient/QtProject/src/qml/Panel_Home.qml | 1 + .../QtProject/src/qml/Panel_NearbySpots.qml | 1 + .../QtProject/src/qml/Panel_Upload.qml | 1 + MobileClient/QtProject/src/qml/Panel_User.qml | 1 + .../src/qml/widgets/TabWidgetTop.qml | 3 +- 10 files changed, 44 insertions(+), 9 deletions(-) diff --git a/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp b/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp index b08c0a2..0945d56 100644 --- a/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp +++ b/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp @@ -26,11 +26,13 @@ //----------------------------------------------------------------------------------------------------------------------------- -ApplicationHelper::ApplicationHelper(Settings *settings, PlateformDetail *plateformDetail, +ApplicationHelper::ApplicationHelper(Settings *settings, + PlateformDetail *plateformDetail, QObject *parent) : QObject(parent), m_Settings(settings), m_PlateformDetail(plateformDetail), + m_DipScaleFactor(), m_CurrentClientVersion(), m_WebApiCommand_GetCurrentClientVersion(this), m_DevelopmentMode(false), @@ -47,6 +49,27 @@ ApplicationHelper::ApplicationHelper(Settings *settings, PlateformDetail *platef // Log phisical dpi Logger::info(QString::number(QApplication::screens().at(0)->physicalDotsPerInch())); + double dipNorm; + switch(m_PlateformDetail->getOS()) + { + case PlateformDetail::OS_DESKTOP: + dipNorm = 96.0; + break; + case PlateformDetail::OS_ANDROID: + dipNorm = 160.0; + break; + case PlateformDetail::OS_IOS: + dipNorm = 160.0; + break; + case PlateformDetail::OS_WINPHONE: + dipNorm = 160.0; + break; + } + + QScreen *screen = qApp->primaryScreen(); +// setDip(screen->physicalDotsPerInch() / screen->devicePixelRatio() / dipNorm); + setDip(screen->physicalDotsPerInch() / 108.0); + // Check if newer version was installed if(m_Settings->get_Application_LastVersion() != QApplication::applicationVersion()) { @@ -76,13 +99,18 @@ ApplicationHelper::~ApplicationHelper() } +//----------------------------------------------------------------------------------------------------------------------------- + int ApplicationHelper::dip() { - return QApplication::screens().at(0)->physicalDotsPerInch() / 108.0; + return m_DipScaleFactor; } -void ApplicationHelper::setDip(int dip) +//----------------------------------------------------------------------------------------------------------------------------- + +void ApplicationHelper::setDip(int dipScaleFactor) { + m_DipScaleFactor = dipScaleFactor; emit signal_Dip_Changed(); } diff --git a/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.h b/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.h index c99400f..8b2c419 100644 --- a/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.h +++ b/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.h @@ -90,6 +90,9 @@ private slots: // Link to PlateformDetail PlateformDetail *m_PlateformDetail; + // Dip Scale Factor + double m_DipScaleFactor; + // Version QString m_CurrentClientVersion; WebApiCommand m_WebApiCommand_GetCurrentClientVersion; diff --git a/MobileClient/QtProject/src/cpp/HelperClasses/PlateformDetail.cpp b/MobileClient/QtProject/src/cpp/HelperClasses/PlateformDetail.cpp index 4deb1a4..9ec36c1 100644 --- a/MobileClient/QtProject/src/cpp/HelperClasses/PlateformDetail.cpp +++ b/MobileClient/QtProject/src/cpp/HelperClasses/PlateformDetail.cpp @@ -16,7 +16,7 @@ PlateformDetail::PlateformDetail(QObject *parent) : QObject(parent), - m_Os(OS_OTHER) + m_Os(OS_DESKTOP) { #ifdef Q_OS_ANDROID m_Os = OS_ANDROID; @@ -47,7 +47,7 @@ PlateformDetail::OS PlateformDetail::getOS() const bool PlateformDetail::isMobile() { - return m_Os != OS_OTHER; + return m_Os != OS_DESKTOP; } //----------------------------------------------------------------------------------------------------------------------------- @@ -71,7 +71,7 @@ QString PlateformDetail::name() case OS_WINPHONE: return "Windows phone"; break; - case OS_OTHER: + case OS_DESKTOP: return "Desktop"; break; } diff --git a/MobileClient/QtProject/src/cpp/HelperClasses/PlateformDetail.h b/MobileClient/QtProject/src/cpp/HelperClasses/PlateformDetail.h index 48c39b1..424a0f0 100644 --- a/MobileClient/QtProject/src/cpp/HelperClasses/PlateformDetail.h +++ b/MobileClient/QtProject/src/cpp/HelperClasses/PlateformDetail.h @@ -25,7 +25,7 @@ class PlateformDetail : public QObject OS_ANDROID, OS_IOS, OS_WINPHONE, - OS_OTHER + OS_DESKTOP }; explicit PlateformDetail(QObject *parent = 0); diff --git a/MobileClient/QtProject/src/qml/Navigator.qml b/MobileClient/QtProject/src/qml/Navigator.qml index bc3309c..c8ac7f9 100644 --- a/MobileClient/QtProject/src/qml/Navigator.qml +++ b/MobileClient/QtProject/src/qml/Navigator.qml @@ -16,7 +16,6 @@ Rectangle { signal continueClicked signal menuClicked - height: text_Title.height * 2 z: 2 // so flickable doesn't draw on top diff --git a/MobileClient/QtProject/src/qml/Panel_Home.qml b/MobileClient/QtProject/src/qml/Panel_Home.qml index 156a539..e8d171c 100644 --- a/MobileClient/QtProject/src/qml/Panel_Home.qml +++ b/MobileClient/QtProject/src/qml/Panel_Home.qml @@ -28,6 +28,7 @@ Item { id: navigator anchors.top: parent.top + height: 30 * hc_Application.dip width: parent.width title : (stackView.currentItem != null) ? stackView.currentItem.navigation_Title : ""; diff --git a/MobileClient/QtProject/src/qml/Panel_NearbySpots.qml b/MobileClient/QtProject/src/qml/Panel_NearbySpots.qml index 9ca8fc4..c7d22ce 100644 --- a/MobileClient/QtProject/src/qml/Panel_NearbySpots.qml +++ b/MobileClient/QtProject/src/qml/Panel_NearbySpots.qml @@ -66,6 +66,7 @@ Item { id: navigator anchors.top: parent.top + height: 30 * hc_Application.dip width: parent.width title : (stackView.currentItem != null) ? stackView.currentItem.navigation_Title : ""; diff --git a/MobileClient/QtProject/src/qml/Panel_Upload.qml b/MobileClient/QtProject/src/qml/Panel_Upload.qml index de11a0f..e4a8e85 100644 --- a/MobileClient/QtProject/src/qml/Panel_Upload.qml +++ b/MobileClient/QtProject/src/qml/Panel_Upload.qml @@ -55,6 +55,7 @@ Item { id: navigator anchors.top: parent.top + height: 30 * hc_Application.dip width: parent.width title : (stackView.currentItem != null) ? stackView.currentItem.navigation_Title : ""; diff --git a/MobileClient/QtProject/src/qml/Panel_User.qml b/MobileClient/QtProject/src/qml/Panel_User.qml index 6668bcf..7e85f3a 100644 --- a/MobileClient/QtProject/src/qml/Panel_User.qml +++ b/MobileClient/QtProject/src/qml/Panel_User.qml @@ -48,6 +48,7 @@ Item { id: navigator anchors.top: parent.top + height: 30 * hc_Application.dip width: parent.width title : (stackView.currentItem != null) ? stackView.currentItem.navigation_Title : ""; diff --git a/MobileClient/QtProject/src/qml/widgets/TabWidgetTop.qml b/MobileClient/QtProject/src/qml/widgets/TabWidgetTop.qml index c264833..1191ff9 100644 --- a/MobileClient/QtProject/src/qml/widgets/TabWidgetTop.qml +++ b/MobileClient/QtProject/src/qml/widgets/TabWidgetTop.qml @@ -51,7 +51,8 @@ Item { Repeater { model: stack.children.length delegate: TabButton { - width: tabWidgetTop.width / stack.children.length; height: 36 + width: tabWidgetTop.width / stack.children.length; + height: 30 * hc_Application.dip iconSource: stack.children[index].tabWidget_ButtonIconSource buttonText: stack.children[index].tabWidget_ButtonText From b5ebae9dc81121b7bd95003f4533a459591585f8 Mon Sep 17 00:00:00 2001 From: Damiano Date: Tue, 19 Apr 2016 23:44:13 -0700 Subject: [PATCH 3/3] minimum dip scale factor = 1 --- .../src/cpp/HelperClasses/ApplicationHelper.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp b/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp index 0945d56..4032217 100644 --- a/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp +++ b/MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp @@ -46,9 +46,7 @@ ApplicationHelper::ApplicationHelper(Settings *settings, .arg(buildTimestamp()) .arg(m_PlateformDetail->name())); - // Log phisical dpi - Logger::info(QString::number(QApplication::screens().at(0)->physicalDotsPerInch())); - + // Dip scale factor double dipNorm; switch(m_PlateformDetail->getOS()) { @@ -65,10 +63,12 @@ ApplicationHelper::ApplicationHelper(Settings *settings, dipNorm = 160.0; break; } - QScreen *screen = qApp->primaryScreen(); -// setDip(screen->physicalDotsPerInch() / screen->devicePixelRatio() / dipNorm); - setDip(screen->physicalDotsPerInch() / 108.0); + //double dip = screen->physicalDotsPerInch() / screen->devicePixelRatio() / dipNorm; + double dip = screen->physicalDotsPerInch() / 108.0; + if(dip <= 1.0) + dip = 1.0; + setDip(dip); // Check if newer version was installed if(m_Settings->get_Application_LastVersion() != QApplication::applicationVersion())