Browse Source

Add advanced explorer settings

pull/72/head
Yusuf Sahin HAMZA 5 years ago
parent
commit
cbdd74a848
  1. 30
      src/mainwindow.cpp
  2. 19
      src/settings.cpp
  3. 10
      src/settings.h
  4. 124
      src/settings.ui

30
src/mainwindow.cpp

@ -420,11 +420,12 @@ void MainWindow::setupStatusBar() {
});
menu.addAction("View tx on block explorer", [=]() {
QString url;
auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) {
url = "https://explorer.testnet.z.cash/tx/" + txid;
url = explorer.testnetTxExplorerUrl + txid;
}
else {
url = "https://explorer.myhush.org/tx/" + txid;
url = explorer.txExplorerUrl + txid;
}
QDesktopServices::openUrl(QUrl(url));
});
@ -517,6 +518,7 @@ void MainWindow::setupSettingsModal() {
settings.rpcpassword->setEnabled(true);
}
// Load current values into the dialog
// Load current values into the dialog
auto conf = Settings::getInstance()->getSettings();
settings.hostname->setText(conf.host);
@ -524,6 +526,13 @@ void MainWindow::setupSettingsModal() {
settings.rpcuser->setText(conf.rpcuser);
settings.rpcpassword->setText(conf.rpcpassword);
// Load current explorer values into the dialog
auto explorer = Settings::getInstance()->getExplorer();
settings.txExplorerUrl->setText(explorer.txExplorerUrl);
settings.addressExplorerUrl->setText(explorer.addressExplorerUrl);
settings.testnetTxExplorerUrl->setText(explorer.testnetTxExplorerUrl);
settings.testnetAddressExplorerUrl->setText(explorer.testnetAddressExplorerUrl);
// Connection tab by default
settings.tabWidget->setCurrentIndex(0);
@ -585,6 +594,13 @@ void MainWindow::setupSettingsModal() {
cl->loadConnection();
}
// Save explorer
Settings::getInstance()->saveExplorer(
settings.txExplorerUrl->text(),
settings.addressExplorerUrl->text(),
settings.testnetTxExplorerUrl->text(),
settings.testnetAddressExplorerUrl->text());
// Check to see if rescan or reindex have been enabled
bool showRestartInfo = false;
if (settings.chkRescan->isChecked()) {
@ -1170,11 +1186,12 @@ void MainWindow::setupBalancesTab() {
menu.addAction(tr("View on block explorer"), [=] () {
QString url;
auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) {
//TODO
url = "https://explorer.testnet.myhush.org/address/" + addr;
url = explorer.testnetAddressExplorerUrl + addr;
} else {
url = "https://explorer.myhush.org/address/" + addr;
url = explorer.addressExplorerUrl + addr;
}
QDesktopServices::openUrl(QUrl(url));
});
@ -1250,10 +1267,11 @@ void MainWindow::setupTransactionsTab() {
menu.addAction(tr("View on block explorer"), [=] () {
QString url;
auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) {
url = "https://explorer.testnet.myhush.org/tx/" + txid;
url = explorer.testnetTxExplorerUrl + txid;
} else {
url = "https://explorer.myhush.org/tx/" + txid;
url = explorer.txExplorerUrl + txid;
}
QDesktopServices::openUrl(QUrl(url));
});

19
src/settings.cpp

@ -30,6 +30,25 @@ void Settings::setAllowFetchPrices(bool allow) {
QSettings().setValue("options/allowfetchprices", allow);
}
Explorer Settings::getExplorer() {
// Load from the QT Settings.
QSettings s;
auto txExplorerUrl = s.value("explorer/txExplorerUrl").toString();
auto addressExplorerUrl = s.value("explorer/addressExplorerUrl").toString();
auto testnetTxExplorerUrl = s.value("explorer/testnetTxExplorerUrl").toString();
auto testnetAddressExplorerUrl = s.value("explorer/testnetAddressExplorerUrl").toString();
return Explorer{txExplorerUrl, addressExplorerUrl, testnetTxExplorerUrl, testnetAddressExplorerUrl};
}
void Settings::saveExplorer(const QString& txExplorerUrl, const QString& addressExplorerUrl, const QString& testnetTxExplorerUrl, const QString& testnetAddressExplorerUrl) {
QSettings s;
s.setValue("explorer/txExplorerUrl", txExplorerUrl);
s.setValue("explorer/addressExplorerUrl", addressExplorerUrl);
s.setValue("explorer/testnetTxExplorerUrl", testnetTxExplorerUrl);
s.setValue("explorer/testnetAddressExplorerUrl", testnetAddressExplorerUrl);
}
Config Settings::getSettings() {
// Load from the QT Settings.

10
src/settings.h

@ -10,6 +10,13 @@ struct Config {
QString rpcpassword;
};
struct Explorer {
QString txExplorerUrl;
QString addressExplorerUrl;
QString testnetTxExplorerUrl;
QString testnetAddressExplorerUrl;
};
struct ToFields;
struct Tx;
@ -28,6 +35,9 @@ public:
static Settings* init();
static Settings* getInstance();
Explorer getExplorer();
void saveExplorer(const QString& txExplorerUrl, const QString& addressExplorerUrl, const QString& testnetTxExplorerUrl, const QString& testnetAddressExplorerUrl);
Config getSettings();
void saveSettings(const QString& host, const QString& port, const QString& username, const QString& password);

124
src/settings.ui

@ -26,7 +26,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -283,6 +283,128 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Explorer</string>
</attribute>
<widget class="QLabel" name="label_14">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>491</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>Tx Explorer URL</string>
</property>
</widget>
<widget class="Line" name="line_5">
<property name="geometry">
<rect>
<x>9</x>
<y>105</y>
<width>491</width>
<height>3</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QLineEdit" name="txExplorerUrl">
<property name="geometry">
<rect>
<x>9</x>
<y>28</y>
<width>491</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string notr="true">https://explorer.myhush.org/tx/</string>
</property>
</widget>
<widget class="QLabel" name="label_15">
<property name="geometry">
<rect>
<x>9</x>
<y>54</y>
<width>491</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>Address Explorer URL</string>
</property>
</widget>
<widget class="QLineEdit" name="addressExplorerUrl">
<property name="geometry">
<rect>
<x>9</x>
<y>73</y>
<width>491</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string notr="true">https://explorer.myhush.org/address/</string>
</property>
</widget>
<widget class="QLabel" name="label_16">
<property name="geometry">
<rect>
<x>9</x>
<y>112</y>
<width>491</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>Testnet Tx Explorer URL</string>
</property>
</widget>
<widget class="QLineEdit" name="testnetTxExplorerUrl">
<property name="geometry">
<rect>
<x>9</x>
<y>131</y>
<width>491</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string notr="true">https://explorer.testnet.z.cash/tx/</string>
</property>
</widget>
<widget class="QLabel" name="label_17">
<property name="geometry">
<rect>
<x>9</x>
<y>160</y>
<width>501</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Testnet Address Explorer URL</string>
</property>
</widget>
<widget class="QLineEdit" name="testnetAddressExplorerUrl">
<property name="geometry">
<rect>
<x>9</x>
<y>180</y>
<width>491</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string notr="true">https://explorer.testnet.myhush.org/address/</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Troubleshooting</string>

Loading…
Cancel
Save