indicator: Simplify sending files from systray icon
Implements https://invent.kde.org/network/kdeconnect-meta/-/issues/10
This commit is contained in:
parent
bb146a76d0
commit
61e7d8f2f3
1 changed files with 18 additions and 8 deletions
|
@ -92,14 +92,24 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface *device)
|
|||
this);
|
||||
|
||||
// Send file
|
||||
const QString kdeconnectHandlerExecutable = QStandardPaths::findExecutable(QStringLiteral("kdeconnect-handler"), {QCoreApplication::applicationDirPath()});
|
||||
if (!kdeconnectHandlerExecutable.isEmpty()) {
|
||||
auto handlerApp = addAction(QIcon::fromTheme(QStringLiteral("document-share")), i18n("Send a file/URL"));
|
||||
QObject::connect(handlerApp, &QAction::triggered, device, [device, kdeconnectHandlerExecutable]() {
|
||||
QProcess::startDetached(kdeconnectHandlerExecutable, {QStringLiteral("--device"), device->id()});
|
||||
});
|
||||
handlerApp->setVisible(true);
|
||||
}
|
||||
auto sendFile = addAction(QIcon::fromTheme(QStringLiteral("document-share")), i18n("Send files"));
|
||||
connect(sendFile, &QAction::triggered, device, [device, this]() {
|
||||
const QList<QUrl> urls = QFileDialog::getOpenFileUrls(this);
|
||||
if (!urls.isEmpty()) {
|
||||
QStringList urlsAsQStringList;
|
||||
for (const QUrl &url : urls)
|
||||
urlsAsQStringList.append(url.toString());
|
||||
ShareDbusInterface *iface = new ShareDbusInterface(device->id(), device);
|
||||
iface->shareUrls(urlsAsQStringList);
|
||||
iface->deleteLater();
|
||||
}
|
||||
});
|
||||
setWhenAvailable(
|
||||
device->hasPlugin(QStringLiteral("kdeconnect_share")),
|
||||
[sendFile](bool available) {
|
||||
sendFile->setVisible(available);
|
||||
},
|
||||
this);
|
||||
|
||||
// SMS Messages
|
||||
const QString kdeconnectsmsExecutable = QStandardPaths::findExecutable(QStringLiteral("kdeconnect-sms"), {QCoreApplication::applicationDirPath()});
|
||||
|
|
Loading…
Reference in a new issue