File indexing completed on 2024-11-10 04:56:51
0001 /* 0002 SPDX-FileCopyrightText: 2020 Cyril Rossi <cyril.rossi@enioka.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kwinscriptsdata.h" 0008 0009 #include <KConfigGroup> 0010 #include <KPackage/Package> 0011 #include <KPackage/PackageLoader> 0012 #include <KPackage/PackageStructure> 0013 #include <KPluginFactory> 0014 0015 KWinScriptsData::KWinScriptsData(QObject *parent) 0016 : KCModuleData(parent) 0017 , m_kwinConfig(KSharedConfig::openConfig("kwinrc")) 0018 { 0019 } 0020 0021 QList<KPluginMetaData> KWinScriptsData::pluginMetaDataList() const 0022 { 0023 const QString scriptFolder = QStringLiteral("kwin/scripts/"); 0024 return KPackage::PackageLoader::self()->findPackages(QStringLiteral("KWin/Script"), scriptFolder); 0025 } 0026 0027 bool KWinScriptsData::isDefaults() const 0028 { 0029 QList<KPluginMetaData> plugins = pluginMetaDataList(); 0030 KConfigGroup cfgGroup(m_kwinConfig, QStringLiteral("Plugins")); 0031 for (auto &plugin : plugins) { 0032 if (cfgGroup.readEntry(plugin.pluginId() + QLatin1String("Enabled"), plugin.isEnabledByDefault()) != plugin.isEnabledByDefault()) { 0033 return false; 0034 } 0035 } 0036 0037 return true; 0038 } 0039 0040 #include "moc_kwinscriptsdata.cpp"