Put hover actions in the RowLayouts

Simplify the code compared to use an ActionToolBar and this should makes
it more reliable.
This commit is contained in:
Carl Schwan
2024-09-20 17:27:50 +02:00
parent 7cf97a5c9b
commit 2969d20a92

View File

@@ -69,9 +69,12 @@ QQC2.Control {
onDelegateChanged: updatePosition() onDelegateChanged: updatePosition()
contentItem: RowLayout { contentItem: RowLayout {
spacing: Kirigami.Units.smallSpacing
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
} }
Kirigami.Icon { Kirigami.Icon {
source: "security-high" source: "security-high"
width: height width: height
@@ -80,57 +83,74 @@ QQC2.Control {
HoverHandler { HoverHandler {
id: hover id: hover
} }
QQC2.ToolTip.text: i18n("This message was sent from a verified device") QQC2.ToolTip.text: i18n("This message was sent from a verified device")
QQC2.ToolTip.visible: hover.hovered QQC2.ToolTip.visible: hover.hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
} }
Kirigami.ActionToolBar {
Layout.maximumWidth: maximumContentWidth + Kirigami.Units.largeSpacing
rightPadding: Kirigami.Units.largeSpacing
alignment: Qt.AlignRight
flat: false
display: QQC2.Button.IconOnly
actions: [ QQC2.Button {
Kirigami.Action {
text: i18n("React") text: i18n("React")
icon.name: "preferences-desktop-emoticons" icon.name: "preferences-desktop-emoticons"
onTriggered: emojiDialog.open() onClicked: emojiDialog.open()
}, display: QQC2.ToolButton.IconOnly
Kirigami.Action {
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
QQC2.Button {
visible: root.delegate && root.delegate.isEditable && !root.currentRoom.readOnly visible: root.delegate && root.delegate.isEditable && !root.currentRoom.readOnly
text: i18n("Edit") text: i18n("Edit")
icon.name: "document-edit" icon.name: "document-edit"
onTriggered: { display: QQC2.Button.IconOnly
onClicked: {
root.currentRoom.editCache.editId = root.delegate.eventId; root.currentRoom.editCache.editId = root.delegate.eventId;
root.currentRoom.mainCache.replyId = ""; root.currentRoom.mainCache.replyId = "";
root.currentRoom.mainCache.threadId = ""; root.currentRoom.mainCache.threadId = "";
} }
},
Kirigami.Action { QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
QQC2.Button {
visible: !root.currentRoom.readOnly visible: !root.currentRoom.readOnly
text: i18n("Reply") text: i18n("Reply")
icon.name: "mail-replied-symbolic" icon.name: "mail-replied-symbolic"
onTriggered: { display: QQC2.Button.IconOnly
onClicked: {
root.currentRoom.mainCache.replyId = root.delegate.eventId; root.currentRoom.mainCache.replyId = root.delegate.eventId;
root.currentRoom.editCache.editId = ""; root.currentRoom.editCache.editId = "";
root.currentRoom.mainCache.threadId = ""; root.currentRoom.mainCache.threadId = "";
root.focusChatBar(); root.focusChatBar();
} }
},
Kirigami.Action { QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
QQC2.Button {
visible: NeoChatConfig.threads && !root.currentRoom.readOnly visible: NeoChatConfig.threads && !root.currentRoom.readOnly
text: i18n("Reply in Thread") text: i18n("Reply in Thread")
icon.name: "dialog-messages" icon.name: "dialog-messages"
onTriggered: { display: QQC2.Button.IconOnly
onClicked: {
root.currentRoom.threadCache.replyId = ""; root.currentRoom.threadCache.replyId = "";
root.currentRoom.threadCache.threadId = root.delegate.isThreaded ? root.delegate.threadRoot : root.delegate.eventId; root.currentRoom.threadCache.threadId = root.delegate.isThreaded ? root.delegate.threadRoot : root.delegate.eventId;
root.currentRoom.mainCache.clearRelations(); root.currentRoom.mainCache.clearRelations();
root.currentRoom.editCache.clearRelations(); root.currentRoom.editCache.clearRelations();
root.focusChatBar(); root.focusChatBar();
} }
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
} }
]
EmojiDialog { EmojiDialog {
id: emojiDialog id: emojiDialog
@@ -144,5 +164,4 @@ QQC2.Control {
} }
} }
} }
}
} }