Skip to content

Commit 49e2489

Browse files
authored
[KDE_PLUGIN] Added KDE 5 support (#3987)
1 parent 6656708 commit 49e2489

2 files changed

Lines changed: 42 additions & 15 deletions

File tree

CMakeLists.txt

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ option(BOX32_BINFMT "Also setup binfmt integration for box32" ${BOX32_BINFMT})
4949
option(LARCH64_ABI_1 "Set to ON if building for Loongarch64 ABI 1.0 system" ${LARCH64_ABI_1})
5050
option(GDBJIT "Set to ON to enable GDB JIT support" ${GDBJIT})
5151
option(WOW64 "Set to ON if you want a WOW64 PE build in addition")
52-
option(BOX64_KDE_PROFILE_PLUGIN "Build the Dolphin/KIO Box64 profile context menu plugin when KF6 is available" OFF)
52+
option(BOX64_KDE_PROFILE_PLUGIN "Build the Dolphin/KIO Box64 profile properties plugin when KF5 or KF6 is available" OFF)
5353

5454
if(TERMUX)
5555
set(TERMUX_PATH "/data/data/com.termux/files")
@@ -1431,42 +1431,57 @@ if(NOT _x86 AND NOT _x86_64)
14311431
check_language(CXX)
14321432
if(CMAKE_CXX_COMPILER)
14331433
enable_language(CXX)
1434-
set(QT_DEFAULT_MAJOR_VERSION 6)
14351434
find_package(ECM QUIET NO_MODULE)
14361435
if(ECM_FOUND)
14371436
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
1438-
include(KDEInstallDirs6 OPTIONAL)
1437+
set(_BOX64_KDE_PROFILE_PLUGIN_KF_MAJOR "")
1438+
1439+
set(QT_DEFAULT_MAJOR_VERSION 6)
14391440
find_package(Qt6 QUIET COMPONENTS Core Widgets)
14401441
find_package(KF6CoreAddons QUIET)
14411442
find_package(KF6KIO QUIET)
14421443
if(Qt6_FOUND AND Qt6Widgets_FOUND AND KF6CoreAddons_FOUND AND KF6KIO_FOUND)
1444+
include(KDEInstallDirs6)
1445+
set(_BOX64_KDE_PROFILE_PLUGIN_KF_MAJOR 6)
1446+
set(_BOX64_KDE_PROFILE_PLUGIN_QT_WIDGETS_TARGET Qt6::Widgets)
1447+
set(_BOX64_KDE_PROFILE_PLUGIN_KIO_WIDGETS_TARGET KF6::KIOWidgets)
1448+
set(_BOX64_KDE_PROFILE_PLUGIN_INSTALL_NAMESPACE "kf6/propertiesdialog")
1449+
else()
1450+
set(QT_DEFAULT_MAJOR_VERSION 5)
1451+
find_package(Qt5 QUIET COMPONENTS Core Widgets)
1452+
find_package(KF5CoreAddons QUIET)
1453+
find_package(KF5KIO QUIET)
1454+
if(Qt5_FOUND AND Qt5Widgets_FOUND AND KF5CoreAddons_FOUND AND KF5KIO_FOUND)
1455+
include(KDEInstallDirs5)
1456+
set(_BOX64_KDE_PROFILE_PLUGIN_KF_MAJOR 5)
1457+
set(_BOX64_KDE_PROFILE_PLUGIN_QT_WIDGETS_TARGET Qt5::Widgets)
1458+
set(_BOX64_KDE_PROFILE_PLUGIN_KIO_WIDGETS_TARGET KF5::KIOWidgets)
1459+
set(_BOX64_KDE_PROFILE_PLUGIN_INSTALL_NAMESPACE "kf5/propertiesdialog")
1460+
endif()
1461+
endif()
1462+
1463+
if(_BOX64_KDE_PROFILE_PLUGIN_KF_MAJOR)
14431464
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
14441465
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
14451466
endif()
1446-
if(DEFINED QT6_INSTALL_PREFIX AND DEFINED QT6_INSTALL_PLUGINS
1447-
AND NOT QT6_INSTALL_PREFIX STREQUAL "" AND NOT QT6_INSTALL_PLUGINS STREQUAL "")
1448-
set(KDE_INSTALL_PLUGINDIR "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_PLUGINS}")
1449-
elseif(DEFINED QT6_INSTALL_PLUGINS AND NOT QT6_INSTALL_PLUGINS STREQUAL "")
1450-
set(KDE_INSTALL_PLUGINDIR "${QT6_INSTALL_PLUGINS}")
1451-
elseif(NOT DEFINED KDE_INSTALL_PLUGINDIR OR KDE_INSTALL_PLUGINDIR STREQUAL "")
1452-
set(KDE_INSTALL_PLUGINDIR "lib/qt6/plugins")
1453-
endif()
14541467
set(_BOX64_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
14551468
set(BUILD_SHARED_LIBS ON)
14561469
kcoreaddons_add_plugin(box64_profile_propertiesplugin
14571470
SOURCES ${CMAKE_SOURCE_DIR}/system/kde/box64_profile_propertiesplugin.cpp
1458-
INSTALL_NAMESPACE "kf6/propertiesdialog")
1471+
INSTALL_NAMESPACE "${_BOX64_KDE_PROFILE_PLUGIN_INSTALL_NAMESPACE}")
14591472
set(BUILD_SHARED_LIBS ${_BOX64_BUILD_SHARED_LIBS})
1460-
target_link_libraries(box64_profile_propertiesplugin PRIVATE KF6::KIOWidgets Qt6::Widgets)
1473+
target_link_libraries(box64_profile_propertiesplugin PRIVATE
1474+
${_BOX64_KDE_PROFILE_PLUGIN_KIO_WIDGETS_TARGET}
1475+
${_BOX64_KDE_PROFILE_PLUGIN_QT_WIDGETS_TARGET})
14611476
set_target_properties(box64_profile_propertiesplugin PROPERTIES
14621477
AUTOMOC ON
14631478
PREFIX ""
14641479
CXX_STANDARD 17
14651480
CXX_STANDARD_REQUIRED ON
14661481
CXX_EXTENSIONS OFF)
1467-
message(STATUS "Building Box64 profile properties dialog plugin")
1482+
message(STATUS "Building Box64 profile properties dialog plugin for KF${_BOX64_KDE_PROFILE_PLUGIN_KF_MAJOR}")
14681483
else()
1469-
message(STATUS "Dolphin/KIO Box64 profile plugin disabled: missing Qt6/KF6 KIO development packages")
1484+
message(STATUS "Dolphin/KIO Box64 profile plugin disabled: missing Qt5/KF5 or Qt6/KF6 KIO development packages")
14701485
endif()
14711486
else()
14721487
message(STATUS "Dolphin/KIO Box64 profile plugin disabled: ECM not found")

system/kde/box64_profile_propertiesplugin.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include <KPluginFactory>
44

5+
#include <kio_version.h>
6+
57
#include <QByteArray>
68
#include <QComboBox>
79
#include <QFile>
@@ -18,6 +20,7 @@
1820
#include <QStandardPaths>
1921
#include <QString>
2022
#include <QUrl>
23+
#include <QVariantList>
2124
#include <QVBoxLayout>
2225
#include <QWidget>
2326

@@ -247,7 +250,11 @@ class Box64ProfilePropertiesPlugin : public KPropertiesDialogPlugin {
247250

248251
public:
249252
explicit Box64ProfilePropertiesPlugin(QObject *parent = nullptr)
253+
#if KIO_VERSION_MAJOR < 6
254+
: KPropertiesDialogPlugin(qobject_cast<KPropertiesDialog *>(parent))
255+
#else
250256
: KPropertiesDialogPlugin(parent)
257+
#endif
251258
, m_command(configuratorCommand())
252259
{
253260
const KFileItemList items = properties->items();
@@ -332,6 +339,11 @@ class Box64ProfilePropertiesPlugin : public KPropertiesDialogPlugin {
332339
properties->addPage(page, localizedText("Box64", "Box64"));
333340
}
334341

342+
Box64ProfilePropertiesPlugin(QObject *parent, const QVariantList &)
343+
: Box64ProfilePropertiesPlugin(parent)
344+
{
345+
}
346+
335347
void applyChanges() override
336348
{
337349
if (m_path.isEmpty()) {

0 commit comments

Comments
 (0)