From 0078c72a374940bc815102315043106350da0911 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Tue, 9 Jun 2020 21:28:15 -0400 Subject: [PATCH] Remove signals in favor of direct function calls --- resources/qml/Reactions.qml | 6 ++---- resources/qml/TimelineRow.qml | 3 --- resources/qml/TimelineView.qml | 3 --- resources/qml/emoji/EmojiPicker.qml | 10 ++++------ 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/resources/qml/Reactions.qml b/resources/qml/Reactions.qml index ea2659b7..c06dc826 100644 --- a/resources/qml/Reactions.qml +++ b/resources/qml/Reactions.qml @@ -5,8 +5,6 @@ import QtQuick.Controls 2.2 // adding new reactions via the emoji picker Flow { id: reactionFlow - // Signal for when a reaction is picked / unpicked - signal picked(string room_id, string event_id, string key, string selfReactedEvent) // highlight colors for selfReactedEvent background property real highlightHue: colors.highlight.hslHue @@ -36,7 +34,7 @@ Flow { onClicked: { console.debug("Picked " + model.key + "in response to " + reactionFlow.eventId + " in room " + reactionFlow.roomId + ". selfReactedEvent: " + model.selfReactedEvent) - reactionFlow.picked(reactionFlow.roomId, reactionFlow.eventId, model.key, model.selfReactedEvent) + timelineManager.reactToMessage(reactionFlow.roomId, reactionFlow.eventId, model.key, model.selfReactedEvent) } @@ -57,7 +55,7 @@ Flow { Text { anchors.baseline: reactionCounter.baseline id: reactionText - text: textMetrics.elidedText + (textMetrics.elidedText == textMetrics.text ? "" : "…") + text: textMetrics.elidedText + (textMetrics.elidedText == model.key ? "" : "…") font.family: settings.emojiFont color: reaction.hovered ? colors.highlight : colors.text maximumLineCount: 1 diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index bfe422f8..dfee62dc 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -63,9 +63,6 @@ MouseArea { reactions: model.reactions roomId: model.roomId eventId: model.id - Component.onCompleted: { - reactionRow.picked.connect(timelineManager.reactToMessage) - } } } diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 9c0fd0b2..ba27d007 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -34,9 +34,6 @@ Page { category: Emoji.Category.People sourceModel: EmojiModel {} } - Component.onCompleted: { - emojiPopup.picked.connect(timelineManager.queueReactionMessage) - } } Menu { diff --git a/resources/qml/emoji/EmojiPicker.qml b/resources/qml/emoji/EmojiPicker.qml index b76596d3..b96adf7e 100644 --- a/resources/qml/emoji/EmojiPicker.qml +++ b/resources/qml/emoji/EmojiPicker.qml @@ -10,7 +10,7 @@ import "../" Popup { - function show(showAt, room_id, event_id) { + function show(showAt, room_id, event_id) { console.debug("Showing emojiPicker for " + event_id + "in room " + room_id) parent = showAt x = Math.round((showAt.width - width) / 2) @@ -18,8 +18,7 @@ Popup { emojiPopup.room_id = room_id emojiPopup.event_id = event_id open() - } - signal picked(string room_id, string event_id, string key) + } property string room_id property string event_id @@ -42,8 +41,6 @@ Popup { focus: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside - onPicked: emojiPopup.close() - ColumnLayout { id: columnView anchors.fill: parent @@ -106,7 +103,8 @@ Popup { // TODO: maybe add favorites at some point? onClicked: { console.debug("Picked " + model.unicode + "in response to " + emojiPopup.event_id + " in room " + emojiPopup.room_id) - emojiPopup.picked(emojiPopup.room_id, emojiPopup.event_id, model.unicode) + emojiPopup.close() + timelineManager.queueReactionMessage(emojiPopup.room_id, emojiPopup.event_id, model.unicode) } }