QXmpp: QXmppColorGeneration.h Source File

QXmpp Version: 1.14.4

Loading...
Searching...
No Matches
QXmppColorGeneration.h
1// SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPCOLORGENERATION_H
6#define QXMPPCOLORGENERATION_H
7
8#include "QXmppGlobal.h"
9
10#ifdef QT_GUI_LIB
11#include <QColor>
12#endif
13
14 class QXmppColorGeneration
15{
16public:
17 struct QXMPP_EXPORT Rgb {
18 quint8 red;
19 quint8 green;
20 quint8 blue;
21 };
22
23 QXMPP_EXPORT static Rgb generateRgb(QStringView str);
24
25#if defined(QT_GUI_LIB) || defined(QXMPP_DOC)
26 static inline QColor generateColor(QStringView str)
27 {
28 auto rgb = generateRgb(str);
29 return QColor(rgb.red, rgb.green, rgb.blue);
30 }
31#endif
32};
33
34namespace QXmpp::Private {
35double generateColorAngle(QStringView str);
36}
37
38#endif // QXMPPCOLORGENERATION_H
QXmppColorGeneration
Generates colors from strings as defined in XEP-0392: Consistent Color Generation.
Definition QXmppColorGeneration.h:15
QXmppColorGeneration::generateRgb
static QXMPP_EXPORT Rgb generateRgb(QStringView str)
Definition QXmppColorGeneration.cpp:26
QXmppColorGeneration::generateColor
static QColor generateColor(QStringView str)
Definition QXmppColorGeneration.h:26