diff --git a/src/gui/tray/ActivityList.qml b/src/gui/tray/ActivityList.qml index acfb1bbdc7491..f3a6416c2afe6 100644 --- a/src/gui/tray/ActivityList.qml +++ b/src/gui/tray/ActivityList.qml @@ -9,7 +9,7 @@ ScrollView { property bool isFileActivityList: false - signal showFileActivity(string objectName, int objectId) + signal openFile(string filePath) signal activityItemClicked(int index) contentWidth: availableWidth @@ -38,8 +38,8 @@ ScrollView { width: activityList.contentWidth flickable: activityList onClicked: { - if (model.isCurrentUserFileActivity) { - showFileActivity(model.objectName, model.objectId) + if (model.isCurrentUserFileActivity && model.openablePath) { + openFile("file://" + model.openablePath); } else { activityItemClicked(model.index) } diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index 7d4041f330558..34873a4d0813c 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -798,9 +798,7 @@ Window { activeFocusOnTab: true model: activityModel - onShowFileActivity: { - openFileActivityDialog(objectName, objectId) - } + onOpenFile: Qt.openUrlExternally(filePath); onActivityItemClicked: { model.slotTriggerDefaultAction(index) } diff --git a/src/gui/tray/activitydata.cpp b/src/gui/tray/activitydata.cpp index 1b8bfc34f2900..0875ee4635a2e 100644 --- a/src/gui/tray/activitydata.cpp +++ b/src/gui/tray/activitydata.cpp @@ -65,6 +65,7 @@ OCC::Activity Activity::fromActivityJson(const QJsonObject &json, const AccountP activity._dateTime = QDateTime::fromString(json.value(QStringLiteral("datetime")).toString(), Qt::ISODate); activity._icon = json.value(QStringLiteral("icon")).toString(); activity._isCurrentUserFileActivity = activity._objectType == QStringLiteral("files") && activityUser == account->davUser(); + activity._isMultiObjectActivity = json.value("objects").toObject().count() > 1; auto richSubjectData = json.value(QStringLiteral("subject_rich")).toArray(); diff --git a/src/gui/tray/activitydata.h b/src/gui/tray/activitydata.h index 944e1f6175562..9371fd736c7d1 100644 --- a/src/gui/tray/activitydata.h +++ b/src/gui/tray/activitydata.h @@ -102,6 +102,7 @@ class Activity static Activity fromActivityJson(const QJsonObject &json, const AccountPtr account); static QString relativeServerFileTypeIconPath(const QMimeType &mimeType); + static QString localFilePathForActivity(const Activity &activity, const AccountPtr account); struct RichSubjectParameter { QString type; // Required @@ -133,6 +134,7 @@ class Activity QString _folder; QString _file; QString _renamedFile; + bool _isMultiObjectActivity; QUrl _link; QDateTime _dateTime; qint64 _expireAtMsecs = -1; diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index f0c6673c639a1..905ebcf4214d0 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -59,6 +59,7 @@ QHash ActivityListModel::roleNames() const auto roles = QAbstractListModel::roleNames(); roles[DisplayPathRole] = "displayPath"; roles[PathRole] = "path"; + roles[OpenablePathRole] = "openablePath"; roles[DisplayLocationRole] = "displayLocation"; roles[LinkRole] = "link"; roles[MessageRole] = "message"; @@ -77,6 +78,7 @@ QHash ActivityListModel::roleNames() const roles[DisplayActions] = "displayActions"; roles[ShareableRole] = "isShareable"; roles[IsCurrentUserFileActivityRole] = "isCurrentUserFileActivity"; + roles[IsCurrentUserFileActivityRole] = "isCurrentUserFileActivity"; roles[ThumbnailRole] = "thumbnail"; roles[TalkNotificationConversationTokenRole] = "conversationToken"; roles[TalkNotificationMessageIdRole] = "messageId"; @@ -263,6 +265,8 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const return getDisplayPath(); case PathRole: return QFileInfo(getFilePath()).path(); + case OpenablePathRole: + return a._isMultiObjectActivity ? QFileInfo(getFilePath()).canonicalPath() : QFileInfo(getFilePath()).canonicalFilePath(); case DisplayLocationRole: return displayLocation(); case ActionsLinksRole: { diff --git a/src/gui/tray/activitylistmodel.h b/src/gui/tray/activitylistmodel.h index 8ea3a49a17e4a..482e804834b4a 100644 --- a/src/gui/tray/activitylistmodel.h +++ b/src/gui/tray/activitylistmodel.h @@ -60,6 +60,7 @@ class ActivityListModel : public QAbstractListModel MessageRole, DisplayPathRole, PathRole, + OpenablePathRole, DisplayLocationRole, // Provides the display path to a file's parent folder, relative to Nextcloud root LinkRole, PointInTimeRole,