0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

refactor: Move MakeUnorderedList into util/string.h to make it reusable

This commit is contained in:
Hennadii Stepanov 2021-08-06 21:51:57 +03:00
parent 6a5ccd65c7
commit 77a90f03ac
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
2 changed files with 10 additions and 6 deletions

View file

@ -28,6 +28,7 @@
#include <qt/utilitydialog.h>
#include <qt/winshutdownmonitor.h>
#include <uint256.h>
#include <util/string.h>
#include <util/system.h>
#include <util/threadnames.h>
#include <util/translation.h>
@ -144,11 +145,6 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
QApplication::installTranslator(&translator);
}
static std::string MakeUnorderedList(const std::vector<std::string>& errors)
{
return Join(errors, "\n", [](const std::string& error) { return "- " + error; });
}
static bool InitSettings()
{
if (!gArgs.GetSettingsPath()) {
@ -186,7 +182,7 @@ static bool InitSettings()
/*: 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.setInformativeText(QObject::tr("A fatal error occurred. Check that settings file is writable, or try running with -nosettings."));
messagebox.setDetailedText(QString::fromStdString(MakeUnorderedList(errors)));
messagebox.setTextFormat(Qt::PlainText);
messagebox.setDefaultButton(QMessageBox::Ok);

View file

@ -64,6 +64,14 @@ inline std::string Join(const std::vector<std::string>& list, const std::string&
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
*/