Changeset View
Changeset View
Standalone View
Standalone View
dataengines/konsoleprofiles/konsoleprofilesservice.cpp
Show All 13 Lines | |||||
14 | * * | 14 | * * | ||
15 | * You should have received a copy of the GNU General Public License * | 15 | * You should have received a copy of the GNU General Public License * | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * | ||
17 | *****************************************************************************/ | 17 | *****************************************************************************/ | ||
18 | 18 | | |||
19 | #include "konsoleprofilesservice.h" | 19 | #include "konsoleprofilesservice.h" | ||
20 | 20 | | |||
21 | #include <QMap> | 21 | #include <QMap> | ||
22 | #include <KToolInvocation> | | |||
23 | #include <QDebug> | 22 | #include <QDebug> | ||
24 | 23 | | |||
24 | #include <KNotificationJobUiDelegate> | ||||
25 | #include <KShell> | ||||
26 | | ||||
27 | #include <KIO/CommandLauncherJob> | ||||
28 | | ||||
25 | KonsoleProfilesService::KonsoleProfilesService(QObject* parent, const QString& profileName) | 29 | KonsoleProfilesService::KonsoleProfilesService(QObject* parent, const QString& profileName) | ||
26 | : Plasma::Service(parent) | 30 | : Plasma::Service(parent) | ||
27 | { | 31 | { | ||
28 | setName(QStringLiteral("org.kde.plasma.dataengine.konsoleprofiles")); | 32 | setName(QStringLiteral("org.kde.plasma.dataengine.konsoleprofiles")); | ||
29 | setDestination(profileName); | 33 | setDestination(profileName); | ||
30 | } | 34 | } | ||
31 | 35 | | |||
32 | Plasma::ServiceJob* KonsoleProfilesService::createJob(const QString& operation, QMap<QString,QVariant>& parameters) | 36 | Plasma::ServiceJob* KonsoleProfilesService::createJob(const QString& operation, QMap<QString,QVariant>& parameters) | ||
Show All 11 Lines | 47 | { | |||
44 | //destination is the profile name, operation is e.g. "open" | 48 | //destination is the profile name, operation is e.g. "open" | ||
45 | // QMap<QString, QVariant>jobParameters = parameters(); | 49 | // QMap<QString, QVariant>jobParameters = parameters(); | ||
46 | const QString operation = operationName(); | 50 | const QString operation = operationName(); | ||
47 | 51 | | |||
48 | qDebug() << "SERVICE START...operation: " << operation << " dest: " << destination(); | 52 | qDebug() << "SERVICE START...operation: " << operation << " dest: " << destination(); | ||
49 | if (operation == QLatin1String("open")) { | 53 | if (operation == QLatin1String("open")) { | ||
50 | // Q_ASSERT(!jobParameters.isEmpty()); | 54 | // Q_ASSERT(!jobParameters.isEmpty()); | ||
51 | 55 | | |||
52 | QStringList args; | 56 | // Would be nice if we could just return this in createJob above | ||
53 | args << QStringLiteral("--profile") << destination(); | 57 | auto *job = new KIO::CommandLauncherJob(QStringLiteral("konsole --profile %1").arg(KShell::quoteArg(destination()))); | ||
54 | KToolInvocation::kdeinitExec(QStringLiteral("konsole"), args); | 58 | job->setDesktopName(QStringLiteral("org.kde.konsole")); | ||
59 | | ||||
60 | auto *delegate = new KNotificationJobUiDelegate; | ||||
61 | delegate->setAutoErrorHandlingEnabled(true); | ||||
62 | job->setUiDelegate(delegate); | ||||
63 | | ||||
64 | connect(job, &KIO::CommandLauncherJob::result, this, [this, job] { | ||||
65 | setError(job->error()); | ||||
66 | setErrorText(job->errorText()); | ||||
67 | emitResult(); | ||||
68 | }); | ||||
55 | 69 | | |||
56 | setResult(true); | 70 | job->start(); | ||
57 | } | 71 | } | ||
58 | } | 72 | } | ||
59 | 73 | |