Warning, file /plasma/kwin/src/kcms/effects/kcm.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kcm.h" 0008 #include "desktopeffectsdata.h" 0009 #include "effectsfilterproxymodel.h" 0010 #include "effectsmodel.h" 0011 0012 #include <KAboutData> 0013 #include <KLocalizedString> 0014 #include <KPluginFactory> 0015 0016 #include <QQuickWindow> 0017 #include <QWindow> 0018 0019 K_PLUGIN_FACTORY_WITH_JSON(DesktopEffectsKCMFactory, 0020 "kcm_kwin_effects.json", 0021 registerPlugin<KWin::DesktopEffectsKCM>(); 0022 registerPlugin<KWin::DesktopEffectsData>();) 0023 0024 namespace KWin 0025 { 0026 0027 DesktopEffectsKCM::DesktopEffectsKCM(QObject *parent, const QVariantList &args) 0028 : KQuickAddons::ConfigModule(parent, args) 0029 , m_model(new EffectsModel(this)) 0030 { 0031 qmlRegisterType<EffectsFilterProxyModel>("org.kde.private.kcms.kwin.effects", 1, 0, "EffectsFilterProxyModel"); 0032 0033 auto about = new KAboutData( 0034 QStringLiteral("kcm_kwin_effects"), 0035 i18n("Desktop Effects"), 0036 QStringLiteral("2.0"), 0037 QString(), 0038 KAboutLicense::GPL); 0039 about->addAuthor(i18n("Vlad Zahorodnii"), QString(), QStringLiteral("vlad.zahorodnii@kde.org")); 0040 setAboutData(about); 0041 0042 setButtons(Apply | Default | Help); 0043 0044 connect(m_model, &EffectsModel::dataChanged, this, &DesktopEffectsKCM::updateNeedsSave); 0045 connect(m_model, &EffectsModel::loaded, this, &DesktopEffectsKCM::updateNeedsSave); 0046 } 0047 0048 DesktopEffectsKCM::~DesktopEffectsKCM() 0049 { 0050 } 0051 0052 QAbstractItemModel *DesktopEffectsKCM::effectsModel() const 0053 { 0054 return m_model; 0055 } 0056 0057 void DesktopEffectsKCM::load() 0058 { 0059 m_model->load(); 0060 setNeedsSave(false); 0061 } 0062 0063 void DesktopEffectsKCM::save() 0064 { 0065 m_model->save(); 0066 setNeedsSave(false); 0067 } 0068 0069 void DesktopEffectsKCM::defaults() 0070 { 0071 m_model->defaults(); 0072 updateNeedsSave(); 0073 } 0074 0075 void DesktopEffectsKCM::onGHNSEntriesChanged() 0076 { 0077 m_model->load(EffectsModel::LoadOptions::KeepDirty); 0078 } 0079 0080 void DesktopEffectsKCM::configure(const QString &pluginId, QQuickItem *context) 0081 { 0082 const QModelIndex index = m_model->findByPluginId(pluginId); 0083 0084 QWindow *transientParent = nullptr; 0085 if (context && context->window()) { 0086 transientParent = context->window(); 0087 } 0088 0089 m_model->requestConfigure(index, transientParent); 0090 } 0091 0092 void DesktopEffectsKCM::updateNeedsSave() 0093 { 0094 setNeedsSave(m_model->needsSave()); 0095 setRepresentsDefaults(m_model->isDefaults()); 0096 } 0097 0098 } // namespace KWin 0099 0100 #include "kcm.moc"