From 7af8383cafb6af0b3d0bd937a2ae4be131df89ee Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sun, 6 Aug 2017 16:51:02 +0200 Subject: [PATCH] add scaleRatio property and isAndroid --- main.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/main.cpp b/main.cpp index 1a9a979d..da9686dd 100644 --- a/main.cpp +++ b/main.cpp @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include "clipboardAdapter.h" #include "filter.h" #include "oscursor.h" @@ -168,6 +170,7 @@ int main(int argc, char *argv[]) bool isWindows = false; bool isIOS = false; bool isMac = false; + bool isAndroid = false; #ifdef Q_OS_WIN isWindows = true; QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); @@ -180,9 +183,42 @@ int main(int argc, char *argv[]) #ifdef Q_OS_MAC isMac = true; #endif +#ifdef Q_OS_ANDROID + isAndroid = true; +#endif engine.rootContext()->setContextProperty("isWindows", isWindows); engine.rootContext()->setContextProperty("isIOS", isIOS); + engine.rootContext()->setContextProperty("isAndroid", isAndroid); + + // screen settings + // Mobile is designed on 128dpi + qreal ref_dpi = 128; + QRect geo = QApplication::desktop()->availableGeometry(); + QRect rect = QGuiApplication::primaryScreen()->geometry(); + qreal height = qMax(rect.width(), rect.height()); + qreal width = qMin(rect.width(), rect.height()); + qreal dpi = QGuiApplication::primaryScreen()->logicalDotsPerInch(); + qreal physicalDpi = QGuiApplication::primaryScreen()->physicalDotsPerInch(); + qreal calculated_ratio = physicalDpi/ref_dpi; + + engine.rootContext()->setContextProperty("screenWidth", geo.width()); + engine.rootContext()->setContextProperty("screenHeight", geo.height()); +#ifdef Q_OS_ANDROID + engine.rootContext()->setContextProperty("scaleRatio", calculated_ratio); +#else + engine.rootContext()->setContextProperty("scaleRatio", 1); +#endif + + qDebug() << "available width: " << geo.width(); + qDebug() << "available height: " << geo.height(); + qDebug() << "devicePixelRatio: " << app.devicePixelRatio(); + qDebug() << "screen height: " << height; + qDebug() << "screen width: " << width; + qDebug() << "screen logical dpi: " << dpi; + qDebug() << "screen Physical dpi: " << physicalDpi; + qDebug() << "screen calculated ratio: " << calculated_ratio; + if (!moneroAccountsRootDir.empty()) { QString moneroAccountsDir = moneroAccountsRootDir.at(0) + "/Monero/wallets";