Remove sender tooltip, and sender label, simplify MessageDelegate, add

an option to invoke GC, and update libqmatrixclient.
square-messages
Black Hat 2018-08-13 22:44:32 +08:00
parent c765af9bce
commit 230231a42f
12 changed files with 58 additions and 26 deletions

@ -1 +1 @@
Subproject commit 825b46f42c3d7c813ccab49023e6f7ed6a5e1477 Subproject commit 4e45218924babe6708fe2128574a3cf6341fe3c6

View File

@ -2,7 +2,7 @@ import QtQuick 2.9
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
Row { Row {
readonly property bool avatarVisible: !sentByMe && aboveAuthor !== author || section !== aboveSection readonly property bool avatarVisible: !(sentByMe || (aboveAuthor === author && section === aboveSection))
spacing: 6 spacing: 6
@ -15,14 +15,6 @@ Row {
visible: avatarVisible visible: avatarVisible
source: author.avatarUrl != "" ? "image://mxc/" + author.avatarUrl : null source: author.avatarUrl != "" ? "image://mxc/" + author.avatarUrl : null
displayText: author.displayName displayText: author.displayName
MouseArea {
anchors.fill: parent
hoverEnabled: true
ToolTip.visible: containsMouse
ToolTip.text: author.displayName
}
} }
Rectangle { Rectangle {

View File

@ -0,0 +1,13 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Dialogs 1.2
FileDialog {
id: locationDialog
title: "Please choose a location"
folder: shortcuts.home
selectFolder: true
onAccepted: currentRoom.downloadFile(eventId, folder + "/" + currentRoom.fileNameToDownload(eventId))
onVisibleChanged: visible ? {} : locationDialog.destroy()
}

View File

@ -1,7 +1,6 @@
import QtQuick 2.9 import QtQuick 2.9
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2 import QtQuick.Controls.Material 2.2
import QtQuick.Dialogs 1.2
Item { Item {
property bool openOnFinished: false property bool openOnFinished: false
@ -15,19 +14,10 @@ Item {
opacity: 0.4 opacity: 0.4
} }
FileDialog {
id: locationDialog
title: "Please choose a location"
folder: shortcuts.home
selectFolder: true
onAccepted: currentRoom.downloadFile(eventId, folder + "/" + currentRoom.fileNameToDownload(eventId))
}
onDownloadedChanged: downloaded && openOnFinished ? openSavedFile() : {} onDownloadedChanged: downloaded && openOnFinished ? openSavedFile() : {}
function saveFileAs() { function saveFileAs() {
locationDialog.open() Qt.createComponent("DownloadDialog.qml").createObject(this).open()
} }
function downloadAndOpen() function downloadAndOpen()

View File

@ -18,6 +18,7 @@ AvatarContainer {
maximumWidth: messageListView.width maximumWidth: messageListView.width
highlighted: !sentByMe highlighted: !sentByMe
timeLabelVisible: false timeLabelVisible: false
authorLabelVisible: messageRow.avatarVisible
displayText: "<b>File: </b>" + content.body displayText: "<b>File: </b>" + content.body
} }

View File

@ -13,6 +13,7 @@ AvatarContainer {
flat: isNotice flat: isNotice
highlighted: !sentByMe highlighted: !sentByMe
timeLabelVisible: Math.abs(time - aboveTime) > 600000 || index == 0 timeLabelVisible: Math.abs(time - aboveTime) > 600000 || index == 0
authorLabelVisible: messageRow.avatarVisible
displayText: display displayText: display
} }

View File

@ -2,6 +2,10 @@ import QtQuick 2.9
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
Menu { Menu {
readonly property bool isFile: eventType === "video" || eventType === "audio" || eventType === "file" || eventType === "image"
id: messageContextMenu
MenuItem { MenuItem {
text: "Copy" text: "Copy"
onTriggered: matriqueController.copyToClipboard(plainText) onTriggered: matriqueController.copyToClipboard(plainText)
@ -30,4 +34,5 @@ Menu {
} }
Component.onCompleted: popup() Component.onCompleted: popup()
onClosed: messageContextMenu.destroy()
} }

View File

@ -11,8 +11,6 @@ Item {
readonly property bool sentByMe: author === currentRoom.localUser readonly property bool sentByMe: author === currentRoom.localUser
readonly property bool isState: eventType === "state" || eventType === "emote" readonly property bool isState: eventType === "state" || eventType === "emote"
readonly property bool isMessage: eventType === "message" || eventType === "notice"
readonly property bool isFile: eventType === "video" || eventType === "audio" || eventType === "file" || eventType === "image"
visible: marks !== EventStatus.Hidden visible: marks !== EventStatus.Hidden
@ -31,6 +29,23 @@ Item {
Loader { Loader {
id: delegateLoader id: delegateLoader
source: eventType != "redaction" ? isMessage ? "MessageBubble.qml" : isState ? "StateBubble.qml" : isFile ? eventType === "image" ? "ImageBubble.qml" : "FileBubble.qml" : "" : "" source: {
if (eventType == "redaction") return ""
switch (eventType) {
case "state":
case "emote":
return "StateBubble.qml"
case "message":
case "notice":
return "MessageBubble.qml"
case "image":
return "ImageBubble.qml"
case "video":
case "audio":
case "file":
return "FileBubble.qml"
}
return ""
}
} }
} }

View File

@ -6,6 +6,7 @@ TextDelegate {
maximumWidth: messageListView.width maximumWidth: messageListView.width
highlighted: eventType === "emote" highlighted: eventType === "emote"
timeLabelVisible: false timeLabelVisible: false
authorLabelVisible: false
displayText: "<b>" + author.displayName + "</b> " + display displayText: "<b>" + author.displayName + "</b> " + display
} }

View File

@ -8,6 +8,7 @@ Rectangle {
property bool highlighted: false property bool highlighted: false
property string displayText: "" property string displayText: ""
property alias timeLabelVisible: timeText.visible property alias timeLabelVisible: timeText.visible
property alias authorLabelVisible: authorText.visible
property int maximumWidth property int maximumWidth
@ -15,8 +16,8 @@ Rectangle {
id: messageRect id: messageRect
width: Math.min(Math.max(messageText.implicitWidth, (timeText.visible ? timeText.implicitWidth : 0)) + 24, maximumWidth) width: Math.min(Math.max(messageText.implicitWidth, (timeText.visible ? timeText.implicitWidth : 0), (authorLabelVisible ? authorText.implicitWidth : 0)) + 24, maximumWidth)
height: messageText.implicitHeight + (timeText.visible ? timeText.implicitHeight : 0) + 24 height: (authorText.visible ? authorText.implicitHeight : 0) + messageText.implicitHeight + (timeText.visible ? timeText.implicitHeight : 0) + 24
color: flat ? "transparent" : highlighted ? Material.accent : background color: flat ? "transparent" : highlighted ? Material.accent : background
border.color: Material.accent border.color: Material.accent
@ -29,6 +30,13 @@ Rectangle {
anchors.margins: 12 anchors.margins: 12
spacing: 0 spacing: 0
Label {
id: authorText
text: author.displayName
color: darkBackground ? "white" : Material.accent
font.bold: true
}
Label { Label {
id: messageText id: messageText
Layout.maximumWidth: parent.width Layout.maximumWidth: parent.width

View File

@ -9,5 +9,10 @@ Page {
id: lazyLoadSwitch id: lazyLoadSwitch
text: "Lazy Load at Initial Sync" text: "Lazy Load at Initial Sync"
} }
Button {
text: "Invoke GC"
highlighted: true
onClicked: gc()
}
} }
} }

View File

@ -32,5 +32,6 @@
<file>qml/form/SettingGeneralForm.qml</file> <file>qml/form/SettingGeneralForm.qml</file>
<file>qml/component/EmojiPicker.qml</file> <file>qml/component/EmojiPicker.qml</file>
<file>qml/component/EmojiButton.qml</file> <file>qml/component/EmojiButton.qml</file>
<file>qml/component/DownloadDialog.qml</file>
</qresource> </qresource>
</RCC> </RCC>