Skip to content

Commit

Permalink
Make it build against Qt 6 and KF 6
Browse files Browse the repository at this point in the history
  • Loading branch information
kbroulik committed Dec 18, 2023
1 parent e765f4f commit 77eb7be
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 12 deletions.
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 Declarative)

if (QT_MAJOR_VERSION STREQUAL "6")
find_package(KF${QT_MAJOR_VERSION} ${KF_MIN_VERSION} REQUIRED COMPONENTS KCMUtils)
else()
find_package(KF${QT_MAJOR_VERSION} ${KF_MIN_VERSION} REQUIRED COMPONENTS Package)
endif()

find_package(Qt${QT_MAJOR_VERSION}QuickControls2 ${QT_MIN_VERSION})
set_package_properties(Qt${QT_MAJOR_VERSION}QuickControls2 PROPERTIES
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
24 changes: 17 additions & 7 deletions src/infocenter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
# SPDX-License-Identifier: BSD-2-Clause
# SPDX-FileCopyrightText: 2023 Kai Uwe Broulik <ghqalpha@broulik.de>

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"
)
plasma/kcms/kinfocenter
)

target_link_libraries(kcm_qalphacloud KF6::KCMUtilsQuick)
else()
kcoreaddons_add_plugin(kcm_qalphacloud SOURCES
kcm.cpp
kcm.h
)

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)
9 changes: 9 additions & 0 deletions src/infocenter/kcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,21 @@ QVariant BatterySocScaleProxyModel::data(const QModelIndex &index, int role) con
return batterySoc * m_factor;
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
KCMAlphaCloud::KCMAlphaCloud(QObject *parent, const KPluginMetaData &data)
: KQuickConfigModule(parent, data)
#else
KCMAlphaCloud::KCMAlphaCloud(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: KQuickAddons::ConfigModule(parent, data, args)
#endif
{
qmlRegisterType<BatterySocScaleProxyModel>("de.broulik.qalphacloud.private.kcm", 1, 0, "BatterySocScaleProxyModel");

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
setButtons(KQuickConfigModule::NoAdditionalButton);
#else
setButtons(KQuickAddons::ConfigModule::NoAdditionalButton);
#endif
}

bool KCMAlphaCloud::presentationBuild() const
Expand Down
16 changes: 15 additions & 1 deletion src/infocenter/kcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@

#pragma once

#include <qglobal.h>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <KQuickConfigModule>
#else
#include <KQuickAddons/ConfigModule>
#endif

#include <QIdentityProxyModel>

Expand All @@ -30,14 +36,22 @@ class BatterySocScaleProxyModel : public QIdentityProxyModel
qreal m_factor = 0;
};

class KCMAlphaCloud : public KQuickAddons::ConfigModule
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
class KCMAlphaCloud : public KQuickConfigModule
#else
class KCMAlphaCloud : public KQuickConfigModule
#endif
{
Q_OBJECT

Q_PROPERTY(bool presentationBuild READ presentationBuild CONSTANT)

public:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
explicit KCMAlphaCloud(QObject *parent, const KPluginMetaData &metaData);
#else
explicit KCMAlphaCloud(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
#endif

bool presentationBuild() const;
};

0 comments on commit 77eb7be

Please sign in to comment.