Skip to content

Commit e8fa39a

Browse files
johnny9jarolrod
authored andcommitted
qml: only show Onboarding if settings/conf file is missing
1 parent fa433b1 commit e8fa39a

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/qml/bitcoin.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,26 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons
9292
LogPrintf("GUI: %s\n", msg.toStdString());
9393
}
9494
}
95+
96+
bool ConfigurationFileExists(ArgsManager& argsman)
97+
{
98+
fs::path settings_path;
99+
if (!argsman.GetSettingsPath(&settings_path)) {
100+
// settings file is disabled
101+
return true;
102+
}
103+
if (fs::exists(settings_path)) {
104+
return true;
105+
}
106+
107+
const fs::path rel_config_path = argsman.GetPathArg("-conf", BITCOIN_CONF_FILENAME);
108+
const fs::path abs_config_path = AbsPathForConfigVal(rel_config_path, true);
109+
if (fs::exists(abs_config_path)) {
110+
return true;
111+
}
112+
113+
return false;
114+
}
95115
} // namespace
96116

97117

@@ -146,11 +166,24 @@ int QmlGuiMain(int argc, char* argv[])
146166
}
147167

148168
/// Read and parse settings.json file.
149-
if (!gArgs.InitSettings(error)) {
169+
std::vector<std::string> errors;
170+
if (!gArgs.ReadSettingsFile(&errors)) {
171+
error = strprintf("Failed loading settings file:\n%s\n", MakeUnorderedList(errors));
150172
InitError(Untranslated(error));
151173
return EXIT_FAILURE;
152174
}
153175

176+
QVariant need_onboarding(true);
177+
if (gArgs.IsArgSet("-datadir") && !gArgs.GetPathArg("-datadir").empty()) {
178+
need_onboarding.setValue(false);
179+
} else if (ConfigurationFileExists(gArgs)) {
180+
need_onboarding.setValue(false);
181+
}
182+
183+
if (gArgs.IsArgSet("-resetguisettings")) {
184+
need_onboarding.setValue(true);
185+
}
186+
154187
// Default printtoconsole to false for the GUI. GUI programs should not
155188
// print to the console unnecessarily.
156189
gArgs.SoftSetBoolArg("-printtoconsole", false);
@@ -208,6 +241,7 @@ int QmlGuiMain(int argc, char* argv[])
208241
OptionsQmlModel options_model{*node};
209242
engine.rootContext()->setContextProperty("optionsModel", &options_model);
210243

244+
engine.rootContext()->setContextProperty("needOnboarding", need_onboarding);
211245
#ifdef __ANDROID__
212246
AppMode app_mode(AppMode::MOBILE);
213247
#else

src/qml/pages/main.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ApplicationWindow {
2121

2222
StackView {
2323
id: main
24-
initialItem: onboardingWizard
24+
initialItem: needOnboarding ? onboardingWizard : node
2525
anchors.fill: parent
2626
}
2727

0 commit comments

Comments
 (0)