KDeclarative

kcmshell.cpp
1 /*
2  SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "kcmshell.h"
8 
9 #include <KAuthorized>
10 #include <KService>
11 
12 #include <KIO/CommandLauncherJob>
13 
14 KCMShell::KCMShell(QObject *parent) : QObject(parent)
15 {
16 
17 }
18 
19 KCMShell::~KCMShell()
20 {
21 
22 }
23 
24 void KCMShell::open(const QStringList &names) const
25 {
26  KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(QStringLiteral("kcmshell5"), names);
27  job->start();
28 }
29 
30 void KCMShell::openSystemSettings(const QString &name, const QStringList &args) const
31 {
32  const QString systemSettings = QStringLiteral("systemsettings");
33  KIO::CommandLauncherJob *job = nullptr;
34 
35  QStringList cmdline{name};
36  if (!args.isEmpty()) {
37  cmdline.append(QStringLiteral("--args"));
38  cmdline.append(args.join(QLatin1Char(' ')));
39  }
40 
41  // Open in System Settings if it's available'
42  if (KService::serviceByDesktopName(systemSettings)) {
43  job = new KIO::CommandLauncherJob(QStringLiteral("systemsettings5"), cmdline);
44  job->setDesktopName(systemSettings);
45  } else {
46  job = new KIO::CommandLauncherJob(QStringLiteral("kcmshell5"), cmdline);
47  }
48 
49  job->start();
50 }
51 
52 void KCMShell::openInfoCenter(const QString &name) const
53 {
54  const QString systemSettings = QStringLiteral("systemsettings");
55  KIO::CommandLauncherJob *job = nullptr;
56 
57  // Open in Info Center if System Settings is available
58  if (KService::serviceByDesktopName(systemSettings)) {
59  job = new KIO::CommandLauncherJob(QStringLiteral("kinfocenter"), QStringList(name));
60  job->setIcon(systemSettings);
61  job->setDesktopName(systemSettings);
62  } else {
63  job = new KIO::CommandLauncherJob(QStringLiteral("kcmshell5"), QStringList(name));
64  }
65 
66  job->start();
67 }
68 
69 QStringList KCMShell::authorize(const QStringList &menuIds) const
70 {
72 }
QString & append(QChar ch)
static Ptr serviceByDesktopName(const QString &_name)
QString join(const QString &separator) const const
void start() override
KCONFIGCORE_EXPORT QStringList authorizeControlModules(const QStringList &menuIds)
bool isEmpty() const const
void setDesktopName(const QString &desktopName)
void setIcon(const QString &iconName)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 25 2021 22:44:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.