mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge 7ebc4c6689 into merged_master (Bitcoin PR bitcoin-core/gui#379)
This commit is contained in:
commit
1d3c63e17b
1 changed files with 53 additions and 3 deletions
|
|
@ -143,6 +143,58 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
|
|||
QApplication::installTranslator(&translator);
|
||||
}
|
||||
|
||||
static std::string JoinErrors(const std::vector<std::string>& errors)
|
||||
{
|
||||
return Join(errors, "\n", [](const std::string& error) { return "- " + error; });
|
||||
}
|
||||
|
||||
static bool InitSettings()
|
||||
{
|
||||
if (!gArgs.GetSettingsPath()) {
|
||||
return true; // Do nothing if settings file disabled.
|
||||
}
|
||||
|
||||
std::vector<std::string> errors;
|
||||
if (!gArgs.ReadSettingsFile(&errors)) {
|
||||
bilingual_str error = _("Settings file could not be read");
|
||||
InitError(Untranslated(strprintf("%s:\n%s\n", error.original, JoinErrors(errors))));
|
||||
|
||||
QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error.translated)), QMessageBox::Reset | QMessageBox::Abort);
|
||||
/*: Explanatory text shown on startup when the settings file cannot be read.
|
||||
Prompts user to make a choice between resetting or aborting. */
|
||||
messagebox.setInformativeText(QObject::tr("Do you want to reset settings to default values, or to abort without making changes?"));
|
||||
messagebox.setDetailedText(QString::fromStdString(JoinErrors(errors)));
|
||||
messagebox.setTextFormat(Qt::PlainText);
|
||||
messagebox.setDefaultButton(QMessageBox::Reset);
|
||||
switch (messagebox.exec()) {
|
||||
case QMessageBox::Reset:
|
||||
break;
|
||||
case QMessageBox::Abort:
|
||||
return false;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
errors.clear();
|
||||
if (!gArgs.WriteSettingsFile(&errors)) {
|
||||
bilingual_str error = _("Settings file could not be written");
|
||||
InitError(Untranslated(strprintf("%s:\n%s\n", error.original, JoinErrors(errors))));
|
||||
|
||||
QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error.translated)), QMessageBox::Ok);
|
||||
/*: Explanatory text shown on startup when the settings file could not be written.
|
||||
Prompts user to check that we have the ability to write to the file.
|
||||
Explains that the user has the option of running without a settings file.*/
|
||||
messagebox.setInformativeText(QObject::tr("A fatal error occured. Check that settings file is writable, or try running with -nosettings."));
|
||||
messagebox.setDetailedText(QString::fromStdString(JoinErrors(errors)));
|
||||
messagebox.setTextFormat(Qt::PlainText);
|
||||
messagebox.setDefaultButton(QMessageBox::Ok);
|
||||
messagebox.exec();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* qDebug() message handler --> debug.log */
|
||||
void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg)
|
||||
{
|
||||
|
|
@ -485,9 +537,7 @@ int GuiMain(int argc, char* argv[])
|
|||
QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: %1").arg(e.what()));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!gArgs.InitSettings(error)) {
|
||||
InitError(Untranslated(error));
|
||||
QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error initializing settings: %1").arg(QString::fromStdString(error)));
|
||||
if (!InitSettings()) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue