Add new Theme helper method to custom-colourize links

Signed-off-by: Michael Schuster <michael@schuster.ms>
This commit is contained in:
Michael Schuster 2019-12-19 19:30:35 +01:00 committed by Michael Schuster
parent 7d542d7989
commit 6adfff1f13
2 changed files with 15 additions and 1 deletions

View file

@ -584,7 +584,7 @@ QColor Theme::getBackgroundAwareLinkColor()
void Theme::replaceLinkColorStringBackgroundAware(QString &linkString, const QColor &backgroundColor)
{
linkString.replace(QRegularExpression("(<a href|<a style='color:#([a-zA-Z0-9]{6});' href)"), QString::fromLatin1("<a style='color:%1;' href").arg(getBackgroundAwareLinkColor(backgroundColor).name()));
replaceLinkColorString(linkString, getBackgroundAwareLinkColor(backgroundColor));
}
void Theme::replaceLinkColorStringBackgroundAware(QString &linkString)
@ -592,6 +592,11 @@ void Theme::replaceLinkColorStringBackgroundAware(QString &linkString)
replaceLinkColorStringBackgroundAware(linkString, QGuiApplication::palette().color(QPalette::Base));
}
void Theme::replaceLinkColorString(QString &linkString, const QColor &newColor)
{
linkString.replace(QRegularExpression("(<a href|<a style='color:#([a-zA-Z0-9]{6});' href)"), QString::fromLatin1("<a style='color:%1;' href").arg(newColor.name()));
}
QIcon Theme::createColorAwareIcon(const QString &name, const QPalette &palette)
{
QImage img(name);

View file

@ -402,6 +402,15 @@ public:
*/
static void replaceLinkColorStringBackgroundAware(QString &linkString);
/**
* @brief Appends a CSS-style colour value to all HTML link tags in a given string, as specified by newColor.
*
* 2019/12/19: Implemented for the Dark Mode on macOS, because the app palette can not account for that (Qt 5.12.5).
*
* This way we also avoid having certain strings re-translated on Transifex.
*/
static void replaceLinkColorString(QString &linkString, const QColor &newColor);
/**
* @brief Creates a colour-aware icon based on the specified palette's base colour.
*