Skip to content

Commit 46b1904

Browse files
committed
qml: only show Onboarding if settings file is missing
1 parent 7cd989d commit 46b1904

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/qml/bitcoin.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons
9090
LogPrintf("GUI: %s\n", msg.toStdString());
9191
}
9292
}
93+
94+
bool SettingsFileExists(ArgsManager& argsman)
95+
{
96+
fs::path settings_path;
97+
if (!argsman.GetSettingsPath(&settings_path)) {
98+
// settings file is disabled
99+
return true;
100+
}
101+
return fs::exists(settings_path);
102+
}
93103
} // namespace
94104

95105

@@ -144,11 +154,19 @@ int QmlGuiMain(int argc, char* argv[])
144154
}
145155

146156
/// Read and parse settings.json file.
147-
if (!gArgs.InitSettings(error)) {
157+
std::vector<std::string> errors;
158+
if (!gArgs.ReadSettingsFile(&errors)) {
159+
error = strprintf("Failed loading settings file:\n%s\n", MakeUnorderedList(errors));
148160
InitError(Untranslated(error));
149161
return EXIT_FAILURE;
150162
}
151163

164+
QVariant need_onboarding(true);
165+
if (gArgs.IsArgSet("-datadir")) {
166+
need_onboarding.setValue(false);
167+
} else if (SettingsFileExists(gArgs)) {
168+
need_onboarding.setValue(false);
169+
}
152170
// Default printtoconsole to false for the GUI. GUI programs should not
153171
// print to the console unnecessarily.
154172
gArgs.SoftSetBoolArg("-printtoconsole", false);
@@ -199,6 +217,7 @@ int QmlGuiMain(int argc, char* argv[])
199217
OptionsQmlModel options_model{*node};
200218
engine.rootContext()->setContextProperty("optionsModel", &options_model);
201219

220+
engine.rootContext()->setContextProperty("needOnboarding", need_onboarding);
202221
#ifdef __ANDROID__
203222
AppMode app_mode(AppMode::MOBILE);
204223
#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)