Commit 47a1091b authored by Dan Leinir Turthra Jensen's avatar Dan Leinir Turthra Jensen 🌈
Browse files

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
parent 48d3613a
......@@ -47,7 +47,6 @@
#include <KRandom>
#include <KIO/Job>
#include <krun.h>
#include <KNewStuff3/KNS3/DownloadDialog>
#include <klocalizedstring.h>
#include <Plasma/Theme>
......@@ -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);
}
}
......
......@@ -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);
......
......@@ -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();
}
}
}
Markdown is supported
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