| 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 | |
| 12 | void KCMLauncher::open(const QStringList &names) const |
| 13 | { |
| 14 | KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(QStringLiteral("kcmshell6" ), names); |
| 15 | job->start(); |
| 16 | } |
| 17 | |
| 18 | void 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(t: args.join(sep: QLatin1Char(' '))); |
| 28 | } |
| 29 | |
| 30 | // Open in System Settings if it's available |
| 31 | if (KService::serviceByDesktopName(name: 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 | |
| 41 | void 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(name: 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" |
| 60 | |