diff --git a/CMakeLists.txt b/CMakeLists.txt index 11d0794..87b37b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include(FeatureSummary) -find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) +find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://invent.kde.org/frameworks/extra-cmake-modules") @@ -72,7 +72,13 @@ if (BUILD_KSYSTEMSTATS) endif() if (BUILD_KINFOCENTER) - find_package(KF${QT_MAJOR_VERSION} ${KF_MIN_VERSION} REQUIRED COMPONENTS CoreAddons Declarative Package) + find_package(KF${QT_MAJOR_VERSION} ${KF_MIN_VERSION} REQUIRED COMPONENTS CoreAddons Package) + + if (QT_MAJOR_VERSION STREQUAL "6") + find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS KCMUtils) + else() + find_package(KF5 ${KF_MIN_VERSION} REQUIRED COMPONENTS Declarative) + endif() find_package(Qt${QT_MAJOR_VERSION}QuickControls2 ${QT_MIN_VERSION}) set_package_properties(Qt${QT_MAJOR_VERSION}QuickControls2 PROPERTIES diff --git a/README.md b/README.md index 57a6050..6b7b6d8 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,7 @@ The following development files are required (as well as their respective indire #### infocenter * KCoreAddons (from KDE Frameworks -* KDeclarative (from KDE Frameworks) +* KDeclarative (from KDE Frameworks 5) or KCMUtils (from KDE Frameworks 6) * KSysGuard (from KDE Plasma) * libsensors * QML module for Kirigami @@ -231,7 +231,6 @@ You can find examples for both C++ and QML in the [examples](examples/) director ## :building_construction: To Do -* The project should be prepared for a Qt 6 build, however this has not been attempted, specifically as KDE Frameworks 6 is still in development. * Running clang-tidy, clazy, and friends on CI * None of the EV-related readouts are implemented. * None of the charging configuration settings (`getChargeConfigInfo`, `updateChargeConfigInfo`, `getDisChargeConfigInfo`, `updateDisChargeConfigInfo`) can be read or altered. diff --git a/src/infocenter/CMakeLists.txt b/src/infocenter/CMakeLists.txt index c1520c9..ca10c36 100644 --- a/src/infocenter/CMakeLists.txt +++ b/src/infocenter/CMakeLists.txt @@ -1,17 +1,31 @@ # SPDX-License-Identifier: BSD-2-Clause # SPDX-FileCopyrightText: 2023 Kai Uwe Broulik -kcoreaddons_add_plugin(kcm_qalphacloud SOURCES +if(QT_MAJOR_VERSION STREQUAL "6") + kcmutils_add_qml_kcm(kcm_qalphacloud + DISABLE_DESKTOP_FILE_GENERATION + + SOURCES + kcm.cpp + kcm.h + + INSTALL_NAMESPACE + "plasma/kcms/kinfocenter" + ) + + target_link_libraries(kcm_qalphacloud KF6::KCMUtilsQuick) +else() + kcoreaddons_add_plugin(kcm_qalphacloud + SOURCES kcm.cpp kcm.h INSTALL_NAMESPACE "plasma/kcms/kinfocenter" -) + ) -target_link_libraries(kcm_qalphacloud - KF${QT_MAJOR_VERSION}::QuickAddons - QAlphaCloud -) + target_link_libraries(kcm_qalphacloud KF5::QuickAddons) +endif() +target_link_libraries(kcm_qalphacloud QAlphaCloud) kpackage_install_package(package kcm_qalphacloud kcms) diff --git a/src/infocenter/kcm.cpp b/src/infocenter/kcm.cpp index a039a99..5e300fc 100644 --- a/src/infocenter/kcm.cpp +++ b/src/infocenter/kcm.cpp @@ -48,11 +48,23 @@ QVariant BatterySocScaleProxyModel::data(const QModelIndex &index, int role) con } KCMAlphaCloud::KCMAlphaCloud(QObject *parent, const KPluginMetaData &data, const QVariantList &args) +#if QT_VERSION_MAJOR == 6 + : KQuickConfigModule(parent, data) +#else : KQuickAddons::ConfigModule(parent, data, args) +#endif { +#if QT_VERSION_MAJOR == 6 + Q_UNUSED(args); +#endif + qmlRegisterType("de.broulik.qalphacloud.private.kcm", 1, 0, "BatterySocScaleProxyModel"); +#if QT_VERSION_MAJOR == 6 + setButtons(KQuickConfigModule::NoAdditionalButton); +#else setButtons(KQuickAddons::ConfigModule::NoAdditionalButton); +#endif } bool KCMAlphaCloud::presentationBuild() const diff --git a/src/infocenter/kcm.h b/src/infocenter/kcm.h index d2214da..1ce0492 100644 --- a/src/infocenter/kcm.h +++ b/src/infocenter/kcm.h @@ -5,7 +5,13 @@ #pragma once +#include + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#else #include +#endif #include @@ -30,14 +36,18 @@ class BatterySocScaleProxyModel : public QIdentityProxyModel qreal m_factor = 0; }; +#if QT_VERSION_MAJOR == 6 +class KCMAlphaCloud : public KQuickConfigModule +#else class KCMAlphaCloud : public KQuickAddons::ConfigModule +#endif { Q_OBJECT Q_PROPERTY(bool presentationBuild READ presentationBuild CONSTANT) public: - explicit KCMAlphaCloud(QObject *parent, const KPluginMetaData &data, const QVariantList &args); + explicit KCMAlphaCloud(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args); bool presentationBuild() const; };