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 696d055 commit 3ffa8cc
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 11 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 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
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
26 changes: 20 additions & 6 deletions src/infocenter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
# SPDX-License-Identifier: BSD-2-Clause
# SPDX-FileCopyrightText: 2023 Kai Uwe Broulik <[email protected]>

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)
12 changes: 12 additions & 0 deletions src/infocenter/kcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<BatterySocScaleProxyModel>("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
Expand Down
12 changes: 11 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,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;
};

0 comments on commit 3ffa8cc

Please sign in to comment.