From 66fb11c964255928b3db8085c041f275d17c0981 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 29 Jul 2016 12:36:49 +0400 Subject: [PATCH] Merge #919: Add option to hide warning about low keys b4647b5 Add option to hide warning about low keys before creating autobackup (but still warn if backup fails) --- src/qt/forms/optionsdialog.ui | 10 ++++++++++ src/qt/optionsdialog.cpp | 1 + src/qt/optionsmodel.cpp | 8 ++++++++ src/qt/optionsmodel.h | 1 + src/qt/overviewpage.cpp | 19 ++++++++++++------- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 09a42a567..724467194 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -173,6 +173,16 @@ + + + + Show warning dialog when PrivateSend detects that wallet has very low number of keys left. + + + Warn if PrivateSend is running out of keys + + + diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 9e6bb16ee..ad1943401 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -201,6 +201,7 @@ void OptionsDialog::setMapper() mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures); mapper->addMapping(ui->privateSendRounds, OptionsModel::PrivateSendRounds); mapper->addMapping(ui->privateSendAmount, OptionsModel::PrivateSendAmount); + mapper->addMapping(ui->lowKeysWarning, OptionsModel::LowKeysWarning); mapper->addMapping(ui->privateSendMultiSession, OptionsModel::PrivateSendMultiSession); /* Network */ diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index a5acd9a35..4541e9a53 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -88,6 +88,9 @@ void OptionsModel::Init(bool resetSettings) settings.setValue("fShowAdvancedPSUI", false); fShowAdvancedPSUI = settings.value("fShowAdvancedPSUI", false).toBool(); + if (!settings.contains("fLowKeysWarning")) + settings.setValue("fLowKeysWarning", true); + // These are shared with the core or have a command-line parameter // and we want command-line parameters to overwrite the GUI settings. // @@ -251,6 +254,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return settings.value("bSpendZeroConfChange"); case ShowAdvancedPSUI: return fShowAdvancedPSUI; + case LowKeysWarning: + return settings.value("fLowKeysWarning"); case PrivateSendRounds: return settings.value("nPrivateSendRounds"); case PrivateSendAmount: @@ -386,6 +391,9 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in settings.setValue("fShowAdvancedPSUI", fShowAdvancedPSUI); Q_EMIT advancedPSUIChanged(fShowAdvancedPSUI); break; + case LowKeysWarning: + settings.setValue("fLowKeysWarning", value); + break; case PrivateSendRounds: if (settings.value("nPrivateSendRounds") != value) { diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index e9302b3bc..4d7c38d4f 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -47,6 +47,7 @@ public: DatabaseCache, // int SpendZeroConfChange, // bool ShowAdvancedPSUI, // bool + LowKeysWarning, // bool PrivateSendRounds, // int PrivateSendAmount, // int ShowMasternodesTab, // bool diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index a3131191b..a23e1008b 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -463,13 +463,18 @@ void OverviewPage::privateSendStatus() // Warn user that wallet is running out of keys if (nWalletBackups > 0 && pwalletMain->nKeysLeftSinceAutoBackup < PS_KEYS_THRESHOLD_WARNING) { - QString strWarn = tr("Very low number of keys left since last automatic backup!") + "

" + - tr("We are about to create a new automatic backup for you, however " - " you should always make sure you have backups " - "saved in some safe place!"); - ui->labelPrivateSendEnabled->setToolTip(strWarn); - LogPrintf("OverviewPage::privateSendStatus - Very low number of keys left since last automatic backup, warning user and trying to create new backup...\n"); - QMessageBox::warning(this, tr("PrivateSend"), strWarn, QMessageBox::Ok, QMessageBox::Ok); + QSettings settings; + if(settings.value("fLowKeysWarning").toBool()) { + QString strWarn = tr("Very low number of keys left since last automatic backup!") + "

" + + tr("We are about to create a new automatic backup for you, however " + " you should always make sure you have backups " + "saved in some safe place!") + "

" + + tr("Note: You turn this message off in options."); + ui->labelPrivateSendEnabled->setToolTip(strWarn); + LogPrintf("OverviewPage::privateSendStatus -- Very low number of keys left since last automatic backup, warning user and trying to create new backup...\n"); + QMessageBox::warning(this, tr("PrivateSend"), strWarn, QMessageBox::Ok, QMessageBox::Ok); + } else + LogPrintf("OverviewPage::privateSendStatus -- Very low number of keys left since last automatic backup, skipping warning and trying to create new backup...\n"); std::string warningString; std::string errorString;