[network/kdeconnect-kde] fileitemactionplugin: fileitemactionplugin: Don't offer sending to the same device
Kai Uwe Broulik <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit afdac225171717cbccd09c94d3b3aaa0ad1b71ea by Kai Uwe Broulik.
Committed on 26/07/2026 at 16:34.
Pushed by broulik into branch 'master'.
fileitemactionplugin: Don't offer sending to the same device
Now that we keep the kdeconnect://uri path in tact, we know which
device we're viewing and can avoid offering to send a file
to the same device.
M +10 -0 fileitemactionplugin/deviceactionjob.cpp
https://invent.kde.org/network/kdeconnect-kde/-/commit/afdac225171717cbccd09c94d3b3aaa0ad1b71ea
diff --git a/fileitemactionplugin/deviceactionjob.cpp b/fileitemactionplugin/deviceactionjob.cpp
index 8c5ec3993..ae3cdf8dd 100644
--- a/fileitemactionplugin/deviceactionjob.cpp
+++ b/fileitemactionplugin/deviceactionjob.cpp
@@ -18,6 +18,8 @@
#include <dbushelper.h>
+#include <algorithm>
+
#include "kdeconnect_fileitemaction_debug.h"
DeviceActionJob::DeviceActionJob(const QList<QUrl> &urls, QObject *parent)
@@ -156,6 +158,14 @@ void DeviceActionJob::onDeviceIconNameReplyFinished(QDBusPendingCallWatcher *wat
void DeviceActionJob::finalizeActions()
{
for (const auto &[deviceId, device] : std::as_const(m_devices).asKeyValueRange()) {
+ // Don't offer "Send to" the same device.
+ const bool urlIsSameDevice = std::all_of(m_urls.cbegin(), m_urls.cend(), [&deviceId](const QUrl &url) {
+ return url.scheme() == QLatin1String("kdeconnect") && url.host() == deviceId;
+ });
+ if (urlIsSameDevice) {
+ continue;
+ }
+
QAction *action = new QAction(QIcon::fromTheme(device.iconName), device.name, m_actionParent);
action->setProperty("id", deviceId);
connect(action, &QAction::triggered, action, [deviceId, urls = m_urls] {