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>
7
10
#include < chainparams.h>
8
11
#include < common/args.h>
9
12
#include < common/system.h>
12
15
#include < interfaces/init.h>
13
16
#include < interfaces/node.h>
14
17
#include < logging.h>
18
+ #include < node/context.h>
15
19
#include < node/interface_ui.h>
16
20
#include < noui.h>
17
21
#include < qml/appmode.h>
@@ -181,60 +185,48 @@ int QmlGuiMain(int argc, char* argv[])
181
185
Q_INIT_RESOURCE (bitcoin_qml);
182
186
qRegisterMetaType<interfaces::BlockAndHeaderTipInfo>(" interfaces::BlockAndHeaderTipInfo" );
183
187
184
- QGuiApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
185
188
QGuiApplication::styleHints ()->setTabFocusBehavior (Qt::TabFocusAllControls);
186
189
QGuiApplication app (argc, argv);
187
190
188
- auto handler_message_box = ::uiInterface.ThreadSafeMessageBox_connect (InitErrorMessageBox);
189
-
190
191
std::unique_ptr<interfaces::Init> init = interfaces::MakeGuiInit (argc, argv);
192
+ auto handler_message_box = ::uiInterface.ThreadSafeMessageBox_connect (InitErrorMessageBox);
191
193
192
194
SetupEnvironment ();
193
195
util::ThreadSetInternalName (" main" );
194
196
195
197
// must be set before parsing command-line options; otherwise,
196
198
// if invalid parameters were passed, QSetting initialization would fail
197
- // and the error will be displayed on terminal
199
+ // and the error will be displayed on terminal.
200
+ // must be set before OptionsModel is initialized or translations are loaded,
201
+ // as it is used to locate QSettings
198
202
app.setOrganizationName (QAPP_ORG_NAME);
199
203
app.setOrganizationDomain (QAPP_ORG_DOMAIN);
200
204
app.setApplicationName (QAPP_APP_NAME_DEFAULT);
201
205
202
- // / Parse command-line options. We do this after qt in order to show an error if there are problems parsing these.
203
- SetupServerArgs (gArgs );
206
+ // Parse command-line options. We do this after qt in order to show an error if there are problems parsing these.
207
+ SetupServerArgs (gArgs , init->canListenIpc ());
208
+
204
209
SetupUIArgs (gArgs );
205
210
std::string error;
206
211
if (!gArgs .ParseParameters (argc, argv, error)) {
207
212
InitError (Untranslated (strprintf (" Cannot parse command line arguments: %s\n " , error)));
208
213
return EXIT_FAILURE;
209
214
}
210
215
211
- // / Determine availability of data directory.
212
- if (!CheckDataDirOption (gArgs )) {
213
- InitError (Untranslated (strprintf (" Specified data directory \" %s\" does not exist.\n " , gArgs .GetArg (" -datadir" , " " ))));
214
- return EXIT_FAILURE;
215
- }
216
-
217
- // / Read and parse bitcoin.conf file.
218
- if (!gArgs .ReadConfigFiles (error, true )) {
219
- InitError (Untranslated (strprintf (" Cannot parse configuration file: %s\n " , error)));
216
+ if (auto error = common::InitConfig (
217
+ gArgs ,
218
+ [](const bilingual_str& msg, const std::vector<std::string>& details) {
219
+ return InitError (msg, details);
220
+ })) {
220
221
return EXIT_FAILURE;
221
222
}
222
223
223
- // / Check for chain settings (Params() calls are only valid after this clause).
224
- try {
225
- SelectParams (gArgs .GetChainType ());
226
- } catch (std::exception &e) {
227
- InitError (Untranslated (strprintf (" %s\n " , e.what ())));
228
- return EXIT_FAILURE;
229
- }
230
-
231
- // / Read and parse settings.json file.
232
- std::vector<std::string> errors;
233
- if (!gArgs .ReadSettingsFile (&errors)) {
234
- error = strprintf (" Failed loading settings file:\n %s\n " , MakeUnorderedList (errors));
235
- InitError (Untranslated (error));
236
- return EXIT_FAILURE;
237
- }
224
+ // legacy GUI: parameterSetup()
225
+ // Default printtoconsole to false for the GUI. GUI programs should not
226
+ // print to the console unnecessarily.
227
+ gArgs .SoftSetBoolArg (" -printtoconsole" , false );
228
+ InitLogging (gArgs );
229
+ InitParameterInteraction (gArgs );
238
230
239
231
QVariant need_onboarding (true );
240
232
if (gArgs .IsArgSet (" -datadir" ) && !gArgs .GetPathArg (" -datadir" ).empty ()) {
@@ -247,16 +239,11 @@ int QmlGuiMain(int argc, char* argv[])
247
239
need_onboarding.setValue (true );
248
240
}
249
241
250
- // Default printtoconsole to false for the GUI. GUI programs should not
251
- // print to the console unnecessarily.
252
- gArgs .SoftSetBoolArg (" -printtoconsole" , false );
253
- InitLogging (gArgs );
254
- InitParameterInteraction (gArgs );
255
-
256
- GUIUtil::LogQtInfo ();
257
-
242
+ // legacy GUI: createNode()
258
243
std::unique_ptr<interfaces::Node> node = init->makeNode ();
259
244
std::unique_ptr<interfaces::Chain> chain = init->makeChain ();
245
+
246
+ // legacy GUI: baseInitialize()
260
247
if (!node->baseInitialize ()) {
261
248
// A dialog with detailed error will have been shown by InitError().
262
249
return EXIT_FAILURE;
@@ -287,7 +274,7 @@ int QmlGuiMain(int argc, char* argv[])
287
274
#endif
288
275
289
276
ChainModel chain_model{*chain};
290
- chain_model.setCurrentNetworkName (QString::fromStdString (ChainTypeToString ( gArgs .GetChainType () )));
277
+ chain_model.setCurrentNetworkName (QString::fromStdString (gArgs .GetChainTypeString ( )));
291
278
setupChainQSettings (&app, chain_model.currentNetworkName ());
292
279
293
280
QObject::connect (&node_model, &NodeModel::setTimeRatioList, &chain_model, &ChainModel::setTimeRatioList);
0 commit comments