summary refs log tree commit diff
path: root/resources/qml
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2020-05-08 00:13:24 +0200
committerGitHub <noreply@github.com>2020-05-08 00:13:24 +0200
commit7beaf868efa500767451666e562b72a9968b6b59 (patch)
tree519d0de73e8c4fb8f8d01e0375b847a287927570 /resources/qml
parentFix messages being immediately read again (diff)
parentRemove unused binding name (diff)
downloadnheko-7beaf868efa500767451666e562b72a9968b6b59.tar.xz
Merge pull request #192 from Nheko-Reborn/reactions
Reactions
Diffstat (limited to 'resources/qml')
-rw-r--r--resources/qml/Avatar.qml4
-rw-r--r--resources/qml/ImageButton.qml8
-rw-r--r--resources/qml/Reactions.qml76
-rw-r--r--resources/qml/TimelineRow.qml4
-rw-r--r--resources/qml/TimelineView.qml20
-rw-r--r--resources/qml/delegates/Reply.qml2
6 files changed, 102 insertions, 12 deletions
diff --git a/resources/qml/Avatar.qml b/resources/qml/Avatar.qml

index b1007469..ed065270 100644 --- a/resources/qml/Avatar.qml +++ b/resources/qml/Avatar.qml
@@ -19,7 +19,7 @@ Rectangle { verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter visible: img.status != Image.Ready - color: colors.brightText + color: colors.text } Image { @@ -43,5 +43,5 @@ Rectangle { } } } - color: colors.dark + color: colors.base } diff --git a/resources/qml/ImageButton.qml b/resources/qml/ImageButton.qml
index dc576e18..dd100503 100644 --- a/resources/qml/ImageButton.qml +++ b/resources/qml/ImageButton.qml
@@ -1,17 +1,11 @@ import QtQuick 2.3 import QtQuick.Controls 2.3 -Button { +AbstractButton { property string image: undefined id: button - flat: true - - // disable background, because we don't want a border on hover - background: Item { - } - Image { id: buttonImg // Workaround, can't get icon.source working for now... diff --git a/resources/qml/Reactions.qml b/resources/qml/Reactions.qml new file mode 100644
index 00000000..cb15b723 --- /dev/null +++ b/resources/qml/Reactions.qml
@@ -0,0 +1,76 @@ +import QtQuick 2.6 +import QtQuick.Controls 2.2 + +Flow { + anchors.left: parent.left + anchors.right: parent.right + spacing: 4 + + property alias reactions: repeater.model + + Repeater { + id: repeater + + AbstractButton { + id: reaction + text: model.key + hoverEnabled: true + implicitWidth: contentItem.childrenRect.width + contentItem.leftPadding*2 + implicitHeight: contentItem.childrenRect.height + + ToolTip.visible: hovered + ToolTip.text: model.users + + + contentItem: Row { + anchors.centerIn: parent + spacing: reactionText.implicitHeight/4 + leftPadding: reactionText.implicitHeight / 2 + rightPadding: reactionText.implicitHeight / 2 + + TextMetrics { + id: textMetrics + font.family: settings.emoji_font_family + elide: Text.ElideRight + elideWidth: 150 + text: reaction.text + } + + Text { + anchors.baseline: reactionCounter.baseline + id: reactionText + text: textMetrics.elidedText + (textMetrics.elidedText == textMetrics.text ? "" : "…") + font.family: settings.emoji_font_family + color: reaction.hovered ? colors.highlight : colors.text + maximumLineCount: 1 + } + + Rectangle { + id: divider + height: reactionCounter.implicitHeight * 1.4 + width: 1 + color: reaction.hovered ? colors.highlight : colors.text + } + + Text { + anchors.verticalCenter: divider.verticalCenter + id: reactionCounter + text: model.counter + font: reaction.font + color: reaction.hovered ? colors.highlight : colors.text + } + } + + background: Rectangle { + anchors.centerIn: parent + implicitWidth: reaction.implicitWidth + implicitHeight: reaction.implicitHeight + border.color: (reaction.hovered || model.selfReacted )? colors.highlight : colors.text + color: colors.base + border.width: 1 + radius: reaction.height / 2.0 + } + } + } +} + diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml
index 05c69112..22222ef3 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml
@@ -52,6 +52,10 @@ MouseArea { modelData: model } + + Reactions { + reactions: model.reactions + } } StatusIndicator { diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml
index 997f901e..eca646d1 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml
@@ -25,6 +25,7 @@ Page { id: settings category: "user" property bool avatar_circles: true + property string emoji_font_family: "default" } Settings { @@ -133,6 +134,21 @@ Page { sequence: StandardKey.MoveToNextPage onActivated: { chat.contentY = chat.contentY + chat.height / 2; chat.returnToBounds(); } } + Shortcut { + sequence: StandardKey.Cancel + onActivated: chat.model.reply = undefined + } + Shortcut { + sequence: "Alt+Up" + onActivated: chat.model.reply = chat.model.indexToId(chat.model.reply? chat.model.idToIndex(chat.model.reply) + 1 : 0) + } + Shortcut { + sequence: "Alt+Down" + onActivated: { + var idx = chat.model.reply? chat.model.idToIndex(chat.model.reply) - 1 : -1 + chat.model.reply = idx >= 0 ? chat.model.indexToId(idx) : undefined + } + } ScrollBar.vertical: ScrollBar { id: scrollbar @@ -210,7 +226,7 @@ Page { anchors.horizontalCenter: parent ? parent.horizontalCenter : undefined visible: section.includes(" ") text: chat.model.formatDateSeparator(modelData.timestamp) - color: colors.brightText + color: colors.text height: fontMetrics.height * 1.4 width: contentWidth * 1.2 @@ -218,7 +234,7 @@ Page { horizontalAlignment: Text.AlignHCenter background: Rectangle { radius: parent.height / 2 - color: colors.dark + color: colors.base } } Row { diff --git a/resources/qml/delegates/Reply.qml b/resources/qml/delegates/Reply.qml
index 1b1be345..90013de9 100644 --- a/resources/qml/delegates/Reply.qml +++ b/resources/qml/delegates/Reply.qml
@@ -15,7 +15,7 @@ Item { MouseArea { anchors.fill: parent preventStealing: true - onClicked: chat.positionViewAtIndex(chat.model.idToIndex(timelineManager.replyingEvent), ListView.Contain) + onClicked: chat.positionViewAtIndex(chat.model.idToIndex(modelData.id), ListView.Contain) cursorShape: Qt.PointingHandCursor }