Refactor the hoverActions
This commit is contained in:
@@ -34,8 +34,6 @@ QQC2.ItemDelegate {
|
|||||||
topPadding: 0
|
topPadding: 0
|
||||||
bottomPadding: 0
|
bottomPadding: 0
|
||||||
|
|
||||||
property alias hoveredBubble: controlContainer.hovered
|
|
||||||
|
|
||||||
//height: mainColumn.childrenRect.height + (readMarker ? Kirigami.Units.smallSpacing : 0)
|
//height: mainColumn.childrenRect.height + (readMarker ? Kirigami.Units.smallSpacing : 0)
|
||||||
//height: mainColumn.implicitHeight + (readMarker ? Kirigami.Units.smallSpacing : 0)
|
//height: mainColumn.implicitHeight + (readMarker ? Kirigami.Units.smallSpacing : 0)
|
||||||
|
|
||||||
@@ -53,21 +51,9 @@ QQC2.ItemDelegate {
|
|||||||
function updateHoverComponent() {
|
function updateHoverComponent() {
|
||||||
hoverComponent.x = column.mapToItem(page, hoverComponentX, hoverComponentY).x;
|
hoverComponent.x = column.mapToItem(page, hoverComponentX, hoverComponentY).x;
|
||||||
hoverComponent.y = column.mapToItem(page, hoverComponentX, hoverComponentY).y;
|
hoverComponent.y = column.mapToItem(page, hoverComponentX, hoverComponentY).y;
|
||||||
hoverComponent.hovered = Qt.binding(() => controlContainer.hovered);
|
hoverComponent.bubble = controlContainer
|
||||||
hoverComponent.showEdit = author.id === Controller.activeConnection.localUserId && (model.eventType === "emote" || model.eventType === "message");
|
|
||||||
hoverComponent.updateFunction = updateHoverComponent;
|
hoverComponent.updateFunction = updateHoverComponent;
|
||||||
|
hoverComponent.event = model
|
||||||
hoverComponent.editClicked = () => {
|
|
||||||
if (hoverComponent.showEdit) {
|
|
||||||
ChatBoxHelper.edit(message, formattedBody, eventId)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
hoverComponent.replyClicked = () => {
|
|
||||||
ChatBoxHelper.replyToMessage(eventId, message, author);
|
|
||||||
};
|
|
||||||
hoverComponent.reacted = emoji => {
|
|
||||||
currentRoom.toggleReaction(eventId, emoji);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
contentItem: ColumnLayout {
|
||||||
|
|||||||
@@ -136,17 +136,15 @@ Kirigami.ScrollablePage {
|
|||||||
}
|
}
|
||||||
Item {
|
Item {
|
||||||
id: hoverActions
|
id: hoverActions
|
||||||
property bool showEdit
|
property var event
|
||||||
property bool hovered: false
|
property bool showEdit: event && (event.author.id === Controller.activeConnection.localUserId && (event.eventType === "emote" || event.eventType === "message"))
|
||||||
|
property var bubble
|
||||||
|
property var hovered: bubble && bubble.hovered
|
||||||
|
|
||||||
visible: (hovered || hoverHandler.hovered) && !Kirigami.Settings.isMobile
|
visible: (hovered || hoverHandler.hovered) && !Kirigami.Settings.isMobile
|
||||||
|
|
||||||
property var updateFunction
|
property var updateFunction
|
||||||
|
|
||||||
property var editClicked
|
|
||||||
property var replyClicked
|
|
||||||
property var reacted
|
|
||||||
|
|
||||||
property alias childWidth: hoverActionsRow.width
|
property alias childWidth: hoverActionsRow.width
|
||||||
property alias childHeight: hoverActionsRow.height
|
property alias childHeight: hoverActionsRow.height
|
||||||
|
|
||||||
@@ -166,7 +164,9 @@ Kirigami.ScrollablePage {
|
|||||||
onClicked: emojiDialog.open();
|
onClicked: emojiDialog.open();
|
||||||
EmojiDialog {
|
EmojiDialog {
|
||||||
id: emojiDialog
|
id: emojiDialog
|
||||||
onReact: hoverActions.reacted(emoji)
|
onReact: {
|
||||||
|
page.currentRoom.toggleReaction(hoverActions.event.eventId, emoji);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QQC2.Button {
|
QQC2.Button {
|
||||||
@@ -174,13 +174,19 @@ Kirigami.ScrollablePage {
|
|||||||
QQC2.ToolTip.visible: hovered
|
QQC2.ToolTip.visible: hovered
|
||||||
visible: hoverActions.showEdit
|
visible: hoverActions.showEdit
|
||||||
icon.name: "document-edit"
|
icon.name: "document-edit"
|
||||||
onClicked: hoverActions.editClicked()
|
onClicked: {
|
||||||
|
if (hoverActions.showEdit) {
|
||||||
|
ChatBoxHelper.edit(hoverActions.event.message, hoverActions.event.formattedBody, hoverActions.event.eventId)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QQC2.Button {
|
QQC2.Button {
|
||||||
QQC2.ToolTip.text: i18n("Reply")
|
QQC2.ToolTip.text: i18n("Reply")
|
||||||
QQC2.ToolTip.visible: hovered
|
QQC2.ToolTip.visible: hovered
|
||||||
icon.name: "mail-replied-symbolic"
|
icon.name: "mail-replied-symbolic"
|
||||||
onClicked: hoverActions.replyClicked()
|
onClicked: {
|
||||||
|
ChatBoxHelper.replyToMessage(hoverActions.event.eventId, hoverActions.event.message, hoverActions.event.author);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user