Perceptual Color

helperqttypes.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef HELPERQTTYPES_H
5#define HELPERQTTYPES_H
6
7#include <qcolor.h>
8#include <qlist.h>
9
10/** @internal
11 *
12 * @file
13 *
14 * Type declarations for types that Qt uses in its API and that have
15 * changed between Qt5 and Qt6. */
16
17namespace PerceptualColor
18{
19
20/** @internal
21 *
22 * The type that <tt>QColor</tt> uses for floating point values.
23 *
24 * This type might vary: On Qt6, it’s <tt>float</tt> while on Qt5 it
25 * is <tt>qreal</tt> which might be either <tt>float</tt> or <tt>double</tt>
26 * depending on the options with which Qt was compiled. */
27using QColorFloatType = decltype(std::declval<QColor>().redF());
28static_assert(std::is_floating_point<QColorFloatType>());
29static_assert( //
30 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().redF())>);
31static_assert( //
32 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().greenF())>);
33static_assert( //
34 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().blueF())>);
35static_assert( //
36 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().alphaF())>);
37static_assert( //
38 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().valueF())>);
39static_assert( //
40 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().lightnessF())>);
41static_assert( //
42 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().saturationF())>);
43static_assert( //
44 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().hsvSaturationF())>);
45static_assert( //
46 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().hslSaturationF())>);
47static_assert( //
48 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().hsvHueF())>);
49static_assert( //
50 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().hslHueF())>);
51static_assert( //
52 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().hueF())>);
53static_assert( //
54 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().magentaF())>);
55static_assert( //
56 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().cyanF())>);
57static_assert( //
58 std::is_same_v<QColorFloatType, decltype(std::declval<QColor>().yellowF())>);
59
60/** @internal
61 *
62 * The type that <tt>QList</tt> uses for index.
63 *
64 * This type might vary between Qt5 and Qt6. */
65using QListSizeType = decltype(std::declval<QList<int>>().count());
66static_assert( //
67 std::is_same_v<QListSizeType, decltype(std::declval<QList<int>>().count())>);
68static_assert( //
69 std::is_same_v<QListSizeType, decltype(std::declval<QList<int>>().size())>);
70static_assert( //
71 std::is_same_v<QListSizeType, decltype(std::declval<QList<int>>().indexOf(0))>);
72static_assert( //
73 std::is_same_v<QListSizeType, decltype(std::declval<QList<int>>().lastIndexOf(0))>);
74
75/** @internal
76 *
77 * The type that <tt>QString</tt> uses for length.
78 *
79 * This type might vary between Qt5 and Qt6.
80 *
81 * @sa @ref QStringSize */
82using QStringLength = decltype(std::declval<QString>().length());
83static_assert( //
84 std::is_same_v<QStringLength, decltype(std::declval<QString>().length())>);
85static_assert( //
86 std::is_same_v<QStringLength, decltype(std::declval<QString>().size())>);
87
88/** @internal
89 *
90 * The type that <tt>QString</tt> uses for size.
91 *
92 * This type might vary between Qt5 and Qt6.
93 *
94 * @sa @ref QStringLength */
95using QStringSize = decltype(std::declval<QString>().size());
96static_assert( //
97 std::is_same_v<QStringLength, decltype(std::declval<QString>().length())>);
98static_assert( //
99 std::is_same_v<QStringLength, decltype(std::declval<QString>().size())>);
100
101} // namespace PerceptualColor
102
103#endif // HELPERQTTYPES_H
The namespace of this library.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:48:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.