|
|
@ -1,3 +1,6 @@ |
|
|
|
#include <singleapplication.h> |
|
|
|
|
|
|
|
#include "precompiled.h" |
|
|
|
#include "mainwindow.h" |
|
|
|
#include "rpc.h" |
|
|
|
#include "settings.h" |
|
|
@ -155,7 +158,34 @@ public: |
|
|
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); |
|
|
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); |
|
|
|
|
|
|
|
QApplication a(argc, argv); |
|
|
|
SingleApplication a(argc, argv, true); |
|
|
|
|
|
|
|
// Command line parser
|
|
|
|
QCommandLineParser parser; |
|
|
|
parser.setApplicationDescription("Shielded desktop wallet and embedded full node for Zcash"); |
|
|
|
parser.addHelpOption(); |
|
|
|
|
|
|
|
// A boolean option for running it headless
|
|
|
|
QCommandLineOption headlessOption(QStringList() << "headless", "Running it via GUI."); |
|
|
|
parser.addOption(headlessOption); |
|
|
|
|
|
|
|
// No embedded will disable the embedded zcashd node
|
|
|
|
QCommandLineOption noembeddedOption(QStringList() << "no-embedded", "Disable embedded zcashd"); |
|
|
|
parser.addOption(noembeddedOption); |
|
|
|
|
|
|
|
// Positional argument will specify a zcash payment URI
|
|
|
|
parser.addPositionalArgument("zcashURI", "An optional zcash URI to pay"); |
|
|
|
|
|
|
|
parser.process(a); |
|
|
|
|
|
|
|
// Check for a positional argument indicating a zcash payment URI
|
|
|
|
if (a.isSecondary()) { |
|
|
|
if (parser.positionalArguments().length() > 0) { |
|
|
|
a.sendMessage(parser.positionalArguments()[0].toUtf8()); |
|
|
|
} |
|
|
|
a.exit( 0 ); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
QCoreApplication::setOrganizationName("zec-qt-wallet-org"); |
|
|
|
QCoreApplication::setApplicationName("zec-qt-wallet"); |
|
|
@ -194,19 +224,7 @@ public: |
|
|
|
exit(0); |
|
|
|
} |
|
|
|
|
|
|
|
// Command line parser
|
|
|
|
QCommandLineParser parser; |
|
|
|
parser.setApplicationDescription("Shielded desktop wallet and embedded full node for Zcash"); |
|
|
|
parser.addHelpOption(); |
|
|
|
|
|
|
|
// A boolean option for running it headless
|
|
|
|
QCommandLineOption headlessOption(QStringList() << "headless", "Running it via GUI."); |
|
|
|
parser.addOption(headlessOption); |
|
|
|
|
|
|
|
QCommandLineOption noembeddedOption(QStringList() << "no-embedded", "Disable embedded zcashd"); |
|
|
|
parser.addOption(noembeddedOption); |
|
|
|
|
|
|
|
parser.process(a); |
|
|
|
// Check for embedded option
|
|
|
|
if (parser.isSet(noembeddedOption)) { |
|
|
|
Settings::getInstance()->setUseEmbedded(false); |
|
|
|
} else { |
|
|
@ -216,6 +234,20 @@ public: |
|
|
|
w = new MainWindow(); |
|
|
|
w->setWindowTitle("ZecWallet v" + QString(APP_VERSION)); |
|
|
|
|
|
|
|
// If there was a payment URI on the command line, pay it
|
|
|
|
if (parser.positionalArguments().length() > 0) { |
|
|
|
w->payZcashURI(parser.positionalArguments()[0]); |
|
|
|
} |
|
|
|
|
|
|
|
// Listen for any secondary instances telling us about a zcash payment URI
|
|
|
|
QObject::connect(&a, &SingleApplication::receivedMessage, [=] (quint32, QByteArray msg) { |
|
|
|
QString uri(msg); |
|
|
|
|
|
|
|
// We need to execute this async, otherwise the app seems to crash for some reason.
|
|
|
|
QTimer::singleShot(1, [=]() { w->payZcashURI(uri); }); |
|
|
|
}); |
|
|
|
|
|
|
|
// Check if starting headless
|
|
|
|
if (parser.isSet(headlessOption)) { |
|
|
|
Settings::getInstance()->setHeadless(true); |
|
|
|
a.setQuitOnLastWindowClosed(false); |
|
|
|