KWin
Loading...
Searching...
No Matches
effectsmodel.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2013 Antonis Tsiapaliokas <kok3rs@gmail.com>
6 SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#pragma once
12
13#include <kwin_export.h>
14
15#include <KSharedConfig>
16
17#include <QAbstractItemModel>
18#include <QString>
19#include <QUrl>
20#include <QWindow>
21
22namespace KWin
23{
24
25class KWIN_EXPORT EffectsModel : public QAbstractItemModel
26{
27 Q_OBJECT
28
29public:
113
117 enum class Status {
121 Disabled = Qt::Unchecked,
127 EnabledUndeterminded = Qt::PartiallyChecked,
131 Enabled = Qt::Checked
132 };
133
134 explicit EffectsModel(QObject *parent = nullptr);
135
136 // Reimplemented from QAbstractItemModel.
137 QHash<int, QByteArray> roleNames() const override;
138 QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
139 QModelIndex parent(const QModelIndex &child) const override;
140 int rowCount(const QModelIndex &parent = {}) const override;
141 int columnCount(const QModelIndex &parent = {}) const override;
142 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
143 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
144
152 void updateEffectStatus(const QModelIndex &rowIndex, Status effectState);
153
157 enum class LoadOptions {
158 None,
162 KeepDirty
163 };
164
170 void load(LoadOptions options = LoadOptions::None);
171
175 void save();
176
182 void defaults();
183
187 bool isDefaults() const;
188
192 bool needsSave() const;
193
197 QModelIndex findByPluginId(const QString &pluginId) const;
198
205 void requestConfigure(const QModelIndex &index, QWindow *transientParent);
206
207Q_SIGNALS:
213 void loaded();
214
215protected:
217 {
218 QString name;
219 QString description;
220 QString authorName;
221 QString authorEmail;
222 QString license;
223 QString version;
225 QString category;
226 QString serviceName;
227 QString iconName;
232 QUrl video;
237 bool changed = false;
239 QVariantList configArgs;
240 };
241
248 virtual bool shouldStore(const EffectData &data) const;
249
250private:
251 void loadBuiltInEffects(const KConfigGroup &kwinConfig);
252 void loadJavascriptEffects(const KConfigGroup &kwinConfig);
253 void loadPluginEffects(const KConfigGroup &kwinConfig);
254
255 QList<EffectData> m_effects;
256 QList<EffectData> m_pendingEffects;
257 int m_lastSerial = -1;
258
259 Q_DISABLE_COPY(EffectsModel)
260};
261
262}