Skip to content

Commit 77a90f0

Browse files
committed
refactor: Move MakeUnorderedList into util/string.h to make it reusable
1 parent 6a5ccd6 commit 77a90f0

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/qt/bitcoin.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <qt/utilitydialog.h>
2929
#include <qt/winshutdownmonitor.h>
3030
#include <uint256.h>
31+
#include <util/string.h>
3132
#include <util/system.h>
3233
#include <util/threadnames.h>
3334
#include <util/translation.h>
@@ -144,11 +145,6 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
144145
QApplication::installTranslator(&translator);
145146
}
146147

147-
static std::string MakeUnorderedList(const std::vector<std::string>& errors)
148-
{
149-
return Join(errors, "\n", [](const std::string& error) { return "- " + error; });
150-
}
151-
152148
static bool InitSettings()
153149
{
154150
if (!gArgs.GetSettingsPath()) {
@@ -186,7 +182,7 @@ static bool InitSettings()
186182
/*: Explanatory text shown on startup when the settings file could not be written.
187183
Prompts user to check that we have the ability to write to the file.
188184
Explains that the user has the option of running without a settings file.*/
189-
messagebox.setInformativeText(QObject::tr("A fatal error occured. Check that settings file is writable, or try running with -nosettings."));
185+
messagebox.setInformativeText(QObject::tr("A fatal error occurred. Check that settings file is writable, or try running with -nosettings."));
190186
messagebox.setDetailedText(QString::fromStdString(MakeUnorderedList(errors)));
191187
messagebox.setTextFormat(Qt::PlainText);
192188
messagebox.setDefaultButton(QMessageBox::Ok);

src/util/string.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ inline std::string Join(const std::vector<std::string>& list, const std::string&
6464
return Join<std::string>(list, separator);
6565
}
6666

67+
/**
68+
* Create an unordered multi-line list of items.
69+
*/
70+
inline std::string MakeUnorderedList(const std::vector<std::string>& items)
71+
{
72+
return Join(items, "\n", [](const std::string& item) { return "- " + item; });
73+
}
74+
6775
/**
6876
* Check if a string does not contain any embedded NUL (\0) characters
6977
*/

0 commit comments

Comments
 (0)