File indexing completed on 2024-04-28 08:49:02

0001 /**
0002  * SPDX-FileCopyrightText: 2022 Nicolas Fella <nicolas.fella@gmx.de>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #include "openconfig.h"
0008 
0009 #include <QDebug>
0010 
0011 #include <KIO/CommandLauncherJob>
0012 
0013 void OpenConfig::setXdgActivationToken(const QString &token)
0014 {
0015     m_currentToken = token;
0016 }
0017 
0018 void OpenConfig::openConfiguration(const QString &deviceId, const QString &pluginId)
0019 {
0020     QStringList args;
0021 
0022     QString argument;
0023 
0024     if (!deviceId.isEmpty()) {
0025         args << QStringLiteral("--args");
0026         argument = deviceId;
0027 
0028         if (!pluginId.isEmpty()) {
0029             argument += QLatin1Char(':') + pluginId;
0030         }
0031 
0032         args << argument;
0033     }
0034 
0035     auto job = new KIO::CommandLauncherJob(QStringLiteral("kdeconnect-settings"), args);
0036     job->setDesktopName(QStringLiteral("org.kde.kdeconnect-settings"));
0037     job->setStartupId(m_currentToken.toUtf8());
0038     job->start();
0039 
0040     m_currentToken = QString();
0041 }
0042 
0043 #include "moc_openconfig.cpp"