From 9ad062ca3003e54ce3c05313588696aece349bd9 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Wed, 21 Nov 2018 19:40:54 +0800 Subject: [PATCH] Improve Reply UI. Fix a bug in ImageItem. Update libqmatrixclient. --- .../Component/Timeline/MessageDelegate.qml | 16 ++++---- imports/Spectral/Menu/MessageContextMenu.qml | 4 +- imports/Spectral/Panel/RoomPanelInput.qml | 40 ++++++++++++++----- include/libqmatrixclient | 2 +- src/imageitem.cpp | 2 +- 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/imports/Spectral/Component/Timeline/MessageDelegate.qml b/imports/Spectral/Component/Timeline/MessageDelegate.qml index 601a18e..69876ce 100644 --- a/imports/Spectral/Component/Timeline/MessageDelegate.qml +++ b/imports/Spectral/Component/Timeline/MessageDelegate.qml @@ -32,7 +32,6 @@ ColumnLayout { visible: avatarVisible font.pixelSize: 13 - font.weight: Font.Medium verticalAlignment: Text.AlignVCenter } @@ -80,7 +79,6 @@ ColumnLayout { anchors.fill: parent onSecondaryClicked: { - index === messageListView.currentIndex ? messageListView.currentIndex = -1 : messageListView.currentIndex = index messageContextMenu.root = root messageContextMenu.model = model messageContextMenu.selectedText = contentLabel.selectedText @@ -227,14 +225,14 @@ ColumnLayout { } } - Label { - Layout.leftMargin: sentByMe ? 12 : 48 +// Label { +// Layout.leftMargin: sentByMe ? 12 : 48 - text: Qt.formatDateTime(time, "dd/MM/yyyy '-' hh:mm") +// text: Qt.formatDateTime(time, "dd/MM/yyyy '-' hh:mm") - visible: index === messageListView.currentIndex +// visible: index === messageListView.currentIndex - font.pixelSize: 13 - verticalAlignment: Text.AlignVCenter - } +// font.pixelSize: 13 +// verticalAlignment: Text.AlignVCenter +// } } diff --git a/imports/Spectral/Menu/MessageContextMenu.qml b/imports/Spectral/Menu/MessageContextMenu.qml index a843067..087b018 100644 --- a/imports/Spectral/Menu/MessageContextMenu.qml +++ b/imports/Spectral/Menu/MessageContextMenu.qml @@ -37,10 +37,10 @@ Menu { text: "Reply" onTriggered: { - roomPanelInput.isReply = true - roomPanelInput.replyUserID = model.author.id + roomPanelInput.replyUser = model.author roomPanelInput.replyEventID = model.eventId roomPanelInput.replyContent = selectedText != "" ? selectedText : model.message + roomPanelInput.isReply = true } } MenuItem { diff --git a/imports/Spectral/Panel/RoomPanelInput.qml b/imports/Spectral/Panel/RoomPanelInput.qml index 4513bd5..314898a 100644 --- a/imports/Spectral/Panel/RoomPanelInput.qml +++ b/imports/Spectral/Panel/RoomPanelInput.qml @@ -14,7 +14,7 @@ import "qrc:/js/md.js" as Markdown Control { property bool isReply - property string replyUserID + property var replyUser property string replyEventID property string replyContent @@ -107,15 +107,37 @@ Control { } } - contentItem: Column { + contentItem: ColumnLayout { spacing: 0 - add: Transition { - NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 250 } + RowLayout { + Layout.fillWidth: true + Layout.margins: 8 + + visible: isReply + + spacing: 8 + + ImageItem { + Layout.preferredWidth: 32 + Layout.preferredHeight: 32 + + source: replyUser ? replyUser.paintable : null + hint: replyUser ? replyUser.displayName : "No name" + } + + Label { + Layout.fillWidth: true + + text: replyContent + font.pixelSize: 16 + + wrapMode: Label.Wrap + } } EmojiPicker { - width: parent.width + Layout.fillWidth: true id: emojiPicker @@ -133,7 +155,7 @@ Control { } RowLayout { - width: parent.width + Layout.fillWidth: true spacing: 0 @@ -179,7 +201,7 @@ Control { id: inputField wrapMode: Text.Wrap - placeholderText: isReply ? "Reply to " + replyUserID : "Send a Message" + placeholderText: "Send a Message" topPadding: 0 bottomPadding: 0 selectByMouse: true @@ -288,7 +310,7 @@ Control { var PREFIX_MARKDOWN = '/md ' if (isReply) { - currentRoom.sendReply(replyUserID, replyEventID, replyContent, text) + currentRoom.sendReply(replyUser.id, replyEventID, replyContent, text) clearReply() return } @@ -356,7 +378,7 @@ Control { function clearReply() { isReply = false - replyUserID = "" + replyUser = null replyEventID = "" replyContent = "" } diff --git a/include/libqmatrixclient b/include/libqmatrixclient index e1fdb33..f9dccac 160000 --- a/include/libqmatrixclient +++ b/include/libqmatrixclient @@ -1 +1 @@ -Subproject commit e1fdb33a4161b29d6df590ccea339d361d9fc4e8 +Subproject commit f9dccac588f2aa1c809018c0c5eb606a1470d2c5 diff --git a/src/imageitem.cpp b/src/imageitem.cpp index 91a397b..b9eafd1 100644 --- a/src/imageitem.cpp +++ b/src/imageitem.cpp @@ -82,7 +82,7 @@ void ImageItem::setPaintable(Paintable *paintable) { } void ImageItem::setHint(QString newHint) { - if (m_hint != newHint) { + if (!m_hint.isNull() && m_hint != newHint) { m_hint = newHint; emit hintChanged(); update();