merge
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "singleapplication"]
|
||||||
|
path = singleapplication
|
||||||
|
url = git@github.com:itay-grudev/SingleApplication.git
|
||||||
1
singleapplication
Submodule
1
singleapplication
Submodule
Submodule singleapplication added at 7163d166a1
60
src/main.cpp
60
src/main.cpp
@@ -1,3 +1,6 @@
|
|||||||
|
#include <singleapplication.h>
|
||||||
|
|
||||||
|
#include "precompiled.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "rpc.h"
|
#include "rpc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
@@ -155,7 +158,34 @@ public:
|
|||||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
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::setOrganizationName("zec-qt-wallet-org");
|
||||||
QCoreApplication::setApplicationName("zec-qt-wallet");
|
QCoreApplication::setApplicationName("zec-qt-wallet");
|
||||||
@@ -194,19 +224,7 @@ public:
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command line parser
|
// Check for embedded option
|
||||||
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);
|
|
||||||
if (parser.isSet(noembeddedOption)) {
|
if (parser.isSet(noembeddedOption)) {
|
||||||
Settings::getInstance()->setUseEmbedded(false);
|
Settings::getInstance()->setUseEmbedded(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -216,6 +234,20 @@ public:
|
|||||||
w = new MainWindow();
|
w = new MainWindow();
|
||||||
w->setWindowTitle("ZecWallet v" + QString(APP_VERSION));
|
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)) {
|
if (parser.isSet(headlessOption)) {
|
||||||
Settings::getInstance()->setHeadless(true);
|
Settings::getInstance()->setHeadless(true);
|
||||||
a.setQuitOnLastWindowClosed(false);
|
a.setQuitOnLastWindowClosed(false);
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Pay Zcash URI
|
// Pay Zcash URI
|
||||||
QObject::connect(ui->actionPay_URI, &QAction::triggered, this, &MainWindow::payZcashURI);
|
QObject::connect(ui->actionPay_URI, &QAction::triggered, [=] () {
|
||||||
|
payZcashURI();
|
||||||
|
});
|
||||||
|
|
||||||
// Import Private Key
|
// Import Private Key
|
||||||
QObject::connect(ui->actionImport_Private_Key, &QAction::triggered, this, &MainWindow::importPrivKey);
|
QObject::connect(ui->actionImport_Private_Key, &QAction::triggered, this, &MainWindow::importPrivKey);
|
||||||
@@ -722,17 +724,50 @@ void MainWindow::doImport(QList<QString>* keys) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::payZcashURI() {
|
|
||||||
|
// Callback invoked when the RPC has finished loading all the balances, and the UI
|
||||||
|
// is now ready to send transactions.
|
||||||
|
void MainWindow::balancesReady() {
|
||||||
|
// First-time check
|
||||||
|
if (uiPaymentsReady)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uiPaymentsReady = true;
|
||||||
|
qDebug() << "Payment UI now ready!";
|
||||||
|
|
||||||
|
// There is a pending URI payment (from the command line, or from a secondary instance),
|
||||||
|
// process it.
|
||||||
|
if (!pendingURIPayment.isEmpty()) {
|
||||||
|
qDebug() << "Paying zcash URI";
|
||||||
|
payZcashURI(pendingURIPayment);
|
||||||
|
pendingURIPayment = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pay the Zcash URI by showing a confirmation window. If the URI parameter is empty, the UI
|
||||||
|
// will prompt for one.
|
||||||
|
void MainWindow::payZcashURI(QString uri) {
|
||||||
|
// If the Payments UI is not ready (i.e, all balances have not loaded), defer the payment URI
|
||||||
|
if (!uiPaymentsReady) {
|
||||||
|
qDebug() << "Payment UI not ready, waiting for UI to pay URI";
|
||||||
|
pendingURIPayment = uri;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Error to display if something goes wrong.
|
// Error to display if something goes wrong.
|
||||||
auto payZcashURIError = [=] (QString errorDetail = "") {
|
auto payZcashURIError = [=] (QString errorDetail = "") {
|
||||||
QMessageBox::critical(this, tr("Error paying zcash URI"),
|
QMessageBox::critical(this, tr("Error paying zcash URI"),
|
||||||
tr("URI should be of the form 'zcash:<addr>?amt=x&memo=y") + "\n" + errorDetail);
|
tr("URI should be of the form 'zcash:<addr>?amt=x&memo=y") + "\n" + errorDetail);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Read a zcash URI and pay it
|
// If there was no URI passed, ask the user for one.
|
||||||
QString uri = QInputDialog::getText(this, tr("Paste Zcash URI"),
|
if (uri.isEmpty()) {
|
||||||
"Zcash URI" + QString(" ").repeated(180));
|
uri = QInputDialog::getText(this, tr("Paste Zcash URI"),
|
||||||
|
"Zcash URI" + QString(" ").repeated(180));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there's no URI, just exit
|
||||||
if (uri.isEmpty())
|
if (uri.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -743,6 +778,7 @@ void MainWindow::payZcashURI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract the address
|
// Extract the address
|
||||||
|
qDebug() << "Recieved URI " << uri;
|
||||||
uri = uri.right(uri.length() - QString("zcash:").length());
|
uri = uri.right(uri.length() - QString("zcash:").length());
|
||||||
|
|
||||||
QRegExp re("([a-zA-Z0-9]+)");
|
QRegExp re("([a-zA-Z0-9]+)");
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ public:
|
|||||||
void createWebsocket(QString wormholecode);
|
void createWebsocket(QString wormholecode);
|
||||||
void stopWebsocket();
|
void stopWebsocket();
|
||||||
|
|
||||||
|
void balancesReady();
|
||||||
|
void payZcashURI(QString uri = "");
|
||||||
|
|
||||||
void updateLabels();
|
void updateLabels();
|
||||||
void updateTAddrCombo(bool checked);
|
void updateTAddrCombo(bool checked);
|
||||||
void updateFromCombo();
|
void updateFromCombo();
|
||||||
@@ -105,7 +108,6 @@ private:
|
|||||||
|
|
||||||
void donate();
|
void donate();
|
||||||
void addressBook();
|
void addressBook();
|
||||||
void payZcashURI();
|
|
||||||
void postToZBoard();
|
void postToZBoard();
|
||||||
void importPrivKey();
|
void importPrivKey();
|
||||||
void exportAllKeys();
|
void exportAllKeys();
|
||||||
@@ -117,6 +119,9 @@ private:
|
|||||||
|
|
||||||
void restoreSavedStates();
|
void restoreSavedStates();
|
||||||
|
|
||||||
|
bool uiPaymentsReady = false;
|
||||||
|
QString pendingURIPayment;
|
||||||
|
|
||||||
WSServer* wsserver = nullptr;
|
WSServer* wsserver = nullptr;
|
||||||
WormholeClient* wormhole = nullptr;
|
WormholeClient* wormhole = nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
#include <QErrorMessage>
|
#include <QErrorMessage>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QWindow>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|||||||
11
src/rpc.cpp
11
src/rpc.cpp
@@ -87,9 +87,8 @@ void RPC::setConnection(Connection* c) {
|
|||||||
|
|
||||||
ui->statusBar->showMessage("Ready!");
|
ui->statusBar->showMessage("Ready!");
|
||||||
|
|
||||||
refreshZECPrice();
|
refreshZECPrice();
|
||||||
// Commented for Android beta.
|
checkForUpdate();
|
||||||
// checkForUpdate();
|
|
||||||
|
|
||||||
// Force update, because this might be coming from a settings update
|
// Force update, because this might be coming from a settings update
|
||||||
// where we need to immediately refresh
|
// where we need to immediately refresh
|
||||||
@@ -772,7 +771,9 @@ void RPC::refreshBalances() {
|
|||||||
allBalances = newBalances;
|
allBalances = newBalances;
|
||||||
utxos = newUtxos;
|
utxos = newUtxos;
|
||||||
|
|
||||||
updateUI(anyTUnconfirmed || anyZUnconfirmed);
|
updateUI(anyTUnconfirmed || anyZUnconfirmed);
|
||||||
|
|
||||||
|
main->balancesReady();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -996,7 +997,7 @@ void RPC::checkForUpdate(bool silent) {
|
|||||||
|
|
||||||
qDebug() << "Version check: Current " << currentVersion << ", Available " << maxVersion;
|
qDebug() << "Version check: Current " << currentVersion << ", Available " << maxVersion;
|
||||||
|
|
||||||
if (maxVersion > currentVersion && maxVersion > maxHiddenVersion) {
|
if (maxVersion > currentVersion && (!silent || maxVersion > maxHiddenVersion)) {
|
||||||
auto ans = QMessageBox::information(main, QObject::tr("Update Available"),
|
auto ans = QMessageBox::information(main, QObject::tr("Update Available"),
|
||||||
QObject::tr("A new release v%1 is available! You have v%2.\n\nWould you like to visit the releases page?")
|
QObject::tr("A new release v%1 is available! You have v%2.\n\nWould you like to visit the releases page?")
|
||||||
.arg(maxVersion.toString())
|
.arg(maxVersion.toString())
|
||||||
|
|||||||
@@ -104,6 +104,9 @@ TRANSLATIONS = res/zec_qt_wallet_es.ts \
|
|||||||
res/zec_qt_wallet_pt.ts \
|
res/zec_qt_wallet_pt.ts \
|
||||||
res/zec_qt_wallet_it.ts
|
res/zec_qt_wallet_it.ts
|
||||||
|
|
||||||
|
include(singleapplication/singleapplication.pri)
|
||||||
|
DEFINES += QAPPLICATION_CLASS=QApplication
|
||||||
|
|
||||||
win32: RC_ICONS = res/icon.ico
|
win32: RC_ICONS = res/icon.ico
|
||||||
ICON = res/logo.icns
|
ICON = res/logo.icns
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user