Browse Source

valgrind + clang warnings cleanup

import_zecw
Aditya Kulkarni 6 years ago
parent
commit
fa4f8685d9
  1. 2
      src/main.cpp
  2. 16
      src/mainwindow.cpp
  3. 4
      src/rpc.cpp
  4. 8
      src/sendtab.cpp
  5. 5
      src/settings.cpp
  6. 202
      src/settings.ui
  7. 109
      src/ui_settings.h

2
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");

16
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;

4
src/rpc.cpp

@ -314,7 +314,7 @@ void RPC::getInfoThenRefresh() {
};
doRPC(payload, [=](const json& reply) {
double progress = reply["verificationprogress"].get<double>();
auto progress = reply["verificationprogress"].get<double>();
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);

8
src/sendtab.cpp

@ -378,10 +378,10 @@ QString MainWindow::doSendTxValidations(QString fromAddr, QList<ToFields> 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();
}

5
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;
}
}

202
src/settings.ui

@ -24,113 +24,100 @@
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Connection</string>
<string>zcashd connection</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>zcashd connection</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>10</number>
</property>
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>RPC Username</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLineEdit" name="rpcuser"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Host</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLineEdit" name="hostname">
<property name="placeholderText">
<string>127.0.0.1</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLineEdit" name="port">
<property name="placeholderText">
<string>8232</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_4">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>RPC Password</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLineEdit" name="rpcpassword"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="confMsg">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
<widget class="QLabel" name="confMsg">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Host</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="hostname">
<property name="placeholderText">
<string>127.0.0.1</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="port">
<property name="placeholderText">
<string>8232</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>RPC Username</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="rpcuser"/>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>RPC Password</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="rpcpassword"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2"/>
</item>
<item>
<spacer name="verticalSpacer">
@ -161,13 +148,6 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>hostname</tabstop>
<tabstop>port</tabstop>
<tabstop>rpcuser</tabstop>
<tabstop>rpcpassword</tabstop>
</tabstops>
<resources/>
<connections>
<connection>

109
src/ui_settings.h

@ -14,8 +14,6 @@
#include <QtWidgets/QDialog>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QFrame>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QSpacerItem>
@ -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", "<html><head/><body><p><br/></p></body></html>", 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", "<html><head/><body><p><br/></p></body></html>", nullptr));
tabWidget->setTabText(tabWidget->indexOf(tab), QApplication::translate("Settings", "Connection", nullptr));
tabWidget->setTabText(tabWidget->indexOf(tab), QApplication::translate("Settings", "zcashd connection", nullptr));
} // retranslateUi
};

Loading…
Cancel
Save