File: processrunner.cpp

package info (click to toggle)
plasma-workspace 4%3A6.3.6-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 104,900 kB
  • sloc: cpp: 125,434; xml: 31,579; python: 3,976; perl: 572; sh: 234; javascript: 74; ruby: 39; ansic: 13; makefile: 9
file content (41 lines) | stat: -rw-r--r-- 968 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
    SPDX-FileCopyrightText: 2013 Eike Hein <hein@kde.org>

    SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "processrunner.h"

#include <KIO/CommandLauncherJob>
#include <KNotificationJobUiDelegate>
#include <KService>

ProcessRunner::ProcessRunner(QObject *parent)
    : QObject(parent)
{
}

ProcessRunner::~ProcessRunner()
{
}

void ProcessRunner::runMenuEditor(QString arg)
{
    const auto service = KService::serviceByDesktopName(QStringLiteral("org.kde.kmenuedit"));

    if (!service) {
        qWarning() << "Could not find kmenuedit";
        return;
    }

    if (arg.isEmpty()) {
        arg = QStringLiteral("/"); // If already open, will collapse editor tree
    }

    auto *job = new KIO::CommandLauncherJob(service->exec(), {arg});
    job->setDesktopName(service->desktopEntryName());
    job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
    job->start();
}

#include "moc_processrunner.cpp"