diff options
author | Joe Donofry <rubberduckie3554@gmail.com> | 2021-06-08 23:16:15 +0000 |
---|---|---|
committer | Joe Donofry <rubberduckie3554@gmail.com> | 2021-06-08 23:16:15 +0000 |
commit | 6f1ba703409322332a9b455b5f33d40c12174db6 (patch) | |
tree | 48f98b88c9b99f22bf40686bb0a35799875cdba2 | |
parent | Translated using Weblate (Esperanto) (diff) | |
parent | Avoid unnecessary QColor -> QString conversions (diff) | |
download | nheko-6f1ba703409322332a9b455b5f33d40c12174db6.tar.xz |
Merge branch 'color_generation_string' into 'master'
Avoid unnecessary QColor -> QString conversions See merge request nheko-reborn/nheko!7
-rw-r--r-- | src/Utils.cpp | 7 | ||||
-rw-r--r-- | src/Utils.h | 4 | ||||
-rw-r--r-- | src/timeline/TimelineViewManager.cpp | 3 |
3 files changed, 6 insertions, 8 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp index c110aa18..562b94fd 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -679,11 +679,10 @@ utils::hashQString(const QString &input) return hash; } -QString -utils::generateContrastingHexColor(const QString &input, const QString &background) +QColor +utils::generateContrastingHexColor(const QString &input, const QColor &backgroundCol) { - const QColor backgroundCol(background); - const qreal backgroundLum = luminance(background); + const qreal backgroundLum = luminance(backgroundCol); // Create a color for the input auto hash = hashQString(input); diff --git a/src/Utils.h b/src/Utils.h index e976cf81..1d48e2c7 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -301,8 +301,8 @@ hashQString(const QString &input); //! Generate a color (matching #RRGGBB) that has an acceptable contrast to background that is based //! on the input string. -QString -generateContrastingHexColor(const QString &input, const QString &background); +QColor +generateContrastingHexColor(const QString &input, const QColor &background); //! Given two luminance values, compute the contrast ratio between them. qreal diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 628f3c31..0785e3e1 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -122,8 +122,7 @@ QColor TimelineViewManager::userColor(QString id, QColor background) { if (!userColors.contains(id)) - userColors.insert( - id, QColor(utils::generateContrastingHexColor(id, background.name()))); + userColors.insert(id, QColor(utils::generateContrastingHexColor(id, background))); return userColors.value(id); } |