KWin
Loading...
Searching...
No Matches
kcm.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "kcm.h"
10#include "effectsmodel.h"
11
12#include <KLocalizedString>
13#include <KPluginFactory>
14
15#include <QQuickWindow>
16#include <QWindow>
17
18K_PLUGIN_FACTORY_WITH_JSON(DesktopEffectsKCMFactory,
19 "kcm_kwin_effects.json",
20 registerPlugin<KWin::DesktopEffectsKCM>();
21 registerPlugin<KWin::DesktopEffectsData>();)
22
23namespace KWin
24{
25
26DesktopEffectsKCM::DesktopEffectsKCM(QObject *parent, const KPluginMetaData &metaData)
27 : KQuickConfigModule(parent, metaData)
28 , m_model(new EffectsModel(this))
29{
30 qmlRegisterType<EffectsFilterProxyModel>("org.kde.private.kcms.kwin.effects", 1, 0, "EffectsFilterProxyModel");
31
32 setButtons(Apply | Default | Help);
33
34 connect(m_model, &EffectsModel::dataChanged, this, &DesktopEffectsKCM::updateNeedsSave);
35 connect(m_model, &EffectsModel::loaded, this, &DesktopEffectsKCM::updateNeedsSave);
36}
37
38DesktopEffectsKCM::~DesktopEffectsKCM()
39{
40}
41
42QAbstractItemModel *DesktopEffectsKCM::effectsModel() const
43{
44 return m_model;
45}
46
47void DesktopEffectsKCM::load()
48{
49 m_model->load();
50 setNeedsSave(false);
51}
52
53void DesktopEffectsKCM::save()
54{
55 m_model->save();
56 setNeedsSave(false);
57}
58
59void DesktopEffectsKCM::defaults()
60{
61 m_model->defaults();
62 updateNeedsSave();
63}
64
65void DesktopEffectsKCM::onGHNSEntriesChanged()
66{
67 m_model->load(EffectsModel::LoadOptions::KeepDirty);
68}
69
70void DesktopEffectsKCM::configure(const QString &pluginId, QQuickItem *context)
71{
72 const QModelIndex index = m_model->findByPluginId(pluginId);
73
74 QWindow *transientParent = nullptr;
75 if (context && context->window()) {
76 transientParent = context->window();
77 }
78
79 m_model->requestConfigure(index, transientParent);
80}
81
82void DesktopEffectsKCM::updateNeedsSave()
83{
84 setNeedsSave(m_model->needsSave());
85 setRepresentsDefaults(m_model->isDefaults());
86}
87
88} // namespace KWin
89
90#include "kcm.moc"
91
92#include "moc_kcm.cpp"
K_PLUGIN_FACTORY_WITH_JSON(KCMKWinDecorationFactory, "kcm_kwindecoration.json", registerPlugin< KCMKWinDecoration >();registerPlugin< KWinDecorationData >();) namespace
Definition kcm.cpp:29