Only show reply button and option button on hover

member1-and-too-many-others
Nicolas Werner 5 years ago
parent bed8c52891
commit 505a8b5742
  1. 162
      resources/qml/TimelineRow.qml

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

Loading…
Cancel
Save