Skip to content

Do not require restart if overridden option is modified #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 65 additions & 11 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,75 @@ void OptionsDialog::setModel(OptionsModel *_model)
/* warn when one of the following settings changes by user action (placed here so init via mapper doesn't trigger them) */

/* Main */
connect(ui->prune, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
connect(ui->prune, &QCheckBox::clicked, [this] {
if (!model->getOverriddenByCommandLine().contains("-prune")) {
showRestartWarning();
}
});
connect(ui->prune, &QCheckBox::clicked, this, &OptionsDialog::togglePruneWarning);
connect(ui->pruneSize, qOverload<int>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);
connect(ui->databaseCache, qOverload<int>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);
connect(ui->externalSignerPath, &QLineEdit::textChanged, [this]{ showRestartWarning(); });
connect(ui->threadsScriptVerif, qOverload<int>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);
connect(ui->pruneSize, qOverload<int>(&QSpinBox::valueChanged), [this] {
if (!model->getOverriddenByCommandLine().contains("-prune")) {
showRestartWarning();
}
});

connect(ui->databaseCache, qOverload<int>(&QSpinBox::valueChanged), [this] {
if (!model->getOverriddenByCommandLine().contains("-dbcache")) {
showRestartWarning();
}
});

connect(ui->threadsScriptVerif, qOverload<int>(&QSpinBox::valueChanged), [this] {
if (!model->getOverriddenByCommandLine().contains("-par")) {
showRestartWarning();
}
});

connect(ui->enableServer, &QCheckBox::clicked, [this] {
if (!model->getOverriddenByCommandLine().contains("-server")) {
showRestartWarning();
}
});

/* Wallet */
connect(ui->spendZeroConfChange, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
connect(ui->spendZeroConfChange, &QCheckBox::clicked, [this] {
if (!model->getOverriddenByCommandLine().contains("-spendzeroconfchange")) {
showRestartWarning();
}
});

connect(ui->externalSignerPath, &QLineEdit::textChanged, [this] {
if (!model->getOverriddenByCommandLine().contains("-signer")) {
showRestartWarning();
}
});

/* Network */
connect(ui->allowIncoming, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
connect(ui->enableServer, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
connect(ui->connectSocks, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
connect(ui->connectSocksTor, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
connect(ui->allowIncoming, &QCheckBox::clicked, [this] {
if (!model->getOverriddenByCommandLine().contains("-listen")) {
showRestartWarning();
}
});

connect(ui->connectSocks, &QCheckBox::clicked, [this] {
if (!model->getOverriddenByCommandLine().contains("-proxy")) {
showRestartWarning();
}
});

connect(ui->connectSocksTor, &QCheckBox::clicked, [this] {
if (!model->getOverriddenByCommandLine().contains("-onion")) {
showRestartWarning();
}
});

/* Display */
connect(ui->lang, qOverload<>(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); });
connect(ui->lang, qOverload<>(&QValueComboBox::valueChanged), [this] {
if (!model->getOverriddenByCommandLine().contains("-lang")) {
showRestartWarning();
}
});

connect(ui->thirdPartyTxUrls, &QLineEdit::textChanged, [this]{ showRestartWarning(); });
}

Expand Down
37 changes: 22 additions & 15 deletions src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,15 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
case ProxyUse:
if (settings.value("fUseProxy") != value) {
settings.setValue("fUseProxy", value.toBool());
setRestartRequired(true);
MaybeRestartRequired("-proxy");
}
break;
case ProxyIP: {
auto ip_port = GetProxySetting(settings, "addrProxy");
if (!ip_port.is_set || ip_port.ip != value.toString()) {
ip_port.ip = value.toString();
SetProxySetting(settings, "addrProxy", ip_port);
setRestartRequired(true);
MaybeRestartRequired("-proxy");
}
}
break;
Expand All @@ -432,7 +432,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
if (!ip_port.is_set || ip_port.port != value.toString()) {
ip_port.port = value.toString();
SetProxySetting(settings, "addrProxy", ip_port);
setRestartRequired(true);
MaybeRestartRequired("-proxy");
}
}
break;
Expand All @@ -441,15 +441,15 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
case ProxyUseTor:
if (settings.value("fUseSeparateProxyTor") != value) {
settings.setValue("fUseSeparateProxyTor", value.toBool());
setRestartRequired(true);
MaybeRestartRequired("-onion");
}
break;
case ProxyIPTor: {
auto ip_port = GetProxySetting(settings, "addrSeparateProxyTor");
if (!ip_port.is_set || ip_port.ip != value.toString()) {
ip_port.ip = value.toString();
SetProxySetting(settings, "addrSeparateProxyTor", ip_port);
setRestartRequired(true);
MaybeRestartRequired("-onion");
}
}
break;
Expand All @@ -458,7 +458,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
if (!ip_port.is_set || ip_port.port != value.toString()) {
ip_port.port = value.toString();
SetProxySetting(settings, "addrSeparateProxyTor", ip_port);
setRestartRequired(true);
MaybeRestartRequired("-onion");
}
}
break;
Expand All @@ -467,13 +467,13 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
case SpendZeroConfChange:
if (settings.value("bSpendZeroConfChange") != value) {
settings.setValue("bSpendZeroConfChange", value);
setRestartRequired(true);
MaybeRestartRequired("-spendzeroconfchange");
}
break;
case ExternalSignerPath:
if (settings.value("external_signer_path") != value.toString()) {
settings.setValue("external_signer_path", value.toString());
setRestartRequired(true);
MaybeRestartRequired("-signer");
}
break;
case SubFeeFromAmount:
Expand All @@ -494,7 +494,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
case Language:
if (settings.value("language") != value) {
settings.setValue("language", value);
setRestartRequired(true);
MaybeRestartRequired("-lang");
}
break;
case UseEmbeddedMonospacedFont:
Expand All @@ -510,37 +510,37 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
case Prune:
if (settings.value("bPrune") != value) {
settings.setValue("bPrune", value);
setRestartRequired(true);
MaybeRestartRequired("-prune");
}
break;
case PruneSize:
if (settings.value("nPruneSize") != value) {
settings.setValue("nPruneSize", value);
setRestartRequired(true);
MaybeRestartRequired("-prune");
}
break;
case DatabaseCache:
if (settings.value("nDatabaseCache") != value) {
settings.setValue("nDatabaseCache", value);
setRestartRequired(true);
MaybeRestartRequired("-dbcache");
}
break;
case ThreadsScriptVerif:
if (settings.value("nThreadsScriptVerif") != value) {
settings.setValue("nThreadsScriptVerif", value);
setRestartRequired(true);
MaybeRestartRequired("-par");
}
break;
case Listen:
if (settings.value("fListen") != value) {
settings.setValue("fListen", value);
setRestartRequired(true);
MaybeRestartRequired("-listen");
}
break;
case Server:
if (settings.value("server") != value) {
settings.setValue("server", value);
setRestartRequired(true);
MaybeRestartRequired("-server");
}
break;
default:
Expand All @@ -565,6 +565,13 @@ void OptionsModel::setDisplayUnit(const QVariant &value)
}
}

void OptionsModel::MaybeRestartRequired(const QString& option)
{
if (!strOverriddenByCommandLine.contains(option)) {
setRestartRequired(true);
}
}

void OptionsModel::setRestartRequired(bool fRequired)
{
QSettings settings;
Expand Down
1 change: 1 addition & 0 deletions src/qt/optionsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class OptionsModel : public QAbstractListModel
void SetPruneTargetGB(int prune_target_gb, bool force = false);

/* Restart flag helper */
void MaybeRestartRequired(const QString& option);
void setRestartRequired(bool fRequired);
bool isRestartRequired() const;

Expand Down