Skip to content

Commit 96fd4ee

Browse files
committed
Add MSG_NOPREFIX flag for user messages
It forces do not prepend error/warning prefix.
1 parent f0641f2 commit 96fd4ee

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

src/noui.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,30 @@ bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& ca
1818
{
1919
bool fSecure = style & CClientUIInterface::SECURE;
2020
style &= ~CClientUIInterface::SECURE;
21+
bool prefix = !(style & CClientUIInterface::MSG_NOPREFIX);
22+
style &= ~CClientUIInterface::MSG_NOPREFIX;
2123

2224
std::string strCaption;
23-
// Check for usage of predefined caption
24-
switch (style) {
25-
case CClientUIInterface::MSG_ERROR:
26-
strCaption += _("Error");
27-
break;
28-
case CClientUIInterface::MSG_WARNING:
29-
strCaption += _("Warning");
30-
break;
31-
case CClientUIInterface::MSG_INFORMATION:
32-
strCaption += _("Information");
33-
break;
34-
default:
35-
strCaption += caption; // Use supplied caption (can be empty)
25+
if (prefix) {
26+
switch (style) {
27+
case CClientUIInterface::MSG_ERROR:
28+
strCaption = "Error: ";
29+
break;
30+
case CClientUIInterface::MSG_WARNING:
31+
strCaption = "Warning: ";
32+
break;
33+
case CClientUIInterface::MSG_INFORMATION:
34+
strCaption = "Information: ";
35+
break;
36+
default:
37+
strCaption = caption + ": "; // Use supplied caption (can be empty)
38+
}
3639
}
3740

38-
if (!fSecure)
39-
LogPrintf("%s: %s\n", strCaption, message);
40-
tfm::format(std::cerr, "%s: %s\n", strCaption.c_str(), message.c_str());
41+
if (!fSecure) {
42+
LogPrintf("%s%s\n", strCaption, message);
43+
}
44+
tfm::format(std::cerr, "%s%s\n", strCaption.c_str(), message.c_str());
4145
return false;
4246
}
4347

src/qt/bitcoingui.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,20 +1046,21 @@ void BitcoinGUI::message(const QString& title, QString message, unsigned int sty
10461046
int nMBoxIcon = QMessageBox::Information;
10471047
int nNotifyIcon = Notificator::Information;
10481048

1049-
QString msgType;
1049+
bool prefix = !(style & CClientUIInterface::MSG_NOPREFIX);
1050+
style &= ~CClientUIInterface::MSG_NOPREFIX;
10501051

1051-
// Prefer supplied title over style based title
1052+
QString msgType;
10521053
if (!title.isEmpty()) {
10531054
msgType = title;
10541055
} else {
10551056
switch (style) {
10561057
case CClientUIInterface::MSG_ERROR:
10571058
msgType = tr("Error");
1058-
message = tr("Error: %1").arg(message);
1059+
if (prefix) message = tr("Error: %1").arg(message);
10591060
break;
10601061
case CClientUIInterface::MSG_WARNING:
10611062
msgType = tr("Warning");
1062-
message = tr("Warning: %1").arg(message);
1063+
if (prefix) message = tr("Warning: %1").arg(message);
10631064
break;
10641065
case CClientUIInterface::MSG_INFORMATION:
10651066
msgType = tr("Information");

src/ui_interface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class CClientUIInterface
6969
/** Force blocking, modal message box dialog (not just OS notification) */
7070
MODAL = 0x10000000U,
7171

72+
/** Do not prepend error/warning prefix */
73+
MSG_NOPREFIX = 0x20000000U,
74+
7275
/** Do not print contents of message to debug log */
7376
SECURE = 0x40000000U,
7477

0 commit comments

Comments
 (0)