From 09b1cea056b8192dd651c4a8a848bd8e6cc69209 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Mon, 8 Feb 2021 17:24:39 +0100 Subject: [PATCH] Port kwindecoration KCM to KNS QML components --- kcmkwin/kwindecoration/kcm.cpp | 21 ------------------- kcmkwin/kwindecoration/kcm.h | 11 +--------- .../package/contents/ui/main.qml | 7 +++++-- 3 files changed, 6 insertions(+), 33 deletions(-) diff --git a/kcmkwin/kwindecoration/kcm.cpp b/kcmkwin/kwindecoration/kcm.cpp index dcb4f5f6a7..de2176acdf 100644 --- a/kcmkwin/kwindecoration/kcm.cpp +++ b/kcmkwin/kwindecoration/kcm.cpp @@ -23,8 +23,6 @@ #include #include -#include - #include "kwindecorationdata.h" #include "kwindecorationsettings.h" @@ -108,25 +106,6 @@ void KCMKWinDecoration::reloadKWinSettings() QMetaObject::invokeMethod(m_themesModel, "init", Qt::QueuedConnection); } -void KCMKWinDecoration::getNewStuff(QQuickItem *context) -{ - if (!m_newStuffDialog) { - m_newStuffDialog = new KNS3::DownloadDialog(QStringLiteral("window-decorations.knsrc")); - m_newStuffDialog->setWindowTitle(i18n("Download New Window Decorations")); - m_newStuffDialog->setWindowModality(Qt::WindowModal); - connect(m_newStuffDialog, &KNS3::DownloadDialog::accepted, this, &KCMKWinDecoration::load); - } - - if (context && context->window()) { - m_newStuffDialog->winId(); // so it creates the windowHandle() - m_newStuffDialog->windowHandle()->setTransientParent(context->window()); - } - - connect(m_newStuffDialog, &QDialog::finished, this, &KCMKWinDecoration::reloadKWinSettings); - - m_newStuffDialog->show(); -} - void KCMKWinDecoration::load() { ManagedConfigModule::load(); diff --git a/kcmkwin/kwindecoration/kcm.h b/kcmkwin/kwindecoration/kcm.h index 97e0043a54..27470277d9 100644 --- a/kcmkwin/kwindecoration/kcm.h +++ b/kcmkwin/kwindecoration/kcm.h @@ -16,11 +16,6 @@ class QAbstractItemModel; class QSortFilterProxyModel; class QQuickItem; -namespace KNS3 -{ -class DownloadDialog; -} - namespace KDecoration2 { enum class BorderSize; @@ -71,8 +66,6 @@ public: void setBorderSize(KDecoration2::BorderSize size); void setTheme(int index); - Q_INVOKABLE void getNewStuff(QQuickItem *context); - Q_SIGNALS: void themeChanged(); void buttonsChanged(); @@ -83,11 +76,11 @@ public Q_SLOTS: void load() override; void save() override; void defaults() override; + void reloadKWinSettings(); private Q_SLOTS: void onLeftButtonsChanged(); void onRightButtonsChanged(); - void reloadKWinSettings(); private: bool isSaveNeeded() const override; @@ -102,8 +95,6 @@ private: KDecoration2::Preview::ButtonsModel *m_rightButtonsModel; KDecoration2::Preview::ButtonsModel *m_availableButtonsModel; - QPointer m_newStuffDialog; - int m_borderSizeIndex = -1; KWinDecorationData *m_data; }; diff --git a/kcmkwin/kwindecoration/package/contents/ui/main.qml b/kcmkwin/kwindecoration/package/contents/ui/main.qml index 1f23fb0dd2..449be8823a 100644 --- a/kcmkwin/kwindecoration/package/contents/ui/main.qml +++ b/kcmkwin/kwindecoration/package/contents/ui/main.qml @@ -11,6 +11,7 @@ import QtQuick.Controls 2.4 as QQC2 import org.kde.kcm 1.5 as KCM import org.kde.kconfig 1.0 // for KAuthorized import org.kde.kirigami 2.4 as Kirigami +import org.kde.newstuff 1.62 as NewStuff Kirigami.Page { id: root @@ -99,11 +100,13 @@ Kirigami.Page { Item { Layout.fillWidth: true } - QQC2.Button { + NewStuff.Button { + id: newstuffButton text: i18nc("button text", "Get New Window Decorations...") icon.name: "get-hot-new-stuff" - onClicked: kcm.getNewStuff(this) visible: KAuthorized.authorize("ghns") + configFile: "window-decorations.knsrc" + onChangedEntriesChanged: kcm.reloadKWinSettings() } } }