Commit 0de1ccf5 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Port away from KDeclarative::ConfigPropertyMap where possible

Because of the wallpaper interface from plasma-frameworks, we can not change
this during KF5. However we can use QQmlPropertyMap as the type, when we do not care
about the KConfig specific bits. Both KConfigPropertyMap and KDeclarative::ConfigPropertyMap
extend from this class.

Task: https://phabricator.kde.org/T12126
parent d6b0c0a0
Pipeline #151184 passed with stage
in 11 minutes and 31 seconds
......@@ -98,6 +98,9 @@ target_link_libraries(plasmashell
PW::KWorkspace
Wayland::Client
)
if (QT_MAJOR_VERSION STREQUAL "6")
target_link_libraries(plasmashell KF5::ConfigQml)
endif()
if (TARGET KUserFeedbackCore)
target_link_libraries(plasmashell KUserFeedbackCore)
target_compile_definitions(plasmashell PRIVATE -DWITH_KUSERFEEDBACKCORE)
......
......@@ -18,7 +18,6 @@
#include <QStandardPaths>
#include <KConfigLoader>
#include <KDeclarative/ConfigPropertyMap>
#include <KDeclarative/KDeclarative>
#include <KLocalizedString>
#include <KPackage/Package>
......@@ -27,6 +26,11 @@
#include <Plasma/Corona>
#include <Plasma/PluginLoader>
#include <PlasmaQuick/ConfigModel>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <KDeclarative/ConfigPropertyMap>
#else
#include <KConfigPropertyMap>
#endif
class WallpaperConfigModel : public PlasmaQuick::ConfigModel
{
......@@ -147,7 +151,7 @@ PlasmaQuick::ConfigModel *ContainmentConfigView::containmentPluginsConfigModel()
return m_containmentPluginsConfigModel;
}
KDeclarative::ConfigPropertyMap *ContainmentConfigView::wallpaperConfiguration() const
QQmlPropertyMap *ContainmentConfigView::wallpaperConfiguration() const
{
return m_currentWallpaperConfig;
}
......@@ -177,7 +181,11 @@ void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper)
KConfigGroup cfg = m_containment->config();
cfg = KConfigGroup(&cfg, "Wallpaper");
cfg = KConfigGroup(&cfg, wallpaper);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
m_currentWallpaperConfig = m_ownWallpaperConfig = new KDeclarative::ConfigPropertyMap(new KConfigLoader(cfg, &file), this);
#else
m_currentWallpaperConfig = m_ownWallpaperConfig = new KConfigPropertyMap(new KConfigLoader(cfg, &file), this);
#endif
}
m_currentWallpaper = wallpaper;
......@@ -191,6 +199,7 @@ void ContainmentConfigView::applyWallpaper()
syncWallpaperObjects();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (m_currentWallpaperConfig && m_ownWallpaperConfig) {
for (const auto &key : m_ownWallpaperConfig->keys()) {
auto value = m_ownWallpaperConfig->value(key);
......@@ -201,6 +210,9 @@ void ContainmentConfigView::applyWallpaper()
delete m_ownWallpaperConfig;
m_ownWallpaperConfig = nullptr;
#else
static_cast<KConfigPropertyMap *>(m_currentWallpaperConfig)->writeConfig();
#endif
Q_EMIT wallpaperConfigurationChanged();
}
......@@ -215,7 +227,7 @@ void ContainmentConfigView::syncWallpaperObjects()
rootContext()->setContextProperty(QStringLiteral("wallpaper"), wallpaperGraphicsObject);
// FIXME: why m_wallpaperGraphicsObject->property("configuration").value<ConfigPropertyMap *>() doesn't work?
m_currentWallpaperConfig = static_cast<KDeclarative::ConfigPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>());
m_currentWallpaperConfig = static_cast<QQmlPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>());
}
WallpaperConfigModel::WallpaperConfigModel(QObject *parent)
......
......@@ -6,9 +6,9 @@
#pragma once
#include <KDeclarative/ConfigPropertyMap>
#include <PlasmaQuick/ConfigModel>
#include <PlasmaQuick/ConfigView>
#include <QQmlPropertyMap>
namespace Plasma
{
......@@ -26,7 +26,7 @@ class ContainmentConfigView : public PlasmaQuick::ConfigView
Q_PROPERTY(QAbstractItemModel *currentContainmentActionsModel READ currentContainmentActionsModel CONSTANT)
Q_PROPERTY(PlasmaQuick::ConfigModel *wallpaperConfigModel READ wallpaperConfigModel CONSTANT)
Q_PROPERTY(PlasmaQuick::ConfigModel *containmentPluginsConfigModel READ containmentPluginsConfigModel CONSTANT)
Q_PROPERTY(KDeclarative::ConfigPropertyMap *wallpaperConfiguration READ wallpaperConfiguration NOTIFY wallpaperConfigurationChanged)
Q_PROPERTY(QQmlPropertyMap *wallpaperConfiguration READ wallpaperConfiguration NOTIFY wallpaperConfigurationChanged)
Q_PROPERTY(QString currentWallpaper READ currentWallpaper WRITE setCurrentWallpaper NOTIFY currentWallpaperChanged)
Q_PROPERTY(QString containmentPlugin READ containmentPlugin WRITE setContainmentPlugin NOTIFY containmentPluginChanged)
......@@ -42,7 +42,7 @@ public:
PlasmaQuick::ConfigModel *containmentPluginsConfigModel();
QString currentWallpaper() const;
void setCurrentWallpaper(const QString &wallpaper);
KDeclarative::ConfigPropertyMap *wallpaperConfiguration() const;
QQmlPropertyMap *wallpaperConfiguration() const;
QString containmentPlugin() const;
void setContainmentPlugin(const QString &plugin);
......@@ -63,6 +63,6 @@ private:
PlasmaQuick::ConfigModel *m_containmentPluginsConfigModel = nullptr;
CurrentContainmentActionsModel *m_currentContainmentActionsModel = nullptr;
QString m_currentWallpaper;
KDeclarative::ConfigPropertyMap *m_currentWallpaperConfig = nullptr;
KDeclarative::ConfigPropertyMap *m_ownWallpaperConfig = nullptr;
QQmlPropertyMap *m_currentWallpaperConfig = nullptr;
QQmlPropertyMap *m_ownWallpaperConfig = nullptr;
};
......@@ -8,9 +8,9 @@
#include "scriptengine.h"
#include <QAction>
#include <QQmlPropertyMap>
#include <kconfigloader.h>
#include <kdeclarative/configpropertymap.h>
#include <kservice.h>
#include <Plasma/Applet>
......@@ -107,8 +107,7 @@ void Applet::writeConfig(const QString &key, const QJSValue &value)
// hacky, but only way to make the wallpaper react immediately
QObject *wallpaperGraphicsObject = applet()->property("wallpaperGraphicsObject").value<QObject *>();
if (wallpaperGraphicsObject) {
KDeclarative::ConfigPropertyMap *config =
static_cast<KDeclarative::ConfigPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>());
auto *config = static_cast<QQmlPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>());
config->setProperty(key.toLatin1(), value.toVariant());
}
} else if (applet()->configScheme()) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment