MCPcopy Create free account
hub / github.com/ElementsProject/elements / showIfNeeded

Method showIfNeeded

src/qt/intro.cpp:205–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205bool Intro::showIfNeeded(bool& did_show_intro, int64_t& prune_MiB)
206{
207 did_show_intro = false;
208
209 QSettings settings;
210 /* If data directory provided on command line, no need to look at settings
211 or show a picking dialog */
212 if(!gArgs.GetArg("-datadir", "").empty())
213 return true;
214 /* 1) Default data directory for operating system */
215 QString dataDir = GUIUtil::getDefaultDataDirectory();
216 /* 2) Allow QSettings to override default dir */
217 dataDir = settings.value("strDataDir", dataDir).toString();
218
219 if(!fs::exists(GUIUtil::QStringToPath(dataDir)) || gArgs.GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || settings.value("fReset", false).toBool() || gArgs.GetBoolArg("-resetguisettings", false))
220 {
221 /* Use selectParams here to guarantee Params() can be used by node interface */
222 try {
223 SelectParams(gArgs.GetChainName());
224 } catch (const std::exception&) {
225 return false;
226 }
227
228 /* If current default data directory does not exist, let the user choose one */
229 Intro intro(0, Params().AssumedBlockchainSize(), Params().AssumedChainStateSize());
230 intro.setDataDirectory(dataDir);
231 intro.setWindowIcon(QIcon(":icons/bitcoin"));
232 did_show_intro = true;
233
234 while(true)
235 {
236 if(!intro.exec())
237 {
238 /* Cancel clicked */
239 return false;
240 }
241 dataDir = intro.getDataDirectory();
242 try {
243 if (TryCreateDirectories(GUIUtil::QStringToPath(dataDir))) {
244 // If a new data directory has been created, make wallets subdirectory too
245 TryCreateDirectories(GUIUtil::QStringToPath(dataDir) / "wallets");
246 }
247 break;
248 } catch (const fs::filesystem_error&) {
249 QMessageBox::critical(nullptr, PACKAGE_NAME,
250 tr("Error: Specified data directory \"%1\" cannot be created.").arg(dataDir));
251 /* fall through, back to choosing screen */
252 }
253 }
254
255 // Additional preferences:
256 prune_MiB = intro.getPruneMiB();
257
258 settings.setValue("strDataDir", dataDir);
259 settings.setValue("fReset", false);
260 }
261 /* Only override -datadir if different from the default, to make it possible to
262 * override -datadir in the bitcoin.conf file in the default data directory

Callers

nothing calls this directly

Calls 15

getDefaultDataDirectoryFunction · 0.85
existsFunction · 0.85
QStringToPathFunction · 0.85
SelectParamsFunction · 0.85
TryCreateDirectoriesFunction · 0.85
PathToStringFunction · 0.85
GetArgMethod · 0.80
GetBoolArgMethod · 0.80
GetChainNameMethod · 0.80
AssumedBlockchainSizeMethod · 0.80
AssumedChainStateSizeMethod · 0.80
setDataDirectoryMethod · 0.80

Tested by

no test coverage detected