// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL #pragma once #include "koutnetsettings.h" #include #include #include namespace koutnet { // The icon theme Qt is asked for by name. // // The window's icons are written against breeze names, so an empty setting // leaves the desktop's own theme in place with main.cpp's breeze fallback // underneath it. Setting one asks Qt for that theme by name - the same string // QIcon::setThemeName() takes, not a path - and the list the settings page // offers is read off the icon directories on the machine rather than written // down here, so a theme that is installed shows up and one that is not does // not. class IconThemeSelector : public QObject { Q_OBJECT Q_PROPERTY(QString theme READ theme WRITE setTheme NOTIFY themeChanged) Q_PROPERTY(bool customised READ customised NOTIFY customisedChanged) public: explicit IconThemeSelector(KOutNetSettings *settings, QObject *parent = nullptr); QString theme() const; void setTheme(const QString &theme); bool customised() const; Q_INVOKABLE QStringList availableThemes() const; Q_INVOKABLE void resetToSystem(); // Puts the stored theme on the application. main.cpp calls it once before // the window exists and every setter calls it again. void apply() const; Q_SIGNALS: void themeChanged(); void customisedChanged(); private: KOutNetSettings *m_settings; // The theme in force before this selector touched anything, which is the // desktop's. Kept so that clearing the setting restores it rather than // leaving the last picked theme applied with no way back. QString m_baseTheme; // Walking the icon search paths only changes when the desktop does, so the // settings page reuses the answer instead of scanning on every open. mutable QStringList m_themes; mutable bool m_themesCached = false; }; } // namespace koutnet