diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set(KDECONNECT_VERSION "${KDECONNECT_VERSION_MAJOR}.${KDECONNECT_VERSION_MINOR}.${KDECONNECT_VERSION_PATCH}") set(QT_MIN_VERSION "5.7.0") -set(KF5_MIN_VERSION "5.42.0") +set(KF5_MIN_VERSION "5.45.0") find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_SOURCE_DIR}/cmake) diff --git a/interfaces/devicesmodel.h b/interfaces/devicesmodel.h --- a/interfaces/devicesmodel.h +++ b/interfaces/devicesmodel.h @@ -71,6 +71,7 @@ Q_SCRIPTABLE DeviceDbusInterface* getDevice(int row) const; QHash roleNames() const override; + int rowForDevice(const QString& id) const; private Q_SLOTS: void deviceAdded(const QString& id); @@ -84,7 +85,6 @@ void rowsChanged(); private: - int rowForDevice(const QString& id) const; void clearDevices(); void appendDevice(DeviceDbusInterface* dev); bool passesFilter(DeviceDbusInterface* dev) const; diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -46,7 +46,7 @@ static QString createId() { return QStringLiteral("kcm")+QString::number(QCoreApplication::applicationPid()); } -KdeConnectKcm::KdeConnectKcm(QWidget* parent, const QVariantList&) +KdeConnectKcm::KdeConnectKcm(QWidget* parent, const QVariantList& args) : KCModule(KAboutData::pluginData(QStringLiteral("kdeconnect-kcm")), parent) , kcmUi(new Ui::KdeConnectKcmUi()) , daemon(new DaemonDbusInterface(this)) @@ -115,6 +115,25 @@ this, &KdeConnectKcm::renameShow); daemon->acquireDiscoveryMode(createId()); + + if (!args.isEmpty() && args.first().type() == QVariant::String) { + const QString input = args.first().toString(); + const auto colonIdx = input.indexOf(QLatin1Char(':')); + const QString deviceId = input.left(colonIdx); + const QString pluginCM = colonIdx < 0 ? QString() : input.mid(colonIdx+1); + + connect(devicesModel, &DevicesModel::rowsInserted, this, [this, deviceId, pluginCM]() { + auto row = devicesModel->rowForDevice(deviceId); + if (row >= 0) { + const QModelIndex idx = sortProxyModel->mapFromSource(devicesModel->index(row)); + kcmUi->deviceList->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect); + } + if (!pluginCM.isEmpty()) { + kcmUi->pluginSelector->showConfiguration(pluginCM); + } + disconnect(devicesModel, &DevicesModel::rowsInserted, this, nullptr); + }); + } } void KdeConnectKcm::renameShow() diff --git a/plugins/runcommand/runcommandplugin.cpp b/plugins/runcommand/runcommandplugin.cpp --- a/plugins/runcommand/runcommandplugin.cpp +++ b/plugins/runcommand/runcommandplugin.cpp @@ -68,6 +68,8 @@ qCInfo(KDECONNECT_PLUGIN_RUNCOMMAND) << "Running:" << "/bin/sh" << "-c" << commandJson[QStringLiteral("command")].toString(); QProcess::startDetached(QStringLiteral("/bin/sh"), QStringList()<< QStringLiteral("-c") << commandJson[QStringLiteral("command")].toString()); return true; + } else if (np.has("setup")) { + QProcess::startDetached(QStringLiteral("kcmshell5"), {QStringLiteral("kdeconnect"), QStringLiteral("--args"), QString(device()->id() + QStringLiteral(":kdeconnect_runcommand")) }); } return false; @@ -83,6 +85,7 @@ { QString commands = config()->get(QStringLiteral("commands"),QStringLiteral("{}")); NetworkPacket np(PACKET_TYPE_RUNCOMMAND, {{"commandList", commands}}); + np.set(QStringLiteral("canAddCommand"), true); sendPacket(np); }