| 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 | /*! |
| 19 | * \class KColorSchemeWatcher |
| 20 | * \inmodule KGuiAddons |
| 21 | * \brief Information about system-wide color preferences. |
| 22 | * \since 5.100 |
| 23 | */ |
| 24 | class KGUIADDONS_EXPORT KColorSchemeWatcher : public QObject |
| 25 | { |
| 26 | Q_OBJECT |
| 27 | public: |
| 28 | /*! |
| 29 | * Encodes the color preference of the user to be used by applications |
| 30 | * as configured in the system settings. On some systems not all values |
| 31 | * are returned, e.g. PreferHighContrast is currently only returned |
| 32 | * on Windows. |
| 33 | * |
| 34 | * \value NoPreference No preference available |
| 35 | * \value PreferDark The user prefers a dark color scheme |
| 36 | * \value PreferLight The user prefers a light color scheme |
| 37 | * \value[since 6.13] PreferHighContrast The user prefers a system-provided high-contrast color scheme |
| 38 | * |
| 39 | * \sa systemPreference |
| 40 | */ |
| 41 | enum ColorPreference { |
| 42 | NoPreference = 0, |
| 43 | PreferDark, |
| 44 | PreferLight, |
| 45 | PreferHighContrast, |
| 46 | }; |
| 47 | Q_ENUM(ColorPreference) |
| 48 | |
| 49 | /*! |
| 50 | * |
| 51 | */ |
| 52 | KColorSchemeWatcher(QObject *parent = nullptr); |
| 53 | ~KColorSchemeWatcher() override; |
| 54 | |
| 55 | /*! |
| 56 | * The system-wide color preference. |
| 57 | */ |
| 58 | ColorPreference systemPreference() const; |
| 59 | |
| 60 | Q_SIGNALS: |
| 61 | /*! |
| 62 | * Emitted when systemPreference changes. |
| 63 | */ |
| 64 | void systemPreferenceChanged(); |
| 65 | |
| 66 | private: |
| 67 | std::unique_ptr<KColorSchemeWatcherPrivate> const d; |
| 68 | }; |
| 69 | |
| 70 | #endif |
| 71 | |