2022-01-04 17:28:26 +03:00
|
|
|
import QtQml 2.15
|
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Layouts 1.2
|
|
|
|
import Style 1.0
|
2022-01-28 19:03:39 +03:00
|
|
|
import com.nextcloud.desktopclient 1.0
|
2022-01-04 17:28:26 +03:00
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
spacing: 20
|
|
|
|
|
|
|
|
property string objectType: ""
|
|
|
|
property variant linksForActionButtons: []
|
|
|
|
property variant linksContextMenu: []
|
|
|
|
property bool displayActions: false
|
|
|
|
|
|
|
|
property color moreActionsButtonColor: "transparent"
|
|
|
|
|
|
|
|
property int maxActionButtons: 0
|
|
|
|
|
|
|
|
property Flickable flickable
|
|
|
|
|
|
|
|
signal triggerAction(int actionIndex)
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: actionsRepeater
|
|
|
|
// a max of maxActionButtons will get dispayed as separate buttons
|
|
|
|
model: root.linksForActionButtons
|
|
|
|
|
|
|
|
ActivityActionButton {
|
|
|
|
id: activityActionButton
|
|
|
|
|
2022-03-29 14:33:06 +03:00
|
|
|
readonly property string verb: model.modelData.verb
|
|
|
|
readonly property bool primary: model.index === 0 && verb !== "DELETE"
|
|
|
|
readonly property bool isTalkReplyButton: verb === "REPLY"
|
|
|
|
|
2022-01-04 17:28:26 +03:00
|
|
|
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
|
|
|
|
toolTipText: model.modelData.label
|
|
|
|
|
|
|
|
imageSource: model.modelData.imageSource
|
|
|
|
imageSourceHover: model.modelData.imageSourceHovered
|
|
|
|
|
2022-02-04 05:39:38 +03:00
|
|
|
textColor: imageSource !== "" ? UserModel.currentUser.headerColor : Style.ncTextColor
|
|
|
|
textColorHovered: imageSource !== "" ? Style.lightHover : Style.ncTextColor
|
2022-01-04 17:28:26 +03:00
|
|
|
|
|
|
|
bold: primary
|
|
|
|
|
2022-03-29 14:33:06 +03:00
|
|
|
onClicked: !isTalkReplyButton? root.triggerAction(model.index) : showReplyOptions(model.index)
|
2022-01-04 17:28:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
2022-02-04 05:39:38 +03:00
|
|
|
icon.color: Style.ncTextColor
|
2022-01-04 17:28:26 +03:00
|
|
|
|
|
|
|
background: Rectangle {
|
2022-02-04 05:39:38 +03:00
|
|
|
color: parent.hovered ? Style.lightHover : root.moreActionsButtonColor
|
2022-01-04 17:28:26 +03:00
|
|
|
radius: width / 2
|
|
|
|
}
|
|
|
|
|
2022-02-04 05:39:38 +03:00
|
|
|
ToolTip {
|
|
|
|
id: moreActionsButtonTooltip
|
|
|
|
visible: parent.hovered
|
|
|
|
delay: Qt.styleHints.mousePressAndHoldInterval
|
|
|
|
text: qsTr("Show more actions")
|
|
|
|
contentItem: Label {
|
|
|
|
text: moreActionsButtonTooltip.text
|
|
|
|
color: Style.ncTextColor
|
|
|
|
}
|
|
|
|
background: Rectangle {
|
|
|
|
border.color: Style.menuBorder
|
|
|
|
color: Style.backgroundColor
|
|
|
|
}
|
|
|
|
}
|
2022-01-04 17:28:26 +03:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|