KCMUtils

kcmlauncher.cpp
1/*
2 SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "kcmlauncher_p.h"
8
9#include <KIO/CommandLauncherJob>
10#include <KService>
11
12void KCMLauncher::open(const QStringList &names) const
13{
14 KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(QStringLiteral("kcmshell6"), names);
15 job->start();
16}
17
18void KCMLauncher::openSystemSettings(const QString &name, const QStringList &args) const
19{
20 // The desktop filename is the same as the binary and icon
21 const QString systemSettings = QStringLiteral("systemsettings");
22 KIO::CommandLauncherJob *job = nullptr;
23
24 QStringList cmdline{name};
25 if (!args.isEmpty()) {
26 cmdline.append(QStringLiteral("--args"));
27 cmdline.append(args.join(QLatin1Char(' ')));
28 }
29
30 // Open in System Settings if it's available
31 if (KService::serviceByDesktopName(systemSettings)) {
32 job = new KIO::CommandLauncherJob(systemSettings, cmdline);
33 job->setDesktopName(systemSettings);
34 } else {
35 job = new KIO::CommandLauncherJob(QStringLiteral("kcmshell6"), cmdline);
36 }
37
38 job->start();
39}
40
41void KCMLauncher::openInfoCenter(const QString &name) const
42{
43 const QString infoCenterDesktopFile = QStringLiteral("org.kde.kinfocenter");
44 const QString infoCenterbinary = QStringLiteral("kinfocenter");
45
46 KIO::CommandLauncherJob *job = nullptr;
47
48 // Open in Info Center if it's available
49 if (KService::serviceByDesktopName(infoCenterDesktopFile)) {
50 job = new KIO::CommandLauncherJob(infoCenterbinary, QStringList(name));
51 job->setDesktopName(infoCenterDesktopFile);
52 } else {
53 job = new KIO::CommandLauncherJob(QStringLiteral("kcmshell6"), QStringList(name));
54 }
55
56 job->start();
57}
58
59#include "moc_kcmlauncher_p.cpp"
void setDesktopName(const QString &desktopName)
void start() override
static Ptr serviceByDesktopName(const QString &_name)
QString name(StandardShortcut id)
bool isEmpty() const const
QString & append(QChar ch)
QString join(QChar separator) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:56 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.