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

Require and use the new NewStuffQuick Button component

Summary:
This removes the need for the custom hack for spawning a dialog,
and is intended to function as a sample for how to implement this
in other KCMs.

Also use the big, pretty Preview mode (because super-visual content)

This could be done wholesale for the entire bunch of KCMs, but i post
this on its own in an attempt to gain feedback on a self contained
example of how to do this porting step.

Without this patch:
{F7668236}

With this patch:
{F7668234}

Depends on D25041

Reviewers: #plasma, #knewstuff, #vdg, broulik, ngraham

Reviewed By: #vdg, ngraham

Subscribers: ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D24942
parent 88bce0e4
......@@ -40,6 +40,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
I18n
KCMUtils
NewStuff
NewStuffQuick
KDELibs4Support
Notifications
NotifyConfig
......
......@@ -28,7 +28,6 @@ target_link_libraries(kcm_lookandfeel
KF5::KDELibs4Support
KF5::Declarative
KF5::QuickAddons
KF5::NewStuff
Qt5::DBus
Qt5::Widgets
......
......@@ -98,21 +98,9 @@ KCMLookandFeel::~KCMLookandFeel()
{
}
void KCMLookandFeel::getNewStuff(QQuickItem *ctx)
void KCMLookandFeel::reloadModel()
{
if (!m_newStuffDialog) {
m_newStuffDialog = new KNS3::DownloadDialog( QLatin1String("lookandfeel.knsrc") );
m_newStuffDialog.data()->setWindowTitle(i18n("Download New Global Themes"));
m_newStuffDialog->setWindowModality(Qt::WindowModal);
m_newStuffDialog->winId(); // so it creates the windowHandle();
connect(m_newStuffDialog.data(), &KNS3::DownloadDialog::accepted, this, &KCMLookandFeel::loadModel);
}
if (ctx && ctx->window()) {
m_newStuffDialog->windowHandle()->setTransientParent(ctx->window());
}
m_newStuffDialog.data()->show();
loadModel();
}
QStandardItemModel *KCMLookandFeel::lookAndFeelModel() const
......
......@@ -24,8 +24,6 @@
#include <KConfigGroup>
#include <QDir>
#include <KNewStuff3/KNS3/DownloadDialog>
#include <KPackage/Package>
#include <KQuickAddons/ConfigModule>
......@@ -87,7 +85,7 @@ public:
void setDesktopSwitcher(const QString &theme);
void setWindowDecoration(const QString &library, const QString &theme);
Q_INVOKABLE void getNewStuff(QQuickItem *ctx);
Q_INVOKABLE void reloadModel();
public Q_SLOTS:
void load() override;
......@@ -107,7 +105,6 @@ private:
KPackage::Package m_package;
QString m_selectedPlugin;
QStringList m_cursorSearchPaths;
QPointer<KNS3::DownloadDialog> m_newStuffDialog;
KConfig m_config;
KConfigGroup m_configGroup;
......
......@@ -21,6 +21,7 @@ import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import QtQuick.Controls 2.3 as QtControls
import org.kde.kirigami 2.4 as Kirigami
import org.kde.newstuff 1.62 as NewStuff
import org.kde.kconfig 1.0 // for KAuthorized
import org.kde.kcm 1.1 as KCM
......@@ -80,11 +81,11 @@ KCM.GridViewKCM {
Item {
Layout.fillWidth: true
}
QtControls.Button {
text: i18n("Get New Global Themes...")
icon.name: "get-hot-new-stuff"
onClicked: kcm.getNewStuff(this);
visible: KAuthorized.authorize("ghns")
NewStuff.Button {
downloadNewWhat: i18n("Global Themes")
configFile: "lookandfeel.knsrc"
viewMode: NewStuff.Page.ViewMode.Preview
onChangedEntriesChanged: kcm.reloadModel();
}
}
}
......
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