Warning, file /plasma/kscreenlocker/kcm/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: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 SPDX-FileCopyrightText: 2019 Kevin Ottens <kevin.ottens@enioka.com> 0004 SPDX-FileCopyrightText: 2020 David Redondo <kde@david-redondo.de> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 #include "kcm.h" 0009 #include "appearancesettings.h" 0010 #include "kscreenlockerdata.h" 0011 #include "lnf_integration.h" 0012 #include "screenlocker_interface.h" 0013 0014 #include <KAboutData> 0015 #include <KConfigLoader> 0016 #include <KConfigPropertyMap> 0017 #include <KGlobalAccel> 0018 #include <KLocalizedString> 0019 #include <KPluginFactory> 0020 0021 #include <KPackage/PackageLoader> 0022 0023 #include <QVector> 0024 0025 K_PLUGIN_FACTORY_WITH_JSON(ScreenLockerKcmFactory, "kcm_screenlocker.json", registerPlugin<ScreenLockerKcm>(); registerPlugin<KScreenLockerData>();) 0026 0027 ScreenLockerKcm::ScreenLockerKcm(QObject *parent, const KPluginMetaData &data, const QVariantList &args) 0028 : KQuickAddons::ManagedConfigModule(parent, data, args) 0029 , m_appearanceSettings(new AppearanceSettings(this)) 0030 { 0031 registerSettings(&KScreenSaverSettings::getInstance()); 0032 0033 constexpr const char *url = "org.kde.private.kcms.screenlocker"; 0034 qRegisterMetaType<QVector<WallpaperInfo>>("QVector<WallpaperInfo>"); 0035 qmlRegisterAnonymousType<KScreenSaverSettings>(url, 1); 0036 qmlRegisterAnonymousType<WallpaperInfo>(url, 1); 0037 qmlRegisterAnonymousType<ScreenLocker::WallpaperIntegration>(url, 1); 0038 qmlRegisterAnonymousType<KConfigPropertyMap>(url, 1); 0039 qmlProtectModule(url, 1); 0040 0041 // Our modules will be checking the Plasmoid attached object when running from Plasma, let it load the module 0042 constexpr const char *uri = "org.kde.plasma.plasmoid"; 0043 qmlRegisterUncreatableType<QObject>(uri, 2, 0, "PlasmoidPlaceholder", QStringLiteral("Do not create objects of type Plasmoid")); 0044 0045 connect(&KScreenSaverSettings::getInstance(), 0046 &KScreenSaverSettings::wallpaperPluginIdChanged, 0047 m_appearanceSettings, 0048 &AppearanceSettings::loadWallpaperConfig); 0049 connect(m_appearanceSettings, &AppearanceSettings::currentWallpaperChanged, this, &ScreenLockerKcm::currentWallpaperChanged); 0050 } 0051 0052 void ScreenLockerKcm::load() 0053 { 0054 ManagedConfigModule::load(); 0055 m_appearanceSettings->load(); 0056 0057 updateState(); 0058 } 0059 0060 void ScreenLockerKcm::save() 0061 { 0062 ManagedConfigModule::save(); 0063 m_appearanceSettings->save(); 0064 0065 // reconfigure through DBus 0066 OrgKdeScreensaverInterface interface(QStringLiteral("org.kde.screensaver"), QStringLiteral("/ScreenSaver"), QDBusConnection::sessionBus()); 0067 if (interface.isValid()) { 0068 interface.configure(); 0069 } 0070 updateState(); 0071 } 0072 0073 void ScreenLockerKcm::defaults() 0074 { 0075 ManagedConfigModule::defaults(); 0076 m_appearanceSettings->defaults(); 0077 0078 updateState(); 0079 } 0080 0081 void ScreenLockerKcm::updateState() 0082 { 0083 m_forceUpdateState = false; 0084 settingsChanged(); 0085 Q_EMIT isDefaultsAppearanceChanged(); 0086 } 0087 0088 void ScreenLockerKcm::forceUpdateState() 0089 { 0090 m_forceUpdateState = true; 0091 settingsChanged(); 0092 Q_EMIT isDefaultsAppearanceChanged(); 0093 } 0094 0095 bool ScreenLockerKcm::isSaveNeeded() const 0096 { 0097 return m_forceUpdateState || m_appearanceSettings->isSaveNeeded(); 0098 } 0099 0100 bool ScreenLockerKcm::isDefaults() const 0101 { 0102 return m_appearanceSettings->isDefaults(); 0103 } 0104 0105 KConfigPropertyMap *ScreenLockerKcm::wallpaperConfiguration() const 0106 { 0107 return m_appearanceSettings->wallpaperConfiguration(); 0108 } 0109 0110 KConfigPropertyMap *ScreenLockerKcm::lnfConfiguration() const 0111 { 0112 return m_appearanceSettings->lnfConfiguration(); 0113 } 0114 0115 KScreenSaverSettings *ScreenLockerKcm::settings() const 0116 { 0117 return &KScreenSaverSettings::getInstance(); 0118 } 0119 0120 QString ScreenLockerKcm::currentWallpaper() const 0121 { 0122 return KScreenSaverSettings::getInstance().wallpaperPluginId(); 0123 } 0124 0125 bool ScreenLockerKcm::isDefaultsAppearance() const 0126 { 0127 return m_appearanceSettings->isDefaults(); 0128 } 0129 0130 QUrl ScreenLockerKcm::lnfConfigFile() const 0131 { 0132 return m_appearanceSettings->lnfConfigFile(); 0133 } 0134 0135 QUrl ScreenLockerKcm::wallpaperConfigFile() const 0136 { 0137 return m_appearanceSettings->wallpaperConfigFile(); 0138 } 0139 0140 ScreenLocker::WallpaperIntegration *ScreenLockerKcm::wallpaperIntegration() const 0141 { 0142 return m_appearanceSettings->wallpaperIntegration(); 0143 } 0144 0145 #include "kcm.moc"