Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwincompositing/model.h
Show All 27 Lines | |||||
28 | #include <QHash> | 28 | #include <QHash> | ||
29 | #include <QList> | 29 | #include <QList> | ||
30 | #include <QQuickWidget> | 30 | #include <QQuickWidget> | ||
31 | #include <QSortFilterProxyModel> | 31 | #include <QSortFilterProxyModel> | ||
32 | #include <QString> | 32 | #include <QString> | ||
33 | #include <KPluginInfo> | 33 | #include <KPluginInfo> | ||
34 | 34 | | |||
35 | namespace KWin { | 35 | namespace KWin { | ||
36 | namespace Compositing { | | |||
37 | | ||||
38 | enum class EffectStatus { | | |||
39 | Disabled = Qt::Unchecked, | | |||
40 | EnabledUndeterminded = Qt::PartiallyChecked, | | |||
41 | Enabled = Qt::Checked | | |||
42 | }; | | |||
43 | | ||||
44 | struct EffectData { | | |||
45 | QString name; | | |||
46 | QString description; | | |||
47 | QString authorName; | | |||
48 | QString authorEmail; | | |||
49 | QString license; | | |||
50 | QString version; | | |||
51 | QString category; | | |||
52 | QString serviceName; | | |||
53 | EffectStatus effectStatus; | | |||
54 | bool enabledByDefault; | | |||
55 | bool enabledByDefaultFunction; | | |||
56 | QUrl video; | | |||
57 | bool supported; | | |||
58 | QString exclusiveGroup; | | |||
59 | bool internal; | | |||
60 | bool configurable; | | |||
61 | bool scripted; | | |||
62 | bool changed = false; | | |||
63 | }; | | |||
64 | | ||||
65 | class EffectModel : public QAbstractItemModel | | |||
66 | { | | |||
67 | | ||||
68 | Q_OBJECT | | |||
69 | 36 | | |||
70 | public: | 37 | class EffectModel; | ||
71 | enum EffectRoles { | | |||
72 | NameRole = Qt::UserRole + 1, | | |||
73 | DescriptionRole, | | |||
74 | AuthorNameRole, | | |||
75 | AuthorEmailRole, | | |||
76 | LicenseRole, | | |||
77 | VersionRole, | | |||
78 | CategoryRole, | | |||
79 | ServiceNameRole, | | |||
80 | EffectStatusRole, | | |||
81 | VideoRole, | | |||
82 | SupportedRole, | | |||
83 | ExclusiveRole, | | |||
84 | InternalRole, | | |||
85 | ConfigurableRole, | | |||
86 | ScriptedRole | | |||
87 | }; | | |||
88 | | ||||
89 | explicit EffectModel(QObject *parent = 0); | | |||
90 | | ||||
91 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; | | |||
92 | QModelIndex parent(const QModelIndex &child) const override; | | |||
93 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | | |||
94 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; | | |||
95 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | | |||
96 | bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; | | |||
97 | QString serviceName(const QString &effectName); | | |||
98 | | ||||
99 | virtual QHash< int, QByteArray > roleNames() const override; | | |||
100 | | ||||
101 | void updateEffectStatus(const QModelIndex &rowIndex, EffectStatus effectState); | | |||
102 | void syncEffectsToKWin(); | | |||
103 | void syncConfig(); | | |||
104 | void loadEffects(); | | |||
105 | void defaults(); | | |||
106 | 38 | | |||
107 | private: | 39 | namespace Compositing { | ||
108 | void loadBuiltInEffects(const KConfigGroup &kwinConfig, const KPluginInfo::List &configs); | | |||
109 | void loadJavascriptEffects(const KConfigGroup &kwinConfig); | | |||
110 | void loadPluginEffects(const KConfigGroup &kwinConfig, const KPluginInfo::List &configs); | | |||
111 | int findRowByServiceName(const QString &serviceName); | | |||
112 | QList<EffectData> m_effectsList; | | |||
113 | QList<EffectData> m_effectsChanged; | | |||
114 | | ||||
115 | }; | | |||
116 | 40 | | |||
117 | class EffectView : public QQuickWidget | 41 | class EffectView : public QQuickWidget | ||
118 | { | 42 | { | ||
119 | 43 | | |||
120 | Q_OBJECT | 44 | Q_OBJECT | ||
121 | 45 | | |||
122 | public: | 46 | public: | ||
123 | enum ViewType { | 47 | enum ViewType { | ||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |