Skip to content

Commit

Permalink
Merge pull request #2 from domi4484/dip
Browse files Browse the repository at this point in the history
Dip
  • Loading branch information
domi4484 committed Apr 29, 2016
2 parents 48c48b4 + b5ebae9 commit 2082a20
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 12 deletions.
47 changes: 45 additions & 2 deletions MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@
#include "../WebApi/WebApi.h"

// Qt includes -----------------------------
#include <QDebug>
#include <QApplication>
#include <QDebug>
#include <QRegularExpression>
#include <QScreen>

//-----------------------------------------------------------------------------------------------------------------------------

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),
Expand All @@ -43,6 +46,30 @@ ApplicationHelper::ApplicationHelper(Settings *settings, PlateformDetail *platef
.arg(buildTimestamp())
.arg(m_PlateformDetail->name()));

// Dip scale factor
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();
//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())
{
Expand Down Expand Up @@ -74,6 +101,22 @@ ApplicationHelper::~ApplicationHelper()

//-----------------------------------------------------------------------------------------------------------------------------

int ApplicationHelper::dip()
{
return m_DipScaleFactor;
}

//-----------------------------------------------------------------------------------------------------------------------------

void ApplicationHelper::setDip(int dipScaleFactor)
{
m_DipScaleFactor = dipScaleFactor;

emit signal_Dip_Changed();
}

//-----------------------------------------------------------------------------------------------------------------------------

QString ApplicationHelper::version() const
{
return QApplication::applicationVersion();
Expand Down
11 changes: 11 additions & 0 deletions MobileClient/QtProject/src/cpp/HelperClasses/ApplicationHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -82,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,7 +47,7 @@ PlateformDetail::OS PlateformDetail::getOS() const

bool PlateformDetail::isMobile()
{
return m_Os != OS_OTHER;
return m_Os != OS_DESKTOP;
}

//-----------------------------------------------------------------------------------------------------------------------------
Expand All @@ -71,7 +71,7 @@ QString PlateformDetail::name()
case OS_WINPHONE:
return "Windows phone";
break;
case OS_OTHER:
case OS_DESKTOP:
return "Desktop";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PlateformDetail : public QObject
OS_ANDROID,
OS_IOS,
OS_WINPHONE,
OS_OTHER
OS_DESKTOP
};

explicit PlateformDetail(QObject *parent = 0);
Expand Down
1 change: 1 addition & 0 deletions MobileClient/QtProject/src/qml/Navigator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Rectangle {

z: 2 // so flickable doesn't draw on top


color: ( mouseBack.pressed
|| mouseContinue.pressed
|| mouseMenu.pressed ) ? Qt.lighter(hc_Application.color_BackgroundNavigator(), 1.2)
Expand Down
2 changes: 1 addition & 1 deletion MobileClient/QtProject/src/qml/Panel_Home.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Item {
id: navigator

anchors.top: parent.top
height: 30 * hc_Application.dip
width: parent.width
height: 40

title : (stackView.currentItem != null) ? stackView.currentItem.navigation_Title : "";
backButtonVisible : stackView.depth > 1
Expand Down
2 changes: 1 addition & 1 deletion MobileClient/QtProject/src/qml/Panel_NearbySpots.qml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ Item {
id: navigator

anchors.top: parent.top
height: 30 * hc_Application.dip
width: parent.width
height: 40

title : (stackView.currentItem != null) ? stackView.currentItem.navigation_Title : "";
backButtonVisible : stackView.depth > 1
Expand Down
2 changes: 1 addition & 1 deletion MobileClient/QtProject/src/qml/Panel_Upload.qml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Item {
id: navigator

anchors.top: parent.top
height: 30 * hc_Application.dip
width: parent.width
height: 40

title : (stackView.currentItem != null) ? stackView.currentItem.navigation_Title : "";
backButtonVisible : (stackView.currentItem != null) ? stackView.currentItem.navigation_BackButtonVisible : false;
Expand Down
2 changes: 1 addition & 1 deletion MobileClient/QtProject/src/qml/Panel_User.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Item {
id: navigator

anchors.top: parent.top
height: 30 * hc_Application.dip
width: parent.width
height: 40

title : (stackView.currentItem != null) ? stackView.currentItem.navigation_Title : "";
backButtonVisible : (stackView.currentItem != null) ? stackView.currentItem.navigation_BackButtonVisible : false;
Expand Down
4 changes: 3 additions & 1 deletion MobileClient/QtProject/src/qml/widgets/TabWidgetBottom.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

// Qt imports ------------------------------
import QtQuick 2.0
import QtQuick.Window 2.0

// Project qml imports ---------------------
import "qrc:/qml/"
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion MobileClient/QtProject/src/qml/widgets/TabWidgetTop.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2082a20

Please sign in to comment.