Improve Reply UI.

Fix a bug in ImageItem.
Update libqmatrixclient.
This commit is contained in:
Black Hat 2018-11-21 19:40:54 +08:00
parent 6d17716e97
commit 9ad062ca30
5 changed files with 42 additions and 22 deletions

View File

@ -32,7 +32,6 @@ ColumnLayout {
visible: avatarVisible visible: avatarVisible
font.pixelSize: 13 font.pixelSize: 13
font.weight: Font.Medium
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@ -80,7 +79,6 @@ ColumnLayout {
anchors.fill: parent anchors.fill: parent
onSecondaryClicked: { onSecondaryClicked: {
index === messageListView.currentIndex ? messageListView.currentIndex = -1 : messageListView.currentIndex = index
messageContextMenu.root = root messageContextMenu.root = root
messageContextMenu.model = model messageContextMenu.model = model
messageContextMenu.selectedText = contentLabel.selectedText messageContextMenu.selectedText = contentLabel.selectedText
@ -227,14 +225,14 @@ ColumnLayout {
} }
} }
Label { // Label {
Layout.leftMargin: sentByMe ? 12 : 48 // 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 // font.pixelSize: 13
verticalAlignment: Text.AlignVCenter // verticalAlignment: Text.AlignVCenter
} // }
} }

View File

@ -37,10 +37,10 @@ Menu {
text: "Reply" text: "Reply"
onTriggered: { onTriggered: {
roomPanelInput.isReply = true roomPanelInput.replyUser = model.author
roomPanelInput.replyUserID = model.author.id
roomPanelInput.replyEventID = model.eventId roomPanelInput.replyEventID = model.eventId
roomPanelInput.replyContent = selectedText != "" ? selectedText : model.message roomPanelInput.replyContent = selectedText != "" ? selectedText : model.message
roomPanelInput.isReply = true
} }
} }
MenuItem { MenuItem {

View File

@ -14,7 +14,7 @@ import "qrc:/js/md.js" as Markdown
Control { Control {
property bool isReply property bool isReply
property string replyUserID property var replyUser
property string replyEventID property string replyEventID
property string replyContent property string replyContent
@ -107,15 +107,37 @@ Control {
} }
} }
contentItem: Column { contentItem: ColumnLayout {
spacing: 0 spacing: 0
add: Transition { RowLayout {
NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 250 } 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 { EmojiPicker {
width: parent.width Layout.fillWidth: true
id: emojiPicker id: emojiPicker
@ -133,7 +155,7 @@ Control {
} }
RowLayout { RowLayout {
width: parent.width Layout.fillWidth: true
spacing: 0 spacing: 0
@ -179,7 +201,7 @@ Control {
id: inputField id: inputField
wrapMode: Text.Wrap wrapMode: Text.Wrap
placeholderText: isReply ? "Reply to " + replyUserID : "Send a Message" placeholderText: "Send a Message"
topPadding: 0 topPadding: 0
bottomPadding: 0 bottomPadding: 0
selectByMouse: true selectByMouse: true
@ -288,7 +310,7 @@ Control {
var PREFIX_MARKDOWN = '/md ' var PREFIX_MARKDOWN = '/md '
if (isReply) { if (isReply) {
currentRoom.sendReply(replyUserID, replyEventID, replyContent, text) currentRoom.sendReply(replyUser.id, replyEventID, replyContent, text)
clearReply() clearReply()
return return
} }
@ -356,7 +378,7 @@ Control {
function clearReply() { function clearReply() {
isReply = false isReply = false
replyUserID = "" replyUser = null
replyEventID = "" replyEventID = ""
replyContent = "" replyContent = ""
} }

@ -1 +1 @@
Subproject commit e1fdb33a4161b29d6df590ccea339d361d9fc4e8 Subproject commit f9dccac588f2aa1c809018c0c5eb606a1470d2c5

View File

@ -82,7 +82,7 @@ void ImageItem::setPaintable(Paintable *paintable) {
} }
void ImageItem::setHint(QString newHint) { void ImageItem::setHint(QString newHint) {
if (m_hint != newHint) { if (!m_hint.isNull() && m_hint != newHint) {
m_hint = newHint; m_hint = newHint;
emit hintChanged(); emit hintChanged();
update(); update();