Prepend the error/warning prefix for GUI messages

This commit is contained in:
Hennadii Stepanov 2019-04-30 00:39:45 +03:00
parent 0221420d1a
commit f0641f274f
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
2 changed files with 15 additions and 14 deletions

View file

@ -1038,9 +1038,10 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
progressBar->setToolTip(tooltip);
}
void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
void BitcoinGUI::message(const QString& title, QString message, unsigned int style, bool* ret)
{
QString strTitle = tr("Bitcoin"); // default title
// Default title. On macOS, the window title is ignored (as required by the macOS Guidelines).
QString strTitle{PACKAGE_NAME};
// Default to information icon
int nMBoxIcon = QMessageBox::Information;
int nNotifyIcon = Notificator::Information;
@ -1050,37 +1051,37 @@ void BitcoinGUI::message(const QString &title, const QString &message, unsigned
// Prefer supplied title over style based title
if (!title.isEmpty()) {
msgType = title;
}
else {
} else {
switch (style) {
case CClientUIInterface::MSG_ERROR:
msgType = tr("Error");
message = tr("Error: %1").arg(message);
break;
case CClientUIInterface::MSG_WARNING:
msgType = tr("Warning");
message = tr("Warning: %1").arg(message);
break;
case CClientUIInterface::MSG_INFORMATION:
msgType = tr("Information");
// No need to prepend the prefix here.
break;
default:
break;
}
}
// Append title to "Bitcoin - "
if (!msgType.isEmpty())
strTitle += " - " + msgType;
// Check for error/warning icon
if (!msgType.isEmpty()) {
strTitle += " - " + msgType;
}
if (style & CClientUIInterface::ICON_ERROR) {
nMBoxIcon = QMessageBox::Critical;
nNotifyIcon = Notificator::Critical;
}
else if (style & CClientUIInterface::ICON_WARNING) {
} else if (style & CClientUIInterface::ICON_WARNING) {
nMBoxIcon = QMessageBox::Warning;
nNotifyIcon = Notificator::Warning;
}
// Display message
if (style & CClientUIInterface::MODAL) {
// Check for buttons, use OK as default, if none was supplied
QMessageBox::StandardButton buttons;
@ -1093,9 +1094,9 @@ void BitcoinGUI::message(const QString &title, const QString &message, unsigned
int r = mBox.exec();
if (ret != nullptr)
*ret = r == QMessageBox::Ok;
}
else
} else {
notificator->notify(static_cast<Notificator::Class>(nNotifyIcon), strTitle, message);
}
}
void BitcoinGUI::changeEvent(QEvent *e)

View file

@ -219,7 +219,7 @@ public Q_SLOTS:
@see CClientUIInterface::MessageBoxFlags
@param[in] ret pointer to a bool that will be modified to whether Ok was clicked (modal only)
*/
void message(const QString &title, const QString &message, unsigned int style, bool *ret = nullptr);
void message(const QString& title, QString message, unsigned int style, bool* ret = nullptr);
#ifdef ENABLE_WALLET
void setCurrentWallet(WalletModel* wallet_model);