Port RoomManager to C++

This also makes it possible to handle the Matrix URI
This commit is contained in:
Carl Schwan
2021-04-27 21:07:10 +00:00
parent a2a6983123
commit b7d98fc6d9
13 changed files with 517 additions and 125 deletions

View File

@@ -5,6 +5,7 @@ import QtQuick 2.15
import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15
import org.kde.neochat 1.0
import org.kde.kirigami 2.15 as Kirigami
TextEdit {
@@ -47,7 +48,7 @@ a{
wrapMode: Text.WordWrap
textFormat: Text.RichText
onLinkActivated: applicationWindow().handleLink(link, currentRoom)
onLinkActivated: RoomManager.openResource(link)
MouseArea {
anchors.fill: parent

View File

@@ -93,9 +93,7 @@ Loader {
Layout.maximumWidth: Kirigami.Units.gridUnit * 24
wrapMode: Text.WordWrap
onLinkActivated: {
applicationWindow().handleLink(link, currentRoom)
}
onLinkActivated: RoomManager.openResource(link);
}
}
}
@@ -189,9 +187,7 @@ Loader {
Layout.fillWidth: true
wrapMode: Text.WordWrap
onLinkActivated: {
applicationWindow().handleLink(link, currentRoom)
}
onLinkActivated: RoomManager.openResource(link);
}
}
}

View File

@@ -116,16 +116,15 @@ Kirigami.ScrollablePage {
action: Kirigami.Action {
id: enterRoomAction
onTriggered: {
var roomItem = roomManager.enterRoom(currentRoom)
roomListItem.KeyNavigation.right = roomItem
roomItem.focus = true;
itemSelection.setCurrentIndex(sortFilterRoomListModel.mapToSource(sortFilterRoomListModel.index(index, 0)), ItemSelectionModel.SelectCurrent)
RoomManager.enterRoom(currentRoom);
itemSelection.setCurrentIndex(sortFilterRoomListModel.mapToSource(
sortFilterRoomListModel.index(index, 0)), ItemSelectionModel.SelectCurrent)
}
}
bold: unreadCount > 0
label: name ?? ""
subtitle: {
let txt = (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm," ")
let txt = (lastEvent.length === 0 ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm, " ")
if (txt.length) {
return txt
}

View File

@@ -21,7 +21,8 @@ import NeoChat.Menu.Timeline 1.0
Kirigami.ScrollablePage {
id: page
required property var currentRoom
/// It's not readonly because of the seperate window view.
property var currentRoom: RoomManager.currentRoom
title: currentRoom.displayName
@@ -30,19 +31,17 @@ Kirigami.ScrollablePage {
onCurrentRoomChanged: ChatBoxHelper.clearEditReply()
ActionsHandler {
id: actionsHandler
room: page.currentRoom
connection: Controller.activeConnection
}
Connections {
target: Controller.activeConnection
function onJoinedRoom(room) {
if(room.id === invitation.id) {
roomManager.enterRoom(room);
RoomManager.enterRoom(room);
}
}
}
@@ -81,7 +80,7 @@ Kirigami.ScrollablePage {
onClicked: {
page.currentRoom.forget()
roomManager.getBack();
RoomManager.getBack();
}
}
@@ -667,6 +666,11 @@ Kirigami.ScrollablePage {
FullScreenImage {}
}
Component {
id: userDetailDialog
UserDetailDialog {}
}
header: TypingPane {
id: typingPane
@@ -746,6 +750,20 @@ Kirigami.ScrollablePage {
}
}
function warning(title, message) {
page.header.contentItem.text = `${title}<br />${message}`;
page.header.contentItem.type = Kirigami.MessageType.Warning;
page.header.contentItem.visible = true;
}
function showUserDetail(user) {
userDetailDialog.createObject(QQC2.ApplicationWindow.overlay, {
room: currentRoom,
user: user,
}).open();
}
function goToLastMessage() {
currentRoom.markAllMessagesAsRead()
// scroll to the very end, i.e to messageListView.YEnd

View File

@@ -16,7 +16,7 @@ import NeoChat.Dialog 1.0
Kirigami.OverlayDrawer {
id: roomDrawer
property var room
readonly property var room: RoomManager.currentRoom
enabled: true