From c8ba6946bd178438256d809b90500cdaba9cf53a Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 17 Nov 2018 22:58:06 +0100 Subject: [PATCH] Allow to enable HTML color (as tooltip must be "black") --- src/blackgui/components/logcomponent.cpp | 2 +- src/blackgui/models/statusmessagelistmodel.cpp | 2 +- src/blackgui/overlaymessages.cpp | 2 +- src/blackmisc/statusmessage.cpp | 17 ++++++++++------- src/blackmisc/statusmessage.h | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/blackgui/components/logcomponent.cpp b/src/blackgui/components/logcomponent.cpp index 1bc521e2c..c1268b6e8 100644 --- a/src/blackgui/components/logcomponent.cpp +++ b/src/blackgui/components/logcomponent.cpp @@ -117,7 +117,7 @@ namespace BlackGui void CLogComponent::appendStatusMessageToConsole(const CStatusMessage &statusMessage) { if (statusMessage.isEmpty()) return; - ui->tep_StatusPageConsole->appendHtml(statusMessage.toHtml(false)); + ui->tep_StatusPageConsole->appendHtml(statusMessage.toHtml(false, true)); } void CLogComponent::appendPlainTextToConsole(const QString &text) diff --git a/src/blackgui/models/statusmessagelistmodel.cpp b/src/blackgui/models/statusmessagelistmodel.cpp index 976d39f4e..1b9343ce3 100644 --- a/src/blackgui/models/statusmessagelistmodel.cpp +++ b/src/blackgui/models/statusmessagelistmodel.cpp @@ -74,7 +74,7 @@ namespace BlackGui { // the underlying model object as summary const CStatusMessage msg(this->at(index)); - return msg.toHtml(false); + return msg.toHtml(false, false); } return CListModelTimestampObjects::data(index, role); } diff --git a/src/blackgui/overlaymessages.cpp b/src/blackgui/overlaymessages.cpp index 58452b40f..88db6ecb9 100644 --- a/src/blackgui/overlaymessages.cpp +++ b/src/blackgui/overlaymessages.cpp @@ -346,7 +346,7 @@ namespace BlackGui } this->setModeToHTMLMessage(); - ui->te_HTMLMessage->setText(message.toHtml(true)); + ui->te_HTMLMessage->setText(message.toHtml(true, true)); this->display(timeOutMs); } diff --git a/src/blackmisc/statusmessage.cpp b/src/blackmisc/statusmessage.cpp index 9ab5be736..13a78ac5d 100644 --- a/src/blackmisc/statusmessage.cpp +++ b/src/blackmisc/statusmessage.cpp @@ -402,7 +402,7 @@ namespace BlackMisc case IndexCategoriesAsString: return CVariant::from(m_categories.toQString()); case IndexCategoriesHumanReadableAsString: return CVariant::from(this->getHumanReadablePattern()); case IndexCategoryHumanReadableOrTechnicalAsString: return CVariant::from(this->getHumanOrTechnicalCategoriesAsString()); - case IndexMessageAsHtml: return CVariant::from(this->toHtml(false)); + case IndexMessageAsHtml: return CVariant::from(this->toHtml(false, true)); default: return CValueObject::propertyByIndex(index); } } @@ -445,7 +445,7 @@ namespace BlackMisc return 0; } - QString CStatusMessage::toHtml(bool withIcon) const + QString CStatusMessage::toHtml(bool withIcon, bool withColors) const { QString img; if (withIcon) @@ -454,12 +454,15 @@ namespace BlackMisc if (!r.isEmpty()) { img = QStringLiteral(" ").arg(r); } } - switch (this->getSeverity()) + if (withColors) { - case SeverityWarning: return img % QStringLiteral("") % this->getMessage() % QStringLiteral(""); - case SeverityError: return img % QStringLiteral("") % this->getMessage() % QStringLiteral(""); - case SeverityDebug: break; - default: break; + switch (this->getSeverity()) + { + case SeverityWarning: return img % QStringLiteral("") % this->getMessage() % QStringLiteral(""); + case SeverityError: return img % QStringLiteral("") % this->getMessage() % QStringLiteral(""); + case SeverityDebug: break; + default: break; + } } return img % this->getMessage(); } diff --git a/src/blackmisc/statusmessage.h b/src/blackmisc/statusmessage.h index a8f784828..ec34027da 100644 --- a/src/blackmisc/statusmessage.h +++ b/src/blackmisc/statusmessage.h @@ -347,7 +347,7 @@ namespace BlackMisc QString convertToQString(bool i18n = false) const; //! To HTML - QString toHtml(bool withIcon) const; + QString toHtml(bool withIcon, bool withColors) const; //! Representing icon static const CIcon &convertToIcon(const CStatusMessage &statusMessage);