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);
|
this);
|
||||||
|
|
||||||
// Send file
|
// Send file
|
||||||
const QString kdeconnectHandlerExecutable = QStandardPaths::findExecutable(QStringLiteral("kdeconnect-handler"), {QCoreApplication::applicationDirPath()});
|
auto sendFile = addAction(QIcon::fromTheme(QStringLiteral("document-share")), i18n("Send files"));
|
||||||
if (!kdeconnectHandlerExecutable.isEmpty()) {
|
connect(sendFile, &QAction::triggered, device, [device, this]() {
|
||||||
auto handlerApp = addAction(QIcon::fromTheme(QStringLiteral("document-share")), i18n("Send a file/URL"));
|
const QList<QUrl> urls = QFileDialog::getOpenFileUrls(this);
|
||||||
QObject::connect(handlerApp, &QAction::triggered, device, [device, kdeconnectHandlerExecutable]() {
|
if (!urls.isEmpty()) {
|
||||||
QProcess::startDetached(kdeconnectHandlerExecutable, {QStringLiteral("--device"), device->id()});
|
QStringList urlsAsQStringList;
|
||||||
});
|
for (const QUrl &url : urls)
|
||||||
handlerApp->setVisible(true);
|
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
|
// SMS Messages
|
||||||
const QString kdeconnectsmsExecutable = QStandardPaths::findExecutable(QStringLiteral("kdeconnect-sms"), {QCoreApplication::applicationDirPath()});
|
const QString kdeconnectsmsExecutable = QStandardPaths::findExecutable(QStringLiteral("kdeconnect-sms"), {QCoreApplication::applicationDirPath()});
|
||||||
|
|
Loading…
Reference in a new issue