From e1359ace86cd76c1073d29563eddecd9afda1b50 Mon Sep 17 00:00:00 2001 From: pazos Date: Wed, 25 Apr 2018 15:23:56 +0200 Subject: [PATCH] refactor platform dependant code --- main.cpp | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/main.cpp b/main.cpp index 38db1c5d..73a149a7 100644 --- a/main.cpp +++ b/main.cpp @@ -65,6 +65,11 @@ #include "QrCodeScanner.h" #endif +bool isIOS = false; +bool isAndroid = false; +bool isWindows = false; +bool isDesktop = false; + void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { // Send all message types to logger @@ -73,6 +78,19 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt int main(int argc, char *argv[]) { + // platform dependant settings +#if ! defined(Q_OS_ANDROID) && ! defined(Q_OS_IOS) + bool isDesktop = true; +#elif defined(Q_OS_ANDROID) + bool isAndroid = true; +#elif defined(Q_OS_IOS) + bool isIOS = true; +#endif +#ifdef Q_OS_WIN + bool isWindows = true; +#endif + + Monero::Utils::onStartup(); // // Enable high DPI scaling on windows & linux //#if !defined(Q_OS_ANDROID) && QT_VERSION >= 0x050600 @@ -92,9 +110,9 @@ int main(int argc, char *argv[]) app.setOrganizationDomain("getmonero.org"); app.setOrganizationName("monero-project"); - #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) - app.setWindowIcon(QIcon(":/images/appicon.ico")); - #endif +#if defined(Q_OS_LINUX) + if (isDesktop) app.setWindowIcon(QIcon(":/images/appicon.ico")); +#endif filter *eventFilter = new filter; app.installEventFilter(eventFilter); @@ -169,7 +187,6 @@ int main(int argc, char *argv[]) engine.rootContext()->setContextProperty("translationManager", TranslationManager::instance()); engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider()); - const QStringList arguments = QCoreApplication::arguments(); engine.rootContext()->setContextProperty("mainApp", &app); @@ -177,6 +194,7 @@ int main(int argc, char *argv[]) // Exclude daemon manager from IOS #ifndef Q_OS_IOS + const QStringList arguments = QCoreApplication::arguments(); DaemonManager * daemonManager = DaemonManager::instance(&arguments); engine.rootContext()->setContextProperty("daemonManager", daemonManager); #endif @@ -186,25 +204,11 @@ int main(int argc, char *argv[]) // to save the wallet file (.keys, .bin), they have to be user-accessible for // backups - I reckon we save that in My Documents\Monero Accounts\ on // Windows, ~/Monero Accounts/ on nix / osx - bool isWindows = false; - bool isIOS = false; - bool isMac = false; - bool isAndroid = false; -#ifdef Q_OS_WIN - isWindows = true; +#if defined (Q_OS_WIN) || defined(Q_OS_IOS) QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); -#elif defined(Q_OS_IOS) - isIOS = true; - QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); -#elif defined(Q_OS_UNIX) +#else QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::HomeLocation); #endif -#ifdef Q_OS_MAC - isMac = true; -#endif -#ifdef Q_OS_ANDROID - isAndroid = true; -#endif engine.rootContext()->setContextProperty("isWindows", isWindows); engine.rootContext()->setContextProperty("isIOS", isIOS);