Skip to content

Commit f0641f2

Browse files
committed
Prepend the error/warning prefix for GUI messages
1 parent 0221420 commit f0641f2

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/qt/bitcoingui.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,9 +1038,10 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
10381038
progressBar->setToolTip(tooltip);
10391039
}
10401040

1041-
void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
1041+
void BitcoinGUI::message(const QString& title, QString message, unsigned int style, bool* ret)
10421042
{
1043-
QString strTitle = tr("Bitcoin"); // default title
1043+
// Default title. On macOS, the window title is ignored (as required by the macOS Guidelines).
1044+
QString strTitle{PACKAGE_NAME};
10441045
// Default to information icon
10451046
int nMBoxIcon = QMessageBox::Information;
10461047
int nNotifyIcon = Notificator::Information;
@@ -1050,37 +1051,37 @@ void BitcoinGUI::message(const QString &title, const QString &message, unsigned
10501051
// Prefer supplied title over style based title
10511052
if (!title.isEmpty()) {
10521053
msgType = title;
1053-
}
1054-
else {
1054+
} else {
10551055
switch (style) {
10561056
case CClientUIInterface::MSG_ERROR:
10571057
msgType = tr("Error");
1058+
message = tr("Error: %1").arg(message);
10581059
break;
10591060
case CClientUIInterface::MSG_WARNING:
10601061
msgType = tr("Warning");
1062+
message = tr("Warning: %1").arg(message);
10611063
break;
10621064
case CClientUIInterface::MSG_INFORMATION:
10631065
msgType = tr("Information");
1066+
// No need to prepend the prefix here.
10641067
break;
10651068
default:
10661069
break;
10671070
}
10681071
}
1069-
// Append title to "Bitcoin - "
1070-
if (!msgType.isEmpty())
1072+
1073+
if (!msgType.isEmpty()) {
10711074
strTitle += " - " + msgType;
1075+
}
10721076

1073-
// Check for error/warning icon
10741077
if (style & CClientUIInterface::ICON_ERROR) {
10751078
nMBoxIcon = QMessageBox::Critical;
10761079
nNotifyIcon = Notificator::Critical;
1077-
}
1078-
else if (style & CClientUIInterface::ICON_WARNING) {
1080+
} else if (style & CClientUIInterface::ICON_WARNING) {
10791081
nMBoxIcon = QMessageBox::Warning;
10801082
nNotifyIcon = Notificator::Warning;
10811083
}
10821084

1083-
// Display message
10841085
if (style & CClientUIInterface::MODAL) {
10851086
// Check for buttons, use OK as default, if none was supplied
10861087
QMessageBox::StandardButton buttons;
@@ -1093,9 +1094,9 @@ void BitcoinGUI::message(const QString &title, const QString &message, unsigned
10931094
int r = mBox.exec();
10941095
if (ret != nullptr)
10951096
*ret = r == QMessageBox::Ok;
1096-
}
1097-
else
1097+
} else {
10981098
notificator->notify(static_cast<Notificator::Class>(nNotifyIcon), strTitle, message);
1099+
}
10991100
}
11001101

11011102
void BitcoinGUI::changeEvent(QEvent *e)

src/qt/bitcoingui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public Q_SLOTS:
219219
@see CClientUIInterface::MessageBoxFlags
220220
@param[in] ret pointer to a bool that will be modified to whether Ok was clicked (modal only)
221221
*/
222-
void message(const QString &title, const QString &message, unsigned int style, bool *ret = nullptr);
222+
void message(const QString& title, QString message, unsigned int style, bool* ret = nullptr);
223223

224224
#ifdef ENABLE_WALLET
225225
void setCurrentWallet(WalletModel* wallet_model);

0 commit comments

Comments
 (0)