// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL #pragma once #include #include #include // Dark, light, or whatever the desktop is set to. This replaced thirteen // hand-written palettes: the mode is resolved once here and the colours are // owned by AppPalette, so the same answer is available with or without a KDE // platform theme (i.e. on Windows too). class ColorSchemeSelector : public QObject { Q_OBJECT QML_ELEMENT QML_SINGLETON Q_PROPERTY(Mode mode READ mode WRITE setMode NOTIFY modeChanged) public: enum Mode { FollowSystem, Light, Dark, }; Q_ENUM(Mode) explicit ColorSchemeSelector(QObject *parent = nullptr); // One instance for both C++ (startup palette setup in AppearanceSetup) and QML: // otherwise changing the mode from AppearancePage would move a second // object and leave the one that seeded AppPalette stale. static ColorSchemeSelector *instance(); static ColorSchemeSelector *create(QQmlEngine *, QJSEngine *) { return instance(); } Mode mode() const { return m_mode; } void setMode(Mode mode); Q_SIGNALS: void modeChanged(); private: static QString schemeIdFor(Mode mode); Mode m_mode = FollowSystem; };