Skip to content

Commit 7a2943e

Browse files
Merge #6833: backport: merge bitcoin-core/gui#600, #601, #602, #701, #603 (migrate some QSettings to settings.json)
076ce3d fix: only reset GUI-managed settings in -resetguisettings (Kittywhiskers Van Gogh) 0c3b224 merge bitcoin-core/gui#603: Add settings.json prune-prev, proxy-prev, onion-prev settings (Kittywhiskers Van Gogh) 45976c7 merge bitcoin-core/gui#701: Persist Mask Values option (Kittywhiskers Van Gogh) e429437 qt: migrate `-font-weight-bold` from QSettings to settings.json (Kittywhiskers Van Gogh) 70ff8ef qt: migrate `-font-weight-normal` from QSettings to settings.json (Kittywhiskers Van Gogh) c3a5ba1 qt: migrate `-font-scale` setting from QSettings to settings.json (Kittywhiskers Van Gogh) a5b5ede qt: migrate `-font-family` setting from QSettings to settings.json (Kittywhiskers Van Gogh) 2bb8106 qt: migrate `-enablecoinjoin` setting from QSettings to settings.json (Kittywhiskers Van Gogh) da15040 qt: migrate `-coinjoindenomshardcap` setting from QSettings to settings.json (Kittywhiskers Van Gogh) 4f744c2 qt: migrate `-coinjoindenomsgoal` setting from QSettings to settings.json (Kittywhiskers Van Gogh) ea60d79 qt: migrate `-coinjoinmultisession` setting from QSettings to settings.json (Kittywhiskers Van Gogh) fb97375 qt: migrate `-coinjoinamount` setting from QSettings to settings.json (Kittywhiskers Van Gogh) 2174fc6 qt: migrate `-coinjoinrounds` setting from QSettings to settings.json (Kittywhiskers Van Gogh) 44833d9 qt: migrate `-coinjoinsessions` setting from QSettings to settings.json (Kittywhiskers Van Gogh) eed631a refactor: spin-off list of option IDs that require string workaround (Kittywhiskers Van Gogh) dd21992 merge bitcoin-core/gui#602: Unify bitcoin-qt and bitcoind persistent settings (Kittywhiskers Van Gogh) d7cc771 qt: move Prune{,Size} handling outside `ENABLE_WALLET` gate (Kittywhiskers Van Gogh) bb2efec qt: remove PrivateSend -> CoinJoin migration logic, remove old values (Kittywhiskers Van Gogh) 4fc25af merge bitcoin-core/gui#601: Pass interfaces::Node references to OptionsModel constructor (Kittywhiskers Van Gogh) 6c9f1ae merge bitcoin-core/gui#600: Add OptionsModel getOption/setOption methods (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * Depends on #6901 * Depends on #7068 * Depends on #6831 ## Breaking Changes See release notes. ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: ACK 076ce3d Tree-SHA512: 5ee94e3fbad13792fa01ae4269f2184356a9359aba9ee1e0b0d5195fa1c32febeed56d41aa2add121c1cbc5d20dc0305bf3a617dea0c8eb35e92b29fd2974f42
2 parents e376079 + 076ce3d commit 7a2943e

15 files changed

+858
-667
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: 30 additions & 10 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(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)
@@ -293,7 +310,6 @@ void BitcoinApplication::createNode(interfaces::Init& init)
293310
{
294311
assert(!m_node);
295312
m_node = init.makeNode();
296-
if (optionsModel) optionsModel->setNode(*m_node);
297313
if (m_splash) m_splash->setNode(*m_node);
298314
}
299315

@@ -330,7 +346,7 @@ void BitcoinApplication::parameterSetup()
330346

331347
void BitcoinApplication::InitPruneSetting(int64_t prune_MiB)
332348
{
333-
optionsModel->SetPruneTargetGB(PruneMiBtoGB(prune_MiB), true);
349+
optionsModel->SetPruneTargetGB(PruneMiBtoGB(prune_MiB));
334350
}
335351

336352
void BitcoinApplication::requestInitialize()
@@ -668,8 +684,17 @@ int GuiMain(int argc, char* argv[])
668684
QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: Failed to load application fonts."));
669685
return EXIT_FAILURE;
670686
}
687+
688+
if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !gArgs.GetBoolArg("-min", false))
689+
app.createSplashScreen(networkStyle.data());
690+
691+
app.createNode(*init);
692+
671693
// Load GUI settings from QSettings
672-
app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false));
694+
if (!app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false))) {
695+
return EXIT_FAILURE;
696+
}
697+
673698
// Validate/set font family
674699
if (gArgs.IsArgSet("-font-family")) {
675700
QString family = gArgs.GetArg("-font-family", GUIUtil::FontRegistry::DEFAULT_FONT.toUtf8().toStdString()).c_str();
@@ -758,11 +783,6 @@ int GuiMain(int argc, char* argv[])
758783
app.InitPruneSetting(prune_MiB);
759784
}
760785

761-
if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !gArgs.GetBoolArg("-min", false))
762-
app.createSplashScreen(networkStyle.data());
763-
764-
app.createNode(*init);
765-
766786
int rv = EXIT_SUCCESS;
767787
try
768788
{

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/bitcoingui.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
889889

890890
connect(optionsModel, &OptionsModel::coinJoinEnabledChanged, this, &BitcoinGUI::updateCoinJoinVisibility);
891891
}
892+
893+
m_mask_values_action->setChecked(_clientModel->getOptionsModel()->getOption(OptionsModel::OptionID::MaskValues).toBool());
892894
} else {
893895
if(trayIconMenu)
894896
{

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)