summary refs log tree commit diff
path: root/src/Utils.h
diff options
context:
space:
mode:
authorJoe <rubberduckie3554@gmail.com>2019-02-08 14:06:37 -0500
committerJoe <rubberduckie3554@gmail.com>2019-02-08 14:06:37 -0500
commitebe5b19e76648019cc1128c05b428a863479f5d3 (patch)
tree0351f0c6050f9190ee619e9d287f3fb229d907f0 /src/Utils.h
parentAdd /bigobj for nheko MSVC build (diff)
parentAdjust cmake minimum for included boost (diff)
downloadnheko-ebe5b19e76648019cc1128c05b428a863479f5d3.tar.xz
Merge branch 'master' of https://github.com/redsky17/nheko
Diffstat (limited to 'src/Utils.h')
-rw-r--r--src/Utils.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Utils.h b/src/Utils.h

index 2a029943..8672e7d4 100644 --- a/src/Utils.h +++ b/src/Utils.h
@@ -14,6 +14,8 @@ #include <mtx/events/collections.hpp> #include <mtx/events/common.hpp> +#include <qmath.h> + class QComboBox; namespace utils { @@ -227,6 +229,23 @@ markdownToHtml(const QString &text); QString linkColor(); +//! Returns the hash code of the input QString +int +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); + +//! Given two luminance values, compute the contrast ratio between them. +qreal +computeContrast(const qreal &one, const qreal &two); + +//! Compute the luminance of a single color. Based on https://stackoverflow.com/a/9733420 +qreal +luminance(const QColor &col); + //! Center a widget in relation to another widget. void centerWidget(QWidget *widget, QWidget *parent);