2021-06-21 21:50:49 +03:00
|
|
|
import QtQml 2.12
|
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import QtQuick.Layouts 1.2
|
|
|
|
import Style 1.0
|
|
|
|
import com.nextcloud.desktopclient 1.0
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: activityMouseArea
|
2021-08-20 16:17:06 +03:00
|
|
|
|
|
|
|
readonly property int maxActionButtons: 2
|
|
|
|
property Flickable flickable
|
|
|
|
|
|
|
|
signal fileActivityButtonClicked(string absolutePath)
|
|
|
|
|
2021-06-21 21:50:49 +03:00
|
|
|
enabled: (path !== "" || link !== "")
|
|
|
|
hoverEnabled: true
|
2021-08-20 16:17:06 +03:00
|
|
|
|
2021-06-21 21:50:49 +03:00
|
|
|
Rectangle {
|
2021-07-28 11:57:58 +03:00
|
|
|
anchors.fill: parent
|
2021-06-21 21:50:49 +03:00
|
|
|
color: (parent.containsMouse ? Style.lightHover : "transparent")
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: activityItem
|
|
|
|
|
|
|
|
readonly property variant links: model.links
|
|
|
|
|
|
|
|
readonly property int itemIndex: model.index
|
|
|
|
|
|
|
|
width: activityMouseArea.width
|
|
|
|
height: Style.trayWindowHeaderHeight
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Accessible.role: Accessible.ListItem
|
|
|
|
Accessible.name: path !== "" ? qsTr("Open %1 locally").arg(displayPath)
|
|
|
|
: message
|
|
|
|
Accessible.onPressAction: activityMouseArea.clicked()
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: activityIcon
|
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
2021-09-14 14:17:03 +03:00
|
|
|
Layout.leftMargin: 20
|
2021-06-21 21:50:49 +03:00
|
|
|
Layout.preferredWidth: shareButton.icon.width
|
|
|
|
Layout.preferredHeight: shareButton.icon.height
|
|
|
|
verticalAlignment: Qt.AlignCenter
|
|
|
|
cache: true
|
|
|
|
source: icon
|
|
|
|
sourceSize.height: 64
|
|
|
|
sourceSize.width: 64
|
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: activityTextColumn
|
2021-09-14 14:17:03 +03:00
|
|
|
Layout.leftMargin: 14
|
2021-06-21 21:50:49 +03:00
|
|
|
Layout.topMargin: 4
|
|
|
|
Layout.bottomMargin: 4
|
|
|
|
Layout.fillWidth: true
|
|
|
|
spacing: 4
|
2021-09-14 14:17:03 +03:00
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
2021-06-21 21:50:49 +03:00
|
|
|
|
|
|
|
Text {
|
|
|
|
id: activityTextTitle
|
|
|
|
text: (type === "Activity" || type === "Notification") ? subject : message
|
|
|
|
width: parent.width
|
|
|
|
elide: Text.ElideRight
|
|
|
|
font.pixelSize: Style.topLinePixelSize
|
|
|
|
color: activityTextTitleColor
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: activityTextInfo
|
|
|
|
text: (type === "Sync") ? displayPath
|
|
|
|
: (type === "File") ? subject
|
|
|
|
: (type === "Notification") ? message
|
|
|
|
: ""
|
|
|
|
height: (text === "") ? 0 : activityTextTitle.height
|
|
|
|
width: parent.width
|
|
|
|
elide: Text.ElideRight
|
|
|
|
font.pixelSize: Style.subLinePixelSize
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: activityTextDateTime
|
|
|
|
text: dateTime
|
|
|
|
height: (text === "") ? 0 : activityTextTitle.height
|
|
|
|
width: parent.width
|
|
|
|
elide: Text.ElideRight
|
|
|
|
font.pixelSize: Style.subLinePixelSize
|
|
|
|
color: "#808080"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: activityActionsLayout
|
|
|
|
spacing: 0
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
|
|
|
Layout.minimumWidth: 28
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
function actionButtonIcon(actionIndex) {
|
|
|
|
const verb = String(model.links[actionIndex].verb);
|
|
|
|
if (verb === "WEB" && (model.objectType === "chat" || model.objectType === "call")) {
|
|
|
|
return "qrc:///client/theme/reply.svg";
|
|
|
|
} else if (verb === "DELETE") {
|
|
|
|
return "qrc:///client/theme/close.svg";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "qrc:///client/theme/confirm.svg";
|
|
|
|
}
|
|
|
|
|
|
|
|
Repeater {
|
2021-08-20 16:17:06 +03:00
|
|
|
model: activityItem.links.length > maxActionButtons ? 1 : activityItem.links.length
|
2021-06-21 21:50:49 +03:00
|
|
|
|
|
|
|
ActivityActionButton {
|
|
|
|
id: activityActionButton
|
|
|
|
|
|
|
|
readonly property int actionIndex: model.index
|
|
|
|
readonly property bool primary: model.index === 0 && String(activityItem.links[actionIndex].verb) !== "DELETE"
|
|
|
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
text: !primary ? "" : activityItem.links[actionIndex].label
|
|
|
|
|
|
|
|
imageSource: !primary ? activityActionsLayout.actionButtonIcon(actionIndex) : ""
|
|
|
|
|
|
|
|
textColor: primary ? Style.ncBlue : "black"
|
|
|
|
textColorHovered: Style.lightHover
|
|
|
|
|
|
|
|
textBorderColor: Style.ncBlue
|
|
|
|
|
|
|
|
textBgColor: "transparent"
|
|
|
|
textBgColorHovered: Style.ncBlue
|
|
|
|
|
|
|
|
tooltipText: activityItem.links[actionIndex].label
|
|
|
|
|
|
|
|
Layout.minimumWidth: primary ? 80 : -1
|
|
|
|
Layout.minimumHeight: parent.height
|
|
|
|
|
|
|
|
Layout.preferredWidth: primary ? -1 : parent.height
|
|
|
|
|
|
|
|
onClicked: activityModel.triggerAction(activityItem.itemIndex, actionIndex)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-08-20 16:17:06 +03:00
|
|
|
|
|
|
|
Button {
|
|
|
|
id: shareButton
|
|
|
|
|
|
|
|
Layout.preferredWidth: parent.height
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
flat: true
|
|
|
|
hoverEnabled: true
|
|
|
|
visible: displayActions && (path !== "")
|
|
|
|
display: AbstractButton.IconOnly
|
|
|
|
icon.source: "qrc:///client/theme/share.svg"
|
|
|
|
icon.color: "transparent"
|
|
|
|
background: Rectangle {
|
|
|
|
color: parent.hovered ? Style.lightHover : "transparent"
|
|
|
|
}
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
|
|
|
|
ToolTip.text: qsTr("Open share dialog")
|
|
|
|
onClicked: Systray.openShareDialog(displayPath, absolutePath)
|
|
|
|
|
|
|
|
Accessible.role: Accessible.Button
|
|
|
|
Accessible.name: qsTr("Share %1").arg(displayPath)
|
|
|
|
Accessible.onPressAction: shareButton.clicked()
|
|
|
|
}
|
2021-06-21 21:50:49 +03:00
|
|
|
|
|
|
|
Button {
|
|
|
|
id: moreActionsButton
|
|
|
|
|
|
|
|
Layout.preferredWidth: parent.height
|
|
|
|
Layout.preferredHeight: parent.height
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
|
|
|
|
flat: true
|
|
|
|
hoverEnabled: true
|
2021-08-20 16:17:06 +03:00
|
|
|
visible: displayActions && ((path !== "") || (activityItem.links.length > maxActionButtons))
|
2021-06-21 21:50:49 +03:00
|
|
|
display: AbstractButton.IconOnly
|
|
|
|
icon.source: "qrc:///client/theme/more.svg"
|
|
|
|
icon.color: "transparent"
|
|
|
|
background: Rectangle {
|
|
|
|
color: parent.hovered ? Style.lightHover : "transparent"
|
|
|
|
}
|
|
|
|
ToolTip.visible: hovered
|
2021-08-20 16:17:06 +03:00
|
|
|
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
|
2021-06-21 21:50:49 +03:00
|
|
|
ToolTip.text: qsTr("Show more actions")
|
|
|
|
|
|
|
|
Accessible.role: Accessible.Button
|
|
|
|
Accessible.name: qsTr("Show more actions")
|
|
|
|
Accessible.onPressAction: moreActionsButton.clicked()
|
|
|
|
|
|
|
|
onClicked: moreActionsButtonContextMenu.popup();
|
|
|
|
|
|
|
|
Connections {
|
2021-08-20 16:17:06 +03:00
|
|
|
target: flickable
|
2021-06-21 21:50:49 +03:00
|
|
|
|
2021-08-20 19:27:25 +03:00
|
|
|
function onMovementStarted() {
|
2021-06-21 21:50:49 +03:00
|
|
|
moreActionsButtonContextMenu.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Container {
|
|
|
|
id: moreActionsButtonContextMenuContainer
|
|
|
|
visible: moreActionsButtonContextMenu.opened
|
|
|
|
|
|
|
|
width: moreActionsButtonContextMenu.width
|
|
|
|
height: moreActionsButtonContextMenu.height
|
|
|
|
anchors.right: moreActionsButton.right
|
|
|
|
anchors.top: moreActionsButton.top
|
|
|
|
|
|
|
|
Menu {
|
|
|
|
id: moreActionsButtonContextMenu
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
// transform model to contain indexed actions with primary action filtered out
|
|
|
|
function actionListToContextMenuList(actionList) {
|
|
|
|
// early out with non-altered data
|
2021-08-20 16:17:06 +03:00
|
|
|
if (activityItem.links.length <= maxActionButtons) {
|
2021-06-21 21:50:49 +03:00
|
|
|
return actionList;
|
|
|
|
}
|
|
|
|
|
|
|
|
// add index to every action and filter 'primary' action out
|
|
|
|
var reducedActionList = actionList.reduce(function(reduced, action, index) {
|
|
|
|
if (!action.primary) {
|
|
|
|
var actionWithIndex = { actionIndex: index, label: action.label };
|
|
|
|
reduced.push(actionWithIndex);
|
|
|
|
}
|
|
|
|
return reduced;
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
return reducedActionList;
|
|
|
|
}
|
2021-08-20 16:17:06 +03:00
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("View activity")
|
|
|
|
onClicked: fileActivityButtonClicked(absolutePath)
|
|
|
|
}
|
2021-06-21 21:50:49 +03:00
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: moreActionsButtonContextMenuRepeater
|
|
|
|
|
|
|
|
model: moreActionsButtonContextMenu.actionListToContextMenuList(activityItem.links)
|
|
|
|
|
|
|
|
delegate: MenuItem {
|
|
|
|
id: moreActionsButtonContextMenuEntry
|
|
|
|
text: model.modelData.label
|
|
|
|
onTriggered: activityModel.triggerAction(activityItem.itemIndex, model.modelData.actionIndex)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|