mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-22 19:49:34 +00:00
add scaleRatio property and isAndroid
This commit is contained in:
parent
c72207c2e2
commit
7af8383caf
1 changed files with 36 additions and 0 deletions
36
main.cpp
36
main.cpp
|
@ -32,6 +32,8 @@
|
|||
#include <QStandardPaths>
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
#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";
|
||||
|
|
Loading…
Reference in a new issue