Options tab with savesent checkbox

This commit is contained in:
adityapk00
2018-10-23 20:41:36 -07:00
parent 2b74c459ee
commit 4c58f70a31
8 changed files with 152 additions and 9 deletions

View File

@@ -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() {

View File

@@ -316,8 +316,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>841</width>
<height>321</height>
<width>849</width>
<height>369</height>
</rect>
</property>
<layout class="QVBoxLayout" name="sendToLayout">
@@ -712,7 +712,7 @@
<x>0</x>
<y>0</y>
<width>889</width>
<height>22</height>
<height>19</height>
</rect>
</property>
<widget class="QMenu" name="menuBalance">
@@ -720,7 +720,6 @@
<string>File</string>
</property>
<addaction name="actionImport_Private_Keys"/>
<addaction name="actionDelete_Sent_History"/>
<addaction name="actionSettings"/>
<addaction name="separator"/>
<addaction name="actionExit"/>

View File

@@ -50,6 +50,10 @@ QList<TransactionItem> 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;

View File

@@ -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();

View File

@@ -36,6 +36,9 @@ public:
int getBlockNumber();
void setBlockNumber(int number);
bool getSaveSent();
void setSaveSent(bool savesent);
bool isSaplingActive();
const QString& getZcashdConfLocation() { return confLocation; }

View File

@@ -20,7 +20,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@@ -134,6 +134,63 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Options</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Outgoing shielded transactions can be saved locally in the UI for convinence. These are not saved with zcashd.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="btnClearSaved">
<property name="text">
<string>Clear Saved</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="chkSaveTxs">
<property name="text">
<string>Save sent shielded transactions</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>

View File

@@ -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);

View File

@@ -11,11 +11,14 @@
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QDialog>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QFrame>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QSpacerItem>
#include <QtWidgets/QTabWidget>
#include <QtWidgets/QVBoxLayout>
@@ -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
};