diff --git a/greeter/CMakeLists.txt b/greeter/CMakeLists.txt --- a/greeter/CMakeLists.txt +++ b/greeter/CMakeLists.txt @@ -12,6 +12,7 @@ greeterapp.cpp main.cpp noaccessnetworkaccessmanagerfactory.cpp + lnf_integration.cpp wallpaper_integration.cpp kwinglplatform.cpp ) diff --git a/greeter/greeterapp.h b/greeter/greeterapp.h --- a/greeter/greeterapp.h +++ b/greeter/greeterapp.h @@ -45,6 +45,7 @@ { class Unlocker; class WallpaperIntegration; +class LnFIntegration; class UnlockApp : public QGuiApplication { @@ -117,6 +118,8 @@ KWayland::Client::PlasmaShell *m_plasmaShell = nullptr; WallpaperIntegration *m_wallpaperIntegration; + LnFIntegration *m_lnfIntegration; + bool m_supportsSeccomp = false; }; } // namespace diff --git a/greeter/greeterapp.cpp b/greeter/greeterapp.cpp --- a/greeter/greeterapp.cpp +++ b/greeter/greeterapp.cpp @@ -23,14 +23,18 @@ #include "authenticator.h" #include "noaccessnetworkaccessmanagerfactory.h" #include "wallpaper_integration.h" +#include "lnf_integration.h" + #include // KDE #include #include #include #include #include +#include + #include //Plasma #include @@ -108,6 +112,7 @@ , m_noLock(false) , m_defaultToSwitchUser(false) , m_wallpaperIntegration(new WallpaperIntegration(this)) + , m_lnfIntegration(new LnFIntegration(this)) { m_authenticator = createAuthenticator(); connect(m_authenticator, &Authenticator::succeeded, this, &QCoreApplication::quit); @@ -186,6 +191,11 @@ m_wallpaperIntegration->setPluginName(KScreenSaverSettings::self()->wallpaperPlugin()); m_wallpaperIntegration->init(); + m_lnfIntegration->setPackage(package); + m_lnfIntegration->setConfig(KScreenSaverSettings::self()->sharedConfig()); + m_lnfIntegration->init(); + + installEventFilter(this); } @@ -295,7 +305,7 @@ context->setContextProperty(QStringLiteral("org_kde_plasma_screenlocker_greeter_interfaceVersion"), 2); context->setContextProperty(QStringLiteral("org_kde_plasma_screenlocker_greeter_view"), view); context->setContextProperty(QStringLiteral("defaultToSwitchUser"), m_defaultToSwitchUser); - + context->setContextProperty(QStringLiteral("config"), m_lnfIntegration->configuration()); view->setSource(m_mainQmlPath); // on error, load the fallback lockscreen to not lock the user out of the system diff --git a/greeter/lnf_integration.h b/greeter/lnf_integration.h new file mode 100644 --- /dev/null +++ b/greeter/lnf_integration.h @@ -0,0 +1,83 @@ +/******************************************************************** + KSld - the KDE Screenlocker Daemon + This file is part of the KDE project. + +Copyright (C) 2016 Martin Gräßlin +Copyright (C) 2017 David Edmundson + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of +the License or (at your option) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +#ifndef KSCREENLOCKER_LNF_INTEGRATION_H +#define KSCREENLOCKER_LNF_INTEGRATION_H + +#include +#include + +class KConfigLoader; + +namespace KDeclarative +{ +class ConfigPropertyMap; +class QmlObject; +} + +namespace ScreenLocker +{ + +class LnFIntegration : public QObject +{ + Q_OBJECT + + Q_PROPERTY(KDeclarative::ConfigPropertyMap *configuration READ configuration NOTIFY configurationChanged) + +public: + LnFIntegration(QObject *parent); + virtual ~LnFIntegration(); + + void init(); + + void setConfig(const KSharedConfig::Ptr &config) { + m_config = config; + } + + void setPackage(const KPackage::Package &package) { + m_package = package; + } + + KPackage::Package package() const { + return m_package; + } + + KDeclarative::ConfigPropertyMap *configuration() const { + return m_configuration; + } + +Q_SIGNALS: + void packageChanged(); + void configurationChanged(); + +private: + KConfigLoader *configScheme(); + KPackage::Package m_package; + KSharedConfig::Ptr m_config; + KConfigLoader *m_configLoader = nullptr; + KDeclarative::ConfigPropertyMap *m_configuration = nullptr; +}; + +} + +#endif diff --git a/greeter/lnf_integration.cpp b/greeter/lnf_integration.cpp new file mode 100644 --- /dev/null +++ b/greeter/lnf_integration.cpp @@ -0,0 +1,74 @@ +/******************************************************************** + KSld - the KDE Screenlocker Daemon + This file is part of the KDE project. + +Copyright (C) 2016 Martin Gräßlin +Copyright (C) 2017 David Edmundson + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of +the License or (at your option) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +#include "lnf_integration.h" + +#include +#include +#include +#include +#include + +#include +#include + +namespace ScreenLocker +{ + +LnFIntegration::LnFIntegration(QObject *parent) + : QObject(parent) +{ + qRegisterMetaType(); +} + +LnFIntegration::~LnFIntegration() = default; + +void LnFIntegration::init() +{ + if (!m_package.isValid()) { + return; + } + if (auto config = configScheme()) { + m_configuration = new KDeclarative::ConfigPropertyMap(config, this); + } +} + + +KConfigLoader *LnFIntegration::configScheme() +{ + if (!m_configLoader) { + const QString xmlPath = m_package.filePath(QByteArrayLiteral("lockscreen"), QStringLiteral("config.xml")); + + const KConfigGroup cfg = m_config->group("Greeter").group("LnF"); + + if (xmlPath.isEmpty()) { + m_configLoader = new KConfigLoader(cfg, 0, this); + } else { + QFile file(xmlPath); + m_configLoader = new KConfigLoader(cfg, &file, this); + } + } + return m_configLoader; +} + +} diff --git a/kcm/CMakeLists.txt b/kcm/CMakeLists.txt --- a/kcm/CMakeLists.txt +++ b/kcm/CMakeLists.txt @@ -4,6 +4,7 @@ set(screenlocker_kcm_SRCS kcm.cpp ../greeter/wallpaper_integration.cpp + ../greeter/lnf_integration.cpp ) include_directories(${CMAKE_CURRENT_BINARY_DIR}/../) diff --git a/kcm/kcm.h b/kcm/kcm.h --- a/kcm/kcm.h +++ b/kcm/kcm.h @@ -30,6 +30,7 @@ namespace ScreenLocker { class WallpaperIntegration; +class LnFIntegration; } namespace KDeclarative @@ -49,6 +50,8 @@ explicit ScreenLockerKcm(QWidget *parent = nullptr, const QVariantList& args = QVariantList()); KDeclarative::ConfigPropertyMap *wallpaperConfiguration() const; + KDeclarative::ConfigPropertyMap *lnfConfiguration() const; + QString currentWallpaper() const; bool eventFilter(QObject *watched, QEvent *event) override; @@ -69,17 +72,21 @@ void loadWallpapers(); void selectWallpaper(const QString &pluginId); void loadWallpaperConfig(); + void loadLnfConfig(); KPackage::Package m_package; KActionCollection *m_actionCollection; ScreenLockerKcmForm *m_ui; ScreenLocker::WallpaperIntegration *m_wallpaperIntegration = nullptr; + ScreenLocker::LnFIntegration* m_lnfIntegration = nullptr; }; //see https://bugreports.qt.io/browse/QTBUG-57714, don't expose a QWidget as a context property class ScreenLockerProxy : public QObject { Q_OBJECT Q_PROPERTY(KDeclarative::ConfigPropertyMap *wallpaperConfiguration READ wallpaperConfiguration NOTIFY wallpaperConfigurationChanged) + Q_PROPERTY(KDeclarative::ConfigPropertyMap *lnfConfiguration READ lnfConfiguration CONSTANT) + Q_PROPERTY(QString currentWallpaper READ currentWallpaper NOTIFY currentWallpaperChanged) public: ScreenLockerProxy(ScreenLockerKcm *parent) : @@ -91,6 +98,9 @@ KDeclarative::ConfigPropertyMap *wallpaperConfiguration() const { return q->wallpaperConfiguration(); } + KDeclarative::ConfigPropertyMap *lnfConfiguration() const { + return q->lnfConfiguration(); + } QString currentWallpaper() const { return q->currentWallpaper(); diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -22,6 +22,8 @@ #include "ui_kcm.h" #include "screenlocker_interface.h" #include "../greeter/wallpaper_integration.h" +#include "../greeter/lnf_integration.h" + #include #include #include @@ -84,16 +86,24 @@ m_ui->wallpaperCombo->installEventFilter(this); - m_ui->wallpaperConfigWidget->setClearColor(m_ui->palette().color(QPalette::Active, QPalette::Window)); auto proxy = new ScreenLockerProxy(this); + m_ui->wallpaperConfigWidget->setClearColor(m_ui->palette().color(QPalette::Active, QPalette::Window)); m_ui->wallpaperConfigWidget->rootContext()->setContextProperty("configDialog", proxy); + m_ui->lnfConfigWidget->setClearColor(m_ui->palette().color(QPalette::Active, QPalette::Window)); + m_ui->lnfConfigWidget->rootContext()->setContextProperty("configDialog", proxy); + + + connect(this, &ScreenLockerKcm::wallpaperConfigurationChanged, proxy, &ScreenLockerProxy::wallpaperConfigurationChanged); connect(this, &ScreenLockerKcm::currentWallpaperChanged, proxy, &ScreenLockerProxy::currentWallpaperChanged); - m_ui->wallpaperConfigWidget->setSource(QUrl(QStringLiteral("qrc:/kscreenlocker-kcm-resources/config.qml"))); + m_ui->wallpaperConfigWidget->setSource(QUrl(QStringLiteral("qrc:/kscreenlocker-kcm-resources/wallpaperconfig.qml"))); connect(m_ui->wallpaperConfigWidget->rootObject(), SIGNAL(configurationChanged()), this, SLOT(changed())); + m_ui->lnfConfigWidget->setSource(QUrl(QStringLiteral("qrc:/kscreenlocker-kcm-resources/lnfconfig.qml"))); + connect(m_ui->lnfConfigWidget->rootObject(), SIGNAL(configurationChanged()), this, SLOT(changed())); + m_ui->installEventFilter(this); } @@ -123,9 +133,15 @@ m_ui->lockscreenShortcut->setKeySequence(shortcuts.first()); } } + m_lnfIntegration = new ScreenLocker::LnFIntegration(this); + m_lnfIntegration->setPackage(m_package); + m_lnfIntegration->setConfig(KScreenSaverSettings::self()->sharedConfig()); + m_lnfIntegration->init(); + selectWallpaper(KScreenSaverSettings::self()->wallpaperPlugin()); loadWallpaperConfig(); + loadLnfConfig(); } void ScreenLockerKcm::test(const QString &plugin) @@ -150,6 +166,7 @@ } KCModule::save(); QMetaObject::invokeMethod(m_ui->wallpaperConfigWidget->rootObject(), "saveConfig"); + QMetaObject::invokeMethod(m_ui->lnfConfigWidget->rootObject(), "saveConfig"); // set the wallpaper config KScreenSaverSettings::self()->setWallpaperPlugin(m_ui->wallpaperCombo->currentData().toString()); @@ -235,14 +252,33 @@ m_ui->wallpaperConfigWidget->rootObject()->setProperty("sourceFile", m_wallpaperIntegration->package().filePath(QByteArrayLiteral("ui"), QStringLiteral("config.qml"))); } +void ScreenLockerKcm::loadLnfConfig() +{ + auto sourceFile = m_package.fileUrl(QByteArrayLiteral("lockscreen"), QStringLiteral("config.qml")); + if (sourceFile.isEmpty()) { + m_ui->lnfConfigWidget->hide(); + return; + } + m_ui->lnfConfigWidget->rootObject()->setProperty("sourceFile", sourceFile); +} + KDeclarative::ConfigPropertyMap * ScreenLockerKcm::wallpaperConfiguration() const { if (!m_wallpaperIntegration) { return nullptr; } return m_wallpaperIntegration->configuration(); } +KDeclarative::ConfigPropertyMap * ScreenLockerKcm::lnfConfiguration() const +{ + if (!m_lnfIntegration) { + return nullptr; + } + return m_lnfIntegration->configuration(); +} + + QString ScreenLockerKcm::currentWallpaper() const { return m_ui->wallpaperCombo->currentData().toString(); @@ -264,6 +300,11 @@ // QtQuick Layouts have a hardcoded 5 px spacing by default object->setProperty("formAlignment", m_ui->wallpaperCombo->x() + 5); } + if (auto object = m_ui->lnfConfigWidget->rootObject()) { + // QtQuick Layouts have a hardcoded 5 px spacing by default + object->setProperty("formAlignment", m_ui->wallpaperCombo->x() + 5); + } + } return false; } diff --git a/kcm/kcm.ui b/kcm/kcm.ui --- a/kcm/kcm.ui +++ b/kcm/kcm.ui @@ -120,7 +120,7 @@ - + @@ -138,9 +138,28 @@ - Wallpaper + Appearance + + + + + 0 + 0 + + + + + 0 + 0 + + + + QQuickWidget::SizeRootObjectToView + + + @@ -151,7 +170,7 @@ Qt::AlignHCenter|Qt::AlignTop - + Wallpaper &Type: @@ -161,7 +180,7 @@ - + @@ -188,11 +207,6 @@ - - QQuickWidget - QWidget -
QtQuickWidgets/QQuickWidget
-
KKeySequenceWidget QWidget @@ -203,6 +217,11 @@ QSpinBox
kpluralhandlingspinbox.h
+ + QQuickWidget + QWidget +
QtQuickWidgets/QQuickWidget
+
diff --git a/kcm/config.qml b/kcm/lnfconfig.qml rename from kcm/config.qml rename to kcm/lnfconfig.qml --- a/kcm/config.qml +++ b/kcm/lnfconfig.qml @@ -35,9 +35,9 @@ if (main.currentItem.saveConfig) { main.currentItem.saveConfig() } - for (var key in configDialog.wallpaperConfiguration) { + for (var key in configDialog.lnfConfiguration) { if (main.currentItem["cfg_"+key] !== undefined) { - configDialog.wallpaperConfiguration[key] = main.currentItem["cfg_"+key] + configDialog.lnfConfiguration[key] = main.currentItem["cfg_"+key] } } } @@ -58,19 +58,18 @@ onSourceFileChanged: { if (sourceFile) { var props = {} - - var wallpaperConfig = configDialog.wallpaperConfiguration - for (var key in wallpaperConfig) { - props["cfg_" + key] = wallpaperConfig[key] + var lnfConfiguration = configDialog.lnfConfiguration + for (var key in lnfConfiguration) { + props["cfg_" + key] = lnfConfiguration[key] } var newItem = push({ item: sourceFile, replace: true, properties: props }) - for (var key in wallpaperConfig) { + for (var key in lnfConfiguration) { var changedSignal = newItem["cfg_" + key + "Changed"] if (changedSignal) { changedSignal.connect(root.configurationChanged) diff --git a/kcm/resources.qrc b/kcm/resources.qrc --- a/kcm/resources.qrc +++ b/kcm/resources.qrc @@ -1,6 +1,7 @@ - config.qml + wallpaperconfig.qml + lnfconfig.qml diff --git a/kcm/config.qml b/kcm/wallpaperconfig.qml rename from kcm/config.qml rename to kcm/wallpaperconfig.qml