File indexing completed on 2024-05-12 03:54:09

0001 /*
0002     SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "kcmlauncher_p.h"
0008 
0009 #include <KIO/CommandLauncherJob>
0010 #include <KService>
0011 
0012 void KCMLauncher::open(const QStringList &names) const
0013 {
0014     KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(QStringLiteral("kcmshell6"), names);
0015     job->start();
0016 }
0017 
0018 void KCMLauncher::openSystemSettings(const QString &name, const QStringList &args) const
0019 {
0020     // The desktop filename is the same as the binary and icon
0021     const QString systemSettings = QStringLiteral("systemsettings");
0022     KIO::CommandLauncherJob *job = nullptr;
0023 
0024     QStringList cmdline{name};
0025     if (!args.isEmpty()) {
0026         cmdline.append(QStringLiteral("--args"));
0027         cmdline.append(args.join(QLatin1Char(' ')));
0028     }
0029 
0030     // Open in System Settings if it's available
0031     if (KService::serviceByDesktopName(systemSettings)) {
0032         job = new KIO::CommandLauncherJob(systemSettings, cmdline);
0033         job->setDesktopName(systemSettings);
0034     } else {
0035         job = new KIO::CommandLauncherJob(QStringLiteral("kcmshell6"), cmdline);
0036     }
0037 
0038     job->start();
0039 }
0040 
0041 void KCMLauncher::openInfoCenter(const QString &name) const
0042 {
0043     const QString infoCenterDesktopFile = QStringLiteral("org.kde.kinfocenter");
0044     const QString infoCenterbinary = QStringLiteral("kinfocenter");
0045 
0046     KIO::CommandLauncherJob *job = nullptr;
0047 
0048     // Open in Info Center if it's available
0049     if (KService::serviceByDesktopName(infoCenterDesktopFile)) {
0050         job = new KIO::CommandLauncherJob(infoCenterbinary, QStringList(name));
0051         job->setDesktopName(infoCenterDesktopFile);
0052     } else {
0053         job = new KIO::CommandLauncherJob(QStringLiteral("kcmshell6"), QStringList(name));
0054     }
0055 
0056     job->start();
0057 }
0058 
0059 #include "moc_kcmlauncher_p.cpp"