Perceptual Color

perceptualsettings.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef PERCEPTUALSETTINGS_H
5#define PERCEPTUALSETTINGS_H
6
7#include "setting.h"
8#include "settings.h"
9#include <qcolor.h>
10#include <qglobal.h>
11#include <qlist.h>
12#include <qmetatype.h>
13#include <qstring.h>
14
15#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
16#include <qtmetamacros.h>
17#else
18#include <qobjectdefs.h>
19#endif
20
21namespace PerceptualColor
22{
23
24/** @internal
25 *
26 * @brief Settings for @ref PerceptualColor.
27 *
28 * @warning This object is not thread-safe.
29 * It must only be used in the main (widget) thread! */
30class PerceptualSettings : public Settings
31{
33
34public:
35 /** @brief Data type for color lists.
36 *
37 * Has serialization support as required by <tt>QSettings</tt>. */
38 using ColorList = QList<QColor>;
39
40 virtual ~PerceptualSettings() override;
41 // Prevent copy and assignment operations to force that only references
42 // to the instance are possible.
43 PerceptualSettings(const PerceptualSettings &) = delete;
44 PerceptualSettings &operator=(const PerceptualSettings &) = delete;
45
46 static PerceptualSettings &instance();
47
48 /** @brief Custom colors of @ref ColorDialog. */
49 Setting<PerceptualSettings::ColorList> customColors;
50
51 /** @brief History of actually selected (confirmed by Okay button
52 * respectively Enter key) colors of @ref ColorDialog. */
53 Setting<PerceptualSettings::ColorList> history;
54
55 /** @brief A specific page from the swatch book.
56 *
57 * This enum is declared to the meta-object system with <tt>Q_ENUM</tt>.
58 * This happens automatically. You do not need to make any manual calls.
59 *
60 * This type is declared as type to Qt’s type system via
61 * <tt>Q_DECLARE_METATYPE</tt>. Depending on your use case (for
62 * example if you want to use for <em>queued</em> signal-slot connections),
63 * you might consider calling <tt>qRegisterMetaType()</tt> for
64 * this type, once you have a QApplication object. */
65 enum class SwatchBookPage {
66 BasicColors, /**< @ref ColorDialogPrivate::m_swatchBookBasicColors */
67 History /**< @ref ColorDialogPrivate::m_swatchBookHistory */
68 };
69 Q_ENUM(SwatchBookPage)
70 /** @brief The swatch book page currently visible at
71 * @ref ColorDialogPrivate::m_swatchBookStack. */
72 Setting<SwatchBookPage> swatchBookPage;
73
74 /** @brief The currently visible tab of @ref ColorDialog with
75 * @ref ColorDialog::DialogLayoutDimensions::Collapsed. */
76 Setting<QString> tab;
77
78 /** @brief The currently visible tab of @ref ColorDialog with
79 * @ref ColorDialog::DialogLayoutDimensions::Expanded. */
80 Setting<QString> tabExpanded;
81
82private:
83 PerceptualSettings();
84
85 /** @internal @brief Only for unit tests. */
86 friend class TestPerceptualSettings;
87};
88
89} // namespace PerceptualColor
90
92Q_DECLARE_METATYPE(PerceptualColor::PerceptualSettings::SwatchBookPage)
93
94#endif // PERCEPTUALSETTINGS_H
The namespace of this library.
Q_ENUM(...)
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.