Skip to content

Commit 8c672b8

Browse files
committed
Merge #247: Only show Onboarding if settings file is missing
27c38a9 qml: only show Onboarding if settings/conf file is missing (johnny9) Pull request description: Commit adds a context property that is used to determine if Onboarding flow is needed. If the user supplies a data directory or their settings.json file is missing, the property "needOnboarding" will be set to true. [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/<PR>) [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/<PR>) [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/insecure_mac_arm64_gui.zip?branch=pull/<PR>) [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/<PR>) ACKs for top commit: jarolrod: ACK 27c38a9 Tree-SHA512: 80cd9e2cf07a4e107918353e0f98880fdfacc78e7348cc6ab1006b58858f0ca18aafc9315344e991da073ee42a9b1459f4d9c60da1b646516aa6370ef735cf18
2 parents 972e7a1 + 27c38a9 commit 8c672b8

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
@@ -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,19 @@ 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+
}
154182
// Default printtoconsole to false for the GUI. GUI programs should not
155183
// print to the console unnecessarily.
156184
gArgs.SoftSetBoolArg("-printtoconsole", false);
@@ -208,6 +236,7 @@ int QmlGuiMain(int argc, char* argv[])
208236
OptionsQmlModel options_model{*node};
209237
engine.rootContext()->setContextProperty("optionsModel", &options_model);
210238

239+
engine.rootContext()->setContextProperty("needOnboarding", need_onboarding);
211240
#ifdef __ANDROID__
212241
AppMode app_mode(AppMode::MOBILE);
213242
#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)