diff --git a/src/main.cpp b/src/main.cpp index 4c44680..5580475 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,7 +9,7 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); QIcon icon(":/icons/res/icon.ico"); - a.setWindowIcon(icon); + QApplication::setWindowIcon(icon); #ifdef Q_OS_LINUX QFontDatabase::addApplicationFont(":/fonts/res/Ubuntu-R.ttf"); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 576d099..b22bcdf 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -120,10 +120,16 @@ void MainWindow::setupSettingsModal() { QIntValidator validator(0, 65535); settings.port->setValidator(&validator); + // Load current values into the dialog + settings.hostname->setText(Settings::getInstance()->getHost()); + settings.port->setText(Settings::getInstance()->getPort()); + settings.rpcuser->setText(Settings::getInstance()->getUsernamePassword().split(":")[0]); + settings.rpcpassword->setText(Settings::getInstance()->getUsernamePassword().split(":")[1]); + // If values are coming from zcash.conf, then disable all the fields auto zcashConfLocation = Settings::getInstance()->getZcashdConfLocation(); if (!zcashConfLocation.isEmpty()) { - settings.confMsg->setText("Values are configured from\n" + zcashConfLocation); + settings.confMsg->setText("Settings are being read from \n" + zcashConfLocation); settings.hostname->setEnabled(false); settings.port->setEnabled(false); settings.rpcuser->setEnabled(false); @@ -134,12 +140,6 @@ void MainWindow::setupSettingsModal() { settings.port->setEnabled(true); settings.rpcuser->setEnabled(true); settings.rpcpassword->setEnabled(true); - - // Load previous values into the dialog - settings.hostname->setText(Settings::getInstance()->getHost()); - settings.port->setText(Settings::getInstance()->getPort()); - settings.rpcuser->setText(Settings::getInstance()->getUsernamePassword().split(":")[0]); - settings.rpcpassword->setText(Settings::getInstance()->getUsernamePassword().split(":")[1]); } if (settingsDialog.exec() == QDialog::Accepted) { @@ -212,6 +212,7 @@ void MainWindow::setupBalancesTab() { menu.addAction("Copy Address", [=] () { QClipboard *clipboard = QGuiApplication::clipboard(); clipboard->setText(addr); + ui->statusBar->showMessage("Copied to clipboard", 3 * 1000); }); if (addr.startsWith("t")) { @@ -244,6 +245,7 @@ void MainWindow::setupTransactionsTab() { menu.addAction("Copy txid", [=] () { QGuiApplication::clipboard()->setText(txid); + ui->statusBar->showMessage("Copied to clipboard", 3 * 1000); }); menu.addAction("View on block explorer", [=] () { QString url; diff --git a/src/rpc.cpp b/src/rpc.cpp index dab8d1d..fa97833 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -314,7 +314,7 @@ void RPC::getInfoThenRefresh() { }; doRPC(payload, [=](const json& reply) { - double progress = reply["verificationprogress"].get(); + auto progress = reply["verificationprogress"].get(); QString statusText = QString() % (progress < 0.99 ? "Syncing" : "Connected") % " (" % @@ -507,7 +507,7 @@ void RPC::refreshTxStatus(const QString& newOpid) { } // If there is some op that we are watching, then show the loading bar, otherwise hide it - if (watchingOps.size() == 0) { + if (watchingOps.empty()) { main->loadingLabel->setVisible(false); } else { main->loadingLabel->setVisible(true); diff --git a/src/sendtab.cpp b/src/sendtab.cpp index 793aa1a..abe10d7 100644 --- a/src/sendtab.cpp +++ b/src/sendtab.cpp @@ -378,10 +378,10 @@ QString MainWindow::doSendTxValidations(QString fromAddr, QList toAddr if (!matchesAnyAddr(fromAddr)) return QString("From Address is Invalid"); - for (auto toAddr = toAddrs.begin(); toAddr != toAddrs.end(); toAddr++) { - if (!matchesAnyAddr(toAddr->addr)) - return QString("Recipient Address ") % toAddr->addr % " is Invalid"; - }; + for (auto toAddr : toAddrs) { + if (!matchesAnyAddr(toAddr.addr)) + return QString("Recipient Address ") % toAddr.addr % " is Invalid"; + } return QString(); } diff --git a/src/settings.cpp b/src/settings.cpp index 99c13ea..6836f55 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -70,8 +70,7 @@ bool Settings::loadFromSettings() { uisettings = new Config{host, port, username, password}; - if (username.isEmpty()) return false; - return true; + return !username.isEmpty(); } bool Settings::loadFromFile() { @@ -145,4 +144,4 @@ bool Settings::isSyncing() { void Settings::setSyncing(bool syncing) { this->_isSyncing = syncing; -} \ No newline at end of file +} diff --git a/src/settings.ui b/src/settings.ui index 3283ada..601ddbf 100644 --- a/src/settings.ui +++ b/src/settings.ui @@ -24,113 +24,100 @@ - Connection + zcashd connection - - - - - zcashd connection - - - - 10 - - - - - - 60 - 0 - - - - RPC Username - - - - - - - - - - - 60 - 0 - - - - Host - - - - - - - 127.0.0.1 - - - - - - - 8232 - - - - - - - - 60 - 0 - - - - RPC Password - - - - - - - - - - - 60 - 0 - - - - Port - - - - - - - <html><head/><body><p><br/></p></body></html> - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - Qt::Horizontal - - - - - - - + + + <html><head/><body><p><br/></p></body></html> + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + + + + + + 60 + 0 + + + + Host + + + + + + + 127.0.0.1 + + + + + + + + 60 + 0 + + + + Port + + + + + + + 8232 + + + + + + + + 60 + 0 + + + + RPC Username + + + + + + + + + + + 60 + 0 + + + + RPC Password + + + + + + + + @@ -161,13 +148,6 @@ - - tabWidget - hostname - port - rpcuser - rpcpassword - diff --git a/src/ui_settings.h b/src/ui_settings.h index ac99532..343f58c 100644 --- a/src/ui_settings.h +++ b/src/ui_settings.h @@ -14,8 +14,6 @@ #include #include #include -#include -#include #include #include #include @@ -32,19 +30,17 @@ public: QTabWidget *tabWidget; QWidget *tab; QVBoxLayout *verticalLayout_3; - QVBoxLayout *verticalLayout_2; - QGroupBox *groupBox; - QGridLayout *gridLayout; - QLabel *label_3; - QLineEdit *rpcuser; + QLabel *confMsg; + QFrame *line; QLabel *label; QLineEdit *hostname; + QLabel *label_2; QLineEdit *port; + QLabel *label_3; + QLineEdit *rpcuser; QLabel *label_4; QLineEdit *rpcpassword; - QLabel *label_2; - QLabel *confMsg; - QFrame *line; + QVBoxLayout *verticalLayout_2; QSpacerItem *verticalSpacer; QDialogButtonBox *buttonBox; @@ -62,73 +58,65 @@ public: tab->setObjectName(QStringLiteral("tab")); verticalLayout_3 = new QVBoxLayout(tab); verticalLayout_3->setObjectName(QStringLiteral("verticalLayout_3")); - verticalLayout_2 = new QVBoxLayout(); - verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2")); - groupBox = new QGroupBox(tab); - groupBox->setObjectName(QStringLiteral("groupBox")); - gridLayout = new QGridLayout(groupBox); - gridLayout->setObjectName(QStringLiteral("gridLayout")); - gridLayout->setContentsMargins(10, -1, -1, -1); - label_3 = new QLabel(groupBox); - label_3->setObjectName(QStringLiteral("label_3")); - label_3->setMinimumSize(QSize(60, 0)); + confMsg = new QLabel(tab); + confMsg->setObjectName(QStringLiteral("confMsg")); + confMsg->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); - gridLayout->addWidget(label_3, 6, 0, 1, 1); + verticalLayout_3->addWidget(confMsg); - rpcuser = new QLineEdit(groupBox); - rpcuser->setObjectName(QStringLiteral("rpcuser")); + line = new QFrame(tab); + line->setObjectName(QStringLiteral("line")); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); - gridLayout->addWidget(rpcuser, 7, 0, 1, 1); + verticalLayout_3->addWidget(line); - label = new QLabel(groupBox); + label = new QLabel(tab); label->setObjectName(QStringLiteral("label")); label->setMinimumSize(QSize(60, 0)); - gridLayout->addWidget(label, 2, 0, 1, 1); + verticalLayout_3->addWidget(label); - hostname = new QLineEdit(groupBox); + hostname = new QLineEdit(tab); hostname->setObjectName(QStringLiteral("hostname")); - gridLayout->addWidget(hostname, 3, 0, 1, 1); - - port = new QLineEdit(groupBox); - port->setObjectName(QStringLiteral("port")); - - gridLayout->addWidget(port, 5, 0, 1, 1); + verticalLayout_3->addWidget(hostname); - label_4 = new QLabel(groupBox); - label_4->setObjectName(QStringLiteral("label_4")); - label_4->setMinimumSize(QSize(60, 0)); + label_2 = new QLabel(tab); + label_2->setObjectName(QStringLiteral("label_2")); + label_2->setMinimumSize(QSize(60, 0)); - gridLayout->addWidget(label_4, 8, 0, 1, 1); + verticalLayout_3->addWidget(label_2); - rpcpassword = new QLineEdit(groupBox); - rpcpassword->setObjectName(QStringLiteral("rpcpassword")); + port = new QLineEdit(tab); + port->setObjectName(QStringLiteral("port")); - gridLayout->addWidget(rpcpassword, 9, 0, 1, 1); + verticalLayout_3->addWidget(port); - label_2 = new QLabel(groupBox); - label_2->setObjectName(QStringLiteral("label_2")); - label_2->setMinimumSize(QSize(60, 0)); + label_3 = new QLabel(tab); + label_3->setObjectName(QStringLiteral("label_3")); + label_3->setMinimumSize(QSize(60, 0)); - gridLayout->addWidget(label_2, 4, 0, 1, 1); + verticalLayout_3->addWidget(label_3); - confMsg = new QLabel(groupBox); - confMsg->setObjectName(QStringLiteral("confMsg")); - confMsg->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); + rpcuser = new QLineEdit(tab); + rpcuser->setObjectName(QStringLiteral("rpcuser")); - gridLayout->addWidget(confMsg, 0, 0, 1, 1); + verticalLayout_3->addWidget(rpcuser); - line = new QFrame(groupBox); - line->setObjectName(QStringLiteral("line")); - line->setFrameShape(QFrame::HLine); - line->setFrameShadow(QFrame::Sunken); + label_4 = new QLabel(tab); + label_4->setObjectName(QStringLiteral("label_4")); + label_4->setMinimumSize(QSize(60, 0)); - gridLayout->addWidget(line, 1, 0, 1, 1); + verticalLayout_3->addWidget(label_4); + rpcpassword = new QLineEdit(tab); + rpcpassword->setObjectName(QStringLiteral("rpcpassword")); - verticalLayout_2->addWidget(groupBox); + verticalLayout_3->addWidget(rpcpassword); + verticalLayout_2 = new QVBoxLayout(); + verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2")); verticalLayout_3->addLayout(verticalLayout_2); @@ -147,10 +135,6 @@ public: verticalLayout->addWidget(buttonBox); - QWidget::setTabOrder(tabWidget, hostname); - QWidget::setTabOrder(hostname, port); - QWidget::setTabOrder(port, rpcuser); - QWidget::setTabOrder(rpcuser, rpcpassword); retranslateUi(Settings); QObject::connect(buttonBox, SIGNAL(accepted()), Settings, SLOT(accept())); @@ -165,15 +149,14 @@ public: void retranslateUi(QDialog *Settings) { Settings->setWindowTitle(QApplication::translate("Settings", "Settings", nullptr)); - groupBox->setTitle(QApplication::translate("Settings", "zcashd connection", nullptr)); - label_3->setText(QApplication::translate("Settings", "RPC Username", nullptr)); + confMsg->setText(QApplication::translate("Settings", "


", nullptr)); label->setText(QApplication::translate("Settings", "Host", nullptr)); hostname->setPlaceholderText(QApplication::translate("Settings", "127.0.0.1", nullptr)); + label_2->setText(QApplication::translate("Settings", "Port", nullptr)); port->setPlaceholderText(QApplication::translate("Settings", "8232", nullptr)); + label_3->setText(QApplication::translate("Settings", "RPC Username", nullptr)); label_4->setText(QApplication::translate("Settings", "RPC Password", nullptr)); - label_2->setText(QApplication::translate("Settings", "Port", nullptr)); - confMsg->setText(QApplication::translate("Settings", "


", nullptr)); - tabWidget->setTabText(tabWidget->indexOf(tab), QApplication::translate("Settings", "Connection", nullptr)); + tabWidget->setTabText(tabWidget->indexOf(tab), QApplication::translate("Settings", "zcashd connection", nullptr)); } // retranslateUi };