File indexing completed on 2024-04-21 05:27:34
0001 /* 0002 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 #include "wallpaper_integration.h" 0007 0008 #include <KConfig> 0009 #include <KConfigGroup> 0010 #include <KConfigLoader> 0011 #include <KPackage/PackageLoader> 0012 0013 #include <QFile> 0014 0015 namespace ScreenLocker 0016 { 0017 WallpaperIntegration::WallpaperIntegration(QQuickItem *parent) 0018 : QQuickItem(parent) 0019 , m_package(KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/Wallpaper"))) 0020 { 0021 qRegisterMetaType<KConfigPropertyMap *>(); 0022 } 0023 0024 WallpaperIntegration::~WallpaperIntegration() = default; 0025 0026 void WallpaperIntegration::init() 0027 { 0028 if (!m_package.isValid()) { 0029 return; 0030 } 0031 if (auto config = configScheme()) { 0032 m_configuration = new KConfigPropertyMap(config, this); 0033 // potd (picture of the day) is using a kded to monitor changes and 0034 // cache data for the lockscreen. Let's notify it. 0035 m_configuration->setNotify(true); 0036 } 0037 } 0038 0039 void WallpaperIntegration::setPluginName(const QString &name) 0040 { 0041 if (m_pluginName == name) { 0042 return; 0043 } 0044 m_pluginName = name; 0045 m_package.setPath(name); 0046 Q_EMIT packageChanged(); 0047 } 0048 0049 KConfigLoader *WallpaperIntegration::configScheme() 0050 { 0051 if (!m_configLoader) { 0052 const QString xmlPath = m_package.filePath(QByteArrayLiteral("config"), QStringLiteral("main.xml")); 0053 0054 const KConfigGroup cfg = m_config->group("Greeter").group("Wallpaper").group(m_pluginName); 0055 0056 if (xmlPath.isEmpty()) { 0057 m_configLoader = new KConfigLoader(cfg, nullptr, this); 0058 } else { 0059 QFile file(xmlPath); 0060 m_configLoader = new KConfigLoader(cfg, &file, this); 0061 } 0062 } 0063 return m_configLoader; 0064 } 0065 0066 QColor WallpaperIntegration::accentColor() const 0067 { 0068 return QColor(); 0069 } 0070 0071 void WallpaperIntegration::setAccentColor(const QColor &) 0072 { 0073 } 0074 } 0075 0076 #include "moc_wallpaper_integration.cpp"