From f520f8ce16ad08583f7e711ce044e7c2f6278c62 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Fri, 15 Jan 2021 20:38:30 -0500 Subject: [PATCH 1/7] Display read receipts when read indicator is clicked --- resources/qml/StatusIndicator.qml | 6 ++++++ resources/qml/TimelineRow.qml | 1 + 2 files changed, 7 insertions(+) diff --git a/resources/qml/StatusIndicator.qml b/resources/qml/StatusIndicator.qml index 0b18b888..3beac649 100644 --- a/resources/qml/StatusIndicator.qml +++ b/resources/qml/StatusIndicator.qml @@ -6,6 +6,7 @@ Rectangle { id: indicator property int state: 0 + property string eventId color: "transparent" width: 16 @@ -31,6 +32,11 @@ Rectangle { anchors.fill: parent hoverEnabled: true + + onClicked: { + if (indicator.state == MtxEvent.Read) + TimelineManager.timeline.readReceiptsAction(indicator.eventId); + } } Image { diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index 57fded90..1eb07daa 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -70,6 +70,7 @@ Item { StatusIndicator { state: model.state + eventId: model.id Layout.alignment: Qt.AlignRight | Qt.AlignTop Layout.preferredHeight: 16 width: 16 From 139ab146bb0f7730ed2c9f315cc51a6d8f43dc6f Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 16 Jan 2021 10:02:55 -0500 Subject: [PATCH 2/7] Use an ImageButton for the StatusIndicator Incidentally, this allows ImageButtons to not change color. --- resources/qml/ImageButton.qml | 8 ++++- resources/qml/StatusIndicator.qml | 55 ++++++++++++++----------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/resources/qml/ImageButton.qml b/resources/qml/ImageButton.qml index b5a34b7b..7e3e0849 100644 --- a/resources/qml/ImageButton.qml +++ b/resources/qml/ImageButton.qml @@ -8,6 +8,7 @@ AbstractButton { property string image: undefined property color highlightColor: colors.highlight property color buttonTextColor: colors.buttonText + property bool changeColorOnHover: true focusPolicy: Qt.NoFocus width: 16 @@ -18,7 +19,12 @@ AbstractButton { // Workaround, can't get icon.source working for now... anchors.fill: parent - source: "image://colorimage/" + image + "?" + (button.hovered ? highlightColor : buttonTextColor) + source: { + var src = "image://colorimage/" + image; + if (changeColorOnHover) + src += "?" + (button.hovered ? highlightColor : buttonTextColor); + return src; + } } MouseArea { diff --git a/resources/qml/StatusIndicator.qml b/resources/qml/StatusIndicator.qml index 3beac649..923fdead 100644 --- a/resources/qml/StatusIndicator.qml +++ b/resources/qml/StatusIndicator.qml @@ -2,16 +2,16 @@ import QtQuick 2.5 import QtQuick.Controls 2.1 import im.nheko 1.0 -Rectangle { +ImageButton { id: indicator property int state: 0 property string eventId - color: "transparent" width: 16 height: 16 - ToolTip.visible: ma.containsMouse && state != MtxEvent.Empty + hoverEnabled: true + ToolTip.visible: hovered && state != MtxEvent.Empty ToolTip.text: { switch (state) { case MtxEvent.Failed: @@ -27,37 +27,30 @@ Rectangle { } } - MouseArea { - id: ma + onClicked: { + if (state == MtxEvent.Read) + TimelineManager.timeline.readReceiptsAction(eventId); + } - anchors.fill: parent - hoverEnabled: true - - onClicked: { - if (indicator.state == MtxEvent.Read) - TimelineManager.timeline.readReceiptsAction(indicator.eventId); + image: { + switch (state) { + case MtxEvent.Failed: + return ":/icons/icons/ui/remove-symbol.png"; + case MtxEvent.Sent: + return ":/icons/icons/ui/clock.png"; + case MtxEvent.Received: + return ":/icons/icons/ui/checkmark.png"; + case MtxEvent.Read: + return ":/icons/icons/ui/double-tick-indicator.png"; + default: + return ""; } } - Image { - id: stateImg - - // Workaround, can't get icon.source working for now... - anchors.fill: parent - source: { - switch (indicator.state) { - case MtxEvent.Failed: - return "image://colorimage/:/icons/icons/ui/remove-symbol.png?" + colors.buttonText; - case MtxEvent.Sent: - return "image://colorimage/:/icons/icons/ui/clock.png?" + colors.buttonText; - case MtxEvent.Received: - return "image://colorimage/:/icons/icons/ui/checkmark.png?" + colors.buttonText; - case MtxEvent.Read: - return "image://colorimage/:/icons/icons/ui/double-tick-indicator.png?" + colors.buttonText; - default: - return ""; - } - } + changeColorOnHover: { + if (state == MtxEvent.Read) + return true; + else + return false; } - } From 7671927fa4c2de3194f0650d5bd7fc48ce03e15b Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 16 Jan 2021 10:16:27 -0500 Subject: [PATCH 3/7] Remove unnecessary properties; simplify hover code --- resources/qml/StatusIndicator.qml | 19 +++++-------------- resources/qml/TimelineRow.qml | 2 -- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/resources/qml/StatusIndicator.qml b/resources/qml/StatusIndicator.qml index 923fdead..e9659f20 100644 --- a/resources/qml/StatusIndicator.qml +++ b/resources/qml/StatusIndicator.qml @@ -5,13 +5,11 @@ import im.nheko 1.0 ImageButton { id: indicator - property int state: 0 - property string eventId - width: 16 height: 16 hoverEnabled: true - ToolTip.visible: hovered && state != MtxEvent.Empty + changeColorOnHover: (model.state == MtxEvent.Read) + ToolTip.visible: hovered && model.state != MtxEvent.Empty ToolTip.text: { switch (state) { case MtxEvent.Failed: @@ -28,12 +26,12 @@ ImageButton { } onClicked: { - if (state == MtxEvent.Read) - TimelineManager.timeline.readReceiptsAction(eventId); + if (model.state == MtxEvent.Read) + TimelineManager.timeline.readReceiptsAction(model.id); } image: { - switch (state) { + switch (model.state) { case MtxEvent.Failed: return ":/icons/icons/ui/remove-symbol.png"; case MtxEvent.Sent: @@ -46,11 +44,4 @@ ImageButton { return ""; } } - - changeColorOnHover: { - if (state == MtxEvent.Read) - return true; - else - return false; - } } diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index 1eb07daa..077171c9 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -69,8 +69,6 @@ Item { } StatusIndicator { - state: model.state - eventId: model.id Layout.alignment: Qt.AlignRight | Qt.AlignTop Layout.preferredHeight: 16 width: 16 From 8f7ca298bc88bace4e4335585885c63e8e548635 Mon Sep 17 00:00:00 2001 From: Loren Burkholder <55629213+LorenDB@users.noreply.github.com> Date: Sat, 16 Jan 2021 10:19:26 -0500 Subject: [PATCH 4/7] Simplify source URL construction Co-authored-by: DeepBlueV7.X --- resources/qml/ImageButton.qml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/resources/qml/ImageButton.qml b/resources/qml/ImageButton.qml index 7e3e0849..58e0a2a9 100644 --- a/resources/qml/ImageButton.qml +++ b/resources/qml/ImageButton.qml @@ -19,12 +19,7 @@ AbstractButton { // Workaround, can't get icon.source working for now... anchors.fill: parent - source: { - var src = "image://colorimage/" + image; - if (changeColorOnHover) - src += "?" + (button.hovered ? highlightColor : buttonTextColor); - return src; - } + source: "image://colorimage/" + image + "?" + ((button.hovered && changeColorOnHover) ? highlightColor : buttonTextColor) } MouseArea { From b46cd339a1bd74ec8a44af0b0d6d7af166026ec6 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 16 Jan 2021 11:41:37 -0500 Subject: [PATCH 5/7] Fix tooltips --- resources/qml/StatusIndicator.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/StatusIndicator.qml b/resources/qml/StatusIndicator.qml index e9659f20..bb8a501d 100644 --- a/resources/qml/StatusIndicator.qml +++ b/resources/qml/StatusIndicator.qml @@ -11,7 +11,7 @@ ImageButton { changeColorOnHover: (model.state == MtxEvent.Read) ToolTip.visible: hovered && model.state != MtxEvent.Empty ToolTip.text: { - switch (state) { + switch (model.state) { case MtxEvent.Failed: return qsTr("Failed"); case MtxEvent.Sent: From 6f6d962ab976cc40cefa1062e3c5a224f1bf77ab Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 16 Jan 2021 11:52:58 -0500 Subject: [PATCH 6/7] Fix warning messages about null image path --- resources/qml/ImageButton.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/ImageButton.qml b/resources/qml/ImageButton.qml index 58e0a2a9..f645162c 100644 --- a/resources/qml/ImageButton.qml +++ b/resources/qml/ImageButton.qml @@ -19,7 +19,7 @@ AbstractButton { // Workaround, can't get icon.source working for now... anchors.fill: parent - source: "image://colorimage/" + image + "?" + ((button.hovered && changeColorOnHover) ? highlightColor : buttonTextColor) + source: image != "" ? ("image://colorimage/" + image + "?" + ((button.hovered && changeColorOnHover) ? highlightColor : buttonTextColor)) : "" } MouseArea { From 93b492e9e6a932bf90ad7718a00080e76fab1681 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 16 Jan 2021 19:55:50 -0500 Subject: [PATCH 7/7] Only use a pointing hand if there is something to click on --- resources/qml/ImageButton.qml | 1 + resources/qml/StatusIndicator.qml | 1 + 2 files changed, 2 insertions(+) diff --git a/resources/qml/ImageButton.qml b/resources/qml/ImageButton.qml index f645162c..9c0faef3 100644 --- a/resources/qml/ImageButton.qml +++ b/resources/qml/ImageButton.qml @@ -5,6 +5,7 @@ import QtQuick.Controls 2.3 AbstractButton { id: button + property alias cursor: mouseArea.cursorShape property string image: undefined property color highlightColor: colors.highlight property color buttonTextColor: colors.buttonText diff --git a/resources/qml/StatusIndicator.qml b/resources/qml/StatusIndicator.qml index bb8a501d..f2f99e09 100644 --- a/resources/qml/StatusIndicator.qml +++ b/resources/qml/StatusIndicator.qml @@ -9,6 +9,7 @@ ImageButton { height: 16 hoverEnabled: true changeColorOnHover: (model.state == MtxEvent.Read) + cursor: (model.state == MtxEvent.Read) ? Qt.PointingHandCursor : Qt.ArrowCursor ToolTip.visible: hovered && model.state != MtxEvent.Empty ToolTip.text: { switch (model.state) {