From 47a1091be9f509e2d1130e78479eabda8a528201 Mon Sep 17 00:00:00 2001 From: Dan Leinir Turthra Jensen Date: Tue, 14 Jan 2020 14:35:40 +0000 Subject: [PATCH] Switch to KNSQuick for getting new wallpapers Summary: This switches the image plugin to using KNewStuffQuick instead of launching the widget dialog through that ol' widget dialog hack. It further uses the big preview mode by default, which just seems to make a lot of sense for wallpapers. Test Plan: Without: Uses the old dialog With: Uses the new dialog, as seen below {F7882885} Reviewers: mart, #plasma, ngraham Reviewed By: mart Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D26665 --- wallpapers/image/image.cpp | 21 +---------------- wallpapers/image/image.h | 1 - .../image/imagepackage/contents/ui/config.qml | 23 ++++++++++--------- 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/wallpapers/image/image.cpp b/wallpapers/image/image.cpp index 88be291f1..7ef9a0bef 100644 --- a/wallpapers/image/image.cpp +++ b/wallpapers/image/image.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include @@ -644,27 +643,9 @@ void Image::backgroundsFound() } } -void Image::getNewWallpaper(QQuickItem *ctx) -{ - if (!m_newStuffDialog) { - m_newStuffDialog = new KNS3::DownloadDialog( QString::fromLatin1("wallpaper.knsrc") ); - KNS3::DownloadDialog *strong = m_newStuffDialog.data(); - strong->setTitle(i18n("Download Wallpapers")); - connect(m_newStuffDialog.data(), &QDialog::accepted, this, &Image::newStuffFinished); - } - - if (ctx && ctx->window()) { - m_newStuffDialog->setWindowModality(Qt::WindowModal); - m_newStuffDialog->winId(); // so it creates the windowHandle(); - m_newStuffDialog->windowHandle()->setTransientParent(ctx->window()); - } - - m_newStuffDialog.data()->show(); -} - void Image::newStuffFinished() { - if (m_model && (!m_newStuffDialog || m_newStuffDialog.data()->changedEntries().size() > 0)) { + if (m_model) { m_model->reload(m_usersWallpapers); } } diff --git a/wallpapers/image/image.h b/wallpapers/image/image.h index 228e3d599..82b7981eb 100644 --- a/wallpapers/image/image.h +++ b/wallpapers/image/image.h @@ -99,7 +99,6 @@ class Image : public QObject, public QQmlParserStatus Q_INVOKABLE void removeSlidePath(const QString &path); Q_INVOKABLE void openFolder(const QString& path); - Q_INVOKABLE void getNewWallpaper(QQuickItem *ctx = nullptr); Q_INVOKABLE void showFileDialog(); Q_INVOKABLE void addUsersWallpaper(const QString &file); diff --git a/wallpapers/image/imagepackage/contents/ui/config.qml b/wallpapers/image/imagepackage/contents/ui/config.qml index 17486d964..930d47d79 100644 --- a/wallpapers/image/imagepackage/contents/ui/config.qml +++ b/wallpapers/image/imagepackage/contents/ui/config.qml @@ -25,7 +25,7 @@ import QtQuick.Window 2.0 // for Screen import org.kde.plasma.wallpapers.image 2.0 as Wallpaper import org.kde.kquickcontrols 2.0 as KQuickControls import org.kde.kquickcontrolsaddons 2.0 -import org.kde.kconfig 1.0 // for KAuthorized +import org.kde.newstuff 1.62 as NewStuff import org.kde.draganddrop 2.0 as DragDrop import org.kde.kcm 1.1 as KCM import org.kde.kirigami 2.5 as Kirigami @@ -344,12 +344,12 @@ ColumnLayout { text: i18nd("plasma_wallpaper_org.kde.image","Add Folder...") onClicked: imageWallpaper.showAddSlidePathsDialog() } - QtControls2.Button { + NewStuff.Button { Layout.alignment: Qt.AlignRight - icon.name: "get-hot-new-stuff" - text: i18nd("plasma_wallpaper_org.kde.image","Get New Wallpapers...") - visible: KAuthorized.authorize("ghns") - onClicked: imageWallpaper.getNewWallpaper(this); + configFile: "wallpaper.knsrc" + downloadNewWhat: i18n("Wallpapers") + viewMode: NewStuff.Page.ViewMode.Preview + onChangedEntriesChanged: imageWallpaper.newStuffFinished(); } } } @@ -443,11 +443,12 @@ ColumnLayout { text: i18nd("plasma_wallpaper_org.kde.image","Add Image...") onClicked: imageWallpaper.showFileDialog(); } - QtControls2.Button { - icon.name: "get-hot-new-stuff" - text: i18nd("plasma_wallpaper_org.kde.image","Get New Wallpapers...") - visible: KAuthorized.authorize("ghns") - onClicked: imageWallpaper.getNewWallpaper(this); + NewStuff.Button { + Layout.alignment: Qt.AlignRight + configFile: "wallpaper.knsrc" + downloadNewWhat: i18n("Wallpapers") + viewMode: NewStuff.Page.ViewMode.Preview + onChangedEntriesChanged: imageWallpaper.newStuffFinished(); } } }