[applets/showdesktop] Port to declarative type registration

Enables LSP & linting for the QML files.
This commit is contained in:
Kristen McWilliam 2025-04-01 22:37:57 +00:00
parent b542ac8537
commit 25a51c2673
7 changed files with 13 additions and 48 deletions

View file

@ -2,16 +2,20 @@ plasma_install_package(package org.kde.plasma.showdesktop)
add_definitions(-DTRANSLATION_DOMAIN="plasma_applet_org.kde.plasma.showdesktop")
set(showdesktop_SRCS
plugin/showdesktop.cpp
plugin/showdesktopplugin.cpp
ecm_add_qml_module(showdesktopplugin
URI org.kde.plasma.private.showdesktop
VERSION 0.1
GENERATE_PLUGIN_SOURCE
)
qt_add_dbus_interface(showdesktop_SRCS plugin/org.kde.KWin.xml kwin_interface)
qt_add_dbus_interface(showdesktop_SRCS org.kde.KWin.xml kwin_interface)
add_library(showdesktopplugin SHARED ${showdesktop_SRCS})
target_sources(showdesktopplugin PRIVATE
showdesktop.cpp
${showdesktop_SRCS}
)
target_link_libraries(showdesktopplugin
target_link_libraries(showdesktopplugin PRIVATE
Qt::Core
Qt::DBus
Qt::Qml
@ -19,5 +23,4 @@ target_link_libraries(showdesktopplugin
KF6::WindowSystem
)
install(TARGETS showdesktopplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/showdesktop)
install(FILES plugin/qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/showdesktop)
ecm_finalize_qml_module(showdesktopplugin)

View file

@ -1,2 +0,0 @@
module org.kde.plasma.private.showdesktop
plugin showdesktopplugin

View file

@ -1,18 +0,0 @@
/*
SPDX-FileCopyrightText: 2014 Ashish Madeti <ashishmadeti@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "showdesktopplugin.h"
#include "showdesktop.h"
// Qt
void ShowDesktopPlugin::registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.showdesktop"));
qmlRegisterType<ShowDesktop>(uri, 0, 1, "ShowDesktop");
}
#include "moc_showdesktopplugin.cpp"

View file

@ -1,20 +0,0 @@
/*
SPDX-FileCopyrightText: 2014 Ashish Madeti <ashishmadeti@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QObject>
#include <QQmlEngine>
#include <QQmlExtensionPlugin>
class ShowDesktopPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
void registerTypes(const char *uri) override;
};

View file

@ -7,12 +7,14 @@
#pragma once
#include <QObject>
#include <qqmlintegration.h>
#include "kwin_interface.h"
class ShowDesktop : public QObject
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(bool showingDesktop READ showingDesktop WRITE setShowingDesktop NOTIFY showingDesktopChanged)