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

Function InitSettings

src/qt/bitcoin.cpp:152–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152static bool InitSettings()
153{
154 if (!gArgs.GetSettingsPath()) {
155 return true; // Do nothing if settings file disabled.
156 }
157
158 std::vector<std::string> errors;
159 if (!gArgs.ReadSettingsFile(&errors)) {
160 std::string error = QT_TRANSLATE_NOOP("bitcoin-core", "Settings file could not be read");
161 std::string error_translated = QCoreApplication::translate("bitcoin-core", error.c_str()).toStdString();
162 InitError(Untranslated(strprintf("%s:\n%s\n", error, MakeUnorderedList(errors))));
163
164 QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error_translated)), QMessageBox::Reset | QMessageBox::Abort);
165 /*: Explanatory text shown on startup when the settings file cannot be read.
166 Prompts user to make a choice between resetting or aborting. */
167 messagebox.setInformativeText(QObject::tr("Do you want to reset settings to default values, or to abort without making changes?"));
168 messagebox.setDetailedText(QString::fromStdString(MakeUnorderedList(errors)));
169 messagebox.setTextFormat(Qt::PlainText);
170 messagebox.setDefaultButton(QMessageBox::Reset);
171 switch (messagebox.exec()) {
172 case QMessageBox::Reset:
173 break;
174 case QMessageBox::Abort:
175 return false;
176 default:
177 assert(false);
178 }
179 }
180
181 errors.clear();
182 if (!gArgs.WriteSettingsFile(&errors)) {
183 std::string error = QT_TRANSLATE_NOOP("bitcoin-core", "Settings file could not be written");
184 std::string error_translated = QCoreApplication::translate("bitcoin-core", error.c_str()).toStdString();
185 InitError(Untranslated(strprintf("%s:\n%s\n", error, MakeUnorderedList(errors))));
186
187 QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error_translated)), QMessageBox::Ok);
188 /*: Explanatory text shown on startup when the settings file could not be written.
189 Prompts user to check that we have the ability to write to the file.
190 Explains that the user has the option of running without a settings file.*/
191 messagebox.setInformativeText(QObject::tr("A fatal error occurred. Check that settings file is writable, or try running with -nosettings."));
192 messagebox.setDetailedText(QString::fromStdString(MakeUnorderedList(errors)));
193 messagebox.setTextFormat(Qt::PlainText);
194 messagebox.setDefaultButton(QMessageBox::Ok);
195 messagebox.exec();
196 return false;
197 }
198 return true;
199}
200
201/* qDebug() message handler --> debug.log */
202void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg)

Callers 1

GuiMainFunction · 0.85

Calls 8

InitErrorFunction · 0.85
UntranslatedFunction · 0.85
MakeUnorderedListFunction · 0.85
GetSettingsPathMethod · 0.80
ReadSettingsFileMethod · 0.80
execMethod · 0.80
WriteSettingsFileMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected