From 6849a4906d2928bb74b2836fb015efafa659e9d4 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Thu, 31 Oct 2019 16:35:32 +0200 Subject: [PATCH] drop ksysguard dependency for kf5>=5.62 --following plasma updates for tasktools in order to drop the ksysguard dependency which is also costly --- CMakeLists.txt | 6 ++-- README.md | 2 +- app/CMakeLists.txt | 72 ++++++++++++++++++++++++++++++-------------- app/wm/tasktools.cpp | 26 ++++++++++++---- 4 files changed, 74 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc3fd4b0c..c3b7ac46f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,8 +19,6 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED NO_MODULE COMPONENTS DBus Gui Qml Quick) -find_package(KF5 REQUIRED COMPONENTS SysGuard) - find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Activities Archive CoreAddons GuiAddons Crash DBusAddons Declarative GlobalAccel I18n IconThemes NewStuff Notifications Plasma PlasmaQuick Wayland WindowSystem XmlGui) @@ -53,6 +51,10 @@ string(REGEX REPLACE "\\." "" KF5_VERSION_MINOR ${KF5_VERSION_MINOR}) message(STATUS "KF5 VERSION : ${KF5_VERSION}") message(STATUS "KF5 VERSION MINOR : ${KF5_VERSION_MINOR}") +if(${KF5_VERSION_MINOR} LESS "62") +find_package(KF5 REQUIRED COMPONENTS SysGuard) +endif() + include(ECMQMLModules) ecm_find_qmlmodule(QtQuick 2.7) ecm_find_qmlmodule(QtQuick.Layouts 1.3) diff --git a/README.md b/README.md index 9d686467d..57741fdbf 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Minimum requirements: KF5GlobalAccel >= 5.38.0 KF5Crash >= 5.38.0 - KSysGuard + KSysGuard [reguired only for kf5<=5.61] For X11 support: KF5WindowSystem >= 5.38.0 diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 69fb1b74a..84bc32d9f 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -32,29 +32,55 @@ add_executable(latte-dock ${lattedock-app_SRCS}) include(FakeTarget.cmake) -target_link_libraries(latte-dock - Qt5::DBus - Qt5::Quick - Qt5::Qml - KF5::Activities - KF5::Archive - KF5::CoreAddons - KF5::Crash - KF5::DBusAddons - KF5::Declarative - KF5::GuiAddons - KF5::GlobalAccel - KF5::I18n - KF5::IconThemes - KF5::Notifications - KF5::NewStuff - KF5::QuickAddons - KF5::Plasma - KF5::PlasmaQuick - KF5::ProcessCore - KF5::WaylandClient - KF5::XmlGui -) +if(${KF5_VERSION_MINOR} LESS "62") + target_link_libraries(latte-dock + Qt5::DBus + Qt5::Quick + Qt5::Qml + KF5::Activities + KF5::Archive + KF5::CoreAddons + KF5::Crash + KF5::DBusAddons + KF5::Declarative + KF5::GuiAddons + KF5::GlobalAccel + KF5::I18n + KF5::IconThemes + KF5::Notifications + KF5::NewStuff + KF5::QuickAddons + KF5::Plasma + KF5::PlasmaQuick + KF5::ProcessCore + KF5::WaylandClient + KF5::XmlGui + ) +else() + target_link_libraries(latte-dock + Qt5::DBus + Qt5::Quick + Qt5::Qml + KF5::Activities + KF5::Archive + KF5::CoreAddons + KF5::Crash + KF5::DBusAddons + KF5::Declarative + KF5::GuiAddons + KF5::GlobalAccel + KF5::I18n + KF5::IconThemes + KF5::Notifications + KF5::NewStuff + KF5::QuickAddons + KF5::Plasma + KF5::PlasmaQuick + KF5::WaylandClient + KF5::XmlGui + ) + +endif() if(HAVE_X11) target_link_libraries(latte-dock diff --git a/app/wm/tasktools.cpp b/app/wm/tasktools.cpp index 1d624a186..6c40ef6f3 100644 --- a/app/wm/tasktools.cpp +++ b/app/wm/tasktools.cpp @@ -16,23 +16,24 @@ License along with this library. If not, see . *********************************************************************/ #include "tasktools.h" +#include #include #include #include #include -//#include #include -//#include #include #include #include #include -#include -#include - -#include +#if KF5_VERSION_MINOR >= 62 + #include +#else + #include + #include +#endif #include #include @@ -503,17 +504,30 @@ KService::List servicesFromPid(quint32 pid, KSharedConfig::Ptr rulesConfig) return KService::List(); } +#if KF5_VERSION_MINOR >= 62 + auto proc = KProcessList::processInfo(pid); + if (!proc.isValid()) { + return KService::List(); + } + + const QString cmdLine = proc.command(); +#else KSysGuard::Processes procs; procs.updateOrAddProcess(pid); KSysGuard::Process *proc = procs.getProcess(pid); const QString &cmdLine = proc ? proc->command().simplified() : QString(); // proc->command has a trailing space??? +#endif if (cmdLine.isEmpty()) { return KService::List(); } +#if KF5_VERSION_MINOR >= 63 + return servicesFromCmdLine(cmdLine, proc.name(), rulesConfig); +#else return servicesFromCmdLine(cmdLine, proc->name(), rulesConfig); +#endif } KService::List servicesFromCmdLine(const QString &_cmdLine, const QString &processName,