Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/common/effectmodel.cpp
- This file was copied from kcmkwin/kwincompositing/model.cpp.
1 | /************************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | * KWin - the KDE window manager * | 2 | KWin - the KDE window manager | ||
3 | * This file is part of the KDE project. * | 3 | This file is part of the KDE project. | ||
4 | * * | 4 | | ||
5 | * Copyright (C) 2013 Antonis Tsiapaliokas <kok3rs@gmail.com> * | 5 | Copyright (C) 2013 Antonis Tsiapaliokas <kok3rs@gmail.com> | ||
6 | * * | 6 | Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com> | ||
7 | * This program is free software; you can redistribute it and/or modify * | 7 | | ||
8 | * it under the terms of the GNU General Public License as published by * | 8 | This program is free software; you can redistribute it and/or modify | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | it under the terms of the GNU General Public License as published by | ||
10 | * (at your option) any later version. * | 10 | the Free Software Foundation; either version 2 of the License, or | ||
11 | * * | 11 | (at your option) any later version. | ||
12 | * This program is distributed in the hope that it will be useful, * | 12 | | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | 13 | This program is distributed in the hope that it will be useful, | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * GNU General Public License for more details. * | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * * | 16 | GNU General Public License for more details. | ||
17 | * You should have received a copy of the GNU General Public License * | 17 | | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * | 18 | You should have received a copy of the GNU General Public License | ||
19 | **************************************************************************/ | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | 20 | *********************************************************************/ | |||
21 | #include "model.h" | 21 | | ||
22 | #include "effectconfig.h" | 22 | #include "effectmodel.h" | ||
23 | #include "compositing.h" | 23 | | ||
24 | #include <config-kwin.h> | 24 | #include <config-kwin.h> | ||
25 | #include <kwin_effects_interface.h> | | |||
26 | #include <effect_builtins.h> | 25 | #include <effect_builtins.h> | ||
26 | #include <kwin_effects_interface.h> | ||||
27 | 27 | | |||
28 | #include <KAboutData> | ||||
28 | #include <KLocalizedString> | 29 | #include <KLocalizedString> | ||
29 | #include <KSharedConfig> | | |||
30 | #include <KCModuleProxy> | | |||
31 | #include <KPackage/PackageLoader> | 30 | #include <KPackage/PackageLoader> | ||
32 | #include <KPluginTrader> | | |||
33 | #include <kdeclarative/kdeclarative.h> | | |||
34 | #include <KPluginLoader> | 31 | #include <KPluginLoader> | ||
35 | #include <KPluginMetaData> | 32 | #include <KPluginMetaData> | ||
36 | #include <KAboutData> | 33 | #include <KPluginTrader> | ||
37 | 34 | | |||
38 | #include <QAbstractItemModel> | | |||
39 | #include <QDBusConnection> | 35 | #include <QDBusConnection> | ||
40 | #include <QDBusInterface> | 36 | #include <QDBusInterface> | ||
41 | #include <QDBusPendingCall> | | |||
42 | #include <QDBusMessage> | 37 | #include <QDBusMessage> | ||
43 | #include <QHash> | 38 | #include <QDBusPendingCall> | ||
44 | #include <QVariant> | | |||
45 | #include <QList> | | |||
46 | #include <QString> | | |||
47 | #include <QQmlEngine> | | |||
48 | #include <QtQml> | | |||
49 | #include <QQuickItem> | | |||
50 | #include <QDebug> | | |||
51 | 39 | | |||
52 | namespace KWin { | 40 | namespace KWin | ||
53 | namespace Compositing { | 41 | { | ||
54 | 42 | | |||
55 | static QString translatedCategory(const QString &category) | 43 | static QString translatedCategory(const QString &category) | ||
56 | { | 44 | { | ||
57 | static const QVector<QString> knownCategories = { | 45 | static const QVector<QString> knownCategories = { | ||
58 | QStringLiteral("Accessibility"), | 46 | QStringLiteral("Accessibility"), | ||
59 | QStringLiteral("Appearance"), | 47 | QStringLiteral("Appearance"), | ||
60 | QStringLiteral("Candy"), | 48 | QStringLiteral("Candy"), | ||
61 | QStringLiteral("Focus"), | 49 | QStringLiteral("Focus"), | ||
62 | QStringLiteral("Show Desktop Animation"), | 50 | QStringLiteral("Show Desktop Animation"), | ||
63 | QStringLiteral("Tools"), | 51 | QStringLiteral("Tools"), | ||
64 | QStringLiteral("Virtual Desktop Switching Animation"), | 52 | QStringLiteral("Virtual Desktop Switching Animation"), | ||
65 | QStringLiteral("Window Management"), | 53 | QStringLiteral("Window Management"), | ||
66 | QStringLiteral("Window Open/Close Animation") | 54 | QStringLiteral("Window Open/Close Animation") | ||
67 | }; | 55 | }; | ||
68 | 56 | | |||
69 | static const QVector<QString> translatedCategories = { | 57 | static const QVector<QString> translatedCategories = { | ||
70 | i18nc("Category of Desktop Effects, used as section header", "Accessibility"), | 58 | i18nc("Category of Desktop Effects, used as section header", "Accessibility"), | ||
71 | i18nc("Category of Desktop Effects, used as section header", "Appearance"), | 59 | i18nc("Category of Desktop Effects, used as section header", "Appearance"), | ||
72 | i18nc("Category of Desktop Effects, used as section header", "Candy"), | 60 | i18nc("Category of Desktop Effects, used as section header", "Candy"), | ||
73 | i18nc("Category of Desktop Effects, used as section header", "Focus"), | 61 | i18nc("Category of Desktop Effects, used as section header", "Focus"), | ||
74 | i18nc("Category of Desktop Effects, used as section header", "Show Desktop Animation"), | 62 | i18nc("Category of Desktop Effects, used as section header", "Show Desktop Animation"), | ||
75 | i18nc("Category of Desktop Effects, used as section header", "Tools"), | 63 | i18nc("Category of Desktop Effects, used as section header", "Tools"), | ||
76 | i18nc("Category of Desktop Effects, used as section header", "Virtual Desktop Switching Animation"), | 64 | i18nc("Category of Desktop Effects, used as section header", "Virtual Desktop Switching Animation"), | ||
77 | i18nc("Category of Desktop Effects, used as section header", "Window Management"), | 65 | i18nc("Category of Desktop Effects, used as section header", "Window Management"), | ||
78 | i18nc("Category of Desktop Effects, used as section header", "Window Open/Close Animation") | 66 | i18nc("Category of Desktop Effects, used as section header", "Window Open/Close Animation") | ||
79 | }; | 67 | }; | ||
68 | | ||||
80 | const int index = knownCategories.indexOf(category); | 69 | const int index = knownCategories.indexOf(category); | ||
81 | if (index == -1) { | 70 | if (index == -1) { | ||
82 | qDebug() << "Unknown category '" << category << "' and thus not translated"; | 71 | qDebug() << "Unknown category '" << category << "' and thus not translated"; | ||
83 | return category; | 72 | return category; | ||
84 | } | 73 | } | ||
74 | | ||||
85 | return translatedCategories[index]; | 75 | return translatedCategories[index]; | ||
86 | } | 76 | } | ||
87 | 77 | | |||
88 | static EffectStatus effectStatus(bool enabled) | 78 | static EffectModel::EffectStatus effectStatus(bool enabled) | ||
89 | { | 79 | { | ||
90 | return enabled ? EffectStatus::Enabled : EffectStatus::Disabled; | 80 | return enabled ? EffectModel::EffectStatus::Enabled : EffectModel::EffectStatus::Disabled; | ||
91 | } | 81 | } | ||
92 | 82 | | |||
93 | EffectModel::EffectModel(QObject *parent) | 83 | EffectModel::EffectModel(QObject *parent) | ||
94 | : QAbstractItemModel(parent) { | 84 | : QAbstractItemModel(parent) | ||
85 | { | ||||
95 | } | 86 | } | ||
96 | 87 | | |||
97 | QHash< int, QByteArray > EffectModel::roleNames() const | 88 | QHash<int, QByteArray> EffectModel::roleNames() const | ||
98 | { | 89 | { | ||
99 | QHash<int, QByteArray> roleNames; | 90 | QHash<int, QByteArray> roleNames; | ||
100 | roleNames[NameRole] = "NameRole"; | 91 | roleNames[NameRole] = "NameRole"; | ||
101 | roleNames[DescriptionRole] = "DescriptionRole"; | 92 | roleNames[DescriptionRole] = "DescriptionRole"; | ||
102 | roleNames[AuthorNameRole] = "AuthorNameRole"; | 93 | roleNames[AuthorNameRole] = "AuthorNameRole"; | ||
103 | roleNames[AuthorEmailRole] = "AuthorEmailRole"; | 94 | roleNames[AuthorEmailRole] = "AuthorEmailRole"; | ||
104 | roleNames[LicenseRole] = "LicenseRole"; | 95 | roleNames[LicenseRole] = "LicenseRole"; | ||
105 | roleNames[VersionRole] = "VersionRole"; | 96 | roleNames[VersionRole] = "VersionRole"; | ||
106 | roleNames[CategoryRole] = "CategoryRole"; | 97 | roleNames[CategoryRole] = "CategoryRole"; | ||
107 | roleNames[ServiceNameRole] = "ServiceNameRole"; | 98 | roleNames[ServiceNameRole] = "ServiceNameRole"; | ||
99 | roleNames[IconNameRole] = "IconNameRole"; | ||||
108 | roleNames[EffectStatusRole] = "EffectStatusRole"; | 100 | roleNames[EffectStatusRole] = "EffectStatusRole"; | ||
109 | roleNames[VideoRole] = "VideoRole"; | 101 | roleNames[VideoRole] = "VideoRole"; | ||
102 | roleNames[WebsiteRole] = "WebsiteRole"; | ||||
110 | roleNames[SupportedRole] = "SupportedRole"; | 103 | roleNames[SupportedRole] = "SupportedRole"; | ||
111 | roleNames[ExclusiveRole] = "ExclusiveRole"; | 104 | roleNames[ExclusiveRole] = "ExclusiveRole"; | ||
112 | roleNames[ConfigurableRole] = "ConfigurableRole"; | 105 | roleNames[ConfigurableRole] = "ConfigurableRole"; | ||
113 | roleNames[ScriptedRole] = QByteArrayLiteral("ScriptedRole"); | 106 | roleNames[ScriptedRole] = QByteArrayLiteral("ScriptedRole"); | ||
107 | roleNames[EnabledByDefaultRole] = "EnabledByDefaultRole"; | ||||
114 | return roleNames; | 108 | return roleNames; | ||
115 | } | 109 | } | ||
116 | 110 | | |||
117 | QModelIndex EffectModel::index(int row, int column, const QModelIndex &parent) const | 111 | QModelIndex EffectModel::index(int row, int column, const QModelIndex &parent) const | ||
118 | { | 112 | { | ||
119 | if (parent.isValid() || column > 0 || column < 0 || row < 0 || row >= m_effectsList.count()) { | 113 | if (parent.isValid() || column > 0 || column < 0 || row < 0 || row >= m_effectsList.count()) { | ||
120 | return QModelIndex(); | 114 | return {}; | ||
121 | } | 115 | } | ||
122 | 116 | | |||
123 | return createIndex(row, column); | 117 | return createIndex(row, column); | ||
124 | } | 118 | } | ||
125 | 119 | | |||
126 | QModelIndex EffectModel::parent(const QModelIndex &child) const | 120 | QModelIndex EffectModel::parent(const QModelIndex &child) const | ||
127 | { | 121 | { | ||
128 | Q_UNUSED(child) | 122 | Q_UNUSED(child) | ||
129 | 123 | return {}; | |||
130 | return QModelIndex(); | | |||
131 | } | 124 | } | ||
132 | 125 | | |||
133 | int EffectModel::columnCount(const QModelIndex &parent) const | 126 | int EffectModel::columnCount(const QModelIndex &parent) const | ||
134 | { | 127 | { | ||
135 | Q_UNUSED(parent) | 128 | Q_UNUSED(parent) | ||
136 | return 1; | 129 | return 1; | ||
137 | } | 130 | } | ||
138 | 131 | | |||
139 | int EffectModel::rowCount(const QModelIndex &parent) const | 132 | int EffectModel::rowCount(const QModelIndex &parent) const | ||
140 | { | 133 | { | ||
141 | if (parent.isValid()) { | 134 | if (parent.isValid()) { | ||
142 | return 0; | 135 | return 0; | ||
143 | } | 136 | } | ||
144 | return m_effectsList.count(); | 137 | return m_effectsList.count(); | ||
145 | } | 138 | } | ||
146 | 139 | | |||
147 | QVariant EffectModel::data(const QModelIndex &index, int role) const | 140 | QVariant EffectModel::data(const QModelIndex &index, int role) const | ||
148 | { | 141 | { | ||
149 | if (!index.isValid()) { | 142 | if (!index.isValid()) { | ||
150 | return QVariant(); | 143 | return {}; | ||
151 | } | 144 | } | ||
152 | 145 | | |||
153 | EffectData currentEffect = m_effectsList.at(index.row()); | 146 | const EffectData effect = m_effectsList.at(index.row()); | ||
154 | switch (role) { | 147 | switch (role) { | ||
155 | case Qt::DisplayRole: | 148 | case Qt::DisplayRole: | ||
156 | case NameRole: | 149 | case NameRole: | ||
157 | return m_effectsList.at(index.row()).name; | 150 | return effect.name; | ||
158 | case DescriptionRole: | 151 | case DescriptionRole: | ||
159 | return m_effectsList.at(index.row()).description; | 152 | return effect.description; | ||
160 | case AuthorNameRole: | 153 | case AuthorNameRole: | ||
161 | return m_effectsList.at(index.row()).authorName; | 154 | return effect.authorName; | ||
162 | case AuthorEmailRole: | 155 | case AuthorEmailRole: | ||
163 | return m_effectsList.at(index.row()).authorEmail; | 156 | return effect.authorEmail; | ||
164 | case LicenseRole: | 157 | case LicenseRole: | ||
165 | return m_effectsList.at(index.row()).license; | 158 | return effect.license; | ||
166 | case VersionRole: | 159 | case VersionRole: | ||
167 | return m_effectsList.at(index.row()).version; | 160 | return effect.version; | ||
168 | case CategoryRole: | 161 | case CategoryRole: | ||
169 | return m_effectsList.at(index.row()).category; | 162 | return effect.category; | ||
170 | case ServiceNameRole: | 163 | case ServiceNameRole: | ||
171 | return m_effectsList.at(index.row()).serviceName; | 164 | return effect.serviceName; | ||
165 | case IconNameRole: | ||||
166 | return effect.iconName; | ||||
172 | case EffectStatusRole: | 167 | case EffectStatusRole: | ||
173 | return (int)m_effectsList.at(index.row()).effectStatus; | 168 | return static_cast<int>(effect.effectStatus); | ||
174 | case VideoRole: | 169 | case VideoRole: | ||
175 | return m_effectsList.at(index.row()).video; | 170 | return effect.video; | ||
171 | case WebsiteRole: | ||||
172 | return effect.website; | ||||
176 | case SupportedRole: | 173 | case SupportedRole: | ||
177 | return m_effectsList.at(index.row()).supported; | 174 | return effect.supported; | ||
178 | case ExclusiveRole: | 175 | case ExclusiveRole: | ||
179 | return m_effectsList.at(index.row()).exclusiveGroup; | 176 | return effect.exclusiveGroup; | ||
180 | case InternalRole: | 177 | case InternalRole: | ||
181 | return m_effectsList.at(index.row()).internal; | 178 | return effect.internal; | ||
182 | case ConfigurableRole: | 179 | case ConfigurableRole: | ||
183 | return m_effectsList.at(index.row()).configurable; | 180 | return effect.configurable; | ||
184 | case ScriptedRole: | 181 | case ScriptedRole: | ||
185 | return m_effectsList.at(index.row()).scripted; | 182 | return effect.scripted; | ||
183 | case EnabledByDefaultRole: | ||||
184 | return effect.enabledByDefault; | ||||
186 | default: | 185 | default: | ||
187 | return QVariant(); | 186 | return {}; | ||
188 | } | 187 | } | ||
189 | } | 188 | } | ||
190 | 189 | | |||
191 | bool EffectModel::setData(const QModelIndex& index, const QVariant& value, int role) | 190 | bool EffectModel::setData(const QModelIndex &index, const QVariant &value, int role) | ||
192 | { | 191 | { | ||
193 | if (!index.isValid()) | 192 | if (!index.isValid()) { | ||
194 | return QAbstractItemModel::setData(index, value, role); | 193 | return QAbstractItemModel::setData(index, value, role); | ||
194 | } | ||||
195 | 195 | | |||
196 | if (role == EffectModel::EffectStatusRole) { | 196 | if (role == EffectModel::EffectStatusRole) { | ||
197 | // note: whenever the StatusRole is modified (even to the same value) the entry | 197 | // note: whenever the StatusRole is modified (even to the same value) the entry | ||
198 | // gets marked as changed and will get saved to the config file. This means the | 198 | // gets marked as changed and will get saved to the config file. This means the | ||
199 | // config file could get polluted | 199 | // config file could get polluted | ||
200 | EffectData &data = m_effectsList[index.row()]; | 200 | EffectData &data = m_effectsList[index.row()]; | ||
201 | data.effectStatus = EffectStatus(value.toInt()); | 201 | data.effectStatus = EffectStatus(value.toInt()); | ||
202 | data.changed = true; | 202 | data.changed = true; | ||
Show All 27 Lines | 229 | for (auto builtin : builtins) { | |||
230 | const BuiltInEffects::EffectData &data = BuiltInEffects::effectData(builtin); | 230 | const BuiltInEffects::EffectData &data = BuiltInEffects::effectData(builtin); | ||
231 | EffectData effect; | 231 | EffectData effect; | ||
232 | effect.name = data.displayName; | 232 | effect.name = data.displayName; | ||
233 | effect.description = data.comment; | 233 | effect.description = data.comment; | ||
234 | effect.authorName = i18n("KWin development team"); | 234 | effect.authorName = i18n("KWin development team"); | ||
235 | effect.authorEmail = QString(); // not used at all | 235 | effect.authorEmail = QString(); // not used at all | ||
236 | effect.license = QStringLiteral("GPL"); | 236 | effect.license = QStringLiteral("GPL"); | ||
237 | effect.version = QStringLiteral(KWIN_VERSION_STRING); | 237 | effect.version = QStringLiteral(KWIN_VERSION_STRING); | ||
238 | effect.untranslatedCategory = data.category; | ||||
238 | effect.category = translatedCategory(data.category); | 239 | effect.category = translatedCategory(data.category); | ||
239 | effect.serviceName = data.name; | 240 | effect.serviceName = data.name; | ||
241 | effect.iconName = QStringLiteral("preferences-system-windows"); | ||||
240 | effect.enabledByDefault = data.enabled; | 242 | effect.enabledByDefault = data.enabled; | ||
241 | effect.enabledByDefaultFunction = (data.enabledFunction != nullptr); | 243 | effect.enabledByDefaultFunction = (data.enabledFunction != nullptr); | ||
242 | const QString enabledKey = QStringLiteral("%1Enabled").arg(effect.serviceName); | 244 | const QString enabledKey = QStringLiteral("%1Enabled").arg(effect.serviceName); | ||
243 | if (kwinConfig.hasKey(enabledKey)) { | 245 | if (kwinConfig.hasKey(enabledKey)) { | ||
244 | effect.effectStatus = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", effect.enabledByDefault)); | 246 | effect.effectStatus = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", effect.enabledByDefault)); | ||
245 | } else if (data.enabledFunction != nullptr) { | 247 | } else if (data.enabledFunction != nullptr) { | ||
246 | effect.effectStatus = EffectStatus::EnabledUndeterminded; | 248 | effect.effectStatus = EffectStatus::EnabledUndeterminded; | ||
247 | } else { | 249 | } else { | ||
248 | effect.effectStatus = effectStatus(effect.enabledByDefault); | 250 | effect.effectStatus = effectStatus(effect.enabledByDefault); | ||
249 | } | 251 | } | ||
250 | effect.video = data.video; | 252 | effect.video = data.video; | ||
253 | effect.website = QUrl(); | ||||
251 | effect.supported = true; | 254 | effect.supported = true; | ||
252 | effect.exclusiveGroup = data.exclusiveCategory; | 255 | effect.exclusiveGroup = data.exclusiveCategory; | ||
253 | effect.internal = data.internal; | 256 | effect.internal = data.internal; | ||
254 | effect.scripted = false; | 257 | effect.scripted = false; | ||
255 | 258 | | |||
256 | auto it = std::find_if(configs.begin(), configs.end(), [data](const KPluginInfo &info) { | 259 | auto it = std::find_if(configs.begin(), configs.end(), [data](const KPluginInfo &info) { | ||
257 | return info.property(QStringLiteral("X-KDE-ParentComponents")).toString() == data.name; | 260 | return info.property(QStringLiteral("X-KDE-ParentComponents")).toString() == data.name; | ||
258 | }); | 261 | }); | ||
259 | effect.configurable = it != configs.end(); | 262 | effect.configurable = it != configs.end(); | ||
260 | 263 | | |||
264 | if (shouldStore(effect)) { | ||||
261 | m_effectsList << effect; | 265 | m_effectsList << effect; | ||
262 | } | 266 | } | ||
263 | } | 267 | } | ||
268 | } | ||||
264 | 269 | | |||
265 | void EffectModel::loadJavascriptEffects(const KConfigGroup &kwinConfig) | 270 | void EffectModel::loadJavascriptEffects(const KConfigGroup &kwinConfig) | ||
266 | { | 271 | { | ||
267 | const auto plugins = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Effect"), QStringLiteral("kwin/effects")); | 272 | const auto plugins = KPackage::PackageLoader::self()->listPackages( | ||
273 | QStringLiteral("KWin/Effect"), | ||||
274 | QStringLiteral("kwin/effects") | ||||
275 | ); | ||||
268 | for (const KPluginMetaData &metaData : plugins) { | 276 | for (const KPluginMetaData &metaData : plugins) { | ||
269 | KPluginInfo plugin(metaData); | 277 | KPluginInfo plugin(metaData); | ||
270 | EffectData effect; | 278 | EffectData effect; | ||
271 | 279 | | |||
272 | effect.name = plugin.name(); | 280 | effect.name = plugin.name(); | ||
273 | effect.description = plugin.comment(); | 281 | effect.description = plugin.comment(); | ||
274 | effect.authorName = plugin.author(); | 282 | effect.authorName = plugin.author(); | ||
275 | effect.authorEmail = plugin.email(); | 283 | effect.authorEmail = plugin.email(); | ||
276 | effect.license = plugin.license(); | 284 | effect.license = plugin.license(); | ||
277 | effect.version = plugin.version(); | 285 | effect.version = plugin.version(); | ||
286 | effect.untranslatedCategory = plugin.category(); | ||||
278 | effect.category = translatedCategory(plugin.category()); | 287 | effect.category = translatedCategory(plugin.category()); | ||
279 | effect.serviceName = plugin.pluginName(); | 288 | effect.serviceName = plugin.pluginName(); | ||
289 | effect.iconName = plugin.icon(); | ||||
280 | effect.effectStatus = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", plugin.isPluginEnabledByDefault())); | 290 | effect.effectStatus = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", plugin.isPluginEnabledByDefault())); | ||
281 | effect.enabledByDefault = plugin.isPluginEnabledByDefault(); | 291 | effect.enabledByDefault = plugin.isPluginEnabledByDefault(); | ||
282 | effect.enabledByDefaultFunction = false; | 292 | effect.enabledByDefaultFunction = false; | ||
283 | effect.video = plugin.property(QStringLiteral("X-KWin-Video-Url")).toUrl(); | 293 | effect.video = plugin.property(QStringLiteral("X-KWin-Video-Url")).toUrl(); | ||
294 | effect.website = plugin.website(); | ||||
284 | effect.supported = true; | 295 | effect.supported = true; | ||
285 | effect.exclusiveGroup = plugin.property(QStringLiteral("X-KWin-Exclusive-Category")).toString(); | 296 | effect.exclusiveGroup = plugin.property(QStringLiteral("X-KWin-Exclusive-Category")).toString(); | ||
286 | effect.internal = plugin.property(QStringLiteral("X-KWin-Internal")).toBool(); | 297 | effect.internal = plugin.property(QStringLiteral("X-KWin-Internal")).toBool(); | ||
287 | effect.scripted = true; | 298 | effect.scripted = true; | ||
288 | 299 | | |||
289 | const QString pluginKeyword = plugin.property(QStringLiteral("X-KDE-PluginKeyword")).toString(); | 300 | const QString pluginKeyword = plugin.property(QStringLiteral("X-KDE-PluginKeyword")).toString(); | ||
290 | if (!pluginKeyword.isEmpty()) { | 301 | if (!pluginKeyword.isEmpty()) { | ||
291 | // scripted effects have their pluginName() as the keyword | 302 | // scripted effects have their pluginName() as the keyword | ||
292 | effect.configurable = plugin.property(QStringLiteral("X-KDE-ParentComponents")).toString() == pluginKeyword; | 303 | effect.configurable = plugin.property(QStringLiteral("X-KDE-ParentComponents")).toString() == pluginKeyword; | ||
293 | } else { | 304 | } else { | ||
294 | effect.configurable = false; | 305 | effect.configurable = false; | ||
295 | } | 306 | } | ||
296 | 307 | | |||
308 | if (shouldStore(effect)) { | ||||
297 | m_effectsList << effect; | 309 | m_effectsList << effect; | ||
298 | } | 310 | } | ||
299 | } | 311 | } | ||
312 | } | ||||
300 | 313 | | |||
301 | void EffectModel::loadPluginEffects(const KConfigGroup &kwinConfig, const KPluginInfo::List &configs) | 314 | void EffectModel::loadPluginEffects(const KConfigGroup &kwinConfig, const KPluginInfo::List &configs) | ||
302 | { | 315 | { | ||
303 | static const QString subDir(QStringLiteral("kwin/effects/plugins/")); | 316 | const QVector<KPluginMetaData> pluginEffects = KPluginLoader::findPlugins( | ||
304 | static const QString serviceType(QStringLiteral("KWin/Effect")); | 317 | QStringLiteral("kwin/effects/plugins/"), | ||
305 | const QVector<KPluginMetaData> pluginEffects = KPluginLoader::findPlugins(subDir, [] (const KPluginMetaData &data) { return data.serviceTypes().contains(serviceType); }); | 318 | [](const KPluginMetaData &data) { | ||
319 | return data.serviceTypes().contains(QStringLiteral("KWin/Effect")); | ||||
320 | } | ||||
321 | ); | ||||
306 | for (KPluginMetaData pluginEffect : pluginEffects) { | 322 | for (KPluginMetaData pluginEffect : pluginEffects) { | ||
307 | if (!pluginEffect.isValid()) | 323 | if (!pluginEffect.isValid()) { | ||
308 | continue; | 324 | continue; | ||
325 | } | ||||
309 | EffectData effect; | 326 | EffectData effect; | ||
310 | effect.name = pluginEffect.name(); | 327 | effect.name = pluginEffect.name(); | ||
311 | effect.description = pluginEffect.description(); | 328 | effect.description = pluginEffect.description(); | ||
312 | effect.license = pluginEffect.license(); | 329 | effect.license = pluginEffect.license(); | ||
313 | effect.version = pluginEffect.version(); | 330 | effect.version = pluginEffect.version(); | ||
314 | effect.category = pluginEffect.category(); | 331 | effect.untranslatedCategory = pluginEffect.category(); | ||
332 | effect.category = translatedCategory(pluginEffect.category()); | ||||
315 | effect.serviceName = pluginEffect.pluginId(); | 333 | effect.serviceName = pluginEffect.pluginId(); | ||
334 | effect.iconName = pluginEffect.iconName(); | ||||
316 | effect.enabledByDefault = pluginEffect.isEnabledByDefault(); | 335 | effect.enabledByDefault = pluginEffect.isEnabledByDefault(); | ||
317 | effect.supported = true; | 336 | effect.supported = true; | ||
318 | effect.enabledByDefaultFunction = false; | 337 | effect.enabledByDefaultFunction = false; | ||
319 | effect.internal = false; | 338 | effect.internal = false; | ||
320 | effect.scripted = false; | 339 | effect.scripted = false; | ||
321 | 340 | | |||
322 | for (int i = 0; i < pluginEffect.authors().count(); ++i) { | 341 | for (int i = 0; i < pluginEffect.authors().count(); ++i) { | ||
323 | effect.authorName.append(pluginEffect.authors().at(i).name()); | 342 | effect.authorName.append(pluginEffect.authors().at(i).name()); | ||
324 | effect.authorEmail.append(pluginEffect.authors().at(i).emailAddress()); | 343 | effect.authorEmail.append(pluginEffect.authors().at(i).emailAddress()); | ||
325 | if (i+1 < pluginEffect.authors().count()) { | 344 | if (i+1 < pluginEffect.authors().count()) { | ||
326 | effect.authorName.append(", "); | 345 | effect.authorName.append(", "); | ||
327 | effect.authorEmail.append(", "); | 346 | effect.authorEmail.append(", "); | ||
328 | } | 347 | } | ||
329 | } | 348 | } | ||
330 | 349 | | |||
331 | if (pluginEffect.rawData().contains("org.kde.kwin.effect")) { | 350 | if (pluginEffect.rawData().contains("org.kde.kwin.effect")) { | ||
332 | const QJsonObject d(pluginEffect.rawData().value("org.kde.kwin.effect").toObject()); | 351 | const QJsonObject d(pluginEffect.rawData().value("org.kde.kwin.effect").toObject()); | ||
333 | effect.exclusiveGroup = d.value("exclusiveGroup").toString(); | 352 | effect.exclusiveGroup = d.value("exclusiveGroup").toString(); | ||
334 | effect.video = QUrl::fromUserInput(d.value("video").toString()); | 353 | effect.video = QUrl::fromUserInput(d.value("video").toString()); | ||
335 | effect.enabledByDefaultFunction = d.value("enabledByDefaultMethod").toBool(); | 354 | effect.enabledByDefaultFunction = d.value("enabledByDefaultMethod").toBool(); | ||
336 | } | 355 | } | ||
337 | 356 | | |||
357 | effect.website = pluginEffect.website(); | ||||
358 | | ||||
338 | const QString enabledKey = QStringLiteral("%1Enabled").arg(effect.serviceName); | 359 | const QString enabledKey = QStringLiteral("%1Enabled").arg(effect.serviceName); | ||
339 | if (kwinConfig.hasKey(enabledKey)) { | 360 | if (kwinConfig.hasKey(enabledKey)) { | ||
340 | effect.effectStatus = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", effect.enabledByDefault)); | 361 | effect.effectStatus = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", effect.enabledByDefault)); | ||
341 | } else if (effect.enabledByDefaultFunction) { | 362 | } else if (effect.enabledByDefaultFunction) { | ||
342 | effect.effectStatus = EffectStatus::EnabledUndeterminded; | 363 | effect.effectStatus = EffectStatus::EnabledUndeterminded; | ||
343 | } else { | 364 | } else { | ||
344 | effect.effectStatus = effectStatus(effect.enabledByDefault); | 365 | effect.effectStatus = effectStatus(effect.enabledByDefault); | ||
345 | } | 366 | } | ||
346 | 367 | | |||
347 | auto it = std::find_if(configs.begin(), configs.end(), [pluginEffect](const KPluginInfo &info) { | 368 | auto it = std::find_if(configs.begin(), configs.end(), | ||
369 | [pluginEffect](const KPluginInfo &info) { | ||||
348 | return info.property(QStringLiteral("X-KDE-ParentComponents")).toString() == pluginEffect.pluginId(); | 370 | return info.property(QStringLiteral("X-KDE-ParentComponents")).toString() == pluginEffect.pluginId(); | ||
349 | }); | 371 | } | ||
372 | ); | ||||
350 | effect.configurable = it != configs.end(); | 373 | effect.configurable = it != configs.end(); | ||
351 | 374 | | |||
375 | if (shouldStore(effect)) { | ||||
352 | m_effectsList << effect; | 376 | m_effectsList << effect; | ||
353 | } | 377 | } | ||
354 | } | 378 | } | ||
379 | } | ||||
355 | 380 | | |||
356 | void EffectModel::loadEffects() | 381 | void EffectModel::load() | ||
357 | { | 382 | { | ||
358 | KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins"); | 383 | KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins"); | ||
359 | 384 | | |||
360 | beginResetModel(); | 385 | beginResetModel(); | ||
361 | m_effectsChanged.clear(); | 386 | m_effectsChanged.clear(); | ||
362 | m_effectsList.clear(); | 387 | m_effectsList.clear(); | ||
363 | const KPluginInfo::List configs = KPluginTrader::self()->query(QStringLiteral("kwin/effects/configs/")); | 388 | const KPluginInfo::List configs = KPluginTrader::self()->query(QStringLiteral("kwin/effects/configs/")); | ||
364 | loadBuiltInEffects(kwinConfig, configs); | 389 | loadBuiltInEffects(kwinConfig, configs); | ||
365 | loadJavascriptEffects(kwinConfig); | 390 | loadJavascriptEffects(kwinConfig); | ||
366 | loadPluginEffects(kwinConfig, configs); | 391 | loadPluginEffects(kwinConfig, configs); | ||
367 | 392 | | |||
368 | qSort(m_effectsList.begin(), m_effectsList.end(), [](const EffectData &a, const EffectData &b) { | 393 | qSort(m_effectsList.begin(), m_effectsList.end(), [](const EffectData &a, const EffectData &b) { | ||
369 | if (a.category == b.category) { | 394 | if (a.category == b.category) { | ||
370 | if (a.exclusiveGroup == b.exclusiveGroup) { | 395 | if (a.exclusiveGroup == b.exclusiveGroup) { | ||
371 | return a.name < b.name; | 396 | return a.name < b.name; | ||
372 | } | 397 | } | ||
373 | return a.exclusiveGroup < b.exclusiveGroup; | 398 | return a.exclusiveGroup < b.exclusiveGroup; | ||
374 | } | 399 | } | ||
375 | return a.category < b.category; | 400 | return a.category < b.category; | ||
376 | }); | 401 | }); | ||
377 | 402 | | |||
378 | OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), | 403 | OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), | ||
379 | QStringLiteral("/Effects"), | 404 | QStringLiteral("/Effects"), | ||
380 | QDBusConnection::sessionBus()); | 405 | QDBusConnection::sessionBus()); | ||
406 | | ||||
381 | if (interface.isValid()) { | 407 | if (interface.isValid()) { | ||
382 | QStringList effectNames; | 408 | QStringList effectNames; | ||
383 | std::for_each(m_effectsList.constBegin(), m_effectsList.constEnd(), [&effectNames](const EffectData &data) { | 409 | effectNames.reserve(m_effectsList.count()); | ||
384 | effectNames << data.serviceName; | 410 | for (const EffectData &data : m_effectsList) { | ||
385 | }); | 411 | effectNames.append(data.serviceName); | ||
412 | } | ||||
413 | | ||||
386 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(interface.areEffectsSupported(effectNames), this); | 414 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(interface.areEffectsSupported(effectNames), this); | ||
387 | watcher->setProperty("effectNames", effectNames); | 415 | watcher->setProperty("effectNames", effectNames); | ||
388 | connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher *self) { | 416 | connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher *self) { | ||
389 | const QStringList effectNames = self->property("effectNames").toStringList(); | 417 | const QStringList effectNames = self->property("effectNames").toStringList(); | ||
390 | const QDBusPendingReply< QList< bool > > reply = *self; | 418 | const QDBusPendingReply<QList<bool > > reply = *self; | ||
391 | QList< bool> supportValues; | 419 | QList<bool> supportValues; | ||
392 | if (reply.isValid()) { | 420 | if (reply.isValid()) { | ||
393 | supportValues.append(reply.value()); | 421 | supportValues.append(reply.value()); | ||
394 | } | 422 | } | ||
395 | if (effectNames.size() == supportValues.size()) { | 423 | if (effectNames.size() == supportValues.size()) { | ||
396 | for (int i = 0; i < effectNames.size(); ++i) { | 424 | for (int i = 0; i < effectNames.size(); ++i) { | ||
397 | const bool supportedValue = supportValues.at(i); | 425 | const bool supportedValue = supportValues.at(i); | ||
398 | const QString &effectName = effectNames.at(i); | 426 | const QString &effectName = effectNames.at(i); | ||
399 | auto it = std::find_if(m_effectsList.begin(), m_effectsList.end(), [effectName](const EffectData &data) { | 427 | auto it = std::find_if(m_effectsList.begin(), m_effectsList.end(), [effectName](const EffectData &data) { | ||
Show All 29 Lines | |||||
429 | } | 457 | } | ||
430 | 458 | | |||
431 | void EffectModel::syncEffectsToKWin() | 459 | void EffectModel::syncEffectsToKWin() | ||
432 | { | 460 | { | ||
433 | OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), | 461 | OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), | ||
434 | QStringLiteral("/Effects"), | 462 | QStringLiteral("/Effects"), | ||
435 | QDBusConnection::sessionBus()); | 463 | QDBusConnection::sessionBus()); | ||
436 | for (int it = 0; it < m_effectsList.size(); it++) { | 464 | for (int it = 0; it < m_effectsList.size(); it++) { | ||
437 | if (m_effectsList.at(it).effectStatus != m_effectsChanged.at(it).effectStatus) { | 465 | if (m_effectsList.at(it).effectStatus == m_effectsChanged.at(it).effectStatus) { | ||
466 | continue; | ||||
467 | } | ||||
438 | if (m_effectsList.at(it).effectStatus != EffectStatus::Disabled) { | 468 | if (m_effectsList.at(it).effectStatus != EffectStatus::Disabled) { | ||
439 | interface.loadEffect(m_effectsList.at(it).serviceName); | 469 | interface.loadEffect(m_effectsList.at(it).serviceName); | ||
440 | } else { | 470 | } else { | ||
441 | interface.unloadEffect(m_effectsList.at(it).serviceName); | 471 | interface.unloadEffect(m_effectsList.at(it).serviceName); | ||
442 | } | 472 | } | ||
443 | } | 473 | } | ||
444 | } | | |||
445 | 474 | | |||
446 | m_effectsChanged = m_effectsList; | 475 | m_effectsChanged = m_effectsList; | ||
447 | } | 476 | } | ||
448 | 477 | | |||
449 | void EffectModel::updateEffectStatus(const QModelIndex &rowIndex, EffectStatus effectState) | 478 | void EffectModel::updateEffectStatus(const QModelIndex &rowIndex, EffectStatus effectState) | ||
450 | { | 479 | { | ||
451 | setData(rowIndex, (int)effectState, EffectModel::EffectStatusRole); | 480 | setData(rowIndex, static_cast<int>(effectState), EffectModel::EffectStatusRole); | ||
452 | } | 481 | } | ||
453 | 482 | | |||
454 | void EffectModel::syncConfig() | 483 | void EffectModel::save() | ||
455 | { | 484 | { | ||
456 | KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins"); | 485 | KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins"); | ||
457 | 486 | | |||
458 | for (auto it = m_effectsList.begin(); it != m_effectsList.end(); it++) { | 487 | for (auto it = m_effectsList.begin(); it != m_effectsList.end(); it++) { | ||
459 | EffectData &effect = *(it); | 488 | EffectData &effect = *(it); | ||
460 | if (!effect.changed) { | 489 | if (!effect.changed) { | ||
461 | continue; | 490 | continue; | ||
462 | } | 491 | } | ||
Show All 22 Lines | 512 | for (int i = 0; i < m_effectsList.count(); ++i) { | |||
485 | if (effect.enabledByDefaultFunction && effect.effectStatus != EffectStatus::EnabledUndeterminded) { | 514 | if (effect.enabledByDefaultFunction && effect.effectStatus != EffectStatus::EnabledUndeterminded) { | ||
486 | updateEffectStatus(index(i, 0), EffectStatus::EnabledUndeterminded); | 515 | updateEffectStatus(index(i, 0), EffectStatus::EnabledUndeterminded); | ||
487 | } else if ((bool)effect.effectStatus != effect.enabledByDefault) { | 516 | } else if ((bool)effect.effectStatus != effect.enabledByDefault) { | ||
488 | updateEffectStatus(index(i, 0), effect.enabledByDefault ? EffectStatus::Enabled : EffectStatus::Disabled); | 517 | updateEffectStatus(index(i, 0), effect.enabledByDefault ? EffectStatus::Enabled : EffectStatus::Disabled); | ||
489 | } | 518 | } | ||
490 | } | 519 | } | ||
491 | } | 520 | } | ||
492 | 521 | | |||
493 | EffectFilterModel::EffectFilterModel(QObject *parent) | 522 | bool EffectModel::shouldStore(const EffectData &data) const | ||
494 | : QSortFilterProxyModel(parent) | | |||
495 | , m_effectModel(new EffectModel(this)) | | |||
496 | , m_filterOutUnsupported(true) | | |||
497 | , m_filterOutInternal(true) | | |||
498 | { | 523 | { | ||
499 | setSourceModel(m_effectModel); | 524 | Q_UNUSED(data) | ||
500 | connect(this, &EffectFilterModel::filterOutUnsupportedChanged, this, &EffectFilterModel::invalidateFilter); | | |||
501 | connect(this, &EffectFilterModel::filterOutInternalChanged, this, &EffectFilterModel::invalidateFilter); | | |||
502 | } | | |||
503 | | ||||
504 | const QString &EffectFilterModel::filter() const | | |||
505 | { | | |||
506 | return m_filter; | | |||
507 | } | | |||
508 | | ||||
509 | void EffectFilterModel::setFilter(const QString &filter) | | |||
510 | { | | |||
511 | if (filter == m_filter) { | | |||
512 | return; | | |||
513 | } | | |||
514 | | ||||
515 | m_filter = filter; | | |||
516 | emit filterChanged(); | | |||
517 | invalidateFilter(); | | |||
518 | } | | |||
519 | | ||||
520 | bool EffectFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const | | |||
521 | { | | |||
522 | if (!m_effectModel) { | | |||
523 | return false; | | |||
524 | } | | |||
525 | | ||||
526 | QModelIndex index = m_effectModel->index(source_row, 0, source_parent); | | |||
527 | if (!index.isValid()) { | | |||
528 | return false; | | |||
529 | } | | |||
530 | | ||||
531 | if (m_filterOutUnsupported) { | | |||
532 | if (!index.data(EffectModel::SupportedRole).toBool()) { | | |||
533 | return false; | | |||
534 | } | | |||
535 | } | | |||
536 | | ||||
537 | if (m_filterOutInternal) { | | |||
538 | if (index.data(EffectModel::InternalRole).toBool()) { | | |||
539 | return false; | | |||
540 | } | | |||
541 | } | | |||
542 | | ||||
543 | if (m_filter.isEmpty()) { | | |||
544 | return true; | 525 | return true; | ||
545 | } | 526 | } | ||
546 | 527 | | |||
547 | QVariant data = index.data(); | | |||
548 | if (!data.isValid()) { | | |||
549 | //An invalid QVariant is valid data | | |||
550 | return true; | | |||
551 | } | | |||
552 | | ||||
553 | if (m_effectModel->data(index, EffectModel::NameRole).toString().contains(m_filter, Qt::CaseInsensitive)) { | | |||
554 | return true; | | |||
555 | } else if (m_effectModel->data(index, EffectModel::DescriptionRole).toString().contains(m_filter, Qt::CaseInsensitive)) { | | |||
556 | return true; | | |||
557 | } | | |||
558 | if (index.data(EffectModel::CategoryRole).toString().contains(m_filter, Qt::CaseInsensitive)) { | | |||
559 | return true; | | |||
560 | } | | |||
561 | | ||||
562 | return false; | | |||
563 | } | | |||
564 | | ||||
565 | void EffectFilterModel::updateEffectStatus(int rowIndex, int effectState) | | |||
566 | { | | |||
567 | const QModelIndex sourceIndex = mapToSource(index(rowIndex, 0)); | | |||
568 | | ||||
569 | m_effectModel->updateEffectStatus(sourceIndex, EffectStatus(effectState)); | | |||
570 | } | 528 | } | ||
571 | | ||||
572 | void EffectFilterModel::syncConfig() | | |||
573 | { | | |||
574 | m_effectModel->syncConfig(); | | |||
575 | } | | |||
576 | | ||||
577 | void EffectFilterModel::load() | | |||
578 | { | | |||
579 | m_effectModel->loadEffects(); | | |||
580 | } | | |||
581 | | ||||
582 | void EffectFilterModel::defaults() | | |||
583 | { | | |||
584 | m_effectModel->defaults(); | | |||
585 | } | | |||
586 | | ||||
587 | EffectView::EffectView(ViewType type, QWidget *parent) | | |||
588 | : QQuickWidget(parent) | | |||
589 | { | | |||
590 | qRegisterMetaType<OpenGLPlatformInterfaceModel*>(); | | |||
591 | qmlRegisterType<EffectConfig>("org.kde.kwin.kwincompositing", 1, 0, "EffectConfig"); | | |||
592 | qmlRegisterType<EffectFilterModel>("org.kde.kwin.kwincompositing", 1, 0, "EffectFilterModel"); | | |||
593 | qmlRegisterType<Compositing>("org.kde.kwin.kwincompositing", 1, 0, "Compositing"); | | |||
594 | qmlRegisterType<CompositingType>("org.kde.kwin.kwincompositing", 1, 0, "CompositingType"); | | |||
595 | init(type); | | |||
596 | } | | |||
597 | | ||||
598 | void EffectView::init(ViewType type) | | |||
599 | { | | |||
600 | KDeclarative::KDeclarative kdeclarative; | | |||
601 | kdeclarative.setDeclarativeEngine(engine()); | | |||
602 | kdeclarative.setTranslationDomain(QStringLiteral(TRANSLATION_DOMAIN)); | | |||
603 | kdeclarative.setupContext(); | | |||
604 | kdeclarative.setupEngine(engine()); | | |||
605 | QString path; | | |||
606 | switch (type) { | | |||
607 | case CompositingSettingsView: | | |||
608 | path = QStringLiteral("kwincompositing/qml/main-compositing.qml"); | | |||
609 | break; | | |||
610 | case DesktopEffectsView: | | |||
611 | path = QStringLiteral("kwincompositing/qml/main.qml"); | | |||
612 | break; | | |||
613 | } | | |||
614 | QString mainFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, path, QStandardPaths::LocateFile); | | |||
615 | setResizeMode(QQuickWidget::SizeRootObjectToView); | | |||
616 | setSource(QUrl(mainFile)); | | |||
617 | rootObject()->setProperty("color", | | |||
618 | KColorScheme(QPalette::Active, KColorScheme::Window, KSharedConfigPtr(0)).background(KColorScheme::NormalBackground).color()); | | |||
619 | connect(rootObject(), SIGNAL(changed()), this, SIGNAL(changed())); | | |||
620 | setMinimumSize(initialSize()); | | |||
621 | connect(rootObject(), SIGNAL(implicitWidthChanged()), this, SLOT(slotImplicitSizeChanged())); | | |||
622 | connect(rootObject(), SIGNAL(implicitHeightChanged()), this, SLOT(slotImplicitSizeChanged())); | | |||
623 | } | | |||
624 | | ||||
625 | void EffectView::save() | | |||
626 | { | | |||
627 | if (auto *model = rootObject()->findChild<EffectFilterModel*>(QStringLiteral("filterModel"))) { | | |||
628 | model->syncConfig(); | | |||
629 | } | | |||
630 | if (auto *compositing = rootObject()->findChild<Compositing*>(QStringLiteral("compositing"))) { | | |||
631 | compositing->save(); | | |||
632 | } | | |||
633 | } | | |||
634 | | ||||
635 | void EffectView::load() | | |||
636 | { | | |||
637 | if (auto *model = rootObject()->findChild<EffectFilterModel*>(QStringLiteral("filterModel"))) { | | |||
638 | model->load(); | | |||
639 | } | | |||
640 | if (auto *compositing = rootObject()->findChild<Compositing*>(QStringLiteral("compositing"))) { | | |||
641 | compositing->reset(); | | |||
642 | } | | |||
643 | } | | |||
644 | | ||||
645 | void EffectView::defaults() | | |||
646 | { | | |||
647 | if (auto *model = rootObject()->findChild<EffectFilterModel*>(QStringLiteral("filterModel"))) { | | |||
648 | model->defaults(); | | |||
649 | } | | |||
650 | if (auto *compositing = rootObject()->findChild<Compositing*>(QStringLiteral("compositing"))) { | | |||
651 | compositing->defaults(); | | |||
652 | } | | |||
653 | } | | |||
654 | | ||||
655 | void EffectView::slotImplicitSizeChanged() | | |||
656 | { | | |||
657 | setMinimumSize(QSize(rootObject()->property("implicitWidth").toInt(), | | |||
658 | rootObject()->property("implicitHeight").toInt())); | | |||
659 | } | | |||
660 | | ||||
661 | }//end namespace Compositing | | |||
662 | }//end namespace KWin | |