mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
merge bitcoin#22653: Rename JoinErrors and re-use it
This commit is contained in:
parent
e24324d266
commit
d158063b6d
@ -22,6 +22,7 @@
|
|||||||
#include <qt/splashscreen.h>
|
#include <qt/splashscreen.h>
|
||||||
#include <qt/utilitydialog.h>
|
#include <qt/utilitydialog.h>
|
||||||
#include <qt/winshutdownmonitor.h>
|
#include <qt/winshutdownmonitor.h>
|
||||||
|
#include <util/string.h>
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
#include <qt/paymentserver.h>
|
#include <qt/paymentserver.h>
|
||||||
@ -148,11 +149,6 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
|
|||||||
QApplication::installTranslator(&translator);
|
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()
|
static bool InitSettings()
|
||||||
{
|
{
|
||||||
if (!gArgs.GetSettingsPath()) {
|
if (!gArgs.GetSettingsPath()) {
|
||||||
@ -162,13 +158,13 @@ static bool InitSettings()
|
|||||||
std::vector<std::string> errors;
|
std::vector<std::string> errors;
|
||||||
if (!gArgs.ReadSettingsFile(&errors)) {
|
if (!gArgs.ReadSettingsFile(&errors)) {
|
||||||
bilingual_str error = _("Settings file could not be read");
|
bilingual_str error = _("Settings file could not be read");
|
||||||
InitError(Untranslated(strprintf("%s:\n%s\n", error.original, JoinErrors(errors))));
|
InitError(Untranslated(strprintf("%s:\n%s\n", error.original, MakeUnorderedList(errors))));
|
||||||
|
|
||||||
QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error.translated)), QMessageBox::Reset | QMessageBox::Abort);
|
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.
|
/*: Explanatory text shown on startup when the settings file cannot be read.
|
||||||
Prompts user to make a choice between resetting or aborting. */
|
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.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.setDetailedText(QString::fromStdString(MakeUnorderedList(errors)));
|
||||||
messagebox.setTextFormat(Qt::PlainText);
|
messagebox.setTextFormat(Qt::PlainText);
|
||||||
messagebox.setDefaultButton(QMessageBox::Reset);
|
messagebox.setDefaultButton(QMessageBox::Reset);
|
||||||
switch (messagebox.exec()) {
|
switch (messagebox.exec()) {
|
||||||
@ -184,14 +180,14 @@ static bool InitSettings()
|
|||||||
errors.clear();
|
errors.clear();
|
||||||
if (!gArgs.WriteSettingsFile(&errors)) {
|
if (!gArgs.WriteSettingsFile(&errors)) {
|
||||||
bilingual_str error = _("Settings file could not be written");
|
bilingual_str error = _("Settings file could not be written");
|
||||||
InitError(Untranslated(strprintf("%s:\n%s\n", error.original, JoinErrors(errors))));
|
InitError(Untranslated(strprintf("%s:\n%s\n", error.original, MakeUnorderedList(errors))));
|
||||||
|
|
||||||
QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error.translated)), QMessageBox::Ok);
|
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.
|
/*: 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.
|
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.*/
|
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.setInformativeText(QObject::tr("A fatal error occurred. Check that settings file is writable, or try running with -nosettings."));
|
||||||
messagebox.setDetailedText(QString::fromStdString(JoinErrors(errors)));
|
messagebox.setDetailedText(QString::fromStdString(MakeUnorderedList(errors)));
|
||||||
messagebox.setTextFormat(Qt::PlainText);
|
messagebox.setTextFormat(Qt::PlainText);
|
||||||
messagebox.setDefaultButton(QMessageBox::Ok);
|
messagebox.setDefaultButton(QMessageBox::Ok);
|
||||||
messagebox.exec();
|
messagebox.exec();
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <txmempool.h>
|
#include <txmempool.h>
|
||||||
#include <undo.h>
|
#include <undo.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
|
#include <util/string.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
@ -1619,7 +1620,7 @@ static RPCHelpMan verifychain()
|
|||||||
"\nVerifies blockchain database.\n",
|
"\nVerifies blockchain database.\n",
|
||||||
{
|
{
|
||||||
{"checklevel", RPCArg::Type::NUM, /* default */ strprintf("%d, range=0-4", DEFAULT_CHECKLEVEL),
|
{"checklevel", RPCArg::Type::NUM, /* default */ strprintf("%d, range=0-4", DEFAULT_CHECKLEVEL),
|
||||||
strprintf("How thorough the block verification is:\n - %s", Join(CHECKLEVEL_DOC, "\n- "))},
|
strprintf("How thorough the block verification is:\n - %s", MakeUnorderedList(CHECKLEVEL_DOC))},
|
||||||
{"nblocks", RPCArg::Type::NUM, /* default */ strprintf("%d, 0=all", DEFAULT_CHECKBLOCKS), "The number of blocks to check."},
|
{"nblocks", RPCArg::Type::NUM, /* default */ strprintf("%d, 0=all", DEFAULT_CHECKBLOCKS), "The number of blocks to check."},
|
||||||
},
|
},
|
||||||
RPCResult{
|
RPCResult{
|
||||||
|
@ -78,6 +78,14 @@ inline std::string Join(const std::vector<std::string>& list, const std::string&
|
|||||||
return Join<std::string>(list, separator);
|
return Join<std::string>(list, separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an unordered multi-line list of items.
|
||||||
|
*/
|
||||||
|
inline std::string MakeUnorderedList(const std::vector<std::string>& items)
|
||||||
|
{
|
||||||
|
return Join(items, "\n", [](const std::string& item) { return "- " + item; });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a string does not contain any embedded NUL (\0) characters
|
* Check if a string does not contain any embedded NUL (\0) characters
|
||||||
*/
|
*/
|
||||||
|
@ -539,11 +539,11 @@ bool ArgsManager::InitSettings(std::string& error)
|
|||||||
|
|
||||||
std::vector<std::string> errors;
|
std::vector<std::string> errors;
|
||||||
if (!ReadSettingsFile(&errors)) {
|
if (!ReadSettingsFile(&errors)) {
|
||||||
error = strprintf("Failed loading settings file:\n- %s\n", Join(errors, "\n- "));
|
error = strprintf("Failed loading settings file:\n%s\n", MakeUnorderedList(errors));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!WriteSettingsFile(&errors)) {
|
if (!WriteSettingsFile(&errors)) {
|
||||||
error = strprintf("Failed saving settings file:\n- %s\n", Join(errors, "\n- "));
|
error = strprintf("Failed saving settings file:\n%s\n", MakeUnorderedList(errors));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user