1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
/*
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "wallpaper_integration.h"
#include <KConfig>
#include <KConfigGroup>
#include <KConfigLoader>
#include <KPackage/PackageLoader>
#include <QFile>
namespace ScreenLocker
{
WallpaperIntegration::WallpaperIntegration(QQuickItem *parent)
: QQuickItem(parent)
, m_package(KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/Wallpaper")))
{
qRegisterMetaType<KConfigPropertyMap *>();
}
WallpaperIntegration::~WallpaperIntegration() = default;
void WallpaperIntegration::init()
{
if (!m_package.isValid()) {
return;
}
if (auto config = configScheme()) {
m_configuration = new KConfigPropertyMap(config, this);
// potd (picture of the day) is using a kded to monitor changes and
// cache data for the lockscreen. Let's notify it.
m_configuration->setNotify(true);
}
}
void WallpaperIntegration::setPluginName(const QString &name)
{
if (m_pluginName == name) {
return;
}
m_pluginName = name;
m_package.setPath(name);
Q_EMIT packageChanged();
}
KConfigLoader *WallpaperIntegration::configScheme()
{
if (!m_configLoader) {
const QString xmlPath = m_package.filePath(QByteArrayLiteral("config"), QStringLiteral("main.xml"));
const KConfigGroup cfg = m_config->group(QStringLiteral("Greeter")).group(QStringLiteral("Wallpaper")).group(m_pluginName);
if (xmlPath.isEmpty()) {
m_configLoader = new KConfigLoader(cfg, nullptr, this);
} else {
QFile file(xmlPath);
m_configLoader = new KConfigLoader(cfg, &file, this);
}
}
return m_configLoader;
}
QColor WallpaperIntegration::accentColor() const
{
return QColor();
}
void WallpaperIntegration::setAccentColor(const QColor &)
{
}
}
#include "moc_wallpaper_integration.cpp"
|