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
wilder-5.25
Alexander Lohnau 4 years ago
parent d6b0c0a046
commit 0de1ccf53e
  1. 3
      shell/CMakeLists.txt
  2. 18
      shell/containmentconfigview.cpp
  3. 10
      shell/containmentconfigview.h
  4. 5
      shell/scripting/applet.cpp

@ -98,6 +98,9 @@ target_link_libraries(plasmashell
PW::KWorkspace PW::KWorkspace
Wayland::Client Wayland::Client
) )
if (QT_MAJOR_VERSION STREQUAL "6")
target_link_libraries(plasmashell KF5::ConfigQml)
endif()
if (TARGET KUserFeedbackCore) if (TARGET KUserFeedbackCore)
target_link_libraries(plasmashell KUserFeedbackCore) target_link_libraries(plasmashell KUserFeedbackCore)
target_compile_definitions(plasmashell PRIVATE -DWITH_KUSERFEEDBACKCORE) target_compile_definitions(plasmashell PRIVATE -DWITH_KUSERFEEDBACKCORE)

@ -18,7 +18,6 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <KConfigLoader> #include <KConfigLoader>
#include <KDeclarative/ConfigPropertyMap>
#include <KDeclarative/KDeclarative> #include <KDeclarative/KDeclarative>
#include <KLocalizedString> #include <KLocalizedString>
#include <KPackage/Package> #include <KPackage/Package>
@ -27,6 +26,11 @@
#include <Plasma/Corona> #include <Plasma/Corona>
#include <Plasma/PluginLoader> #include <Plasma/PluginLoader>
#include <PlasmaQuick/ConfigModel> #include <PlasmaQuick/ConfigModel>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <KDeclarative/ConfigPropertyMap>
#else
#include <KConfigPropertyMap>
#endif
class WallpaperConfigModel : public PlasmaQuick::ConfigModel class WallpaperConfigModel : public PlasmaQuick::ConfigModel
{ {
@ -147,7 +151,7 @@ PlasmaQuick::ConfigModel *ContainmentConfigView::containmentPluginsConfigModel()
return m_containmentPluginsConfigModel; return m_containmentPluginsConfigModel;
} }
KDeclarative::ConfigPropertyMap *ContainmentConfigView::wallpaperConfiguration() const QQmlPropertyMap *ContainmentConfigView::wallpaperConfiguration() const
{ {
return m_currentWallpaperConfig; return m_currentWallpaperConfig;
} }
@ -177,7 +181,11 @@ void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper)
KConfigGroup cfg = m_containment->config(); KConfigGroup cfg = m_containment->config();
cfg = KConfigGroup(&cfg, "Wallpaper"); cfg = KConfigGroup(&cfg, "Wallpaper");
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); 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; m_currentWallpaper = wallpaper;
@ -191,6 +199,7 @@ void ContainmentConfigView::applyWallpaper()
syncWallpaperObjects(); syncWallpaperObjects();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (m_currentWallpaperConfig && m_ownWallpaperConfig) { if (m_currentWallpaperConfig && m_ownWallpaperConfig) {
for (const auto &key : m_ownWallpaperConfig->keys()) { for (const auto &key : m_ownWallpaperConfig->keys()) {
auto value = m_ownWallpaperConfig->value(key); auto value = m_ownWallpaperConfig->value(key);
@ -201,6 +210,9 @@ void ContainmentConfigView::applyWallpaper()
delete m_ownWallpaperConfig; delete m_ownWallpaperConfig;
m_ownWallpaperConfig = nullptr; m_ownWallpaperConfig = nullptr;
#else
static_cast<KConfigPropertyMap *>(m_currentWallpaperConfig)->writeConfig();
#endif
Q_EMIT wallpaperConfigurationChanged(); Q_EMIT wallpaperConfigurationChanged();
} }
@ -215,7 +227,7 @@ void ContainmentConfigView::syncWallpaperObjects()
rootContext()->setContextProperty(QStringLiteral("wallpaper"), wallpaperGraphicsObject); rootContext()->setContextProperty(QStringLiteral("wallpaper"), wallpaperGraphicsObject);
// FIXME: why m_wallpaperGraphicsObject->property("configuration").value<ConfigPropertyMap *>() doesn't work? // 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) WallpaperConfigModel::WallpaperConfigModel(QObject *parent)

@ -6,9 +6,9 @@
#pragma once #pragma once
#include <KDeclarative/ConfigPropertyMap>
#include <PlasmaQuick/ConfigModel> #include <PlasmaQuick/ConfigModel>
#include <PlasmaQuick/ConfigView> #include <PlasmaQuick/ConfigView>
#include <QQmlPropertyMap>
namespace Plasma namespace Plasma
{ {
@ -26,7 +26,7 @@ class ContainmentConfigView : public PlasmaQuick::ConfigView
Q_PROPERTY(QAbstractItemModel *currentContainmentActionsModel READ currentContainmentActionsModel CONSTANT) Q_PROPERTY(QAbstractItemModel *currentContainmentActionsModel READ currentContainmentActionsModel CONSTANT)
Q_PROPERTY(PlasmaQuick::ConfigModel *wallpaperConfigModel READ wallpaperConfigModel CONSTANT) Q_PROPERTY(PlasmaQuick::ConfigModel *wallpaperConfigModel READ wallpaperConfigModel CONSTANT)
Q_PROPERTY(PlasmaQuick::ConfigModel *containmentPluginsConfigModel READ containmentPluginsConfigModel 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 currentWallpaper READ currentWallpaper WRITE setCurrentWallpaper NOTIFY currentWallpaperChanged)
Q_PROPERTY(QString containmentPlugin READ containmentPlugin WRITE setContainmentPlugin NOTIFY containmentPluginChanged) Q_PROPERTY(QString containmentPlugin READ containmentPlugin WRITE setContainmentPlugin NOTIFY containmentPluginChanged)
@ -42,7 +42,7 @@ public:
PlasmaQuick::ConfigModel *containmentPluginsConfigModel(); PlasmaQuick::ConfigModel *containmentPluginsConfigModel();
QString currentWallpaper() const; QString currentWallpaper() const;
void setCurrentWallpaper(const QString &wallpaper); void setCurrentWallpaper(const QString &wallpaper);
KDeclarative::ConfigPropertyMap *wallpaperConfiguration() const; QQmlPropertyMap *wallpaperConfiguration() const;
QString containmentPlugin() const; QString containmentPlugin() const;
void setContainmentPlugin(const QString &plugin); void setContainmentPlugin(const QString &plugin);
@ -63,6 +63,6 @@ private:
PlasmaQuick::ConfigModel *m_containmentPluginsConfigModel = nullptr; PlasmaQuick::ConfigModel *m_containmentPluginsConfigModel = nullptr;
CurrentContainmentActionsModel *m_currentContainmentActionsModel = nullptr; CurrentContainmentActionsModel *m_currentContainmentActionsModel = nullptr;
QString m_currentWallpaper; QString m_currentWallpaper;
KDeclarative::ConfigPropertyMap *m_currentWallpaperConfig = nullptr; QQmlPropertyMap *m_currentWallpaperConfig = nullptr;
KDeclarative::ConfigPropertyMap *m_ownWallpaperConfig = nullptr; QQmlPropertyMap *m_ownWallpaperConfig = nullptr;
}; };

@ -8,9 +8,9 @@
#include "scriptengine.h" #include "scriptengine.h"
#include <QAction> #include <QAction>
#include <QQmlPropertyMap>
#include <kconfigloader.h> #include <kconfigloader.h>
#include <kdeclarative/configpropertymap.h>
#include <kservice.h> #include <kservice.h>
#include <Plasma/Applet> #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 // hacky, but only way to make the wallpaper react immediately
QObject *wallpaperGraphicsObject = applet()->property("wallpaperGraphicsObject").value<QObject *>(); QObject *wallpaperGraphicsObject = applet()->property("wallpaperGraphicsObject").value<QObject *>();
if (wallpaperGraphicsObject) { if (wallpaperGraphicsObject) {
KDeclarative::ConfigPropertyMap *config = auto *config = static_cast<QQmlPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>());
static_cast<KDeclarative::ConfigPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>());
config->setProperty(key.toLatin1(), value.toVariant()); config->setProperty(key.toLatin1(), value.toVariant());
} }
} else if (applet()->configScheme()) { } else if (applet()->configScheme()) {

Loading…
Cancel
Save