Changeset View
Changeset View
Standalone View
Standalone View
kcm/kcm.cpp
Show All 40 Lines | |||||
41 | #include "interfaces/devicesmodel.h" | 41 | #include "interfaces/devicesmodel.h" | ||
42 | #include "devicessortproxymodel.h" | 42 | #include "devicessortproxymodel.h" | ||
43 | #include "kdeconnect-version.h" | 43 | #include "kdeconnect-version.h" | ||
44 | 44 | | |||
45 | K_PLUGIN_FACTORY(KdeConnectKcmFactory, registerPlugin<KdeConnectKcm>();) | 45 | K_PLUGIN_FACTORY(KdeConnectKcmFactory, registerPlugin<KdeConnectKcm>();) | ||
46 | 46 | | |||
47 | static QString createId() { return QStringLiteral("kcm")+QString::number(QCoreApplication::applicationPid()); } | 47 | static QString createId() { return QStringLiteral("kcm")+QString::number(QCoreApplication::applicationPid()); } | ||
48 | 48 | | |||
49 | KdeConnectKcm::KdeConnectKcm(QWidget* parent, const QVariantList&) | 49 | KdeConnectKcm::KdeConnectKcm(QWidget* parent, const QVariantList& args) | ||
50 | : KCModule(KAboutData::pluginData(QStringLiteral("kdeconnect-kcm")), parent) | 50 | : KCModule(KAboutData::pluginData(QStringLiteral("kdeconnect-kcm")), parent) | ||
51 | , kcmUi(new Ui::KdeConnectKcmUi()) | 51 | , kcmUi(new Ui::KdeConnectKcmUi()) | ||
52 | , daemon(new DaemonDbusInterface(this)) | 52 | , daemon(new DaemonDbusInterface(this)) | ||
53 | , devicesModel(new DevicesModel(this)) | 53 | , devicesModel(new DevicesModel(this)) | ||
54 | , currentDevice(nullptr) | 54 | , currentDevice(nullptr) | ||
55 | { | 55 | { | ||
56 | KAboutData* about = new KAboutData(QStringLiteral("kdeconnect-kcm"), | 56 | KAboutData* about = new KAboutData(QStringLiteral("kdeconnect-kcm"), | ||
57 | i18n("KDE Connect Settings"), | 57 | i18n("KDE Connect Settings"), | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
110 | connect(kcmUi->rename_edit,&QLineEdit::returnPressed, | 110 | connect(kcmUi->rename_edit,&QLineEdit::returnPressed, | ||
111 | this, &KdeConnectKcm::renameDone); | 111 | this, &KdeConnectKcm::renameDone); | ||
112 | connect(kcmUi->renameDone_button,&QAbstractButton::clicked, | 112 | connect(kcmUi->renameDone_button,&QAbstractButton::clicked, | ||
113 | this, &KdeConnectKcm::renameDone); | 113 | this, &KdeConnectKcm::renameDone); | ||
114 | connect(kcmUi->renameShow_button,&QAbstractButton::clicked, | 114 | connect(kcmUi->renameShow_button,&QAbstractButton::clicked, | ||
115 | this, &KdeConnectKcm::renameShow); | 115 | this, &KdeConnectKcm::renameShow); | ||
116 | 116 | | |||
117 | daemon->acquireDiscoveryMode(createId()); | 117 | daemon->acquireDiscoveryMode(createId()); | ||
118 | | ||||
119 | if (!args.isEmpty() && args.first().type() == QVariant::String) { | ||||
120 | const QString input = args.first().toString(); | ||||
121 | const auto colonIdx = input.indexOf(QLatin1Char(':')); | ||||
122 | const QString deviceId = input.left(colonIdx); | ||||
nicolasfella: this would be args.first | |||||
123 | const QString pluginCM = colonIdx < 0 ? QString() : input.mid(colonIdx+1); | ||||
nicolasfella: And this args.second | |||||
124 | | ||||
125 | connect(devicesModel, &DevicesModel::rowsInserted, this, [this, deviceId, pluginCM]() { | ||||
126 | auto row = devicesModel->rowForDevice(deviceId); | ||||
127 | if (row >= 0) { | ||||
128 | const QModelIndex idx = sortProxyModel->mapFromSource(devicesModel->index(row)); | ||||
129 | kcmUi->deviceList->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect); | ||||
130 | } | ||||
131 | if (!pluginCM.isEmpty()) { | ||||
132 | kcmUi->pluginSelector->showConfiguration(pluginCM); | ||||
133 | } | ||||
134 | disconnect(devicesModel, &DevicesModel::rowsInserted, this, nullptr); | ||||
135 | }); | ||||
136 | } | ||||
118 | } | 137 | } | ||
119 | 138 | | |||
120 | void KdeConnectKcm::renameShow() | 139 | void KdeConnectKcm::renameShow() | ||
121 | { | 140 | { | ||
122 | setRenameMode(true); | 141 | setRenameMode(true); | ||
123 | } | 142 | } | ||
124 | 143 | | |||
125 | void KdeConnectKcm::renameDone() | 144 | void KdeConnectKcm::renameDone() | ||
▲ Show 20 Lines • Show All 248 Lines • Show Last 20 Lines |
this would be args.first