From 28aa9a516c57b8967e07bc137f75f86a8af16791 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 9 Apr 2022 14:52:00 +0200 Subject: [PATCH] Have directory ID still accessible in recent changes despite showing name Show it as tool tip and allow copying it via the context menu --- model/syncthingrecentchangesmodel.cpp | 2 ++ plasmoid/package/contents/ui/RecentChangesPage.qml | 8 ++++++++ tray/gui/traywidget.cpp | 3 +++ 3 files changed, 13 insertions(+) diff --git a/model/syncthingrecentchangesmodel.cpp b/model/syncthingrecentchangesmodel.cpp index 90795c1..db0485c 100644 --- a/model/syncthingrecentchangesmodel.cpp +++ b/model/syncthingrecentchangesmodel.cpp @@ -120,6 +120,8 @@ QVariant SyncthingRecentChangesModel::data(const QModelIndex &index, int role) c % QString::fromStdString(change.fileChange.eventTime.toString(DateTimeOutputFormat::DateAndTime, true))); case 1: return change.deviceId.isEmpty() ? change.fileChange.modifiedBy : change.deviceId; + case 2: + return change.directoryId; case 3: return change.fileChange.path; // usually too long so add a tooltip } diff --git a/plasmoid/package/contents/ui/RecentChangesPage.qml b/plasmoid/package/contents/ui/RecentChangesPage.qml index 692fb3f..7f63ed3 100644 --- a/plasmoid/package/contents/ui/RecentChangesPage.qml +++ b/plasmoid/package/contents/ui/RecentChangesPage.qml @@ -98,6 +98,9 @@ Item { function copyDeviceId() { plasmoid.nativeInterface.copyToClipboard(modifiedBy) } + function copyFolderId() { + plasmoid.nativeInterface.copyToClipboard(folderId) + } } PlasmaComponents.Menu { @@ -112,6 +115,11 @@ Item { icon: "network-server-symbolic" onClicked: recentChangesView.currentItem.copyDeviceId() } + PlasmaComponents.MenuItem { + text: qsTr("Copy directory ID") + icon: "folder" + onClicked: recentChangesView.currentItem.copyFolderId() + } } } } diff --git a/tray/gui/traywidget.cpp b/tray/gui/traywidget.cpp index 8c41c56..d0b321c 100644 --- a/tray/gui/traywidget.cpp +++ b/tray/gui/traywidget.cpp @@ -597,6 +597,9 @@ void TrayWidget::showRecentChangesContextMenu(const QPoint &position) QIcon(QStringLiteral(":/icons/hicolor/scalable/places/network-workgroup.svg"))), tr("Copy device ID")), &QAction::triggered, this, copyRole(SyncthingRecentChangesModel::ModifiedBy)); + connect(menu.addAction(QIcon::fromTheme(QStringLiteral("folder"), QIcon(QStringLiteral(":/icons/hicolor/scalable/places/folder.svg"))), + tr("Copy directory ID")), + &QAction::triggered, this, copyRole(SyncthingRecentChangesModel::DirectoryId)); showViewMenu(position, *m_ui->recentChangesTreeView, menu); }