Allow to enable HTML color (as tooltip must be "black")

This commit is contained in:
Klaus Basan
2018-11-17 22:58:06 +01:00
parent 3096822f70
commit c8ba6946bd
5 changed files with 14 additions and 11 deletions

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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("<img src=\"%1\"> ").arg(r); }
}
switch (this->getSeverity())
if (withColors)
{
case SeverityWarning: return img % QStringLiteral("<font color=\"yellow\">") % this->getMessage() % QStringLiteral("</font>");
case SeverityError: return img % QStringLiteral("<font color=\"red\">") % this->getMessage() % QStringLiteral("</font>");
case SeverityDebug: break;
default: break;
switch (this->getSeverity())
{
case SeverityWarning: return img % QStringLiteral("<font color=\"yellow\">") % this->getMessage() % QStringLiteral("</font>");
case SeverityError: return img % QStringLiteral("<font color=\"red\">") % this->getMessage() % QStringLiteral("</font>");
case SeverityDebug: break;
default: break;
}
}
return img % this->getMessage();
}

View File

@@ -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);