| 1 | /* |
| 2 | * SPDX-FileCopyrightText: 2021 Nicolas Fella <nicolas.fella@gmx.de> |
| 3 | * |
| 4 | * SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #ifndef KCOLORSCHEMEWATCHER_H |
| 8 | #define KCOLORSCHEMEWATCHER_H |
| 9 | |
| 10 | #include "kguiaddons_export.h" |
| 11 | |
| 12 | #include <QObject> |
| 13 | |
| 14 | #include <memory> |
| 15 | |
| 16 | class KColorSchemeWatcherPrivate; |
| 17 | |
| 18 | #if KGUIADDONS_ENABLE_DEPRECATED_SINCE(6, 22) |
| 19 | |
| 20 | /*! |
| 21 | * \class KColorSchemeWatcher |
| 22 | * \inmodule KGuiAddons |
| 23 | * \brief Information about system-wide color preferences. |
| 24 | * \since 5.100 |
| 25 | * \deprecated[6.22] |
| 26 | * Use QStyleHints and QAccessibilityHints instead |
| 27 | */ |
| 28 | class KGUIADDONS_EXPORT KColorSchemeWatcher : public QObject |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | public: |
| 32 | /*! |
| 33 | * Encodes the color preference of the user to be used by applications |
| 34 | * as configured in the system settings. On some systems not all values |
| 35 | * are returned, e.g. PreferHighContrast is currently only returned |
| 36 | * on Windows. |
| 37 | * |
| 38 | * \value NoPreference No preference available |
| 39 | * \value PreferDark The user prefers a dark color scheme |
| 40 | * \value PreferLight The user prefers a light color scheme |
| 41 | * \value[since 6.13] PreferHighContrast The user prefers a system-provided high-contrast color scheme |
| 42 | * |
| 43 | * \sa systemPreference |
| 44 | */ |
| 45 | enum ColorPreference { |
| 46 | NoPreference = 0, |
| 47 | PreferDark, |
| 48 | PreferLight, |
| 49 | PreferHighContrast, |
| 50 | }; |
| 51 | Q_ENUM(ColorPreference) |
| 52 | |
| 53 | /*! |
| 54 | * |
| 55 | */ |
| 56 | KGUIADDONS_DEPRECATED_VERSION(6, 22, "Use Qt API instead" ) |
| 57 | KColorSchemeWatcher(QObject *parent = nullptr); |
| 58 | ~KColorSchemeWatcher() override; |
| 59 | |
| 60 | /*! |
| 61 | * The system-wide color preference. |
| 62 | */ |
| 63 | ColorPreference systemPreference() const; |
| 64 | |
| 65 | Q_SIGNALS: |
| 66 | /*! |
| 67 | * Emitted when systemPreference changes. |
| 68 | */ |
| 69 | void systemPreferenceChanged(); |
| 70 | |
| 71 | private: |
| 72 | std::unique_ptr<KColorSchemeWatcherPrivate> const d; |
| 73 | }; |
| 74 | |
| 75 | #endif |
| 76 | |
| 77 | #endif |
| 78 | |