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

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