Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
trinity/qml/Client.qml

1191 lines
34 KiB
QML
Raw Normal View History

import QtQuick 2.15
2021-07-21 16:08:15 -04:00
import QtQuick.Controls 2.3
import QtGraphicalEffects 1.0
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
2021-07-21 16:08:15 -04:00
import trinity.matrix 1.0
Rectangle {
id: client
color: myPalette.window
2021-07-21 16:08:15 -04:00
property bool shouldScroll: false
property var openProfile: function(member) {
var popup = Qt.createComponent("qrc:/Profile.qml")
var popupContainer = popup.createObject(window, {"parent": window, "member": member})
2021-07-21 16:08:15 -04:00
popupContainer.open()
}
2021-07-21 16:08:15 -04:00
property var openRoom: function(room) {
var popup = Qt.createComponent("qrc:/RoomSettings.qml")
var popupContainer = popup.createObject(window, {"parent": window, "room": room})
2021-07-21 16:08:15 -04:00
popupContainer.open()
}
2021-07-21 16:08:15 -04:00
Rectangle {
anchors.fill: parent
visible: !matrix.initialSyncComplete
2021-07-21 16:08:15 -04:00
z: 1000
2021-07-21 16:08:15 -04:00
MouseArea {
anchors.fill: parent
hoverEnabled: true
}
2021-07-21 16:08:15 -04:00
BusyIndicator {
id: syncIndicator
2021-07-21 16:08:15 -04:00
anchors.centerIn: parent
}
2021-07-21 16:08:15 -04:00
Text {
anchors.top: syncIndicator.bottom
anchors.horizontalCenter: parent.horizontalCenter
2021-07-21 16:08:15 -04:00
text: "Synchronizing events..."
}
2021-07-21 16:08:15 -04:00
Button {
anchors.bottom: parent.bottom
anchors.bottomMargin: 15
anchors.horizontalCenter: parent.horizontalCenter
2021-07-21 16:08:15 -04:00
text: "Log out"
}
}
2021-07-21 16:08:15 -04:00
Rectangle {
id: channels
2021-07-21 16:08:15 -04:00
width: 180
2021-07-21 16:08:15 -04:00
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
2021-07-21 16:08:15 -04:00
Rectangle {
id: profileRect
2021-07-21 16:08:15 -04:00
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
2021-07-21 16:08:15 -04:00
height: 45
2021-07-21 16:08:15 -04:00
color: myPalette.mid
Text {
text: "Placeholder name"
}
Button {
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 10
text: "Switch"
onClicked: accountMenu.popup()
Menu {
id: accountMenu
Repeater {
model: app.accounts
MenuItem {
text: modelData.profileName
onClicked: app.switchAccount(modelData.profileName)
2021-07-21 16:08:15 -04:00
}
}
MenuSeparator {}
MenuItem {
text: "Add new account"
onClicked: app.addAccount("test")
}
2021-07-21 16:08:15 -04:00
}
}
}
2021-07-21 16:08:15 -04:00
ListView {
id: channelListView
2021-07-21 16:08:15 -04:00
anchors.left: parent.left
anchors.right: parent.right
anchors.top: profileRect.bottom
anchors.bottom: parent.bottom
anchors.margins: 10
2021-07-21 16:08:15 -04:00
spacing: 5
2021-07-21 16:08:15 -04:00
model: matrix.roomListModel
2021-07-21 16:08:15 -04:00
section.property: "section"
section.criteria: ViewSection.FullString
section.delegate: Rectangle {
width: parent.width
height: 25
2021-07-21 16:08:15 -04:00
color: "transparent"
2021-07-21 16:08:15 -04:00
Text {
anchors.verticalCenter: parent.verticalCenter
2021-07-21 16:08:15 -04:00
anchors.left: parent.left
anchors.leftMargin: 5
2021-07-21 16:08:15 -04:00
text: section
color: myPalette.text
textFormat: Text.PlainText
2021-07-21 16:08:15 -04:00
}
}
delegate: Rectangle {
anchors.left: parent.left
anchors.right: parent.right
height: 25
2021-07-21 16:08:15 -04:00
property bool selected: channelListView.currentIndex === matrix.roomListModel.getOriginalIndex(index)
2021-07-21 16:08:15 -04:00
color: selected ? myPalette.highlight : "transparent"
radius: 5
RoundedImage {
id: roomAvatar
anchors.top: parent.top
anchors.topMargin: 5
anchors.left: parent.left
anchors.leftMargin: 5
width: 18
height: 18
source: avatarURL ? avatarURL : "placeholder.png"
2021-07-21 16:08:15 -04:00
}
Text {
text: alias
anchors.verticalCenter: parent.verticalCenter
anchors.left: roomAvatar.right
anchors.leftMargin: 5
anchors.right: parent.right
anchors.rightMargin: 5
2021-07-21 16:08:15 -04:00
color: selected ? "white" : (highlightCount > 0 ? "red" : (notificationCount > 0 ? "blue" : myPalette.text))
2021-07-21 16:08:15 -04:00
textFormat: Text.PlainText
elide: Text.ElideRight
}
2021-07-21 16:08:15 -04:00
MouseArea {
anchors.fill: parent
2021-07-21 16:08:15 -04:00
cursorShape: Qt.PointingHandCursor
2021-07-21 16:08:15 -04:00
acceptedButtons: Qt.LeftButton | Qt.RightButton
2021-07-21 16:08:15 -04:00
onReleased: {
if(mouse.button == Qt.LeftButton) {
if(!selected) {
var originalIndex = matrix.roomListModel.getOriginalIndex(index)
matrix.changeCurrentRoom(originalIndex)
channelListView.currentIndex = originalIndex
}
} else
contextMenu.popup()
}
}
2021-07-21 16:08:15 -04:00
Menu {
id: contextMenu
2021-07-21 16:08:15 -04:00
MenuItem {
text: "Mark As Read"
2021-07-21 16:08:15 -04:00
onReleased: matrix.readUpTo(matrix.getRoom(matrix.roomListModel.getOriginalIndex(index)), 0)
}
2021-07-21 16:08:15 -04:00
MenuSeparator {}
2021-07-21 16:08:15 -04:00
GroupBox {
title: "Notification Settings"
2021-07-21 16:08:15 -04:00
Column {
spacing: 10
RadioButton {
text: "All messages"
ToolTip.text: "Recieve a notification for all messages in this room."
ToolTip.visible: hovered
onReleased: matrix.getRoom(matrix.roomListModel.getOriginalIndex(index)).notificationLevel = 2
checked: matrix.getRoom(matrix.roomListModel.getOriginalIndex(index)).notificationLevel === 2
}
2021-07-21 16:08:15 -04:00
RadioButton {
text: "Only Mentions"
2021-07-21 16:08:15 -04:00
ToolTip.text: "Recieve a notification for mentions in this room."
ToolTip.visible: hovered
onReleased: matrix.getRoom(matrix.roomListModel.getOriginalIndex(index)).notificationLevel = 1
checked: matrix.getRoom(matrix.roomListModel.getOriginalIndex(index)).notificationLevel === 1
}
RadioButton {
text: "Mute"
ToolTip.text: "Don't get notifications or unread indicators for this room."
ToolTip.visible: hovered
onReleased: matrix.getRoom(matrix.roomListModel.getOriginalIndex(index)).notificationLevel = 0
checked: matrix.getRoom(matrix.roomListModel.getOriginalIndex(index)).notificationLevel === 3
}
2021-07-21 16:08:15 -04:00
}
}
MenuSeparator {}
2021-07-21 16:08:15 -04:00
MenuItem {
text: "Settings"
2021-07-21 16:08:15 -04:00
onReleased: openRoom(matrix.getRoom(matrix.roomListModel.getOriginalIndex(index)))
}
2021-07-21 16:08:15 -04:00
MenuSeparator {}
2021-07-21 16:08:15 -04:00
MenuItem {
text: "Leave Room"
2021-07-21 16:08:15 -04:00
onReleased: {
showDialog("Leave Confirmation", "Are you sure you want to leave " + alias + "?", [
{
text: "Yes",
onClicked: function(dialog) {
matrix.leaveRoom(id)
dialog.close()
}
},
{
text: "No",
onClicked: function(dialog) {
dialog.close()
}
}
])
}
2021-07-21 16:08:15 -04:00
}
}
}
}
2021-07-21 16:08:15 -04:00
Button {
width: parent.width
2021-07-21 16:08:15 -04:00
anchors.bottom: directoryButton.top
2021-07-21 16:08:15 -04:00
text: "Switch account"
2021-07-21 16:08:15 -04:00
onClicked: app.addAccount("test")
}
2021-07-21 16:08:15 -04:00
Button {
id: communitiesButton
width: parent.width
anchors.bottom: parent.bottom
2021-07-21 16:08:15 -04:00
text: "Communities"
2021-07-21 16:08:15 -04:00
onClicked: stack.push("qrc:/Communities.qml")
}
Button {
id: directoryButton
width: parent.width
2021-07-21 16:08:15 -04:00
anchors.bottom: communitiesButton.top
2021-07-21 16:08:15 -04:00
text: "Directory"
2021-07-21 16:08:15 -04:00
onClicked: stack.push("qrc:/Directory.qml")
}
2021-07-21 16:08:15 -04:00
}
Rectangle {
id: rightArea
height: parent.height
anchors.left: channels.right
anchors.right: parent.right
Rectangle {
id: overlay
2021-07-21 16:08:15 -04:00
z: 999
anchors.top: roomHeader.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
visible: matrix.currentRoom.guestDenied
Text {
id: invitedByLabel
anchors.centerIn: parent
color: myPalette.text
text: "You have been invited to this room by " + matrix.currentRoom.invitedBy
textFormat: Text.PlainText
}
RowLayout {
anchors.top: invitedByLabel.bottom
anchors.topMargin: 15
anchors.horizontalCenter: parent.horizontalCenter
Button {
text: "Accept"
onReleased: {
matrix.joinRoom(matrix.currentRoom.id)
}
}
Button {
text: "Deny"
onReleased: {
matrix.joinRoom(matrix.currentRoom.id)
}
}
}
}
2021-07-21 16:08:15 -04:00
Rectangle {
id: roomHeader
height: 45
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
2021-07-21 16:08:15 -04:00
color: myPalette.mid
2021-07-21 16:08:15 -04:00
RoundedImage {
2021-07-21 16:08:15 -04:00
id: channelAvatar
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 15
width: 33
height: 33
source: matrix.currentRoom.avatar ? matrix.currentRoom.avatar : "placeholder.png"
}
Text {
id: channelTitle
font.pointSize: 12
2021-07-21 16:08:15 -04:00
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 15
anchors.left: channelAvatar.right
text: matrix.currentRoom.name
color: myPalette.text
2021-07-21 16:08:15 -04:00
textFormat: Text.PlainText
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onReleased: openRoom(matrix.currentRoom)
}
2021-07-21 16:08:15 -04:00
}
Text {
id: channelTopic
font.pointSize: 12
anchors.verticalCenter: parent.verticalCenter
maximumLineCount: 1
2021-07-21 16:08:15 -04:00
anchors.left: channelTitle.right
anchors.leftMargin: 10
anchors.right: audioCallButton.left
2021-07-21 16:08:15 -04:00
text: {
if(matrix.currentRoom.direct)
return "";
if(matrix.currentRoom.topic.length == 0)
return "This room has no topic set."
else
return matrix.currentRoom.topic
}
color: myPalette.text
2021-07-21 16:08:15 -04:00
elide: Text.ElideRight
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onReleased: showDialog(matrix.currentRoom.name, matrix.currentRoom.topic)
}
textFormat: Text.PlainText
}
ToolBarButton {
id: videoCallButton
2021-07-21 16:08:15 -04:00
anchors.verticalCenter: parent.verticalCenter
anchors.right: audioCallButton.left
2021-07-21 16:08:15 -04:00
anchors.rightMargin: 10
name: "Video Call"
toolIcon: "icons/memberlist.png"
}
2021-07-21 16:08:15 -04:00
ToolBarButton {
id: audioCallButton
2021-07-21 16:08:15 -04:00
anchors.verticalCenter: parent.verticalCenter
2021-07-21 16:08:15 -04:00
anchors.right: notificationsButton.left
anchors.rightMargin: 10
2021-07-21 16:08:15 -04:00
name: "Voice Call"
toolIcon: "icons/memberlist.png"
}
2021-07-21 16:08:15 -04:00
ToolBarButton {
id: notificationsButton
2021-07-21 16:08:15 -04:00
anchors.verticalCenter: parent.verticalCenter
2021-07-21 16:08:15 -04:00
anchors.right: roomInfoButton.left
anchors.rightMargin: 10
2021-07-21 16:08:15 -04:00
name: "Notifications"
toolIcon: "icons/memberlist.png"
2021-07-21 16:08:15 -04:00
}
ToolBarButton {
id: roomInfoButton
2021-07-21 16:08:15 -04:00
anchors.verticalCenter: parent.verticalCenter
anchors.right: settingsButton.left
anchors.rightMargin: 10
2021-07-21 16:08:15 -04:00
onPressed: {
if(memberList.width == 0)
memberList.width = 200
else
memberList.width = 0
}
2021-07-21 16:08:15 -04:00
name: "Room Info"
toolIcon: "icons/memberlist.png"
isActivated: memberList.width == 200
}
2021-07-21 16:08:15 -04:00
ToolBarButton {
id: settingsButton
2021-07-21 16:08:15 -04:00
anchors.verticalCenter: parent.verticalCenter
2021-07-21 16:08:15 -04:00
anchors.right: parent.right
anchors.rightMargin: 15
2021-07-21 16:08:15 -04:00
onPressed: stack.push("qrc:/Settings.qml")
name: "Settings"
toolIcon: "icons/settings.png"
2021-07-21 16:08:15 -04:00
}
}
Rectangle {
id: messagesArea
anchors.top: roomHeader.bottom
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.right: memberList.left
2021-07-21 16:08:15 -04:00
Rectangle {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: messageInputParent.top
2021-07-21 16:08:15 -04:00
clip: true
color: myPalette.light
2021-07-21 16:08:15 -04:00
ListView {
id: messages
model: matrix.eventModel
anchors.fill: parent
cacheBuffer: 200
delegate: Rectangle {
anchors.left: messages.contentItem.left
anchors.right: messages.contentItem.right
anchors.margins: 10
2021-07-21 16:08:15 -04:00
height: (condense ? 5 : 25) + messageArea.height
color: "transparent"
property string attachment: display.attachment
property var sender: matrix.resolveMemberId(display.sender)
property var eventId: display.eventId
property var msg: display.msg
RoundedImage {
2021-07-21 16:08:15 -04:00
id: avatar
width: 33
height: 33
anchors.top: parent.top
anchors.topMargin: 5
anchors.left: parent.left
anchors.leftMargin: 5
source: sender == null ? "placeholder.png"
: (sender.avatarURL ? sender.avatarURL : "placeholder.png")
2021-07-21 16:08:15 -04:00
visible: !condense
}
Text {
id: senderText
text: condense || sender == null ? "" : sender.displayName
2021-07-21 16:08:15 -04:00
color: myPalette.text
font.bold: true
2021-07-21 16:08:15 -04:00
anchors.left: avatar.right
anchors.leftMargin: 10
textFormat: Text.PlainText
}
MouseArea {
id: senderClickArea
anchors.left: avatar.left
anchors.right: senderText.right
anchors.top: avatar.top
anchors.bottom: avatar.bottom
cursorShape: Qt.PointingHandCursor
onClicked: openProfile(sender)
}
2021-07-21 16:08:15 -04:00
Text {
text: condense ? "" : timestamp
color: myPalette.dark
2021-07-21 16:08:15 -04:00
anchors.left: senderText.right
anchors.leftMargin: 10
textFormat: Text.PlainText
}
Rectangle {
id: messageArea
y: condense ? 0 : 20
height: {
if(display.msgType === "text")
return message.contentHeight
else if(display.msgType === "image")
return messageThumbnail.height
else
return preview.height
}
anchors.left: condense ? parent.left : avatar.right
anchors.leftMargin: condense ? 48 : 10
anchors.right: parent.right
2021-07-21 16:08:15 -04:00
color: "transparent"
TextEdit {
id: message
width: parent.width
text: display.msg
wrapMode: Text.WordWrap
2021-07-21 16:08:15 -04:00
textFormat: Text.RichText
readOnly: true
selectByMouse: true
color: display.sent ? myPalette.text : myPalette.mid
2021-07-21 16:08:15 -04:00
visible: display.msgType === "text"
}
Image {
id: messageThumbnail
visible: display.msgType === "image"
source: display.thumbnail
fillMode: Image.PreserveAspectFit
width: Math.min(sourceSize.width, 400)
}
MouseArea {
enabled: display.msgType === "image"
cursorShape: Qt.PointingHandCursor
anchors.fill: messageThumbnail
onReleased: showImage(display.attachment)
}
Rectangle {
id: preview
width: 350
height: 45
visible: display.msgType === "file"
radius: 5
color: Qt.rgba(0.05, 0.05, 0.05, 1.0)
Text {
id: previewFilename
x: 15
y: 7
text: display.msg
color: "#048dc2"
}
Text {
id: previewFilesize
x: 15
y: 22
font.pointSize: 9
text: display.attachmentSize / 1000.0 + " KB"
color: "gray"
}
ToolButton {
id: previewFileDownload
width: 25
height: 25
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 10
Image {
id: downloadButtonImage
anchors.fill: parent
sourceSize.width: parent.width
sourceSize.height: parent.height
source: "icons/download.png"
}
ColorOverlay {
anchors.fill: parent
source: downloadButtonImage
color: parent.hovered ? "white" : Qt.rgba(0.8, 0.8, 0.8, 1.0)
}
onClicked: {
console.log(attachment)
Qt.openUrlExternally(attachment)
}
}
}
}
MouseArea {
anchors.fill: messageArea
acceptedButtons: Qt.RightButton
propagateComposedEvents: true
onClicked: contextMenu.popup()
}
Menu {
id: contextMenu
MenuItem {
text: "Remove"
onReleased: matrix.removeMessage(eventId)
}
MenuItem {
text: "Permalink"
onReleased: Qt.openUrlExternally("https://matrix.to/#/" + matrix.currentRoom.id + "/" + eventId)
}
MenuItem {
text: "Quote"
onReleased: messageInput.append("> " + msg + "\n\n")
}
}
}
ScrollBar.vertical: ScrollBar {}
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.VerticalFlick
verticalLayoutDirection: ListView.BottomToTop
onMovingVerticallyChanged: {
if(verticalVelocity < 0)
matrix.readMessageHistory(matrix.currentRoom)
}
// we scrolled
onContentYChanged: {
var index = indexAt(0, contentY + height - 5)
matrix.readUpTo(matrix.currentRoom, index)
}
// a new message was added
onContentHeightChanged: {
var index = indexAt(0, contentY + height - 5)
matrix.readUpTo(matrix.currentRoom, index)
//print(contentHeight + "," + height);
if(contentHeight < height) {
matrix.readMessageHistory(matrix.currentRoom)
2021-07-21 16:08:15 -04:00
}
}
}
}
Rectangle {
id: messageInputParent
anchors.bottom: parent.bottom
2021-07-21 16:08:15 -04:00
width: parent.width
height: 55
color: "transparent"
2021-07-21 16:08:15 -04:00
ToolButton {
id: attachButton
icon.name: "mail-attachment"
width: 30
height: 30
anchors.top: parent.top
anchors.topMargin: 5
anchors.left: parent.left
anchors.leftMargin: 5
ToolTip.text: "Attach File"
ToolTip.visible: hovered
onReleased: openAttachmentFileDialog.open()
}
TextArea {
id: messageInput
width: parent.width - attachButton.width - 10
height: 30
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
anchors.left: attachButton.right
anchors.leftMargin: 5
anchors.right: parent.right
anchors.rightMargin: 5
placeholderText: "Send a " + (matrix.currentRoom.encrypted ? "encrypted" : "unencrypted") + " message to " + matrix.currentRoom.name
2021-07-21 16:08:15 -04:00
Keys.onReturnPressed: {
if(event.modifiers & Qt.ShiftModifier) {
event.accepted = false
} else {
event.accepted = true
matrix.sendMessage(matrix.currentRoom, text)
clear()
}
}
onTextChanged: {
height = Math.max(30, contentHeight + 13)
parent.height = Math.max(55, contentHeight + 20)
}
}
ToolButton {
id: markdownButton
icon.name: "text-x-generic"
width: 20
height: 20
anchors.top: messageInput.top
anchors.topMargin: 5
anchors.right: emojiButton.left
anchors.rightMargin: 5
ToolTip.text: "Markdown is " + (matrix.markdownEnabled ? "enabled" : "disabled")
ToolTip.visible: hovered
onReleased: matrix.markdownEnabled = !matrix.markdownEnabled
}
ToolButton {
id: emojiButton
icon.name: "face-smile"
width: 20
height: 20
anchors.top: messageInput.top
anchors.topMargin: 5
anchors.right: messageInput.right
anchors.rightMargin: 5
ToolTip.text: "Add emoji"
ToolTip.visible: hovered
}
Text {
id: typingLabel
anchors.bottom: messageInputParent.bottom
color: myPalette.text
2021-07-21 16:08:15 -04:00
text: matrix.typingText
textFormat: Text.PlainText
}
}
}
Rectangle {
id: memberList
anchors.top: roomHeader.bottom
anchors.right: parent.right
2021-07-21 16:08:15 -04:00
color: myPalette.midlight
2021-07-21 16:08:15 -04:00
width: matrix.currentRoom.direct ? 0 : 200
height: parent.height - roomHeader.height
ListView {
id: memberListView
2021-07-21 16:08:15 -04:00
model: matrix.memberModel
clip: true
2021-07-21 16:08:15 -04:00
anchors.top: parent.top
anchors.bottom: inviteButton.top
anchors.left: parent.left
anchors.right: parent.right
section.property: "section"
section.criteria: ViewSection.FullString
section.delegate: Rectangle {
2021-07-21 16:08:15 -04:00
width: parent.width
height: 25
color: "transparent"
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 5
text: section
color: myPalette.text
textFormat: Text.PlainText
}
}
delegate: Rectangle {
width: memberListView.contentItem.width
2021-07-21 16:08:15 -04:00
height: 50
color: "transparent"
property string memberId: id
RoundedImage {
2021-07-21 16:08:15 -04:00
id: memberAvatar
width: 33
height: 33
2021-07-21 16:08:15 -04:00
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 10
source: avatarURL ? avatarURL : "placeholder.png"
}
Text {
anchors.left: memberAvatar.right
anchors.leftMargin: 10
anchors.verticalCenter: parent.verticalCenter
color: myPalette.text
2021-07-21 16:08:15 -04:00
text: displayName
textFormat: Text.PlainText
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
cursorShape: Qt.PointingHandCursor
2021-07-21 16:08:15 -04:00
onClicked: function(mouse) {
if(mouse.button == Qt.LeftButton) {
openProfile(matrix.resolveMemberId(id))
} else {
memberContextMenu.popup()
}
}
2021-07-21 16:08:15 -04:00
}
Menu {
id: memberContextMenu
MenuItem {
text: "Profile"
onReleased: openProfile(matrix.resolveMemberId(id))
2021-07-21 16:08:15 -04:00
}
MenuItem {
text: "Mention"
onReleased: messageInput.append(displayName + ": ")
}
MenuItem {
text: "Start Direct Chat"
onReleased: matrix.startDirectChat(id)
}
MenuSeparator {}
Menu {
title: "Invite to room"
Repeater {
model: matrix.roomListModel
MenuItem {
text: alias
onReleased: {
matrix.inviteToRoom(matrix.resolveRoomId(id), memberId)
}
}
}
}
}
}
ScrollBar.vertical: ScrollBar {}
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.VerticalFlick
}
Button {
id: inviteButton
2021-07-21 16:08:15 -04:00
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 8
2021-07-21 16:08:15 -04:00
text: "Invite to room"
2021-07-21 16:08:15 -04:00
onClicked: {
var popup = Qt.createComponent("qrc:/InviteDialog.qml")
var popupContainer = popup.createObject(window, {"parent": window})
2021-07-21 16:08:15 -04:00
popupContainer.open()
}
2021-07-21 16:08:15 -04:00
}
}
}
Timer {
id: syncTimer
interval: 1500
running: true
onTriggered: {
shouldScroll = messages.contentY == messages.contentHeight - messages.height
matrix.sync()
}
}
Timer {
id: memberTimer
interval: 60000
running: true
onTriggered: matrix.updateMembers(matrix.currentRoom)
}
Timer {
id: typingTimer
interval: 15000 //15 seconds
running: true
onTriggered: {
if(messageInput.text.length !== 0)
matrix.setTyping(matrix.currentRoom)
}
}
Connections {
target: matrix
function onSyncFinished() {
2021-07-21 16:08:15 -04:00
syncTimer.start()
if(shouldScroll)
messages.positionViewAtEnd()
}
function onInitialSyncFinished() {
matrix.changeCurrentRoom(0)
}
2021-07-21 16:08:15 -04:00
function onCurrentRoomChanged() {
2021-07-21 16:08:15 -04:00
if(messages.contentY < messages.originY + 5)
matrix.readMessageHistory(matrix.currentRoom)
}
function onMessage(room, sender, content) {
2021-07-21 16:08:15 -04:00
var notificationLevel = room.notificationLevel
var shouldDisplay = false
if(notificationLevel === 2) {
shouldDisplay = true
} else if(notificationLevel === 1) {
if(content.includes(matrix.displayName))
shouldDisplay = true
}
if(shouldDisplay)
desktop.showMessage(matrix.resolveMemberId(sender).displayName + " (" + room.name + ")", content)
}
}
FileDialog {
id: openAttachmentFileDialog
folder: shortcuts.home
selectExisting: true
selectFolder: false
selectMultiple: false
onAccepted: {
matrix.uploadAttachment(matrix.currentRoom, fileUrl)
close()
}
onRejected: close()
}
}