Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 48 additions & 5 deletions src/gui/tray/ActivityList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ScrollView {
}

signal openFile(string filePath)
signal showInFileManager(int index)
signal activityItemClicked(int index)

contentWidth: availableWidth
Expand All @@ -51,6 +52,14 @@ ScrollView {
ListView {
id: activityList

function openFileOrLink(index) {
if (model.isCurrentUserFileActivity && model.openablePath) {
openFile("file://" + model.openablePath);
} else {
activityItemClicked(index);
}
}

Accessible.role: Accessible.List
Accessible.name: qsTr("Activity list")

Expand Down Expand Up @@ -117,11 +126,25 @@ ScrollView {

forceActiveFocus();
}
onClicked: {
if (model.isCurrentUserFileActivity && model.openablePath) {
openFile("file://" + model.openablePath);
} else {
activityItemClicked(model.activityIndex)

MouseArea {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you better use a TapHandler ?
that would be more up to date with current API to handle mouse input

anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: (mouse)=> {
switch (mouse.button) {
case Qt.LeftButton:
activityList.openFileOrLink(activityList.currentIndex)
break;
case Qt.RightButton:
// We only want to allow the context menu for actual files
if (model.showFileDetails) {
contextMenu.x = mouse.x;
contextMenu.y = mouse.y;
contextMenu.selectedItem = activityList.currentIndex
contextMenu.open();
}
break;
}
}
}
}
Expand All @@ -148,6 +171,26 @@ ScrollView {
visible: !controlRoot.atYBeginning && controlRoot.contentHeight > controlRoot.height
}

Menu {
id: contextMenu
property int selectedItem

MenuItem {
text: qsTr("Open local file")
onTriggered: {
activityList.currentIndex = contextMenu.selectedItem
activityList.openFileOrLink(contextMenu.selectedItem);
}
}
MenuItem {
text: qsTr("Show in file manager")
onTriggered: {
activityList.currentIndex = contextMenu.selectedItem
showInFileManager(contextMenu.selectedItem);
}
}
}

Column {
id: placeholderColumn
width: parent.width * 0.8
Expand Down
5 changes: 2 additions & 3 deletions src/gui/tray/MainWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,8 @@ ApplicationWindow {
activeFocusOnTab: true
model: activityModel
onOpenFile: Qt.openUrlExternally(filePath);
onActivityItemClicked: {
model.slotTriggerDefaultAction(index)
}
onShowInFileManager: index => model.slotTriggerShowInFileManager(index)
onActivityItemClicked: index => model.slotTriggerDefaultAction(index)
Connections {
target: activityModel
function onInteractiveActivityReceived() {
Expand Down
16 changes: 16 additions & 0 deletions src/gui/tray/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "caseclashfilenamedialog.h"
#include "activitydata.h"
#include "systray.h"
#include "openfilemanager.h"
#include "filesystem.h"
#include "common/utility.h"

#include <QtCore>
Expand Down Expand Up @@ -863,6 +865,20 @@ void ActivityListModel::slotTriggerDismiss(const int activityIndex)
emit sendNotificationRequest(activity._accName, Utility::concatUrlPath(accountState()->account()->url(), "ocs/v2.php/apps/notifications/api/v2/notifications/" + QString::number(activity._id)).toString(), deleteVerb, activityIndex);
}

void ActivityListModel::slotTriggerShowInFileManager(const int activityIndex)
{
if (activityIndex < 0 || activityIndex >= _finalList.size()) {
qCWarning(lcActivity) << "Couldn't trigger show in file manager at index" << activityIndex << "/ final list size:" << _finalList.size();
return;
}

const auto modelIndex = index(activityIndex);
const auto path = data(modelIndex, PathRole).toString();
if (FileSystem::fileExists(path)) {
showInFileManager(path);
}
}

AccountState *ActivityListModel::accountState() const
{
return _accountState;
Expand Down
1 change: 1 addition & 0 deletions src/gui/tray/activitylistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public slots:
void slotTriggerDefaultAction(const int activityIndex);
void slotTriggerAction(const int activityIndex, const int actionIndex);
void slotTriggerDismiss(const int activityIndex);
void slotTriggerShowInFileManager(const int activityIndex);

void addNotificationToActivityList(const OCC::Activity &activity);
void addErrorToActivityList(const OCC::Activity &activity, const OCC::ActivityListModel::ErrorType type);
Expand Down