Skip to content

Commit dd21992

Browse files
committed
merge bitcoin-core/gui#602: Unify bitcoin-qt and bitcoind persistent settings
Changes related to external signers are not included as we don't have support for them. Additionally, pruning affects governance and txindex.
1 parent d7cc771 commit dd21992

File tree

13 files changed

+413
-252
lines changed

13 files changed

+413
-252
lines changed

doc/release-notes-6833.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
GUI changes
2+
-----------
3+
4+
Configuration changes made in the Dash GUI (such as the pruning setting,
5+
proxy settings, UPNP preferences) are now saved to `<datadir>/settings.json`
6+
file rather than to the Qt settings backend (windows registry or unix desktop
7+
config files), so these settings will now apply to dashd, instead of being
8+
ignored.
9+
10+
Also, the interaction between GUI settings and `dash.conf` settings is
11+
simplified. Settings from `dash.conf` are now displayed normally in the GUI
12+
settings dialog, instead of in a separate warning message ("Options set in this
13+
dialog are overridden by the configuration file: -setting=value"). And these
14+
settings can now be edited because `settings.json` values take precedence over
15+
`dash.conf` values.

src/qt/bitcoin.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,26 @@ void BitcoinApplication::createPaymentServer()
265265
}
266266
#endif
267267

268-
void BitcoinApplication::createOptionsModel(bool resetSettings)
268+
bool BitcoinApplication::createOptionsModel(bool resetSettings)
269269
{
270-
optionsModel = new OptionsModel(node(), this, resetSettings);
270+
optionsModel = new OptionsModel(node(), this);
271+
if (resetSettings) {
272+
optionsModel->Reset();
273+
}
274+
bilingual_str error;
275+
if (!optionsModel->Init(error)) {
276+
fs::path settings_path;
277+
if (gArgs.GetSettingsPath(&settings_path)) {
278+
error += Untranslated("\n");
279+
std::string quoted_path = strprintf("%s", fs::quoted(fs::PathToString(settings_path)));
280+
error.original += strprintf("Settings file %s might be corrupt or invalid.", quoted_path);
281+
error.translated += tr("Settings file %1 might be corrupt or invalid.").arg(QString::fromStdString(quoted_path)).toStdString();
282+
}
283+
InitError(error);
284+
QMessageBox::critical(nullptr, PACKAGE_NAME, QString::fromStdString(error.translated));
285+
return false;
286+
}
287+
return true;
271288
}
272289

273290
void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
@@ -329,7 +346,7 @@ void BitcoinApplication::parameterSetup()
329346

330347
void BitcoinApplication::InitPruneSetting(int64_t prune_MiB)
331348
{
332-
optionsModel->SetPruneTargetGB(PruneMiBtoGB(prune_MiB), true);
349+
optionsModel->SetPruneTargetGB(PruneMiBtoGB(prune_MiB));
333350
}
334351

335352
void BitcoinApplication::requestInitialize()
@@ -674,7 +691,10 @@ int GuiMain(int argc, char* argv[])
674691
app.createNode(*init);
675692

676693
// Load GUI settings from QSettings
677-
app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false));
694+
if (!app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false))) {
695+
return EXIT_FAILURE;
696+
}
697+
678698
// Validate/set font family
679699
if (gArgs.IsArgSet("-font-family")) {
680700
QString family = gArgs.GetArg("-font-family", GUIUtil::FontRegistry::DEFAULT_FONT.toUtf8().toStdString()).c_str();

src/qt/bitcoin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class BitcoinApplication: public QApplication
4646
/// parameter interaction/setup based on rules
4747
void parameterSetup();
4848
/// Create options model
49-
void createOptionsModel(bool resetSettings);
49+
[[nodiscard]] bool createOptionsModel(bool resetSettings);
5050
/// Initialize prune setting
5151
void InitPruneSetting(int64_t prune_MiB);
5252
/// Create main window

src/qt/forms/optionsdialog.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ https://explore.transifex.com/dash/dash/</string>
11401140
<item>
11411141
<widget class="QLabel" name="overriddenByCommandLineInfoLabel">
11421142
<property name="text">
1143-
<string>Options set in this dialog are overridden by the command line or in the configuration file:</string>
1143+
<string>Options set in this dialog are overridden by the command line:</string>
11441144
</property>
11451145
<property name="textFormat">
11461146
<enum>Qt::PlainText</enum>

src/qt/optionsdialog.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include <QIntValidator>
3636
#include <QLocale>
3737
#include <QMessageBox>
38-
#include <QSettings>
3938
#include <QShowEvent>
4039
#include <QSystemTrayIcon>
4140
#include <QTimer>
@@ -84,10 +83,6 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
8483
#ifndef USE_NATPMP
8584
ui->mapPortNatpmp->setEnabled(false);
8685
#endif
87-
connect(this, &QDialog::accepted, [this](){
88-
QSettings settings;
89-
model->node().mapPort(settings.value("fUseUPnP").toBool(), settings.value("fUseNatpmp").toBool());
90-
});
9186

9287
ui->proxyIp->setEnabled(false);
9388
ui->proxyPort->setEnabled(false);

0 commit comments

Comments
 (0)