File indexing completed on 2026-06-07 05:41:21
0001 /* 0002 SPDX-FileCopyrightText: 2019 Valerio Pilo <vpilo@coldshock.net> 0003 SPDX-FileCopyrightText: 2019 Cyril Rossi <cyril.rossi@enioka.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #pragma once 0009 0010 #include <KQuickManagedConfigModule> 0011 #include <QAbstractListModel> 0012 0013 class QAbstractItemModel; 0014 class QSortFilterProxyModel; 0015 class QQuickItem; 0016 0017 namespace KDecoration2 0018 { 0019 enum class BorderSize; 0020 0021 namespace Preview 0022 { 0023 class ButtonsModel; 0024 } 0025 namespace Configuration 0026 { 0027 class DecorationsModel; 0028 } 0029 } 0030 0031 class KWinDecorationSettings; 0032 class KWinDecorationData; 0033 0034 class KCMKWinDecoration : public KQuickManagedConfigModule 0035 { 0036 Q_OBJECT 0037 Q_PROPERTY(KWinDecorationSettings *settings READ settings CONSTANT) 0038 Q_PROPERTY(QSortFilterProxyModel *themesModel READ themesModel CONSTANT) 0039 Q_PROPERTY(QStringList borderSizesModel READ borderSizesModel NOTIFY themeChanged) 0040 Q_PROPERTY(int borderIndex READ borderIndex WRITE setBorderIndex NOTIFY borderIndexChanged) 0041 Q_PROPERTY(int borderSize READ borderSize NOTIFY borderSizeChanged) 0042 Q_PROPERTY(int recommendedBorderSize READ recommendedBorderSize CONSTANT) 0043 Q_PROPERTY(int theme READ theme WRITE setTheme NOTIFY themeChanged) 0044 Q_PROPERTY(QAbstractListModel *leftButtonsModel READ leftButtonsModel NOTIFY buttonsChanged) 0045 Q_PROPERTY(QAbstractListModel *rightButtonsModel READ rightButtonsModel NOTIFY buttonsChanged) 0046 Q_PROPERTY(QAbstractListModel *availableButtonsModel READ availableButtonsModel CONSTANT) 0047 0048 public: 0049 KCMKWinDecoration(QObject *parent, const KPluginMetaData &metaData); 0050 0051 KWinDecorationSettings *settings() const; 0052 QSortFilterProxyModel *themesModel() const; 0053 QAbstractListModel *leftButtonsModel(); 0054 QAbstractListModel *rightButtonsModel(); 0055 QAbstractListModel *availableButtonsModel() const; 0056 QStringList borderSizesModel() const; 0057 int borderIndex() const; 0058 int borderSize() const; 0059 int recommendedBorderSize() const; 0060 int theme() const; 0061 0062 void setBorderIndex(int index); 0063 void setBorderSize(int index); 0064 void setBorderSize(KDecoration2::BorderSize size); 0065 void setTheme(int index); 0066 0067 Q_SIGNALS: 0068 void themeChanged(); 0069 void borderIndexChanged(); 0070 void borderSizeChanged(); 0071 0072 public Q_SLOTS: 0073 void load() override; 0074 void save() override; 0075 void defaults() override; 0076 void reloadKWinSettings(); 0077 0078 private Q_SLOTS: 0079 void onLeftButtonsChanged(); 0080 void onRightButtonsChanged(); 0081 0082 private: 0083 bool isSaveNeeded() const override; 0084 0085 int borderSizeIndexFromString(const QString &size) const; 0086 QString borderSizeIndexToString(int index) const; 0087 0088 KDecoration2::Configuration::DecorationsModel *m_themesModel; 0089 QSortFilterProxyModel *m_proxyThemesModel; 0090 0091 KDecoration2::Preview::ButtonsModel *m_leftButtonsModel; 0092 KDecoration2::Preview::ButtonsModel *m_rightButtonsModel; 0093 KDecoration2::Preview::ButtonsModel *m_availableButtonsModel; 0094 0095 int m_borderSizeIndex = -1; 0096 KWinDecorationData *m_data; 0097 };