File indexing completed on 2024-11-10 04:56:49
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 <KLocalizedString> 0013 #include <KPluginFactory> 0014 0015 #include <QQuickWindow> 0016 #include <QWindow> 0017 0018 K_PLUGIN_FACTORY_WITH_JSON(DesktopEffectsKCMFactory, 0019 "kcm_kwin_effects.json", 0020 registerPlugin<KWin::DesktopEffectsKCM>(); 0021 registerPlugin<KWin::DesktopEffectsData>();) 0022 0023 namespace KWin 0024 { 0025 0026 DesktopEffectsKCM::DesktopEffectsKCM(QObject *parent, const KPluginMetaData &metaData) 0027 : KQuickConfigModule(parent, metaData) 0028 , m_model(new EffectsModel(this)) 0029 { 0030 qmlRegisterType<EffectsFilterProxyModel>("org.kde.private.kcms.kwin.effects", 1, 0, "EffectsFilterProxyModel"); 0031 0032 setButtons(Apply | Default | Help); 0033 0034 connect(m_model, &EffectsModel::dataChanged, this, &DesktopEffectsKCM::updateNeedsSave); 0035 connect(m_model, &EffectsModel::loaded, this, &DesktopEffectsKCM::updateNeedsSave); 0036 } 0037 0038 DesktopEffectsKCM::~DesktopEffectsKCM() 0039 { 0040 } 0041 0042 QAbstractItemModel *DesktopEffectsKCM::effectsModel() const 0043 { 0044 return m_model; 0045 } 0046 0047 void DesktopEffectsKCM::load() 0048 { 0049 m_model->load(); 0050 setNeedsSave(false); 0051 } 0052 0053 void DesktopEffectsKCM::save() 0054 { 0055 m_model->save(); 0056 setNeedsSave(false); 0057 } 0058 0059 void DesktopEffectsKCM::defaults() 0060 { 0061 m_model->defaults(); 0062 updateNeedsSave(); 0063 } 0064 0065 void DesktopEffectsKCM::onGHNSEntriesChanged() 0066 { 0067 m_model->load(EffectsModel::LoadOptions::KeepDirty); 0068 } 0069 0070 void DesktopEffectsKCM::configure(const QString &pluginId, QQuickItem *context) 0071 { 0072 const QModelIndex index = m_model->findByPluginId(pluginId); 0073 0074 QWindow *transientParent = nullptr; 0075 if (context && context->window()) { 0076 transientParent = context->window(); 0077 } 0078 0079 m_model->requestConfigure(index, transientParent); 0080 } 0081 0082 void DesktopEffectsKCM::updateNeedsSave() 0083 { 0084 setNeedsSave(m_model->needsSave()); 0085 setRepresentsDefaults(m_model->isDefaults()); 0086 } 0087 0088 } // namespace KWin 0089 0090 #include "kcm.moc" 0091 0092 #include "moc_kcm.cpp"