Port kwindecoration KCM to KNS QML components

This commit is contained in:
Alexander Lohnau 2021-02-08 17:24:39 +01:00
parent 2d68196536
commit 09b1cea056
3 changed files with 6 additions and 33 deletions

View file

@ -23,8 +23,6 @@
#include <QQuickWindow> #include <QQuickWindow>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <KNewStuff3/KNS3/DownloadDialog>
#include "kwindecorationdata.h" #include "kwindecorationdata.h"
#include "kwindecorationsettings.h" #include "kwindecorationsettings.h"
@ -108,25 +106,6 @@ void KCMKWinDecoration::reloadKWinSettings()
QMetaObject::invokeMethod(m_themesModel, "init", Qt::QueuedConnection); 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() void KCMKWinDecoration::load()
{ {
ManagedConfigModule::load(); ManagedConfigModule::load();

View file

@ -16,11 +16,6 @@ class QAbstractItemModel;
class QSortFilterProxyModel; class QSortFilterProxyModel;
class QQuickItem; class QQuickItem;
namespace KNS3
{
class DownloadDialog;
}
namespace KDecoration2 namespace KDecoration2
{ {
enum class BorderSize; enum class BorderSize;
@ -71,8 +66,6 @@ public:
void setBorderSize(KDecoration2::BorderSize size); void setBorderSize(KDecoration2::BorderSize size);
void setTheme(int index); void setTheme(int index);
Q_INVOKABLE void getNewStuff(QQuickItem *context);
Q_SIGNALS: Q_SIGNALS:
void themeChanged(); void themeChanged();
void buttonsChanged(); void buttonsChanged();
@ -83,11 +76,11 @@ public Q_SLOTS:
void load() override; void load() override;
void save() override; void save() override;
void defaults() override; void defaults() override;
void reloadKWinSettings();
private Q_SLOTS: private Q_SLOTS:
void onLeftButtonsChanged(); void onLeftButtonsChanged();
void onRightButtonsChanged(); void onRightButtonsChanged();
void reloadKWinSettings();
private: private:
bool isSaveNeeded() const override; bool isSaveNeeded() const override;
@ -102,8 +95,6 @@ private:
KDecoration2::Preview::ButtonsModel *m_rightButtonsModel; KDecoration2::Preview::ButtonsModel *m_rightButtonsModel;
KDecoration2::Preview::ButtonsModel *m_availableButtonsModel; KDecoration2::Preview::ButtonsModel *m_availableButtonsModel;
QPointer<KNS3::DownloadDialog> m_newStuffDialog;
int m_borderSizeIndex = -1; int m_borderSizeIndex = -1;
KWinDecorationData *m_data; KWinDecorationData *m_data;
}; };

View file

@ -11,6 +11,7 @@ import QtQuick.Controls 2.4 as QQC2
import org.kde.kcm 1.5 as KCM import org.kde.kcm 1.5 as KCM
import org.kde.kconfig 1.0 // for KAuthorized import org.kde.kconfig 1.0 // for KAuthorized
import org.kde.kirigami 2.4 as Kirigami import org.kde.kirigami 2.4 as Kirigami
import org.kde.newstuff 1.62 as NewStuff
Kirigami.Page { Kirigami.Page {
id: root id: root
@ -99,11 +100,13 @@ Kirigami.Page {
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
} }
QQC2.Button { NewStuff.Button {
id: newstuffButton
text: i18nc("button text", "Get New Window Decorations...") text: i18nc("button text", "Get New Window Decorations...")
icon.name: "get-hot-new-stuff" icon.name: "get-hot-new-stuff"
onClicked: kcm.getNewStuff(this)
visible: KAuthorized.authorize("ghns") visible: KAuthorized.authorize("ghns")
configFile: "window-decorations.knsrc"
onChangedEntriesChanged: kcm.reloadKWinSettings()
} }
} }
} }