From d917e7754cb4056eb5d8d8776835cc142d4a74be Mon Sep 17 00:00:00 2001 From: Arjun <37590483+denverbdr@users.noreply.github.com> Date: Thu, 27 Jun 2019 10:51:17 -0700 Subject: [PATCH] Move desktopservices to settings --- src/mainwindow.cpp | 25 +++---------------------- src/settings.cpp | 21 +++++++++++++++++++++ src/settings.h | 3 +++ 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 00a1208..a2cde36 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -424,14 +424,7 @@ void MainWindow::setupStatusBar() { QGuiApplication::clipboard()->setText(txid); }); menu.addAction("View tx on block explorer", [=]() { - QString url; - if (Settings::getInstance()->isTestnet()) { - url = "https://explorer.testnet.z.cash/tx/" + txid; - } - else { - url = "https://explorer.zcha.in/transactions/" + txid; - } - QDesktopServices::openUrl(QUrl(url)); + Settings::openTxInExplorer(txid); }); } @@ -1109,13 +1102,7 @@ void MainWindow::setupBalancesTab() { } menu.addAction(tr("View on block explorer"), [=] () { - QString url; - if (Settings::getInstance()->isTestnet()) { - url = "https://explorer.testnet.z.cash/address/" + addr; - } else { - url = "https://explorer.zcha.in/accounts/" + addr; - } - QDesktopServices::openUrl(QUrl(url)); + Settings::openAddressInExplorer(addr); }); } @@ -1175,13 +1162,7 @@ void MainWindow::setupTransactionsTab() { } menu.addAction(tr("View on block explorer"), [=] () { - QString url; - if (Settings::getInstance()->isTestnet()) { - url = "https://explorer.testnet.z.cash/tx/" + txid; - } else { - url = "https://explorer.zcha.in/transactions/" + txid; - } - QDesktopServices::openUrl(QUrl(url)); + Settings::openTxInExplorer(txid); }); // Payment Request diff --git a/src/settings.cpp b/src/settings.cpp index c15d558..2773364 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -160,6 +160,27 @@ void Settings::saveRestore(QDialog* d) { }); } +void Settings::openAddressInExplorer(QString address) { + QString url; + if (Settings::getInstance()->isTestnet()) { + url = "https://explorer.testnet.z.cash/address/" + address; + } else { + url = "https://explorer.zcha.in/accounts/" + address; + } + QDesktopServices::openUrl(QUrl(url)); +} + +void Settings::openTxInExplorer(QString txid) { + QString url; + if (Settings::getInstance()->isTestnet()) { + url = "https://explorer.testnet.z.cash/tx/" + txid; + } + else { + url = "https://explorer.zcha.in/transactions/" + txid; + } + QDesktopServices::openUrl(QUrl(url)); +} + QString Settings::getUSDFormat(double bal) { return "$" + QLocale(QLocale::English).toString(bal, 'f', 2); } diff --git a/src/settings.h b/src/settings.h index 827877f..8e1b7ef 100644 --- a/src/settings.h +++ b/src/settings.h @@ -77,6 +77,9 @@ public: static void saveRestore(QDialog* d); + static void openAddressInExplorer(QString address); + static void openTxInExplorer(QString txid); + static PaymentURI parseURI(QString paymentURI); static QString paymentURIPretty(PaymentURI);