From 77a90f03acd551bcc538f6728939cc2ed8c6a3c4 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Fri, 6 Aug 2021 21:51:57 +0300 Subject: refactor: Move MakeUnorderedList into util/string.h to make it reusable --- src/qt/bitcoin.cpp | 8 ++------ src/util/string.h | 8 ++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index ababab31d3..09f453363d 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -144,11 +145,6 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans QApplication::installTranslator(&translator); } -static std::string MakeUnorderedList(const std::vector& 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); diff --git a/src/util/string.h b/src/util/string.h index b26facc502..5617e4acc1 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -64,6 +64,14 @@ inline std::string Join(const std::vector& list, const std::string& return Join(list, separator); } +/** + * Create an unordered multi-line list of items. + */ +inline std::string MakeUnorderedList(const std::vector& items) +{ + return Join(items, "\n", [](const std::string& item) { return "- " + item; }); +} + /** * Check if a string does not contain any embedded NUL (\0) characters */ -- cgit v1.2.3