diff --git a/src/kcms/decoration/declarative-plugin/CMakeLists.txt b/src/kcms/decoration/declarative-plugin/CMakeLists.txt index 4dda6c1363..5fee85fc35 100644 --- a/src/kcms/decoration/declarative-plugin/CMakeLists.txt +++ b/src/kcms/decoration/declarative-plugin/CMakeLists.txt @@ -1,17 +1,18 @@ -set(plugin_SRCS +ecm_add_qml_module(kdecorationprivatedeclarative URI org.kde.kwin.private.kdecoration DEPENDENCIES QtCore QtQuick GENERATE_PLUGIN_SOURCE) + +target_sources(kdecorationprivatedeclarative PRIVATE previewbutton.cpp previewbridge.cpp previewclient.cpp previewitem.cpp previewsettings.cpp - plugin.cpp buttonsmodel.cpp ../../../decorations/decorationpalette.cpp ../../../decorations/decorations_logging.cpp + types.h ) -add_library(kdecorationprivatedeclarative SHARED ${plugin_SRCS}) -target_link_libraries(kdecorationprivatedeclarative +target_link_libraries(kdecorationprivatedeclarative PRIVATE KDecoration2::KDecoration KDecoration2::KDecoration2Private Qt::DBus @@ -22,5 +23,4 @@ target_link_libraries(kdecorationprivatedeclarative KF6::Service ) -install(TARGETS kdecorationprivatedeclarative DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/kwin/private/kdecoration ) -install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/kwin/private/kdecoration ) +ecm_finalize_qml_module(kdecorationprivatedeclarative) diff --git a/src/kcms/decoration/declarative-plugin/buttonsmodel.h b/src/kcms/decoration/declarative-plugin/buttonsmodel.h index 1bd97c30e8..cdb1c616d2 100644 --- a/src/kcms/decoration/declarative-plugin/buttonsmodel.h +++ b/src/kcms/decoration/declarative-plugin/buttonsmodel.h @@ -8,6 +8,8 @@ #include #include +#include + namespace KDecoration2 { @@ -18,6 +20,7 @@ class PreviewBridge; class ButtonsModel : public QAbstractListModel { Q_OBJECT + QML_ELEMENT public: explicit ButtonsModel(const QList &buttons, QObject *parent = nullptr); explicit ButtonsModel(QObject *parent = nullptr); diff --git a/src/kcms/decoration/declarative-plugin/plugin.cpp b/src/kcms/decoration/declarative-plugin/plugin.cpp deleted file mode 100644 index ab87d52e4a..0000000000 --- a/src/kcms/decoration/declarative-plugin/plugin.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - SPDX-FileCopyrightText: 2014 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL -*/ -#include "plugin.h" -#include "buttonsmodel.h" -#include "previewbridge.h" -#include "previewbutton.h" -#include "previewclient.h" -#include "previewitem.h" -#include "previewsettings.h" - -#include -#include - -namespace KDecoration2 -{ -namespace Preview -{ - -void Plugin::registerTypes(const char *uri) -{ - Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.kwin.private.kdecoration")); - qmlRegisterType(uri, 1, 0, "Bridge"); - qmlRegisterType(uri, 1, 0, "Settings"); - qmlRegisterType(uri, 1, 0, "Decoration"); - qmlRegisterType(uri, 1, 0, "Button"); - qmlRegisterType(uri, 1, 0, "ButtonsModel"); - qmlRegisterAnonymousType(uri, 1); - qmlRegisterAnonymousType(uri, 1); - qmlRegisterAnonymousType(uri, 1); - qmlRegisterAnonymousType(uri, 1); -} - -} -} - -#include "moc_plugin.cpp" diff --git a/src/kcms/decoration/declarative-plugin/plugin.h b/src/kcms/decoration/declarative-plugin/plugin.h deleted file mode 100644 index f0d59aecb1..0000000000 --- a/src/kcms/decoration/declarative-plugin/plugin.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - SPDX-FileCopyrightText: 2014 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL -*/ -#pragma once - -#include - -namespace KDecoration2 -{ -namespace Preview -{ - -class Plugin : public QQmlExtensionPlugin -{ - Q_PLUGIN_METADATA(IID "org.kde.kdecoration2") - Q_OBJECT -public: - void registerTypes(const char *uri) override; -}; - -} -} diff --git a/src/kcms/decoration/declarative-plugin/previewbridge.h b/src/kcms/decoration/declarative-plugin/previewbridge.h index 4801c044fe..2eed0ade8d 100644 --- a/src/kcms/decoration/declarative-plugin/previewbridge.h +++ b/src/kcms/decoration/declarative-plugin/previewbridge.h @@ -10,6 +10,7 @@ #include #include +#include class QQuickItem; @@ -24,9 +25,11 @@ class PreviewClient; class PreviewItem; class PreviewSettings; -class PreviewBridge : public DecorationBridge +class PreviewBridge : public KDecoration2::DecorationBridge { Q_OBJECT + QML_ANONYMOUS + Q_PROPERTY(QString plugin READ plugin WRITE setPlugin NOTIFY pluginChanged) Q_PROPERTY(QString theme READ theme WRITE setTheme NOTIFY themeChanged) Q_PROPERTY(QString kcmoduleName READ kcmoduleName WRITE setKcmoduleName NOTIFY kcmoduleNameChanged) @@ -85,6 +88,7 @@ private: class BridgeItem : public QObject { Q_OBJECT + QML_NAMED_ELEMENT(Bridge) Q_PROPERTY(QString plugin READ plugin WRITE setPlugin NOTIFY pluginChanged) Q_PROPERTY(QString theme READ theme WRITE setTheme NOTIFY themeChanged) Q_PROPERTY(QString kcmoduleName READ kcmoduleName WRITE setKcmoduleName NOTIFY kcmoduleNameChanged) diff --git a/src/kcms/decoration/declarative-plugin/previewbutton.h b/src/kcms/decoration/declarative-plugin/previewbutton.h index d6ff7d923a..2b2a444b68 100644 --- a/src/kcms/decoration/declarative-plugin/previewbutton.h +++ b/src/kcms/decoration/declarative-plugin/previewbutton.h @@ -22,6 +22,7 @@ class Settings; class PreviewButtonItem : public QQuickPaintedItem { Q_OBJECT + QML_NAMED_ELEMENT(Button) Q_PROPERTY(KDecoration2::Preview::PreviewBridge *bridge READ bridge WRITE setBridge NOTIFY bridgeChanged) Q_PROPERTY(KDecoration2::Preview::Settings *settings READ settings WRITE setSettings NOTIFY settingsChanged) Q_PROPERTY(int type READ typeAsInt WRITE setType NOTIFY typeChanged) diff --git a/src/kcms/decoration/declarative-plugin/previewclient.h b/src/kcms/decoration/declarative-plugin/previewclient.h index d5c38dfe2d..6dcc01f115 100644 --- a/src/kcms/decoration/declarative-plugin/previewclient.h +++ b/src/kcms/decoration/declarative-plugin/previewclient.h @@ -10,6 +10,7 @@ #include #include #include +#include class QAbstractItemModel; @@ -20,6 +21,7 @@ namespace Preview class PreviewClient : public QObject, public ApplicationMenuEnabledDecoratedClientPrivate { Q_OBJECT + QML_ANONYMOUS Q_PROPERTY(KDecoration2::Decoration *decoration READ decoration CONSTANT) Q_PROPERTY(QString caption READ caption WRITE setCaption NOTIFY captionChanged) Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged) diff --git a/src/kcms/decoration/declarative-plugin/previewitem.h b/src/kcms/decoration/declarative-plugin/previewitem.h index ab07aeb9ce..ff7ae1172c 100644 --- a/src/kcms/decoration/declarative-plugin/previewitem.h +++ b/src/kcms/decoration/declarative-plugin/previewitem.h @@ -23,6 +23,7 @@ class Settings; class PreviewItem : public QQuickPaintedItem { Q_OBJECT + QML_NAMED_ELEMENT(Decoration) Q_PROPERTY(KDecoration2::Decoration *decoration READ decoration NOTIFY decorationChanged) Q_PROPERTY(KDecoration2::Preview::PreviewBridge *bridge READ bridge WRITE setBridge NOTIFY bridgeChanged) Q_PROPERTY(KDecoration2::Preview::Settings *settings READ settings WRITE setSettings NOTIFY settingsChanged) diff --git a/src/kcms/decoration/declarative-plugin/previewsettings.h b/src/kcms/decoration/declarative-plugin/previewsettings.h index 8206b9e26d..aa4fc37777 100644 --- a/src/kcms/decoration/declarative-plugin/previewsettings.h +++ b/src/kcms/decoration/declarative-plugin/previewsettings.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace KDecoration2 { @@ -116,6 +117,7 @@ private: class Settings : public QObject { Q_OBJECT + QML_ELEMENT Q_PROPERTY(KDecoration2::Preview::PreviewBridge *bridge READ bridge WRITE setBridge NOTIFY bridgeChanged) Q_PROPERTY(KDecoration2::DecorationSettings *settings READ settingsPointer NOTIFY settingsChanged) Q_PROPERTY(int borderSizesIndex READ borderSizesIndex WRITE setBorderSizesIndex NOTIFY borderSizesIndexChanged) diff --git a/src/kcms/decoration/declarative-plugin/qmldir b/src/kcms/decoration/declarative-plugin/qmldir deleted file mode 100644 index 42770220aa..0000000000 --- a/src/kcms/decoration/declarative-plugin/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -module org.kde.kwin.private.kdecoration -plugin kdecorationprivatedeclarative diff --git a/src/kcms/decoration/declarative-plugin/types.h b/src/kcms/decoration/declarative-plugin/types.h new file mode 100644 index 0000000000..115d4c13e3 --- /dev/null +++ b/src/kcms/decoration/declarative-plugin/types.h @@ -0,0 +1,25 @@ +/* + SPDX-FileCopyrightText: 2024 Nicolas Fella + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL +*/ +#pragma once + +#include + +#include +#include + +struct DecorationForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(KDecoration2::Decoration) +}; + +struct DecorationShadowForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(KDecoration2::DecorationShadow) +};