diff --git a/kcm/kcm.h b/kcm/kcm.h --- a/kcm/kcm.h +++ b/kcm/kcm.h @@ -37,12 +37,10 @@ class ConfigPropertyMap; } + class ScreenLockerKcm : public KCModule { Q_OBJECT - Q_PROPERTY(KDeclarative::ConfigPropertyMap *wallpaperConfiguration READ wallpaperConfiguration NOTIFY wallpaperConfigurationChanged) - Q_PROPERTY(QString currentWallpaper READ currentWallpaper NOTIFY currentWallpaperChanged) - public: enum Roles { PluginNameRole = Qt::UserRole +1, @@ -76,3 +74,32 @@ ScreenLockerKcmForm *m_ui; ScreenLocker::WallpaperIntegration *m_wallpaperIntegration = 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(QString currentWallpaper READ currentWallpaper NOTIFY currentWallpaperChanged) +public: + ScreenLockerProxy(ScreenLockerKcm *parent) : + QObject(parent), + q(parent) + { + } + + KDeclarative::ConfigPropertyMap *wallpaperConfiguration() const { + return q->wallpaperConfiguration(); + } + + QString currentWallpaper() const { + return q->currentWallpaper(); + } + +signals: + void wallpaperConfigurationChanged(); + void currentWallpaperChanged(); + +private: + ScreenLockerKcm* q; +}; diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -87,7 +87,12 @@ m_ui->wallpaperCombo->installEventFilter(this); m_ui->wallpaperConfigWidget->setClearColor(m_ui->palette().color(QPalette::Active, QPalette::Window)); - m_ui->wallpaperConfigWidget->rootContext()->setContextProperty("configDialog", this); + auto proxy = new ScreenLockerProxy(this); + m_ui->wallpaperConfigWidget->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"))); connect(m_ui->wallpaperConfigWidget->rootObject(), SIGNAL(configurationChanged()), this, SLOT(changed()));