Update libqmatrixclient.

Add author label.
Add time label.
Use Roboto font.
This commit is contained in:
Black Hat 2018-11-20 08:21:28 +08:00
parent f892236bfe
commit 6d17716e97
6 changed files with 177 additions and 142 deletions

View File

@ -9,7 +9,7 @@ import Spectral.Setting 0.1
import Spectral.Component 2.0
import Spectral.Font 0.1
RowLayout {
ColumnLayout {
readonly property bool avatarVisible: !sentByMe && (aboveAuthor !== author || aboveSection !== section || aboveEventType === "state" || aboveEventType === "emote" || aboveEventType === "other")
readonly property bool highlighted: !(sentByMe || eventType === "notice" )
readonly property bool sentByMe: author === currentRoom.localUser
@ -18,12 +18,31 @@ RowLayout {
signal saveFileAs()
signal openExternally()
Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
id: root
spacing: 0
Label {
Layout.leftMargin: 48
text: author.displayName
visible: avatarVisible
font.pixelSize: 13
font.weight: Font.Medium
verticalAlignment: Text.AlignVCenter
}
RowLayout {
Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
z: -5
id: messageRow
Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
spacing: 4
ImageItem {
@ -46,7 +65,7 @@ RowLayout {
}
Control {
Layout.maximumWidth: messageListView.width - (!sentByMe ? 40 + messageRow.spacing : 0) - 48
Layout.maximumWidth: messageListView.width - (!sentByMe ? 32 + messageRow.spacing : 0) - 48
topPadding: 8
bottomPadding: 8
@ -54,14 +73,15 @@ RowLayout {
rightPadding: 16
background: Rectangle {
color: sentByMe ? "#009DC2" : (highlighted || eventType) === "notice" ? "#4285F4" : "#673AB7"
color: sentByMe ? "#009DC2" : eventType === "notice" ? "#4285F4" : "#673AB7"
radius: 18
AutoMouseArea {
anchors.fill: parent
onSecondaryClicked: {
messageContextMenu.row = messageRow
index === messageListView.currentIndex ? messageListView.currentIndex = -1 : messageListView.currentIndex = index
messageContextMenu.root = root
messageContextMenu.model = model
messageContextMenu.selectedText = contentLabel.selectedText
messageContextMenu.popup()
@ -139,8 +159,8 @@ RowLayout {
}
Component.onCompleted: {
messageRow.saveFileAs.connect(saveFileAs)
messageRow.openExternally.connect(downloadAndOpen)
root.saveFileAs.connect(saveFileAs)
root.openExternally.connect(downloadAndOpen)
}
}
}
@ -160,8 +180,8 @@ RowLayout {
id: downloadable
Component.onCompleted: {
messageRow.saveFileAs.connect(saveFileAs)
messageRow.openExternally.connect(downloadAndOpen)
root.saveFileAs.connect(saveFileAs)
root.openExternally.connect(downloadAndOpen)
}
}
}
@ -198,11 +218,23 @@ RowLayout {
onDownloadedChanged: downloaded && playOnFinished ? spectralController.playAudio(progressInfo.localPath) : {}
Component.onCompleted: {
messageRow.saveFileAs.connect(saveFileAs)
messageRow.openExternally.connect(downloadAndOpen)
root.saveFileAs.connect(saveFileAs)
root.openExternally.connect(downloadAndOpen)
}
}
}
}
}
}
Label {
Layout.leftMargin: sentByMe ? 12 : 48
text: Qt.formatDateTime(time, "dd/MM/yyyy '-' hh:mm")
visible: index === messageListView.currentIndex
font.pixelSize: 13
verticalAlignment: Text.AlignVCenter
}
}

View File

@ -2,7 +2,7 @@ import QtQuick 2.9
import QtQuick.Controls 2.2
Menu {
property var row: null
property var root: null
property var model: null
property string selectedText
@ -23,14 +23,14 @@ Menu {
height: visible ? undefined : 0
text: "Open Externally"
onTriggered: row.openExternally()
onTriggered: root.openExternally()
}
MenuItem {
visible: isFile
height: visible ? undefined : 0
text: "Save As"
onTriggered: row.saveFileAs()
onTriggered: root.saveFileAs()
}
MenuItem {
height: visible ? undefined : 0

View File

@ -80,10 +80,12 @@ Item {
id: messageListView
spacing: 4
displayMarginBeginning: 100
displayMarginEnd: 100
verticalLayoutDirection: ListView.BottomToTop
spacing: 4
highlightMoveDuration: 500
boundsBehavior: Flickable.DragOverBounds

@ -1 +1 @@
Subproject commit 6f18091a48530399908fbc6ebcb0697bae970abb
Subproject commit e1fdb33a4161b29d6df590ccea339d361d9fc4e8

View File

@ -11,3 +11,4 @@ Primary=#344955
Accent=#673AB7
;Foreground=#1D333E
;Background=#161616
Font/Family=Roboto

View File

@ -75,11 +75,11 @@ void Controller::loginWithCredentials(QString serverAddr, QString user,
setConnection(conn);
});
connect(conn, &Connection::networkError,
[=](QString error, QByteArray detail) {
[=](QString error, QString, int, int) {
emit errorOccured("Network Error", error);
});
connect(conn, &Connection::loginError,
[=](QString error, QByteArray detail) {
[=](QString error, QString) {
emit errorOccured("Login Failed", error);
});
}
@ -150,11 +150,11 @@ void Controller::invokeLogin() {
addConnection(c);
});
connect(c, &Connection::loginError,
[=](QString error, QByteArray detail) {
[=](QString error, QString) {
emit errorOccured("Login Failed", error);
});
connect(c, &Connection::networkError,
[=](QString error, QByteArray detail) {
[=](QString error, QString, int, int) {
emit errorOccured("Network Error", error);
});
c->connectWithToken(account.userId(), accessToken, account.deviceId());