mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
Avoid unnecessary QColor -> QString conversions
This commit is contained in:
parent
ca91e9d0d1
commit
0a833b6e9b
3 changed files with 6 additions and 8 deletions
|
@ -679,11 +679,10 @@ utils::hashQString(const QString &input)
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QColor
|
||||||
utils::generateContrastingHexColor(const QString &input, const QString &background)
|
utils::generateContrastingHexColor(const QString &input, const QColor &backgroundCol)
|
||||||
{
|
{
|
||||||
const QColor backgroundCol(background);
|
const qreal backgroundLum = luminance(backgroundCol);
|
||||||
const qreal backgroundLum = luminance(background);
|
|
||||||
|
|
||||||
// Create a color for the input
|
// Create a color for the input
|
||||||
auto hash = hashQString(input);
|
auto hash = hashQString(input);
|
||||||
|
|
|
@ -301,8 +301,8 @@ hashQString(const QString &input);
|
||||||
|
|
||||||
//! Generate a color (matching #RRGGBB) that has an acceptable contrast to background that is based
|
//! Generate a color (matching #RRGGBB) that has an acceptable contrast to background that is based
|
||||||
//! on the input string.
|
//! on the input string.
|
||||||
QString
|
QColor
|
||||||
generateContrastingHexColor(const QString &input, const QString &background);
|
generateContrastingHexColor(const QString &input, const QColor &background);
|
||||||
|
|
||||||
//! Given two luminance values, compute the contrast ratio between them.
|
//! Given two luminance values, compute the contrast ratio between them.
|
||||||
qreal
|
qreal
|
||||||
|
|
|
@ -122,8 +122,7 @@ QColor
|
||||||
TimelineViewManager::userColor(QString id, QColor background)
|
TimelineViewManager::userColor(QString id, QColor background)
|
||||||
{
|
{
|
||||||
if (!userColors.contains(id))
|
if (!userColors.contains(id))
|
||||||
userColors.insert(
|
userColors.insert(id, QColor(utils::generateContrastingHexColor(id, background)));
|
||||||
id, QColor(utils::generateContrastingHexColor(id, background.name())));
|
|
||||||
return userColors.value(id);
|
return userColors.value(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue