File indexing completed on 2024-04-28 13:21:10

0001 /*
0002 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
0003 SPDX-FileCopyrightText: 2017 David Edmundson <davidedmundson@kde.org>
0004 
0005 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 #include "lnf_integration.h"
0008 
0009 #include <KConfig>
0010 #include <KConfigGroup>
0011 #include <KConfigLoader>
0012 
0013 #include <QFile>
0014 
0015 namespace ScreenLocker
0016 {
0017 LnFIntegration::LnFIntegration(QObject *parent)
0018     : QObject(parent)
0019 {
0020     qRegisterMetaType<KConfigPropertyMap *>();
0021 }
0022 
0023 LnFIntegration::~LnFIntegration() = default;
0024 
0025 void LnFIntegration::init()
0026 {
0027     if (!m_package.isValid()) {
0028         return;
0029     }
0030     if (auto config = configScheme()) {
0031         m_configuration = new KConfigPropertyMap(config, this);
0032     }
0033 }
0034 
0035 KConfigLoader *LnFIntegration::configScheme()
0036 {
0037     if (!m_configLoader) {
0038         const QString xmlPath = m_package.filePath(QByteArrayLiteral("lockscreen"), QStringLiteral("config.xml"));
0039 
0040         const KConfigGroup cfg = m_config->group("Greeter").group("LnF");
0041 
0042         if (xmlPath.isEmpty()) {
0043             m_configLoader = new KConfigLoader(cfg, nullptr, this);
0044         } else {
0045             QFile file(xmlPath);
0046             m_configLoader = new KConfigLoader(cfg, &file, this);
0047         }
0048     }
0049     return m_configLoader;
0050 }
0051 
0052 }