Skip to content

Commit 27c38a9

Browse files
committed
qml: only show Onboarding if settings/conf file is missing
1 parent 7cd989d commit 27c38a9

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/qml/bitcoin.cpp

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

95115

@@ -144,11 +164,19 @@ int QmlGuiMain(int argc, char* argv[])
144164
}
145165

146166
/// Read and parse settings.json file.
147-
if (!gArgs.InitSettings(error)) {
167+
std::vector<std::string> errors;
168+
if (!gArgs.ReadSettingsFile(&errors)) {
169+
error = strprintf("Failed loading settings file:\n%s\n", MakeUnorderedList(errors));
148170
InitError(Untranslated(error));
149171
return EXIT_FAILURE;
150172
}
151173

174+
QVariant need_onboarding(true);
175+
if (gArgs.IsArgSet("-datadir") && !gArgs.GetPathArg("-datadir").empty()) {
176+
need_onboarding.setValue(false);
177+
} else if (ConfigurationFileExists(gArgs)) {
178+
need_onboarding.setValue(false);
179+
}
152180
// Default printtoconsole to false for the GUI. GUI programs should not
153181
// print to the console unnecessarily.
154182
gArgs.SoftSetBoolArg("-printtoconsole", false);
@@ -199,6 +227,7 @@ int QmlGuiMain(int argc, char* argv[])
199227
OptionsQmlModel options_model{*node};
200228
engine.rootContext()->setContextProperty("optionsModel", &options_model);
201229

230+
engine.rootContext()->setContextProperty("needOnboarding", need_onboarding);
202231
#ifdef __ANDROID__
203232
AppMode app_mode(AppMode::MOBILE);
204233
#else

src/qml/pages/main.qml

+1-1
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)