File indexing completed on 2026-07-12 16:17:44
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 "utils.h" 0011 0012 #include <KQuickAddons/ManagedConfigModule> 0013 0014 class QAbstractItemModel; 0015 class QSortFilterProxyModel; 0016 class QQuickItem; 0017 0018 namespace KDecoration2 0019 { 0020 enum class BorderSize; 0021 0022 namespace Preview 0023 { 0024 class ButtonsModel; 0025 } 0026 namespace Configuration 0027 { 0028 class DecorationsModel; 0029 } 0030 } 0031 0032 class KWinDecorationSettings; 0033 class KWinDecorationData; 0034 0035 class KCMKWinDecoration : public KQuickAddons::ManagedConfigModule 0036 { 0037 Q_OBJECT 0038 Q_PROPERTY(KWinDecorationSettings *settings READ settings CONSTANT) 0039 Q_PROPERTY(QSortFilterProxyModel *themesModel READ themesModel CONSTANT) 0040 Q_PROPERTY(QStringList borderSizesModel READ borderSizesModel NOTIFY themeChanged) 0041 Q_PROPERTY(int borderIndex READ borderIndex WRITE setBorderIndex NOTIFY borderIndexChanged) 0042 Q_PROPERTY(int borderSize READ borderSize NOTIFY borderSizeChanged) 0043 Q_PROPERTY(int recommendedBorderSize READ recommendedBorderSize CONSTANT) 0044 Q_PROPERTY(int theme READ theme WRITE setTheme NOTIFY themeChanged) 0045 Q_PROPERTY(QAbstractListModel *leftButtonsModel READ leftButtonsModel NOTIFY buttonsChanged) 0046 Q_PROPERTY(QAbstractListModel *rightButtonsModel READ rightButtonsModel NOTIFY buttonsChanged) 0047 Q_PROPERTY(QAbstractListModel *availableButtonsModel READ availableButtonsModel CONSTANT) 0048 0049 public: 0050 KCMKWinDecoration(QObject *parent, const QVariantList &arguments); 0051 0052 KWinDecorationSettings *settings() const; 0053 QSortFilterProxyModel *themesModel() const; 0054 QAbstractListModel *leftButtonsModel(); 0055 QAbstractListModel *rightButtonsModel(); 0056 QAbstractListModel *availableButtonsModel() const; 0057 QStringList borderSizesModel() const; 0058 int borderIndex() const; 0059 int borderSize() const; 0060 int recommendedBorderSize() const; 0061 int theme() const; 0062 0063 void setBorderIndex(int index); 0064 void setBorderSize(int index); 0065 void setBorderSize(KDecoration2::BorderSize size); 0066 void setTheme(int index); 0067 0068 Q_SIGNALS: 0069 void themeChanged(); 0070 void borderIndexChanged(); 0071 void borderSizeChanged(); 0072 0073 public Q_SLOTS: 0074 void load() override; 0075 void save() override; 0076 void defaults() override; 0077 void reloadKWinSettings(); 0078 0079 private Q_SLOTS: 0080 void onLeftButtonsChanged(); 0081 void onRightButtonsChanged(); 0082 0083 private: 0084 bool isSaveNeeded() const override; 0085 0086 int borderSizeIndexFromString(const QString &size) const; 0087 QString borderSizeIndexToString(int index) const; 0088 0089 KDecoration2::Configuration::DecorationsModel *m_themesModel; 0090 QSortFilterProxyModel *m_proxyThemesModel; 0091 0092 KDecoration2::Preview::ButtonsModel *m_leftButtonsModel; 0093 KDecoration2::Preview::ButtonsModel *m_rightButtonsModel; 0094 KDecoration2::Preview::ButtonsModel *m_availableButtonsModel; 0095 0096 int m_borderSizeIndex = -1; 0097 KWinDecorationData *m_data; 0098 };