Cleanup some methods to make them easier to read
This commit is contained in:
@@ -18,52 +18,99 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
// Status Bar
|
// Status Bar
|
||||||
loadingLabel = new QLabel();
|
setupStatusBar();
|
||||||
loadingMovie = new QMovie(":/icons/res/loading.gif");
|
|
||||||
loadingMovie->setScaledSize(QSize(32, 16));
|
|
||||||
loadingMovie->start();
|
|
||||||
loadingLabel->setAttribute(Qt::WA_NoSystemBackground);
|
|
||||||
loadingLabel->setMovie(loadingMovie);
|
|
||||||
|
|
||||||
ui->statusBar->addPermanentWidget(loadingLabel);
|
// Settings editor
|
||||||
loadingLabel->setVisible(false);
|
setupSettingsModal();
|
||||||
|
|
||||||
// Custom status bar menu
|
// Set up exit action
|
||||||
|
QObject::connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close);
|
||||||
|
|
||||||
|
// Set up donate action
|
||||||
|
QObject::connect(ui->actionDonate, &QAction::triggered, this, &MainWindow::donate);
|
||||||
|
|
||||||
|
// Set up check for updates action
|
||||||
|
QObject::connect(ui->actionCheck_for_Updates, &QAction::triggered, [=] () {
|
||||||
|
QDesktopServices::openUrl(QUrl("https://github.com/adityapk00/zcash-qt-wallet/releases"));
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(ui->actionImport_Private_Keys, &QAction::triggered, this, &MainWindow::importPrivKeys);
|
||||||
|
|
||||||
|
// Set up about action
|
||||||
|
QObject::connect(ui->actionAbout, &QAction::triggered, [=] () {
|
||||||
|
QDialog aboutDialog(this);
|
||||||
|
Ui_about about;
|
||||||
|
about.setupUi(&aboutDialog);
|
||||||
|
|
||||||
|
QString version = QString("Version ") % QString(APP_VERSION) % " (" % QString(__DATE__) % ")";
|
||||||
|
about.versionLabel->setText(version);
|
||||||
|
|
||||||
|
aboutDialog.exec();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initialize to the balances tab
|
||||||
|
ui->tabWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
|
setupSendTab();
|
||||||
|
setupTransactionsTab();
|
||||||
|
setupRecieveTab();
|
||||||
|
setupBalancesTab();
|
||||||
|
|
||||||
|
rpc = new RPC(new QNetworkAccessManager(this), this);
|
||||||
|
rpc->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::setupStatusBar() {
|
||||||
|
// Status Bar
|
||||||
|
loadingLabel = new QLabel();
|
||||||
|
loadingMovie = new QMovie(":/icons/res/loading.gif");
|
||||||
|
loadingMovie->setScaledSize(QSize(32, 16));
|
||||||
|
loadingMovie->start();
|
||||||
|
loadingLabel->setAttribute(Qt::WA_NoSystemBackground);
|
||||||
|
loadingLabel->setMovie(loadingMovie);
|
||||||
|
|
||||||
|
ui->statusBar->addPermanentWidget(loadingLabel);
|
||||||
|
loadingLabel->setVisible(false);
|
||||||
|
|
||||||
|
// Custom status bar menu
|
||||||
ui->statusBar->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->statusBar->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
QObject::connect(ui->statusBar, &QStatusBar::customContextMenuRequested, [=](QPoint pos) {
|
QObject::connect(ui->statusBar, &QStatusBar::customContextMenuRequested, [=](QPoint pos) {
|
||||||
auto msg = ui->statusBar->currentMessage();
|
auto msg = ui->statusBar->currentMessage();
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
|
|
||||||
if (!msg.isEmpty() && msg.startsWith(Utils::txidStatusMessage)) {
|
if (!msg.isEmpty() && msg.startsWith(Utils::txidStatusMessage)) {
|
||||||
auto txid = msg.split(":")[1].trimmed();
|
auto txid = msg.split(":")[1].trimmed();
|
||||||
menu.addAction("Copy txid", [=]() {
|
menu.addAction("Copy txid", [=]() {
|
||||||
QGuiApplication::clipboard()->setText(txid);
|
QGuiApplication::clipboard()->setText(txid);
|
||||||
});
|
});
|
||||||
menu.addAction("View tx on block explorer", [=]() {
|
menu.addAction("View tx on block explorer", [=]() {
|
||||||
QString url;
|
QString url;
|
||||||
if (Settings::getInstance()->isTestnet()) {
|
if (Settings::getInstance()->isTestnet()) {
|
||||||
url = "https://explorer.testnet.z.cash/tx/" + txid;
|
url = "https://explorer.testnet.z.cash/tx/" + txid;
|
||||||
} else {
|
}
|
||||||
url = "https://explorer.zcha.in/transactions/" + txid;
|
else {
|
||||||
}
|
url = "https://explorer.zcha.in/transactions/" + txid;
|
||||||
QDesktopServices::openUrl(QUrl(url));
|
}
|
||||||
});
|
QDesktopServices::openUrl(QUrl(url));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.addAction("Refresh", [=]() {
|
menu.addAction("Refresh", [=]() {
|
||||||
rpc->refresh();
|
rpc->refresh();
|
||||||
});
|
});
|
||||||
QPoint gpos(mapToGlobal(pos).x(), mapToGlobal(pos).y() + this->height() - ui->statusBar->height());
|
QPoint gpos(mapToGlobal(pos).x(), mapToGlobal(pos).y() + this->height() - ui->statusBar->height());
|
||||||
menu.exec(gpos);
|
menu.exec(gpos);
|
||||||
});
|
});
|
||||||
|
|
||||||
statusLabel = new QLabel();
|
statusLabel = new QLabel();
|
||||||
ui->statusBar->addPermanentWidget(statusLabel);
|
ui->statusBar->addPermanentWidget(statusLabel);
|
||||||
|
|
||||||
statusIcon = new QLabel();
|
statusIcon = new QLabel();
|
||||||
ui->statusBar->addPermanentWidget(statusIcon);
|
ui->statusBar->addPermanentWidget(statusIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::setupSettingsModal() {
|
||||||
// Set up File -> Settings action
|
// Set up File -> Settings action
|
||||||
QObject::connect(ui->actionSettings, &QAction::triggered, [=]() {
|
QObject::connect(ui->actionSettings, &QAction::triggered, [=]() {
|
||||||
QDialog settingsDialog(this);
|
QDialog settingsDialog(this);
|
||||||
@@ -73,7 +120,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
QIntValidator validator(0, 65535);
|
QIntValidator validator(0, 65535);
|
||||||
settings.port->setValidator(&validator);
|
settings.port->setValidator(&validator);
|
||||||
|
|
||||||
|
|
||||||
// If values are coming from zcash.conf, then disable all the fields
|
// If values are coming from zcash.conf, then disable all the fields
|
||||||
auto zcashConfLocation = Settings::getInstance()->getZcashdConfLocation();
|
auto zcashConfLocation = Settings::getInstance()->getZcashdConfLocation();
|
||||||
if (!zcashConfLocation.isEmpty()) {
|
if (!zcashConfLocation.isEmpty()) {
|
||||||
@@ -113,42 +159,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set up exit action
|
|
||||||
QObject::connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close);
|
|
||||||
|
|
||||||
// Set up donate action
|
|
||||||
QObject::connect(ui->actionDonate, &QAction::triggered, this, &MainWindow::donate);
|
|
||||||
|
|
||||||
// Set up check for updates action
|
|
||||||
QObject::connect(ui->actionCheck_for_Updates, &QAction::triggered, [=] () {
|
|
||||||
QDesktopServices::openUrl(QUrl("https://github.com/adityapk00/zcash-qt-wallet/releases"));
|
|
||||||
});
|
|
||||||
|
|
||||||
QObject::connect(ui->actionImport_Private_Keys, &QAction::triggered, this, &MainWindow::importPrivKeys);
|
|
||||||
|
|
||||||
// Set up about action
|
|
||||||
QObject::connect(ui->actionAbout, &QAction::triggered, [=] () {
|
|
||||||
QDialog aboutDialog(this);
|
|
||||||
Ui_about about;
|
|
||||||
about.setupUi(&aboutDialog);
|
|
||||||
|
|
||||||
QString version = QString("Version ") % QString(APP_VERSION) % " (" % QString(__DATE__) % ")";
|
|
||||||
about.versionLabel->setText(version);
|
|
||||||
|
|
||||||
aboutDialog.exec();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Initialize to the balances tab
|
|
||||||
ui->tabWidget->setCurrentIndex(0);
|
|
||||||
|
|
||||||
setupSendTab();
|
|
||||||
setupTransactionsTab();
|
|
||||||
setupRecieveTab();
|
|
||||||
setupBalancesTab();
|
|
||||||
|
|
||||||
rpc = new RPC(new QNetworkAccessManager(this), this);
|
|
||||||
rpc->refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::donate() {
|
void MainWindow::donate() {
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ private:
|
|||||||
void setupRecieveTab();
|
void setupRecieveTab();
|
||||||
void setupBalancesTab();
|
void setupBalancesTab();
|
||||||
|
|
||||||
|
void setupSettingsModal();
|
||||||
|
void setupStatusBar();
|
||||||
|
|
||||||
void removeExtraAddresses();
|
void removeExtraAddresses();
|
||||||
void setDefaultPayFrom();
|
void setDefaultPayFrom();
|
||||||
|
|
||||||
|
|||||||
@@ -243,10 +243,6 @@ void RPC::handleConnectionError(const QString& error) {
|
|||||||
% "\n\nA zcash.conf was found at\n" % confLocation
|
% "\n\nA zcash.conf was found at\n" % confLocation
|
||||||
% "\nbut we can't connect to zcashd. Is rpcuser=<user> and rpcpassword=<pass> set in the zcash.conf file?";
|
% "\nbut we can't connect to zcashd. Is rpcuser=<user> and rpcpassword=<pass> set in the zcash.conf file?";
|
||||||
}
|
}
|
||||||
} else if (error.contains("bad request", Qt::CaseInsensitive)) {
|
|
||||||
explanation = QString()
|
|
||||||
% "\n\nThis is most likely an internal error. Are you using zcashd v2.0 or higher? You might "
|
|
||||||
% "need to file a bug report here: https://github.com/adityapk00/zcash-qt-wallet/issues";
|
|
||||||
} else if (error.contains("internal server error", Qt::CaseInsensitive) ||
|
} else if (error.contains("internal server error", Qt::CaseInsensitive) ||
|
||||||
error.contains("rewinding", Qt::CaseInsensitive) ||
|
error.contains("rewinding", Qt::CaseInsensitive) ||
|
||||||
error.contains("loading", Qt::CaseInsensitive)) {
|
error.contains("loading", Qt::CaseInsensitive)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user