Port nightcolor to declarative type registration

This commit is contained in:
Nicolas Fella 2025-04-18 22:02:54 +02:00
parent 988c33a627
commit c9f3d5f2ae
6 changed files with 10 additions and 59 deletions

View file

@ -5,7 +5,6 @@ set_source_files_properties(${KWIN_NIGHTLIGHT_INTERFACE} PROPERTIES NO_NAMESPACE
qt_add_dbus_interfaces(DBUS_SRCS ${KWIN_NIGHTLIGHT_INTERFACE})
set(nightcolorplugin_SRCS
nightcolorplugin.cpp
nightcolorutil.cpp
enum.h
${DBUS_SRCS}
@ -13,9 +12,11 @@ set(nightcolorplugin_SRCS
kconfig_add_kcfg_files(nightcolorplugin_SRCS nightcolorsettings.kcfgc GENERATE_MOC)
add_library(nightcolorplugin ${nightcolorplugin_SRCS})
ecm_add_qml_module(nightcolorplugin URI "org.kde.plasma.quicksetting.nightcolor" GENERATE_PLUGIN_SOURCE)
target_link_libraries(nightcolorplugin
target_sources(nightcolorplugin PRIVATE ${nightcolorplugin_SRCS})
target_link_libraries(nightcolorplugin PRIVATE
Qt::Core
Qt::DBus
Qt::Qml
@ -25,10 +26,6 @@ target_link_libraries(nightcolorplugin
KF6::ConfigGui
)
set_property(TARGET nightcolorplugin PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/org/kde/plasma/quicksetting/nightcolor)
file(COPY qmldir DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/org/kde/plasma/quicksetting/nightcolor)
install(TARGETS nightcolorplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/quicksetting/nightcolor)
install(FILES qmldir ${qml_SRC} DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/quicksetting/nightcolor)
ecm_finalize_qml_module(nightcolorplugin)
plasma_install_package(package org.kde.plasma.quicksetting.nightcolor quicksettings)

View file

@ -1,23 +0,0 @@
/*
* SPDX-FileCopyrightText: 2022 by Devin Lin <devin@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "nightcolorplugin.h"
#include <QQmlContext>
#include <QQuickItem>
#include "nightcolorutil.h"
void NightColorPlugin::registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.quicksetting.nightcolor"));
qmlRegisterSingletonType<NightColorUtil>(uri, 1, 0, "NightColorUtil", [](QQmlEngine *, QJSEngine *) {
return new NightColorUtil;
});
}
//#include "moc_nightcolorplugin.cpp"

View file

@ -1,21 +0,0 @@
/*
* SPDX-FileCopyrightText: 2022 by Devin Lin <devin@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QUrl>
#include <QQmlEngine>
#include <QQmlExtensionPlugin>
class NightColorPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
void registerTypes(const char *uri) override;
};

View file

@ -7,6 +7,7 @@
#pragma once
#include <QObject>
#include <qqmlregistration.h>
#include "nightcolorsettings.h"
#include "nightlightinterface.h"
@ -14,6 +15,9 @@
class NightColorUtil : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
public:

View file

@ -6,7 +6,7 @@
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
import org.kde.plasma.quicksetting.nightcolor 1.0 as NightColor
import org.kde.plasma.quicksetting.nightcolor as NightColor
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
QS.QuickSetting {

View file

@ -1,6 +0,0 @@
# SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
# SPDX-License-Identifier: GPL-2.0-or-later
module org.kde.plasma.quicksetting.nightcolor
plugin nightcolorplugin
classname NightColorPlugin