File 0002-Use-platform-detection-from-KWorkSpace-in-KCMShell.patch of Package kde-cli-tools5

From cc5f6765b3e25f411120d2100fb14f0d69de75a1 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Tue, 27 Mar 2018 09:24:09 +0200
Subject: [PATCH 2/3] Use platform detection from KWorkSpace in KCMShell

Summary: In a Wayland session, KCMs need to use the wayland platform plugin.

Test Plan: kcmshell5 kscreen now works properly.

Reviewers: #plasma, romangg

Reviewed By: #plasma, romangg

Subscribers: romangg, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D11739
---
 CMakeLists.txt          | 2 ++
 kcmshell/CMakeLists.txt | 1 +
 kcmshell/main.cpp       | 8 ++++++++
 3 files changed, 11 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 26d5e7e..0c04e8d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,6 +50,8 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
     QUIET
 )
 
+find_package(LibKWorkspace ${PROJECT_VERSION} REQUIRED)
+
 # Disables automatic conversions from QString (or char *) to QUrl.
 add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
 
diff --git a/kcmshell/CMakeLists.txt b/kcmshell/CMakeLists.txt
index f787136..7c33290 100644
--- a/kcmshell/CMakeLists.txt
+++ b/kcmshell/CMakeLists.txt
@@ -11,6 +11,7 @@ target_link_libraries(kdeinit_kcmshell5
    KF5::I18n
    KF5::WindowSystem
    KF5::Activities
+   PW::KWorkspace
 )
 
 install(TARGETS kdeinit_kcmshell5  ${INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/kcmshell/main.cpp b/kcmshell/main.cpp
index 93dd6f8..d855b96 100644
--- a/kcmshell/main.cpp
+++ b/kcmshell/main.cpp
@@ -40,6 +40,8 @@
 #include <KStartupInfo>
 #include <KActivities/ResourceInstance>
 
+#include <kworkspace.h>
+
 #include <QIcon>
 #include <QCommandLineParser>
 #include <QCommandLineOption>
@@ -173,7 +175,13 @@ void KCMShell::appExit(const QString &appId, const QString &oldName, const QStri
 
 extern "C" Q_DECL_EXPORT int kdemain(int _argc, char *_argv[])
 {
+    const bool qpaVariable = qEnvironmentVariableIsSet("QT_QPA_PLATFORM");
+    KWorkSpace::detectPlatform(argc, argv);
     KCMShell app(_argc, _argv);
+    if (!qpaVariable) {
+        // don't leak the env variable to processes we start
+        qunsetenv("QT_QPA_PLATFORM");
+    }
     KLocalizedString::setApplicationDomain("kcmshell5");
 
     app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
-- 
2.16.2

openSUSE Build Service is sponsored by