summary refs log tree commit diff
path: root/src/Utils.cpp
diff options
context:
space:
mode:
authorredsky17 <joedonofry@gmail.com>2019-01-18 04:09:42 +0000
committerredsky17 <joedonofry@gmail.com>2019-01-18 04:09:42 +0000
commit1882198e4b1df455e3e125d4729790a9fd881809 (patch)
tree483bb1e82bb0e430203bc8034e1f212c672620e4 /src/Utils.cpp
parentMerge branch 'master' of github.com:nheko-reborn/nheko (diff)
downloadnheko-1882198e4b1df455e3e125d4729790a9fd881809.tar.xz
Make the author text slightly large.
Add author color generated based on user id.
Diffstat (limited to 'src/Utils.cpp')
-rw-r--r--src/Utils.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp
index 8176cb43..6229d42a 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -382,6 +382,23 @@ utils::linkColor()
         return QPalette().color(QPalette::Link).name();
 }
 
+QString
+utils::generateHexColor(const QString &input)
+{
+        auto hash = 0;
+
+        for (int i = 0; i < input.length(); i++) {
+                hash = input.at(i).digitValue() + ((hash << 5) - hash);
+        }
+        hash *= 13;
+        QString colour("#");
+        for (int i = 0; i < 3; i++) {
+                int value = (hash >> (i * 8)) & 0xFF;
+                colour.append(("00" + QString::number(value, 16)).right(2));
+        }
+        return colour;
+}
+
 void
 utils::centerWidget(QWidget *widget, QWidget *parent)
 {