|
4 | 4 |
|
5 | 5 | #include <qml/bitcoin.h> |
6 | 6 |
|
7 | | -#include <common/args.h> |
8 | | -#include <common/init.h> |
9 | | -#include <common/system.h> |
10 | 7 | #include <chainparams.h> |
11 | 8 | #include <common/args.h> |
| 9 | +#include <common/init.h> |
12 | 10 | #include <common/system.h> |
13 | 11 | #include <init.h> |
14 | 12 | #include <interfaces/chain.h> |
|
20 | 18 | #include <noui.h> |
21 | 19 | #include <qml/appmode.h> |
22 | 20 | #include <qml/bitcoinamount.h> |
| 21 | +#include <qml/bitcoinstartup.h> |
23 | 22 | #include <qml/clipboard.h> |
24 | 23 | #ifdef __ANDROID__ |
25 | 24 | #include <qml/androidnotifier.h> |
|
56 | 55 | #ifdef ENABLE_TEST_AUTOMATION |
57 | 56 | #include <qml/test/testbridge.h> |
58 | 57 | #endif |
| 58 | +#include <util/chaintype.h> |
59 | 59 | #include <util/threadnames.h> |
60 | 60 | #include <util/translation.h> |
61 | 61 |
|
@@ -96,17 +96,6 @@ Q_IMPORT_PLUGIN(QtQuickTemplates2Plugin) |
96 | 96 | #endif |
97 | 97 |
|
98 | 98 | namespace { |
99 | | -void SetupUIArgs(ArgsManager& argsman) |
100 | | -{ |
101 | | - argsman.AddArg("-lang=<lang>", "Set language, for example \"de_DE\" (default: system locale)", ArgsManager::ALLOW_ANY, OptionsCategory::GUI); |
102 | | - argsman.AddArg("-min", "Start minimized", ArgsManager::ALLOW_ANY, OptionsCategory::GUI); |
103 | | - argsman.AddArg("-resetguisettings", "Reset all settings changed in the GUI", ArgsManager::ALLOW_ANY, OptionsCategory::GUI); |
104 | | - argsman.AddArg("-skiponboard", "Skip onboarding flow and start directly in the main app", ArgsManager::ALLOW_ANY, OptionsCategory::GUI); |
105 | | -#ifdef ENABLE_TEST_AUTOMATION |
106 | | - argsman.AddArg("-test-automation=<path>", "Enable test automation bridge on the given Unix socket path", ArgsManager::ALLOW_ANY, OptionsCategory::GUI); |
107 | | -#endif |
108 | | -} |
109 | | - |
110 | 99 | AppMode SetupAppMode() |
111 | 100 | { |
112 | 101 | bool wallet_enabled; |
@@ -156,39 +145,6 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons |
156 | 145 | } |
157 | 146 | } |
158 | 147 |
|
159 | | -bool ConfigurationFileExists(ArgsManager& argsman) |
160 | | -{ |
161 | | - fs::path settings_path; |
162 | | - if (!argsman.GetSettingsPath(&settings_path)) { |
163 | | - // settings file is disabled |
164 | | - return true; |
165 | | - } |
166 | | - if (fs::exists(settings_path)) { |
167 | | - return true; |
168 | | - } |
169 | | - |
170 | | - const fs::path rel_config_path = argsman.GetPathArg("-conf", BITCOIN_CONF_FILENAME); |
171 | | - const fs::path abs_config_path = AbsPathForConfigVal(argsman, rel_config_path, true); |
172 | | - if (fs::exists(abs_config_path)) { |
173 | | - return true; |
174 | | - } |
175 | | - |
176 | | - return false; |
177 | | -} |
178 | | - |
179 | | -void setupChainQSettings(QGuiApplication* app, QString chain) |
180 | | -{ |
181 | | - if (chain.compare("MAIN") == 0) { |
182 | | - app->setApplicationName(QAPP_APP_NAME_DEFAULT); |
183 | | - } else if (chain.compare("TEST") == 0) { |
184 | | - app->setApplicationName(QAPP_APP_NAME_TESTNET); |
185 | | - } else if (chain.compare("SIGNET") == 0) { |
186 | | - app->setApplicationName(QAPP_APP_NAME_SIGNET); |
187 | | - } else if (chain.compare("REGTEST") == 0) { |
188 | | - app->setApplicationName(QAPP_APP_NAME_REGTEST); |
189 | | - } |
190 | | -} |
191 | | - |
192 | 148 | void LoadFontResource(const QString& path) |
193 | 149 | { |
194 | 150 | if (QFontDatabase::addApplicationFont(path) < 0) { |
@@ -251,19 +207,7 @@ int QmlGuiMain(int argc, char* argv[]) |
251 | 207 | InitLogging(gArgs); |
252 | 208 | InitParameterInteraction(gArgs); |
253 | 209 |
|
254 | | - QVariant need_onboarding(true); |
255 | | - if (gArgs.IsArgSet("-datadir") && !gArgs.GetPathArg("-datadir").empty()) { |
256 | | - need_onboarding.setValue(false); |
257 | | - } else if (ConfigurationFileExists(gArgs)) { |
258 | | - need_onboarding.setValue(false); |
259 | | - } |
260 | | - |
261 | | - if (gArgs.IsArgSet("-resetguisettings")) { |
262 | | - need_onboarding.setValue(true); |
263 | | - } |
264 | | - if (gArgs.GetBoolArg("-skiponboard", false)) { |
265 | | - need_onboarding.setValue(false); |
266 | | - } |
| 210 | + const bool need_onboarding{ShouldShowOnboarding(gArgs, ConfigurationFileExists(gArgs))}; |
267 | 211 |
|
268 | 212 | // legacy GUI: createNode() |
269 | 213 | std::unique_ptr<interfaces::Node> node = init->makeNode(); |
@@ -300,8 +244,9 @@ int QmlGuiMain(int argc, char* argv[]) |
300 | 244 | #endif |
301 | 245 |
|
302 | 246 | ChainModel chain_model{*chain}; |
303 | | - chain_model.setCurrentNetworkName(QString::fromStdString(gArgs.GetChainTypeString())); |
304 | | - setupChainQSettings(&app, chain_model.currentNetworkName()); |
| 247 | + const ChainType chain_type{Params().GetChainType()}; |
| 248 | + chain_model.setCurrentNetworkName(QString::fromStdString(ChainTypeToString(chain_type))); |
| 249 | + ApplyChainQSettingsApplicationName(app, chain_type); |
305 | 250 |
|
306 | 251 | QObject::connect(&node_model, &NodeModel::setTimeRatioList, &chain_model, &ChainModel::setTimeRatioList); |
307 | 252 | QObject::connect(&node_model, &NodeModel::setTimeRatioListInitial, &chain_model, &ChainModel::setTimeRatioListInitial); |
@@ -349,7 +294,7 @@ int QmlGuiMain(int argc, char* argv[]) |
349 | 294 | engine.rootContext()->setContextProperty("walletListModel", &wallet_list_model); |
350 | 295 | #endif |
351 | 296 |
|
352 | | - OptionsQmlModel options_model(*node, !need_onboarding.toBool()); |
| 297 | + OptionsQmlModel options_model(*node, !need_onboarding); |
353 | 298 |
|
354 | 299 | AppMode app_mode = SetupAppMode(); |
355 | 300 | DesktopWindowBehaviorModel desktop_window_behavior_model{app_mode.isDesktop()}; |
|
0 commit comments