Only show reply button and option button on hover

This commit is contained in:
Nicolas Werner 2020-02-26 23:43:15 +01:00
parent bed8c52891
commit 505a8b5742
1 changed files with 113 additions and 77 deletions

View File

@ -7,92 +7,128 @@ import im.nheko 1.0
import "./delegates" import "./delegates"
RowLayout { MouseArea {
property var view: chat id: rowArea
anchors.leftMargin: avatarSize + 4
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
height: row.height
Column { hoverEnabled: true
Layout.fillWidth: true preventStealing: true
Layout.alignment: Qt.AlignTop propagateComposedEvents: true
spacing: 4 acceptedButtons: Qt.NoButton
// fancy reply, if this is a reply property bool showButtons: false
Reply {
visible: model.replyTo Timer {
modelData: chat.model.getDump(model.replyTo) running: rowArea.containsMouse
userColor: timelineManager.userColor(modelData.userId, colors.window) interval: 150
onTriggered: rowArea.state = "showButtons"
}
states: [
State {
name: "hideButtons"
when: !rowArea.containsMouse
PropertyChanges { target: rowArea; showButtons: false; }
},
State {
name: "showButtons"
PropertyChanges { target: rowArea; showButtons: true; }
}
]
RowLayout {
id: row
anchors.leftMargin: avatarSize + 4
anchors.left: parent.left
anchors.right: parent.right
Column {
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
spacing: 4
// fancy reply, if this is a reply
Reply {
visible: model.replyTo
modelData: chat.model.getDump(model.replyTo)
userColor: timelineManager.userColor(modelData.userId, colors.window)
}
// actual message content
MessageDelegate {
id: contentItem
width: parent.width
modelData: model
}
} }
// actual message content ImageButton {
MessageDelegate { visible: rowArea.showButtons
id: contentItem Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: parent.width width: 16
id: replyButton
modelData: model
}
}
StatusIndicator {
state: model.state
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
}
EncryptionIndicator {
visible: model.isEncrypted
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
}
ImageButton {
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
id: replyButton
hoverEnabled: true
image: ":/icons/icons/ui/mail-reply.png"
ToolTip.visible: hovered
ToolTip.text: qsTr("Reply")
onClicked: view.model.replyAction(model.id)
}
ImageButton {
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
id: optionsButton
hoverEnabled: true
image: ":/icons/icons/ui/vertical-ellipsis.png"
ToolTip.visible: hovered
ToolTip.text: qsTr("Options")
onClicked: messageContextMenu.show(model.id, model.type, optionsButton)
}
Text {
Layout.alignment: Qt.AlignRight | Qt.AlignTop
text: model.timestamp.toLocaleTimeString("HH:mm")
color: inactiveColors.text
MouseArea{
id: ma
anchors.fill: parent
hoverEnabled: true hoverEnabled: true
image: ":/icons/icons/ui/mail-reply.png"
ToolTip.visible: hovered
ToolTip.text: qsTr("Reply")
onClicked: chat.model.replyAction(model.id)
}
ImageButton {
visible: rowArea.showButtons
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
id: optionsButton
hoverEnabled: true
image: ":/icons/icons/ui/vertical-ellipsis.png"
ToolTip.visible: hovered
ToolTip.text: qsTr("Options")
onClicked: messageContextMenu.show(model.id, model.type, optionsButton)
} }
ToolTip.visible: ma.containsMouse StatusIndicator {
ToolTip.text: Qt.formatDateTime(model.timestamp, Qt.DefaultLocaleLongDate) state: model.state
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
}
EncryptionIndicator {
visible: model.isEncrypted
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
width: 16
}
Text {
Layout.alignment: Qt.AlignRight | Qt.AlignTop
text: model.timestamp.toLocaleTimeString("HH:mm")
color: inactiveColors.text
MouseArea{
id: ma
anchors.fill: parent
hoverEnabled: true
}
ToolTip.visible: ma.containsMouse
ToolTip.text: Qt.formatDateTime(model.timestamp, Qt.DefaultLocaleLongDate)
}
} }
} }