diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5e38f06..78de9ef 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -121,12 +121,33 @@ void MainWindow::setupStatusBar() { } void MainWindow::setupSettingsModal() { + // Set up File -> Settings action QObject::connect(ui->actionSettings, &QAction::triggered, [=]() { QDialog settingsDialog(this); Ui_Settings settings; settings.setupUi(&settingsDialog); + // Setup save sent check box + QObject::connect(settings.chkSaveTxs, &QCheckBox::stateChanged, [=](auto checked) { + Settings::getInstance()->setSaveSent(checked); + }); + + // Setup clear button + QObject::connect(settings.btnClearSaved, &QCheckBox::clicked, [=]() { + if (QMessageBox::warning(this, "Clear saved history?", + "Shielded z-Address sent transactions are stored locally in your wallet. You may delete this saved information safely any time for your privacy.\nDo you want to delete this now ?", + QMessageBox::Yes, QMessageBox::Cancel)) { + SentTxStore::deleteHistory(); + // Reload after the clear button so existing txs disappear + rpc->refresh(); + } + }); + + // Save sent transactions + settings.chkSaveTxs->setChecked(Settings::getInstance()->getSaveSent()); + + // Connection Settings QIntValidator validator(0, 65535); settings.port->setValidator(&validator); @@ -153,6 +174,9 @@ void MainWindow::setupSettingsModal() { settings.rpcpassword->setEnabled(true); } + // Connection tab by default + settings.tabWidget->setCurrentIndex(0); + if (settingsDialog.exec() == QDialog::Accepted) { if (zcashConfLocation.isEmpty()) { // Save settings @@ -168,6 +192,7 @@ void MainWindow::setupSettingsModal() { } }; }); + } void MainWindow::donate() { diff --git a/src/mainwindow.ui b/src/mainwindow.ui index c0e684b..a0db06f 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -316,8 +316,8 @@ 0 0 - 841 - 321 + 849 + 369 @@ -712,7 +712,7 @@ 0 0 889 - 22 + 19 @@ -720,7 +720,6 @@ File - diff --git a/src/senttxstore.cpp b/src/senttxstore.cpp index 23d0b79..5e8b2bb 100644 --- a/src/senttxstore.cpp +++ b/src/senttxstore.cpp @@ -50,6 +50,10 @@ QList SentTxStore::readSentTxFile() { } void SentTxStore::addToSentTx(Tx tx, QString txid) { + // Save transactions only if the settings are allowed + if (!Settings::getInstance()->getSaveSent()) + return; + QFile data(writeableFile()); QJsonDocument jsonDoc; diff --git a/src/settings.cpp b/src/settings.cpp index ed9ce53..e39ac2e 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -11,6 +11,19 @@ Settings::~Settings() { delete uisettings; } +bool Settings::getSaveSent() { + // Load from the QT Settings. + QSettings s; + + return s.value("options/savesenttx", true).toBool(); +} + +void Settings::setSaveSent(bool savesent) { + QSettings s; + + s.setValue("options/savesenttx", savesent); +} + Settings* Settings::init() { if (instance == nullptr) instance = new Settings(); diff --git a/src/settings.h b/src/settings.h index 123259e..570c4d2 100644 --- a/src/settings.h +++ b/src/settings.h @@ -36,6 +36,9 @@ public: int getBlockNumber(); void setBlockNumber(int number); + bool getSaveSent(); + void setSaveSent(bool savesent); + bool isSaplingActive(); const QString& getZcashdConfLocation() { return confLocation; } diff --git a/src/settings.ui b/src/settings.ui index 601ddbf..62109af 100644 --- a/src/settings.ui +++ b/src/settings.ui @@ -20,7 +20,7 @@ - 0 + 1 @@ -134,6 +134,63 @@ + + + Options + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Outgoing shielded transactions can be saved locally in the UI for convinence. These are not saved with zcashd. + + + true + + + + + + + Clear Saved + + + + + + + Save sent shielded transactions + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + diff --git a/src/ui_mainwindow.h b/src/ui_mainwindow.h index 56fb1e8..39fbd79 100644 --- a/src/ui_mainwindow.h +++ b/src/ui_mainwindow.h @@ -368,7 +368,7 @@ public: sendToScrollArea->setWidgetResizable(true); sendToWidgets = new QWidget(); sendToWidgets->setObjectName(QStringLiteral("sendToWidgets")); - sendToWidgets->setGeometry(QRect(0, 0, 841, 321)); + sendToWidgets->setGeometry(QRect(0, 0, 849, 369)); sendToLayout = new QVBoxLayout(sendToWidgets); sendToLayout->setSpacing(6); sendToLayout->setContentsMargins(11, 11, 11, 11); @@ -640,7 +640,7 @@ public: MainWindow->setCentralWidget(centralWidget); menuBar = new QMenuBar(MainWindow); menuBar->setObjectName(QStringLiteral("menuBar")); - menuBar->setGeometry(QRect(0, 0, 889, 22)); + menuBar->setGeometry(QRect(0, 0, 889, 19)); menuBalance = new QMenu(menuBar); menuBalance->setObjectName(QStringLiteral("menuBalance")); menuHelp = new QMenu(menuBar); @@ -669,7 +669,6 @@ public: menuBar->addAction(menuBalance->menuAction()); menuBar->addAction(menuHelp->menuAction()); menuBalance->addAction(actionImport_Private_Keys); - menuBalance->addAction(actionDelete_Sent_History); menuBalance->addAction(actionSettings); menuBalance->addSeparator(); menuBalance->addAction(actionExit); diff --git a/src/ui_settings.h b/src/ui_settings.h index 343f58c..253c9dd 100644 --- a/src/ui_settings.h +++ b/src/ui_settings.h @@ -11,11 +11,14 @@ #include #include +#include #include #include #include +#include #include #include +#include #include #include #include @@ -42,6 +45,13 @@ public: QLineEdit *rpcpassword; QVBoxLayout *verticalLayout_2; QSpacerItem *verticalSpacer; + QWidget *tab_2; + QGridLayout *gridLayout; + QSpacerItem *horizontalSpacer; + QLabel *label_5; + QPushButton *btnClearSaved; + QCheckBox *chkSaveTxs; + QSpacerItem *verticalSpacer_2; QDialogButtonBox *buttonBox; void setupUi(QDialog *Settings) @@ -125,6 +135,35 @@ public: verticalLayout_3->addItem(verticalSpacer); tabWidget->addTab(tab, QString()); + tab_2 = new QWidget(); + tab_2->setObjectName(QStringLiteral("tab_2")); + gridLayout = new QGridLayout(tab_2); + gridLayout->setObjectName(QStringLiteral("gridLayout")); + horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + + gridLayout->addItem(horizontalSpacer, 2, 0, 1, 1); + + label_5 = new QLabel(tab_2); + label_5->setObjectName(QStringLiteral("label_5")); + label_5->setWordWrap(true); + + gridLayout->addWidget(label_5, 1, 0, 1, 2); + + btnClearSaved = new QPushButton(tab_2); + btnClearSaved->setObjectName(QStringLiteral("btnClearSaved")); + + gridLayout->addWidget(btnClearSaved, 2, 1, 1, 1); + + chkSaveTxs = new QCheckBox(tab_2); + chkSaveTxs->setObjectName(QStringLiteral("chkSaveTxs")); + + gridLayout->addWidget(chkSaveTxs, 0, 0, 1, 2); + + verticalSpacer_2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout->addItem(verticalSpacer_2, 3, 0, 1, 2); + + tabWidget->addTab(tab_2, QString()); verticalLayout->addWidget(tabWidget); @@ -140,7 +179,7 @@ public: QObject::connect(buttonBox, SIGNAL(accepted()), Settings, SLOT(accept())); QObject::connect(buttonBox, SIGNAL(rejected()), Settings, SLOT(reject())); - tabWidget->setCurrentIndex(0); + tabWidget->setCurrentIndex(1); QMetaObject::connectSlotsByName(Settings); @@ -157,6 +196,10 @@ public: 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)); + label_5->setText(QApplication::translate("Settings", "Outgoing shielded transactions can be saved locally in the UI for convinence. These are not saved with zcashd.", nullptr)); + btnClearSaved->setText(QApplication::translate("Settings", "Clear Saved", nullptr)); + chkSaveTxs->setText(QApplication::translate("Settings", "Save sent shielded transactions", nullptr)); + tabWidget->setTabText(tabWidget->indexOf(tab_2), QApplication::translate("Settings", "Options", nullptr)); } // retranslateUi };