From 1882198e4b1df455e3e125d4729790a9fd881809 Mon Sep 17 00:00:00 2001 From: redsky17 Date: Fri, 18 Jan 2019 04:09:42 +0000 Subject: Make the author text slightly large. Add author color generated based on user id. --- src/Utils.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/Utils.cpp') 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) { -- cgit 1.5.1