mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 12:09:57 +00:00
refactor platform dependant code
This commit is contained in:
parent
60cefb3820
commit
e1359ace86
1 changed files with 24 additions and 20 deletions
42
main.cpp
42
main.cpp
|
@ -65,6 +65,11 @@
|
||||||
#include "QrCodeScanner.h"
|
#include "QrCodeScanner.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool isIOS = false;
|
||||||
|
bool isAndroid = false;
|
||||||
|
bool isWindows = false;
|
||||||
|
bool isDesktop = false;
|
||||||
|
|
||||||
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
{
|
{
|
||||||
// Send all message types to logger
|
// 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[])
|
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();
|
Monero::Utils::onStartup();
|
||||||
// // Enable high DPI scaling on windows & linux
|
// // Enable high DPI scaling on windows & linux
|
||||||
//#if !defined(Q_OS_ANDROID) && QT_VERSION >= 0x050600
|
//#if !defined(Q_OS_ANDROID) && QT_VERSION >= 0x050600
|
||||||
|
@ -92,8 +110,8 @@ int main(int argc, char *argv[])
|
||||||
app.setOrganizationDomain("getmonero.org");
|
app.setOrganizationDomain("getmonero.org");
|
||||||
app.setOrganizationName("monero-project");
|
app.setOrganizationName("monero-project");
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
#if defined(Q_OS_LINUX)
|
||||||
app.setWindowIcon(QIcon(":/images/appicon.ico"));
|
if (isDesktop) app.setWindowIcon(QIcon(":/images/appicon.ico"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
filter *eventFilter = new filter;
|
filter *eventFilter = new filter;
|
||||||
|
@ -169,7 +187,6 @@ int main(int argc, char *argv[])
|
||||||
engine.rootContext()->setContextProperty("translationManager", TranslationManager::instance());
|
engine.rootContext()->setContextProperty("translationManager", TranslationManager::instance());
|
||||||
|
|
||||||
engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider());
|
engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider());
|
||||||
const QStringList arguments = QCoreApplication::arguments();
|
|
||||||
|
|
||||||
engine.rootContext()->setContextProperty("mainApp", &app);
|
engine.rootContext()->setContextProperty("mainApp", &app);
|
||||||
|
|
||||||
|
@ -177,6 +194,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// Exclude daemon manager from IOS
|
// Exclude daemon manager from IOS
|
||||||
#ifndef Q_OS_IOS
|
#ifndef Q_OS_IOS
|
||||||
|
const QStringList arguments = QCoreApplication::arguments();
|
||||||
DaemonManager * daemonManager = DaemonManager::instance(&arguments);
|
DaemonManager * daemonManager = DaemonManager::instance(&arguments);
|
||||||
engine.rootContext()->setContextProperty("daemonManager", daemonManager);
|
engine.rootContext()->setContextProperty("daemonManager", daemonManager);
|
||||||
#endif
|
#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
|
// 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
|
// backups - I reckon we save that in My Documents\Monero Accounts\ on
|
||||||
// Windows, ~/Monero Accounts/ on nix / osx
|
// Windows, ~/Monero Accounts/ on nix / osx
|
||||||
bool isWindows = false;
|
#if defined (Q_OS_WIN) || defined(Q_OS_IOS)
|
||||||
bool isIOS = false;
|
|
||||||
bool isMac = false;
|
|
||||||
bool isAndroid = false;
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
isWindows = true;
|
|
||||||
QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
|
QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
|
||||||
#elif defined(Q_OS_IOS)
|
#else
|
||||||
isIOS = true;
|
|
||||||
QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
|
|
||||||
#elif defined(Q_OS_UNIX)
|
|
||||||
QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
isMac = true;
|
|
||||||
#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);
|
||||||
|
|
Loading…
Reference in a new issue