blob: 130a515665eb68ff67137917c10c04a568a50e9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
import QtQml 2.15
import QtQuick 2.15
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
import Style 1.0
import com.nextcloud.desktopclient 1.0
RowLayout {
id: root
spacing: 20
property string objectType: ""
property variant linksForActionButtons: []
property variant linksContextMenu: []
property bool displayActions: false
property color moreActionsButtonColor: "transparent"
property color adjustedHeaderColor: "transparent"
property int maxActionButtons: 0
property Flickable flickable
signal triggerAction(int actionIndex)
signal showReplyField()
Repeater {
id: actionsRepeater
// a max of maxActionButtons will get dispayed as separate buttons
model: root.linksForActionButtons
ActivityActionButton {
id: activityActionButton
readonly property string verb: model.modelData.verb
readonly property bool primary: (model.index === 0 && verb !== "DELETE") || model.modelData.primary
readonly property bool isTalkReplyButton: verb === "REPLY"
Layout.minimumWidth: primary ? Style.activityItemActionPrimaryButtonMinWidth : Style.activityItemActionSecondaryButtonMinWidth
Layout.preferredHeight: primary ? parent.height : parent.height * 0.3
Layout.preferredWidth: primary ? -1 : parent.height
text: model.modelData.label
imageSource: model.modelData.imageSource ? model.modelData.imageSource + root.adjustedHeaderColor : ""
imageSourceHover: model.modelData.imageSourceHovered ? model.modelData.imageSourceHovered + UserModel.currentUser.headerTextColor : ""
textColor: primary ? root.adjustedHeaderColor : Style.ncTextColor
textColorHovered: primary ? UserModel.currentUser.headerTextColor : Style.ncTextColor
primaryButton: primary
onClicked: !isTalkReplyButton ? root.triggerAction(model.index) : root.showReplyField()
}
}
Loader {
// actions that do not fit maxActionButtons limit, must be put into a context menu
id: moreActionsButtonContainer
Layout.preferredWidth: parent.height
Layout.topMargin: Style.roundedButtonBackgroundVerticalMargins
Layout.bottomMargin: Style.roundedButtonBackgroundVerticalMargins
Layout.fillHeight: true
active: root.displayActions && (root.linksContextMenu.length > 0)
sourceComponent: Button {
id: moreActionsButton
icon.source: "qrc:///client/theme/more.svg"
icon.color: Style.ncTextColor
background: Rectangle {
color: parent.hovered ? Style.lightHover : root.moreActionsButtonColor
radius: width / 2
}
NCToolTip {
visible: parent.hovered
text: qsTr("Show more actions")
}
Accessible.name: qsTr("Show more actions")
onClicked: moreActionsButtonContextMenu.popup(moreActionsButton.x, moreActionsButton.y);
Connections {
target: root.flickable
function onMovementStarted() {
moreActionsButtonContextMenu.close();
}
}
ActivityItemContextMenu {
id: moreActionsButtonContextMenu
maxActionButtons: root.maxActionButtons
linksContextMenu: root.linksContextMenu
onMenuEntryTriggered: function(entryIndex) {
root.triggerAction(entryIndex)
}
}
}
}
}
|