valgrind + clang warnings cleanup

This commit is contained in:
Aditya Kulkarni
2018-10-17 23:20:40 -07:00
parent 995b6bc96d
commit fa4f8685d9
7 changed files with 171 additions and 207 deletions

View File

@@ -9,7 +9,7 @@ int main(int argc, char *argv[])
QApplication a(argc, argv); QApplication a(argc, argv);
QIcon icon(":/icons/res/icon.ico"); QIcon icon(":/icons/res/icon.ico");
a.setWindowIcon(icon); QApplication::setWindowIcon(icon);
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
QFontDatabase::addApplicationFont(":/fonts/res/Ubuntu-R.ttf"); QFontDatabase::addApplicationFont(":/fonts/res/Ubuntu-R.ttf");

View File

@@ -120,10 +120,16 @@ void MainWindow::setupSettingsModal() {
QIntValidator validator(0, 65535); QIntValidator validator(0, 65535);
settings.port->setValidator(&validator); 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 // 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()) {
settings.confMsg->setText("Values are configured from\n" + zcashConfLocation); settings.confMsg->setText("Settings are being read from \n" + zcashConfLocation);
settings.hostname->setEnabled(false); settings.hostname->setEnabled(false);
settings.port->setEnabled(false); settings.port->setEnabled(false);
settings.rpcuser->setEnabled(false); settings.rpcuser->setEnabled(false);
@@ -134,12 +140,6 @@ void MainWindow::setupSettingsModal() {
settings.port->setEnabled(true); settings.port->setEnabled(true);
settings.rpcuser->setEnabled(true); settings.rpcuser->setEnabled(true);
settings.rpcpassword->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) { if (settingsDialog.exec() == QDialog::Accepted) {
@@ -212,6 +212,7 @@ void MainWindow::setupBalancesTab() {
menu.addAction("Copy Address", [=] () { menu.addAction("Copy Address", [=] () {
QClipboard *clipboard = QGuiApplication::clipboard(); QClipboard *clipboard = QGuiApplication::clipboard();
clipboard->setText(addr); clipboard->setText(addr);
ui->statusBar->showMessage("Copied to clipboard", 3 * 1000);
}); });
if (addr.startsWith("t")) { if (addr.startsWith("t")) {
@@ -244,6 +245,7 @@ void MainWindow::setupTransactionsTab() {
menu.addAction("Copy txid", [=] () { menu.addAction("Copy txid", [=] () {
QGuiApplication::clipboard()->setText(txid); QGuiApplication::clipboard()->setText(txid);
ui->statusBar->showMessage("Copied to clipboard", 3 * 1000);
}); });
menu.addAction("View on block explorer", [=] () { menu.addAction("View on block explorer", [=] () {
QString url; QString url;

View File

@@ -314,7 +314,7 @@ void RPC::getInfoThenRefresh() {
}; };
doRPC(payload, [=](const json& reply) { doRPC(payload, [=](const json& reply) {
double progress = reply["verificationprogress"].get<double>(); auto progress = reply["verificationprogress"].get<double>();
QString statusText = QString() % QString statusText = QString() %
(progress < 0.99 ? "Syncing" : "Connected") % (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 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); main->loadingLabel->setVisible(false);
} else { } else {
main->loadingLabel->setVisible(true); main->loadingLabel->setVisible(true);

View File

@@ -378,10 +378,10 @@ QString MainWindow::doSendTxValidations(QString fromAddr, QList<ToFields> toAddr
if (!matchesAnyAddr(fromAddr)) return QString("From Address is Invalid"); if (!matchesAnyAddr(fromAddr)) return QString("From Address is Invalid");
for (auto toAddr = toAddrs.begin(); toAddr != toAddrs.end(); toAddr++) { for (auto toAddr : toAddrs) {
if (!matchesAnyAddr(toAddr->addr)) if (!matchesAnyAddr(toAddr.addr))
return QString("Recipient Address ") % toAddr->addr % " is Invalid"; return QString("Recipient Address ") % toAddr.addr % " is Invalid";
}; }
return QString(); return QString();
} }

View File

@@ -70,8 +70,7 @@ bool Settings::loadFromSettings() {
uisettings = new Config{host, port, username, password}; uisettings = new Config{host, port, username, password};
if (username.isEmpty()) return false; return !username.isEmpty();
return true;
} }
bool Settings::loadFromFile() { bool Settings::loadFromFile() {

View File

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

View File

@@ -14,8 +14,6 @@
#include <QtWidgets/QDialog> #include <QtWidgets/QDialog>
#include <QtWidgets/QDialogButtonBox> #include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QFrame> #include <QtWidgets/QFrame>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QLabel> #include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit> #include <QtWidgets/QLineEdit>
#include <QtWidgets/QSpacerItem> #include <QtWidgets/QSpacerItem>
@@ -32,19 +30,17 @@ public:
QTabWidget *tabWidget; QTabWidget *tabWidget;
QWidget *tab; QWidget *tab;
QVBoxLayout *verticalLayout_3; QVBoxLayout *verticalLayout_3;
QVBoxLayout *verticalLayout_2;
QGroupBox *groupBox;
QGridLayout *gridLayout;
QLabel *label_3;
QLineEdit *rpcuser;
QLabel *label;
QLineEdit *hostname;
QLineEdit *port;
QLabel *label_4;
QLineEdit *rpcpassword;
QLabel *label_2;
QLabel *confMsg; QLabel *confMsg;
QFrame *line; QFrame *line;
QLabel *label;
QLineEdit *hostname;
QLabel *label_2;
QLineEdit *port;
QLabel *label_3;
QLineEdit *rpcuser;
QLabel *label_4;
QLineEdit *rpcpassword;
QVBoxLayout *verticalLayout_2;
QSpacerItem *verticalSpacer; QSpacerItem *verticalSpacer;
QDialogButtonBox *buttonBox; QDialogButtonBox *buttonBox;
@@ -62,73 +58,65 @@ public:
tab->setObjectName(QStringLiteral("tab")); tab->setObjectName(QStringLiteral("tab"));
verticalLayout_3 = new QVBoxLayout(tab); verticalLayout_3 = new QVBoxLayout(tab);
verticalLayout_3->setObjectName(QStringLiteral("verticalLayout_3")); verticalLayout_3->setObjectName(QStringLiteral("verticalLayout_3"));
verticalLayout_2 = new QVBoxLayout(); confMsg = new QLabel(tab);
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));
gridLayout->addWidget(label_3, 6, 0, 1, 1);
rpcuser = new QLineEdit(groupBox);
rpcuser->setObjectName(QStringLiteral("rpcuser"));
gridLayout->addWidget(rpcuser, 7, 0, 1, 1);
label = new QLabel(groupBox);
label->setObjectName(QStringLiteral("label"));
label->setMinimumSize(QSize(60, 0));
gridLayout->addWidget(label, 2, 0, 1, 1);
hostname = new QLineEdit(groupBox);
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);
label_4 = new QLabel(groupBox);
label_4->setObjectName(QStringLiteral("label_4"));
label_4->setMinimumSize(QSize(60, 0));
gridLayout->addWidget(label_4, 8, 0, 1, 1);
rpcpassword = new QLineEdit(groupBox);
rpcpassword->setObjectName(QStringLiteral("rpcpassword"));
gridLayout->addWidget(rpcpassword, 9, 0, 1, 1);
label_2 = new QLabel(groupBox);
label_2->setObjectName(QStringLiteral("label_2"));
label_2->setMinimumSize(QSize(60, 0));
gridLayout->addWidget(label_2, 4, 0, 1, 1);
confMsg = new QLabel(groupBox);
confMsg->setObjectName(QStringLiteral("confMsg")); confMsg->setObjectName(QStringLiteral("confMsg"));
confMsg->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); confMsg->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse);
gridLayout->addWidget(confMsg, 0, 0, 1, 1); verticalLayout_3->addWidget(confMsg);
line = new QFrame(groupBox); line = new QFrame(tab);
line->setObjectName(QStringLiteral("line")); line->setObjectName(QStringLiteral("line"));
line->setFrameShape(QFrame::HLine); line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken); line->setFrameShadow(QFrame::Sunken);
gridLayout->addWidget(line, 1, 0, 1, 1); verticalLayout_3->addWidget(line);
label = new QLabel(tab);
label->setObjectName(QStringLiteral("label"));
label->setMinimumSize(QSize(60, 0));
verticalLayout_2->addWidget(groupBox); verticalLayout_3->addWidget(label);
hostname = new QLineEdit(tab);
hostname->setObjectName(QStringLiteral("hostname"));
verticalLayout_3->addWidget(hostname);
label_2 = new QLabel(tab);
label_2->setObjectName(QStringLiteral("label_2"));
label_2->setMinimumSize(QSize(60, 0));
verticalLayout_3->addWidget(label_2);
port = new QLineEdit(tab);
port->setObjectName(QStringLiteral("port"));
verticalLayout_3->addWidget(port);
label_3 = new QLabel(tab);
label_3->setObjectName(QStringLiteral("label_3"));
label_3->setMinimumSize(QSize(60, 0));
verticalLayout_3->addWidget(label_3);
rpcuser = new QLineEdit(tab);
rpcuser->setObjectName(QStringLiteral("rpcuser"));
verticalLayout_3->addWidget(rpcuser);
label_4 = new QLabel(tab);
label_4->setObjectName(QStringLiteral("label_4"));
label_4->setMinimumSize(QSize(60, 0));
verticalLayout_3->addWidget(label_4);
rpcpassword = new QLineEdit(tab);
rpcpassword->setObjectName(QStringLiteral("rpcpassword"));
verticalLayout_3->addWidget(rpcpassword);
verticalLayout_2 = new QVBoxLayout();
verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2"));
verticalLayout_3->addLayout(verticalLayout_2); verticalLayout_3->addLayout(verticalLayout_2);
@@ -147,10 +135,6 @@ public:
verticalLayout->addWidget(buttonBox); verticalLayout->addWidget(buttonBox);
QWidget::setTabOrder(tabWidget, hostname);
QWidget::setTabOrder(hostname, port);
QWidget::setTabOrder(port, rpcuser);
QWidget::setTabOrder(rpcuser, rpcpassword);
retranslateUi(Settings); retranslateUi(Settings);
QObject::connect(buttonBox, SIGNAL(accepted()), Settings, SLOT(accept())); QObject::connect(buttonBox, SIGNAL(accepted()), Settings, SLOT(accept()));
@@ -165,15 +149,14 @@ public:
void retranslateUi(QDialog *Settings) void retranslateUi(QDialog *Settings)
{ {
Settings->setWindowTitle(QApplication::translate("Settings", "Settings", nullptr)); Settings->setWindowTitle(QApplication::translate("Settings", "Settings", nullptr));
groupBox->setTitle(QApplication::translate("Settings", "zcashd connection", nullptr)); confMsg->setText(QApplication::translate("Settings", "<html><head/><body><p><br/></p></body></html>", nullptr));
label_3->setText(QApplication::translate("Settings", "RPC Username", nullptr));
label->setText(QApplication::translate("Settings", "Host", nullptr)); label->setText(QApplication::translate("Settings", "Host", nullptr));
hostname->setPlaceholderText(QApplication::translate("Settings", "127.0.0.1", nullptr)); hostname->setPlaceholderText(QApplication::translate("Settings", "127.0.0.1", nullptr));
port->setPlaceholderText(QApplication::translate("Settings", "8232", nullptr));
label_4->setText(QApplication::translate("Settings", "RPC Password", nullptr));
label_2->setText(QApplication::translate("Settings", "Port", nullptr)); label_2->setText(QApplication::translate("Settings", "Port", nullptr));
confMsg->setText(QApplication::translate("Settings", "<html><head/><body><p><br/></p></body></html>", nullptr)); port->setPlaceholderText(QApplication::translate("Settings", "8232", nullptr));
tabWidget->setTabText(tabWidget->indexOf(tab), QApplication::translate("Settings", "Connection", nullptr)); label_3->setText(QApplication::translate("Settings", "RPC Username", nullptr));
label_4->setText(QApplication::translate("Settings", "RPC Password", nullptr));
tabWidget->setTabText(tabWidget->indexOf(tab), QApplication::translate("Settings", "zcashd connection", nullptr));
} // retranslateUi } // retranslateUi
}; };