add scaleRatio property and isAndroid

This commit is contained in:
Jaquee 2017-08-06 16:51:02 +02:00
parent c72207c2e2
commit 7af8383caf

View file

@ -32,6 +32,8 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QDebug> #include <QDebug>
#include <QObject> #include <QObject>
#include <QDesktopWidget>
#include <QScreen>
#include "clipboardAdapter.h" #include "clipboardAdapter.h"
#include "filter.h" #include "filter.h"
#include "oscursor.h" #include "oscursor.h"
@ -168,6 +170,7 @@ int main(int argc, char *argv[])
bool isWindows = false; bool isWindows = false;
bool isIOS = false; bool isIOS = false;
bool isMac = false; bool isMac = false;
bool isAndroid = false;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
isWindows = true; isWindows = true;
QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
@ -180,9 +183,42 @@ int main(int argc, char *argv[])
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
isMac = true; isMac = true;
#endif #endif
#ifdef Q_OS_ANDROID
isAndroid = true;
#endif
engine.rootContext()->setContextProperty("isWindows", isWindows); engine.rootContext()->setContextProperty("isWindows", isWindows);
engine.rootContext()->setContextProperty("isIOS", isIOS); 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()) { if (!moneroAccountsRootDir.empty()) {
QString moneroAccountsDir = moneroAccountsRootDir.at(0) + "/Monero/wallets"; QString moneroAccountsDir = moneroAccountsRootDir.at(0) + "/Monero/wallets";