diff --git a/src/qml/Component/ChatBox/ChatBar.qml b/src/qml/Component/ChatBox/ChatBar.qml index d86a0bf09..901e92057 100644 --- a/src/qml/Component/ChatBox/ChatBar.qml +++ b/src/qml/Component/ChatBox/ChatBar.qml @@ -46,6 +46,8 @@ QQC2.Control { */ property alias textField: textField + property NeoChatConnection connection + /** * @brief The list of actions in the ChatBar. * @@ -414,6 +416,7 @@ QQC2.Control { y: -height - 5 z: 1 chatDocumentHandler: documentHandler + connection: root.connection Behavior on height { NumberAnimation { property: "height" diff --git a/src/qml/Component/ChatBox/ChatBox.qml b/src/qml/Component/ChatBox/ChatBox.qml index a551fb2cf..3530595d0 100644 --- a/src/qml/Component/ChatBox/ChatBox.qml +++ b/src/qml/Component/ChatBox/ChatBox.qml @@ -36,6 +36,8 @@ ColumnLayout { */ required property NeoChatRoom currentRoom + required property NeoChatConnection connection + /** * @brief A message has been sent from the chat bar. */ @@ -62,6 +64,8 @@ ColumnLayout { ChatBar { id: chatBar + connection: root.connection + visible: root.currentRoom.canSendEvent("m.room.message") Layout.fillWidth: true diff --git a/src/qml/Component/ChatBox/CompletionMenu.qml b/src/qml/Component/ChatBox/CompletionMenu.qml index 6aef27da9..8d67dbaac 100644 --- a/src/qml/Component/ChatBox/CompletionMenu.qml +++ b/src/qml/Component/ChatBox/CompletionMenu.qml @@ -17,11 +17,13 @@ QQC2.Popup { id: root width: parent.width + required property NeoChatConnection connection + visible: completions.count > 0 RoomListModel { id: roomListModel - connection: Controller.activeConnection + connection: root.connection } property var chatDocumentHandler diff --git a/src/qml/Component/Devtools/RoomData.qml b/src/qml/Component/Devtools/RoomData.qml index 20a305043..6225d8e57 100644 --- a/src/qml/Component/Devtools/RoomData.qml +++ b/src/qml/Component/Devtools/RoomData.qml @@ -14,6 +14,7 @@ ColumnLayout { id: root required property NeoChatRoom room + required property NeoChatConnection connection FormCard.FormHeader { title: i18nc("@title", "Choose Room") @@ -26,7 +27,7 @@ ColumnLayout { valueRole: "roomId" model: RoomListModel { id: roomListModel - connection: Controller.activeConnection + connection: root.connection } currentIndex: -1 Component.onCompleted: currentIndex = roomListModel.rowForRoom(root.room) diff --git a/src/qml/Component/Devtools/ServerData.qml b/src/qml/Component/Devtools/ServerData.qml index d7d918a06..5038c3257 100644 --- a/src/qml/Component/Devtools/ServerData.qml +++ b/src/qml/Component/Devtools/ServerData.qml @@ -12,13 +12,17 @@ import org.kde.kitemmodels 1.0 import org.kde.neochat 1.0 ColumnLayout { + id: root + + required property NeoChatConnection connection + FormCard.FormHeader { title: i18n("Server Capabilities") } FormCard.FormCard { FormCard.FormTextDelegate { text: i18n("Can change password") - description: Controller.activeConnection.canChangePassword + description: root.connection.canChangePassword } } FormCard.FormHeader { @@ -26,7 +30,7 @@ ColumnLayout { } FormCard.FormCard { FormCard.FormTextDelegate { - text: Controller.activeConnection.defaultRoomVersion + text: root.connection.defaultRoomVersion } } FormCard.FormHeader { diff --git a/src/qml/Component/QuickSwitcher.qml b/src/qml/Component/QuickSwitcher.qml index 5a641f3fb..b461a75ec 100644 --- a/src/qml/Component/QuickSwitcher.qml +++ b/src/qml/Component/QuickSwitcher.qml @@ -14,6 +14,8 @@ import './RoomList' as RoomList QQC2.Dialog { id: root + required property NeoChatConnection connection + parent: applicationWindow().overlay width: Math.min(700, parent.width) height: 400 @@ -84,13 +86,15 @@ QQC2.Dialog { filterText: searchField.text sourceModel: RoomListModel { id: roomListModel - connection: Controller.activeConnection + connection: root.connection } } delegate: RoomList.RoomDelegate { filterText: searchField.text + connection: root.connection + onClicked: { RoomManager.enterRoom(currentRoom); root.close() diff --git a/src/qml/Component/Timeline/EventDelegate.qml b/src/qml/Component/Timeline/EventDelegate.qml index 5be57ce8a..69e3075d4 100644 --- a/src/qml/Component/Timeline/EventDelegate.qml +++ b/src/qml/Component/Timeline/EventDelegate.qml @@ -10,8 +10,10 @@ import org.kde.neochat 1.0 DelegateChooser { id: root + role: "delegateType" property var room + required property NeoChatConnection connection DelegateChoice { roleValue: DelegateType.State @@ -20,22 +22,30 @@ DelegateChooser { DelegateChoice { roleValue: DelegateType.Emote - delegate: MessageDelegate {} + delegate: MessageDelegate { + connection: root.connection + } } DelegateChoice { roleValue: DelegateType.Message - delegate: MessageDelegate {} + delegate: MessageDelegate { + connection: root.connection + } } DelegateChoice { roleValue: DelegateType.Notice - delegate: MessageDelegate {} + delegate: MessageDelegate { + connection: root.connection + } } DelegateChoice { roleValue: DelegateType.Image - delegate: ImageDelegate {} + delegate: ImageDelegate { + connection: root.connection + } } DelegateChoice { @@ -45,22 +55,30 @@ DelegateChooser { DelegateChoice { roleValue: DelegateType.Audio - delegate: AudioDelegate {} + delegate: AudioDelegate { + connection: root.connection + } } DelegateChoice { roleValue: DelegateType.Video - delegate: VideoDelegate {} + delegate: VideoDelegate { + connection: root.connection + } } DelegateChoice { roleValue: DelegateType.File - delegate: FileDelegate {} + delegate: FileDelegate { + connection: root.connection + } } DelegateChoice { roleValue: DelegateType.Encrypted - delegate: EncryptedDelegate {} + delegate: EncryptedDelegate { + connection: root.connection + } } DelegateChoice { @@ -70,17 +88,22 @@ DelegateChooser { DelegateChoice { roleValue: DelegateType.Poll - delegate: PollDelegate {} + delegate: PollDelegate { + connection: root.connection + } } DelegateChoice { roleValue: DelegateType.Location - delegate: LocationDelegate {} + delegate: LocationDelegate { + connection: root.connection + } } DelegateChoice { roleValue: DelegateType.LiveLocation delegate: LiveLocationDelegate { room: root.room + connection: root.connection } } diff --git a/src/qml/Component/Timeline/MessageEditComponent.qml b/src/qml/Component/Timeline/MessageEditComponent.qml index a3860d524..57ee4feb7 100644 --- a/src/qml/Component/Timeline/MessageEditComponent.qml +++ b/src/qml/Component/Timeline/MessageEditComponent.qml @@ -12,6 +12,7 @@ QQC2.TextArea { id: root property NeoChatRoom room + required property NeoChatConnection connection onRoomChanged: room.chatBoxEditIdChanged.connect(updateEditText) property string messageId @@ -101,6 +102,7 @@ QQC2.TextArea { height: implicitHeight y: -height - 5 z: 10 + connection: root.connection chatDocumentHandler: documentHandler Behavior on height { NumberAnimation { diff --git a/src/qml/Component/Timeline/TimelineContainer.qml b/src/qml/Component/Timeline/TimelineContainer.qml index 5f5eb12e2..a5c9d4ed7 100644 --- a/src/qml/Component/Timeline/TimelineContainer.qml +++ b/src/qml/Component/Timeline/TimelineContainer.qml @@ -243,6 +243,8 @@ ColumnLayout { */ readonly property alias hovered: bubble.hovered + required property NeoChatConnection connection + /** * @brief Open the context menu for the message. */ @@ -612,6 +614,7 @@ ColumnLayout { file: file, progressInfo: root.progressInfo, plainText: root.plainText, + connection: root.connection, }); contextMenu.open(); } @@ -626,6 +629,7 @@ ColumnLayout { eventType: root.delegateType, plainText: root.plainText, htmlText: root.display, + connection: root.connection, }); contextMenu.open(); } diff --git a/src/qml/Component/TimelineView.qml b/src/qml/Component/TimelineView.qml index 7b7ae044c..44f96b7d4 100644 --- a/src/qml/Component/TimelineView.qml +++ b/src/qml/Component/TimelineView.qml @@ -122,6 +122,7 @@ QQC2.ScrollView { delegate: EventDelegate { room: root.currentRoom + connection: root.connection } QQC2.RoundButton { diff --git a/src/qml/Menu/GlobalMenu.qml b/src/qml/Menu/GlobalMenu.qml index e46cf8a8b..4f7a60968 100644 --- a/src/qml/Menu/GlobalMenu.qml +++ b/src/qml/Menu/GlobalMenu.qml @@ -10,6 +10,10 @@ import QtQuick.Layouts 1.10 import org.kde.neochat 1.0 Labs.MenuBar { + id: root + + required property NeoChatConnection connection + Labs.Menu { title: i18nc("menu", "NeoChat") @@ -23,7 +27,7 @@ Labs.MenuBar { shortcut: StandardKey.Preferences onTriggered: pageStack.pushDialogLayer("qrc:/SettingsPage.qml", { - connection: Controller.activeConnection + connection: root.connection }, { title: i18n("Configure") }) @@ -41,7 +45,7 @@ Labs.MenuBar { Labs.MenuItem { text: i18nc("menu", "New Private Chat…") enabled: pageStack.layers.currentItem.title !== i18n("Start a Chat") && AccountRegistry.accountCount > 0 - onTriggered: pushReplaceLayer("qrc:/StartChatPage.qml", {connection: Controller.activeConnection}) + onTriggered: pushReplaceLayer("qrc:/StartChatPage.qml", {connection: root.connection}) } Labs.MenuItem { text: i18nc("menu", "New Group…") @@ -55,10 +59,10 @@ Labs.MenuBar { Labs.MenuItem { text: i18nc("menu", "Browse Chats…") onTriggered: { - let dialog = pageStack.pushDialogLayer("qrc:/JoinRoomPage.qml", {connection: Controller.activeConnection}, {title: i18nc("@title", "Explore Rooms")}) + let dialog = pageStack.pushDialogLayer("qrc:/JoinRoomPage.qml", {connection: root.connection}, {title: i18nc("@title", "Explore Rooms")}) dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => { if (isJoined) { - RoomManager.enterRoom(Controller.activeConnection.room(roomId)) + RoomManager.enterRoom(root.connection.room(roomId)) } else { Controller.joinRoom(roomId) } diff --git a/src/qml/Menu/Timeline/MessageDelegateContextMenu.qml b/src/qml/Menu/Timeline/MessageDelegateContextMenu.qml index f01a725bb..12ffd187d 100644 --- a/src/qml/Menu/Timeline/MessageDelegateContextMenu.qml +++ b/src/qml/Menu/Timeline/MessageDelegateContextMenu.qml @@ -21,6 +21,8 @@ Loader { required property string plainText property string htmlText: undefined + required property NeoChatConnection connection + property list nestedActions property list actions: [ @@ -31,7 +33,7 @@ Loader { currentRoom.chatBoxEditId = eventId; currentRoom.chatBoxReplyId = ""; } - visible: author.id === Controller.activeConnection.localUserId && (root.eventType === DelegateType.Emote || root.eventType === DelegateType.Message) + visible: author.id === root.connection.localUserId && (root.eventType === DelegateType.Emote || root.eventType === DelegateType.Message) }, Kirigami.Action { text: i18n("Reply") @@ -45,12 +47,14 @@ Loader { text: i18nc("@action:inmenu As in 'Forward this message'", "Forward") icon.name: "mail-forward-symbolic" onTriggered: { - let page = applicationWindow().pageStack.pushDialogLayer("qrc:/ChooseRoomDialog.qml", {}, { + let page = applicationWindow().pageStack.pushDialogLayer("qrc:/ChooseRoomDialog.qml", { + connection: root.connection + }, { title: i18nc("@title", "Forward Message"), width: Kirigami.Units.gridUnit * 25 }) page.chosen.connect(function(targetRoomId) { - Controller.activeConnection.room(targetRoomId).postHtmlMessage(root.plainText, root.htmlText ? root.htmlText : root.plainText) + root.connection.room(targetRoomId).postHtmlMessage(root.plainText, root.htmlText ? root.htmlText : root.plainText) page.closeDialog() }) } diff --git a/src/qml/Page/ChooseRoomDialog.qml b/src/qml/Page/ChooseRoomDialog.qml index f566de535..2a1ab7b6a 100644 --- a/src/qml/Page/ChooseRoomDialog.qml +++ b/src/qml/Page/ChooseRoomDialog.qml @@ -17,6 +17,8 @@ Kirigami.ScrollablePage { signal chosen(string roomId) + required property NeoChatConnection connection + header: Kirigami.SearchField { onTextChanged: sortModel.filterText = text } @@ -25,7 +27,7 @@ Kirigami.ScrollablePage { model: SortFilterRoomListModel { id: sortModel sourceModel: RoomListModel { - connection: Controller.activeConnection + connection: root.connection } } delegate: RoomDelegate { @@ -34,6 +36,7 @@ Kirigami.ScrollablePage { onClicked: { root.chosen(roomDelegate.currentRoom.id) } + connection: root.connection } } } diff --git a/src/qml/Page/DevtoolsPage.qml b/src/qml/Page/DevtoolsPage.qml index 09b366e1c..bc57636be 100644 --- a/src/qml/Page/DevtoolsPage.qml +++ b/src/qml/Page/DevtoolsPage.qml @@ -13,6 +13,7 @@ FormCard.FormCardPage { id: root property NeoChatRoom room + required property NeoChatConnection connection title: i18n("Developer Tools") @@ -37,7 +38,10 @@ FormCard.FormCardPage { RoomData { room: root.room + connection: root.connection + } + ServerData { + connection: root.connection } - ServerData {} } } diff --git a/src/qml/Page/JoinRoomPage.qml b/src/qml/Page/JoinRoomPage.qml index 6a82609a8..40d7b37e7 100644 --- a/src/qml/Page/JoinRoomPage.qml +++ b/src/qml/Page/JoinRoomPage.qml @@ -225,7 +225,6 @@ Kirigami.ScrollablePage { publicRoomListModel.next(); } delegate: ExplorerDelegate { - connection: root.connection onRoomSelected: (roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => { root.roomSelected(roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined); root.closeDialog(); diff --git a/src/qml/Page/RoomList/AccountMenu.qml b/src/qml/Page/RoomList/AccountMenu.qml index 7c11f3d87..53f5bb4cd 100644 --- a/src/qml/Page/RoomList/AccountMenu.qml +++ b/src/qml/Page/RoomList/AccountMenu.qml @@ -12,13 +12,16 @@ import '../Dialog' as Dialog QQC2.Menu { id: root + + required property NeoChatConnection connection + margins: Kirigami.Units.smallSpacing QQC2.MenuItem { text: i18n("Edit this account") icon.name: "document-edit" onTriggered: pageStack.pushDialogLayer("qrc:/AccountEditorPage.qml", { - connection: Controller.activeConnection + connection: root.connection }, { title: i18n("Account editor") }); @@ -28,7 +31,7 @@ QQC2.Menu { icon.name: "notifications" onTriggered: pageStack.pushDialogLayer("qrc:/SettingsPage.qml", { defaultPage: "notifications", - connection: Controller.activeConnection, + connection: root.connection, }, { title: i18n("Configure") }); @@ -38,7 +41,7 @@ QQC2.Menu { icon.name: "computer-symbolic" onTriggered: pageStack.pushDialogLayer("qrc:/SettingsPage.qml", { defaultPage: "devices", - connection: Controller.activeConnection, + connection: root.connection, }, { title: i18n("Configure") }) @@ -52,7 +55,7 @@ QQC2.Menu { Component { id: confirmLogoutDialogComponent Dialog.ConfirmLogout { - connection: Controller.activeConnection + connection: root.connection } } } diff --git a/src/qml/Page/RoomList/ContextMenu.qml b/src/qml/Page/RoomList/ContextMenu.qml index 20b259176..b18a9e424 100644 --- a/src/qml/Page/RoomList/ContextMenu.qml +++ b/src/qml/Page/RoomList/ContextMenu.qml @@ -16,7 +16,10 @@ import org.kde.neochat 1.0 */ Loader { id: root + property NeoChatRoom room + required property NeoChatConnection connection + signal closed() Component { @@ -116,7 +119,7 @@ Loader { QQC2.MenuItem { text: i18n("Room Settings") icon.name: "configure" - onTriggered: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room}, { title: i18n("Room Settings") }) + onTriggered: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room, connection: connection}, { title: i18n("Room Settings") }) } QQC2.MenuSeparator {} @@ -183,7 +186,7 @@ Loader { QQC2.ToolButton { icon.name: 'settings-configure' onClicked: { - QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room}, { title: i18n("Room Settings") }) + QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room, connection: root.connection}, { title: i18n("Room Settings") }) drawer.close() } } diff --git a/src/qml/Page/RoomList/ExploreComponent.qml b/src/qml/Page/RoomList/ExploreComponent.qml index ec434868c..415f5c13b 100644 --- a/src/qml/Page/RoomList/ExploreComponent.qml +++ b/src/qml/Page/RoomList/ExploreComponent.qml @@ -20,10 +20,10 @@ RowLayout { text: i18n("Explore rooms") icon.name: "compass" onTriggered: { - let dialog = pageStack.pushDialogLayer("qrc:/JoinRoomPage.qml", {connection: Controller.activeConnection}, {title: i18nc("@title", "Explore Rooms")}) + let dialog = pageStack.pushDialogLayer("qrc:/JoinRoomPage.qml", {connection: root.connection}, {title: i18nc("@title", "Explore Rooms")}) dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => { if (isJoined) { - RoomManager.enterRoom(Controller.activeConnection.room(roomId)) + RoomManager.enterRoom(root.connection.room(roomId)) } else { Controller.joinRoom(roomId) } @@ -33,7 +33,7 @@ RowLayout { property Kirigami.Action chatAction: Kirigami.Action { text: i18n("Start a Chat") icon.name: "list-add-user" - onTriggered: pageStack.pushDialogLayer("qrc:/StartChatPage.qml", {connection: Controller.activeConnection}, {title: i18nc("@title", "Start a Chat")}) + onTriggered: pageStack.pushDialogLayer("qrc:/StartChatPage.qml", {connection: root.connection}, {title: i18nc("@title", "Start a Chat")}) } property Kirigami.Action roomAction: Kirigami.Action { text: i18n("Create a Room") diff --git a/src/qml/Page/RoomList/Page.qml b/src/qml/Page/RoomList/Page.qml index 44159d3c4..bb7d532b2 100644 --- a/src/qml/Page/RoomList/Page.qml +++ b/src/qml/Page/RoomList/Page.qml @@ -102,6 +102,8 @@ Kirigami.Page { id: spaceDrawer Layout.preferredWidth: spaceDrawer.enabled ? Kirigami.Units.gridUnit * 3 : 0 Layout.fillHeight: true + + connection: root.connection } Kirigami.Separator { @@ -161,14 +163,14 @@ Kirigami.Page { text: sortFilterRoomListModel.filterText.length > 0 ? i18n("Search in room directory") : i18n("Explore rooms") onTriggered: { let dialog = pageStack.layers.push("qrc:/JoinRoomPage.qml", { - connection: Controller.activeConnection, + connection: root.connection, keyword: sortFilterRoomListModel.filterText }, { title: i18nc("@title", "Explore Rooms") }) dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => { if (isJoined) { - RoomManager.enterRoom(Controller.activeConnection.room(roomId)) + RoomManager.enterRoom(root.connection.room(roomId)) } else { Controller.joinRoom(roomId) } @@ -265,6 +267,8 @@ Kirigami.Page { RoomList.RoomDelegate { filterText: sortFilterRoomListModel.filterText + connection: root.connection + height: visible ? implicitHeight : 0 visible: categoryVisible || filterText.length > 0 || Config.mergeRoomList @@ -282,6 +286,7 @@ Kirigami.Page { footer: UserInfo { width: parent.width visible: !root.collapsed + connection: root.connection } MouseArea { diff --git a/src/qml/Page/RoomList/RoomDelegate.qml b/src/qml/Page/RoomList/RoomDelegate.qml index 02277fb56..7498d0aec 100644 --- a/src/qml/Page/RoomList/RoomDelegate.qml +++ b/src/qml/Page/RoomList/RoomDelegate.qml @@ -22,6 +22,7 @@ Delegates.RoundedItemDelegate { required property int notificationCount required property int highlightCount required property NeoChatRoom currentRoom + required property NeoChatConnection connection required property bool categoryVisible required property string filterText required property string avatar @@ -138,6 +139,7 @@ Delegates.RoundedItemDelegate { const component = Qt.createComponent(Qt.resolvedUrl("./ContextMenu.qml")) const menu = component.createObject(root, { room: root.currentRoom, + connection: root.connection, }); if (!Kirigami.Settings.isMobile && !Config.compactRoomList) { configButton.visible = true; diff --git a/src/qml/Page/RoomList/SpaceDrawer.qml b/src/qml/Page/RoomList/SpaceDrawer.qml index fc624a976..0bfdea4d6 100644 --- a/src/qml/Page/RoomList/SpaceDrawer.qml +++ b/src/qml/Page/RoomList/SpaceDrawer.qml @@ -17,6 +17,8 @@ QQC2.Control { readonly property real pinnedWidth: Kirigami.Units.gridUnit * 6 property bool drawerEnabled: true + required property NeoChatConnection connection + leftPadding: 0 rightPadding: 0 topPadding: 0 @@ -73,12 +75,12 @@ QQC2.Control { Repeater { model: SortFilterSpaceListModel { sourceModel: RoomListModel { - connection: Controller.activeConnection + connection: root.connection } } onCountChanged: { root.enabled = count > 0 - if (!Controller.activeConnection.room(root.selectedSpaceId)) { + if (!root.connection.room(root.selectedSpaceId)) { root.selectedSpaceId = "" } } @@ -111,7 +113,8 @@ QQC2.Control { function createContextMenu(room) { let context = spaceListContextMenu.createObject(root, { - room: room + room: room, + connection: root.connection }); context.open() } diff --git a/src/qml/Page/RoomList/SpaceListContextMenu.qml b/src/qml/Page/RoomList/SpaceListContextMenu.qml index 7aabc3507..8836529f9 100644 --- a/src/qml/Page/RoomList/SpaceListContextMenu.qml +++ b/src/qml/Page/RoomList/SpaceListContextMenu.qml @@ -16,7 +16,10 @@ import org.kde.neochat 1.0 */ Loader { id: root + property NeoChatRoom room + required property NeoChatConnection connection + signal closed() Component { @@ -41,7 +44,7 @@ Loader { QQC2.MenuItem { text: i18nc("'Space' is a matrix space", "Space Settings") icon.name: 'settings-configure' - onTriggered: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room}, { title: i18n("Space Settings") }) + onTriggered: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room, connection: connection}, { title: i18n("Space Settings") }) } QQC2.MenuSeparator {} @@ -99,7 +102,7 @@ Loader { QQC2.ToolButton { icon.name: 'settings-configure' - onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room}, { title: i18n("Space Settings") }) + onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room, connection: root.connection}, { title: i18n("Space Settings") }) } } Kirigami.BasicListItem { diff --git a/src/qml/Page/RoomList/UserInfo.qml b/src/qml/Page/RoomList/UserInfo.qml index 54764fa59..897174494 100644 --- a/src/qml/Page/RoomList/UserInfo.qml +++ b/src/qml/Page/RoomList/UserInfo.qml @@ -15,6 +15,8 @@ QQC2.ToolBar { padding: 0 + required property NeoChatConnection connection + property var addAccount contentItem: ColumnLayout { @@ -126,7 +128,7 @@ QQC2.ToolBar { } onClicked: { - Controller.activeConnection = userDelegate.connection + root.connection = userDelegate.connection if (switchUserButton.checked) { switchUserButton.checked = false } @@ -164,7 +166,7 @@ QQC2.ToolBar { accountMenu.open(); } else { pageStack.pushDialogLayer(Qt.resolvedUrl('qrc:/AccountEditorPage.qml'), { - connection: Controller.activeConnection + connection: root.connection }, { title: i18n("Account editor") }); @@ -175,10 +177,10 @@ QQC2.ToolBar { text: i18n("Edit this account") contentItem: KirigamiComponents.Avatar { - readonly property string mediaId: Controller.activeConnection.localUser.avatarMediaId + readonly property string mediaId: root.connection.localUser.avatarMediaId source: mediaId ? ("image://mxc/" + mediaId) : "" - name: Controller.activeConnection.localUser.displayName ?? Controller.activeConnection.localUser.id + name: root.connection.localUser.displayName ?? root.connection.localUser.id } } @@ -187,13 +189,13 @@ QQC2.ToolBar { spacing: 0 QQC2.Label { id: displayNameLabel - text: Controller.activeConnection.localUser.displayName + text: root.connection.localUser.displayName textFormat: Text.PlainText elide: Text.ElideRight Layout.fillWidth: true } QQC2.Label { - text: (Controller.activeConnection.label.length > 0 ? (Controller.activeConnection.label + " ") : "") + Controller.activeConnection.localUser.id + text: (root.connection.label.length > 0 ? (root.connection.label + " ") : "") + root.connection.localUser.id font.pointSize: displayNameLabel.font.pointSize * 0.8 opacity: 0.7 textFormat: Text.PlainText @@ -232,7 +234,7 @@ QQC2.ToolBar { } QQC2.ToolButton { icon.name: "settings-configure" - onClicked: pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {connection: Controller.activeConnection}, { title: i18n("Configure") }) + onClicked: pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {connection: root.connection}, { title: i18n("Configure") }) text: i18n("Open Settings") display: QQC2.AbstractButton.IconOnly Layout.minimumWidth: Layout.preferredWidth @@ -249,6 +251,7 @@ QQC2.ToolBar { AccountMenu { id: accountMenu y: -height + connection: root.connection } } } diff --git a/src/qml/Page/RoomPage.qml b/src/qml/Page/RoomPage.qml index d90a7e82a..31fa510c5 100644 --- a/src/qml/Page/RoomPage.qml +++ b/src/qml/Page/RoomPage.qml @@ -18,6 +18,8 @@ Kirigami.Page { /// Not readonly because of the separate window view. property NeoChatRoom currentRoom: RoomManager.currentRoom + + required property NeoChatConnection connection property bool loading: !root.currentRoom || (root.currentRoom.timelineSize === 0 && !root.currentRoom.allHistoryLoaded) /// Disable cancel shortcut. Used by the separate window since it provides its own cancel implementation. @@ -109,6 +111,7 @@ Kirigami.Page { id: chatBox width: parent.width currentRoom: root.currentRoom + connection: root.connection onMessageSent: { if (!timelineViewLoader.item.atYEnd) { timelineViewLoader.item.goToLastMessage(); @@ -153,7 +156,7 @@ Kirigami.Page { } Connections { - target: Controller.activeConnection + target: root.connection function onJoinedRoom(room, invited) { if(root.currentRoom.id === invited.id) { RoomManager.enterRoom(room); diff --git a/src/qml/Page/RoomWindow.qml b/src/qml/Page/RoomWindow.qml index 91ae75406..a4c9f9085 100644 --- a/src/qml/Page/RoomWindow.qml +++ b/src/qml/Page/RoomWindow.qml @@ -13,6 +13,8 @@ Kirigami.ApplicationWindow { id: root required property NeoChatRoom currentRoom + required property NeoChatConnection connection + minimumWidth: Kirigami.Units.gridUnit * 10 minimumHeight: Kirigami.Units.gridUnit * 15 @@ -24,6 +26,7 @@ Kirigami.ApplicationWindow { visible: true currentRoom: root.currentRoom disableCancelShortcut: true + connection: root.connection } onCurrentRoomChanged: if (!currentRoom) { diff --git a/src/qml/Page/SearchPage.qml b/src/qml/Page/SearchPage.qml index b311bb765..614f5f545 100644 --- a/src/qml/Page/SearchPage.qml +++ b/src/qml/Page/SearchPage.qml @@ -13,6 +13,7 @@ Kirigami.ScrollablePage { id: root property NeoChatRoom currentRoom + required property NeoChatConnection connection title: i18nc("@action:title", "Search Messages") @@ -20,7 +21,7 @@ Kirigami.ScrollablePage { SearchModel { id: searchModel - connection: Controller.activeConnection + connection: root.connection searchText: searchField.text room: root.currentRoom } @@ -71,6 +72,8 @@ Kirigami.ScrollablePage { } model: searchModel - delegate: EventDelegate {} + delegate: EventDelegate { + connection: root.connection + } } } diff --git a/src/qml/RoomDrawer/RoomDrawer.qml b/src/qml/RoomDrawer/RoomDrawer.qml index 36d573116..0bc62d956 100644 --- a/src/qml/RoomDrawer/RoomDrawer.qml +++ b/src/qml/RoomDrawer/RoomDrawer.qml @@ -13,7 +13,9 @@ import org.kde.neochat 1.0 Kirigami.OverlayDrawer { id: root + readonly property NeoChatRoom room: RoomManager.currentRoom + required property NeoChatConnection connection width: actualWidth @@ -98,7 +100,7 @@ Kirigami.OverlayDrawer { text: i18n("Room settings") display: QQC2.AbstractButton.IconOnly - onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room}, { title: i18n("Room Settings") }) + onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/Categories.qml', {room: room, connection: root.connection}, { title: i18n("Room Settings") }) QQC2.ToolTip.text: text QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay @@ -118,6 +120,7 @@ Kirigami.OverlayDrawer { id: roomInformation RoomInformation { room: root.room + connection: root.connection } } @@ -125,6 +128,7 @@ Kirigami.OverlayDrawer { id: roomMedia RoomMedia { currentRoom: root.room + connection: root.connection } } diff --git a/src/qml/RoomDrawer/RoomDrawerPage.qml b/src/qml/RoomDrawer/RoomDrawerPage.qml index 974b9dae8..d10bcbfd3 100644 --- a/src/qml/RoomDrawer/RoomDrawerPage.qml +++ b/src/qml/RoomDrawer/RoomDrawerPage.qml @@ -25,6 +25,7 @@ Kirigami.Page { * @brief The current room that user is viewing. */ readonly property NeoChatRoom room: RoomManager.currentRoom + required property NeoChatConnection connection title: drawerItemLoader.item ? drawerItemLoader.item.title : "" @@ -43,7 +44,7 @@ Kirigami.Page { displayHint: Kirigami.DisplayHint.IconOnly text: i18n("Settings") icon.name: "settings-configure" - onTriggered: applicationWindow().pageStack.pushDialogLayer('qrc:/Categories.qml', {room: root.room}, { title: i18n("Room Settings") }) + onTriggered: applicationWindow().pageStack.pushDialogLayer('qrc:/Categories.qml', {room: root.room, connection: root.connection}, { title: i18n("Room Settings") }) } ] @@ -58,6 +59,7 @@ Kirigami.Page { id: roomInformation RoomInformation { room: root.room + connection: root.connection } } @@ -65,6 +67,7 @@ Kirigami.Page { id: roomMedia RoomMedia { currentRoom: root.room + connection: root.connection } } diff --git a/src/qml/RoomDrawer/RoomInformation.qml b/src/qml/RoomDrawer/RoomInformation.qml index bb157235c..5b5e1e4af 100644 --- a/src/qml/RoomDrawer/RoomInformation.qml +++ b/src/qml/RoomDrawer/RoomInformation.qml @@ -32,6 +32,8 @@ QQC2.ScrollView { */ required property NeoChatRoom room + required property NeoChatConnection connection + /** * @brief The title that should be displayed for this component if available. */ @@ -77,7 +79,7 @@ QQC2.ScrollView { Layout.fillWidth: true onClicked: { - applicationWindow().pageStack.pushDialogLayer("qrc:/DevtoolsPage.qml", {room: root.room}, {title: i18n("Developer Tools")}) + applicationWindow().pageStack.pushDialogLayer("qrc:/DevtoolsPage.qml", {room: root.room, connection: root.connection}, {title: i18n("Developer Tools")}) } } @@ -91,7 +93,8 @@ QQC2.ScrollView { onClicked: { pageStack.pushDialogLayer("qrc:/SearchPage.qml", { - currentRoom: root.room + currentRoom: root.room, + connection: root.connection }, { title: i18nc("@action:title", "Search") }) diff --git a/src/qml/RoomDrawer/RoomMedia.qml b/src/qml/RoomDrawer/RoomMedia.qml index e8a28d909..f30066fa2 100644 --- a/src/qml/RoomDrawer/RoomMedia.qml +++ b/src/qml/RoomDrawer/RoomMedia.qml @@ -33,6 +33,8 @@ QQC2.ScrollView { */ required property NeoChatRoom currentRoom + required property NeoChatConnection connection + // HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890) QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff @@ -54,6 +56,7 @@ QQC2.ScrollView { alwaysShowAuthor: true alwaysMaxWidth: true cardBackground: false + connection: root.connection } } @@ -63,6 +66,7 @@ QQC2.ScrollView { alwaysShowAuthor: true alwaysMaxWidth: true cardBackground: false + connection: root.connection } } } diff --git a/src/qml/RoomSettings/Categories.qml b/src/qml/RoomSettings/Categories.qml index 856ff3c1c..02b9bf838 100644 --- a/src/qml/RoomSettings/Categories.qml +++ b/src/qml/RoomSettings/Categories.qml @@ -10,7 +10,9 @@ import org.kde.neochat 1.0 KirigamiSettings.CategorizedSettings { id: root + property NeoChatRoom room + required property NeoChatConnection connection objectName: "settingsPage" actions: [ @@ -21,7 +23,8 @@ KirigamiSettings.CategorizedSettings { page: Qt.resolvedUrl("General.qml") initialProperties: { return { - room: root.room + room: root.room, + connection: root.connection } } }, diff --git a/src/qml/RoomSettings/General.qml b/src/qml/RoomSettings/General.qml index e90c0d304..c25bc9e5b 100644 --- a/src/qml/RoomSettings/General.qml +++ b/src/qml/RoomSettings/General.qml @@ -17,6 +17,7 @@ FormCard.FormCardPage { id: root property NeoChatRoom room + required property NeoChatConnection connection title: i18n("General") @@ -287,7 +288,7 @@ FormCard.FormCardPage { actions: Kirigami.Action { text: i18n("See older messages…") onTriggered: { - RoomManager.enterRoom(Controller.activeConnection.room(room.predecessorId)); + RoomManager.enterRoom(root.connection.room(room.predecessorId)); root.close(); } } @@ -301,7 +302,7 @@ FormCard.FormCardPage { actions: Kirigami.Action { text: i18n("See new room…") onTriggered: { - RoomManager.enterRoom(Controller.activeConnection.room(room.successorId)); + RoomManager.enterRoom(root.connection.room(room.successorId)); root.close(); } } diff --git a/src/qml/Settings/DevicesPage.qml b/src/qml/Settings/DevicesPage.qml index e1a24cfb9..9d10264f9 100644 --- a/src/qml/Settings/DevicesPage.qml +++ b/src/qml/Settings/DevicesPage.qml @@ -46,7 +46,7 @@ FormCard.FormCardPage { FormCard.AbstractFormDelegate { Layout.fillWidth: true - visible: Controller.activeConnection && devicesModel.count === 0 // We can assume 0 means loading since there is at least one device + visible: root.connection && devicesModel.count === 0 // We can assume 0 means loading since there is at least one device contentItem: Kirigami.LoadingPlaceholder { } } @@ -56,7 +56,7 @@ FormCard.FormCardPage { Layout.alignment: Qt.AlignHCenter text: i18n("Please login to view the signed-in devices for your account.") type: Kirigami.MessageType.Information - visible: !Controller.activeConnection + visible: !root.connection } property Kirigami.OverlaySheet passwordSheet: Kirigami.OverlaySheet { diff --git a/src/qml/Settings/EmoticonFormCard.qml b/src/qml/Settings/EmoticonFormCard.qml index 4e4d408a5..08d41fecd 100644 --- a/src/qml/Settings/EmoticonFormCard.qml +++ b/src/qml/Settings/EmoticonFormCard.qml @@ -19,6 +19,7 @@ FormCard.FormCard { } property var emoticonType + required property NeoChatConnection connection Flow { id: stickerFlow @@ -28,7 +29,7 @@ FormCard.FormCard { id: emoticonFilterModel sourceModel: AccountEmoticonModel { id: stickerModel - connection: Controller.activeConnection + connection: root.connection } showStickers: root.emoticonType === EmoticonFormCard.Stickers showEmojis: root.emoticonType === EmoticonFormCard.Emojis diff --git a/src/qml/Settings/EmoticonsPage.qml b/src/qml/Settings/EmoticonsPage.qml index 87135e2ab..a792c1172 100644 --- a/src/qml/Settings/EmoticonsPage.qml +++ b/src/qml/Settings/EmoticonsPage.qml @@ -11,6 +11,8 @@ import org.kde.neochat 1.0 FormCard.FormCardPage { id: root + required property NeoChatConnection connection + title: i18nc("@title", "Stickers & Emojis") FormCard.FormHeader { @@ -18,6 +20,7 @@ FormCard.FormCardPage { } EmoticonFormCard { emoticonType: EmoticonFormCard.Emojis + connection: root.connection } FormCard.FormHeader { @@ -25,6 +28,7 @@ FormCard.FormCardPage { } EmoticonFormCard { emoticonType: EmoticonFormCard.Stickers + connection: root.connection } diff --git a/src/qml/Settings/SettingsPage.qml b/src/qml/Settings/SettingsPage.qml index d501c8eb0..7022c86f4 100644 --- a/src/qml/Settings/SettingsPage.qml +++ b/src/qml/Settings/SettingsPage.qml @@ -44,6 +44,11 @@ KirigamiSettings.CategorizedSettings { text: i18n("Stickers & Emojis") icon.name: "preferences-desktop-emoticons" page: Qt.resolvedUrl("EmoticonsPage.qml") + initialProperties: { + return { + connection: root.connection + } + } }, KirigamiSettings.SettingAction { diff --git a/src/qml/main.qml b/src/qml/main.qml index 7e652beb4..dc16a1d01 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -22,6 +22,8 @@ Kirigami.ApplicationWindow { property RoomPage roomPage + property NeoChatConnection connection: Controller.activeConnection + minimumWidth: Kirigami.Units.gridUnit * 20 minimumHeight: Kirigami.Units.gridUnit * 15 @@ -47,7 +49,9 @@ Kirigami.ApplicationWindow { Loader { active: Kirigami.Settings.hasPlatformMenuBar && !Kirigami.Settings.isMobile - source: Qt.resolvedUrl("qrc:/GlobalMenu.qml") + sourceComponent: GlobalMenu { + connection: root.connection + } } // This timer allows to batch update the window size change to reduce @@ -76,14 +80,16 @@ Kirigami.ApplicationWindow { Loader { id: quickView active: !Kirigami.Settings.isMobile - sourceComponent: QuickSwitcher { } + sourceComponent: QuickSwitcher { + connection: root.connection + } } Connections { target: RoomManager function onPushRoom(room, event) { - root.roomPage = pageStack.push("qrc:/RoomPage.qml"); + root.roomPage = pageStack.push("qrc:/RoomPage.qml", {connection: root.connection}); root.roomPage.forceActiveFocus(); if (event.length > 0) { roomPage.goToEvent(event); @@ -107,7 +113,7 @@ Kirigami.ApplicationWindow { } function onOpenRoomInNewWindow(room) { - const secondaryWindow = roomWindow.createObject(undefined, {currentRoom: room}); + const secondaryWindow = roomWindow.createObject(undefined, {currentRoom: room, connection: root.connection}); secondaryWindow.width = root.width - pageStack.get(0).width; secondaryWindow.show(); } @@ -128,7 +134,9 @@ Kirigami.ApplicationWindow { } function openRoomDrawer() { - pageStack.push("qrc:/RoomDrawerPage.qml") + pageStack.push("qrc:/RoomDrawerPage.qml", { + connection: root.connection + }) } contextDrawer: RoomDrawer { @@ -138,6 +146,8 @@ Kirigami.ApplicationWindow { // It is used to ensure that user choice is remembered when changing pages and expanding and contracting the window width property bool drawerUserState: Config.autoRoomInfoDrawer + connection: root.connection + // Connect to the onClicked function of the RoomDrawer handle button Connections { target: contextDrawer.handle.children[0] @@ -190,7 +200,7 @@ Kirigami.ApplicationWindow { RoomList.Page { id: roomList - connection: Controller.activeConnection + connection: root.connection Shortcut { sequences: ["Ctrl+PgUp", "Ctrl+Backtab", "Alt+Up"] @@ -280,10 +290,10 @@ Kirigami.ApplicationWindow { } Connections { - target: Controller.activeConnection + target: root.connection function onDirectChatAvailable(directChat) { - RoomManager.enterRoom(Controller.activeConnection.room(directChat.id)); + RoomManager.enterRoom(root.connection.room(directChat.id)); } function onNewKeyVerificationSession(session) { applicationWindow().pageStack.pushDialogLayer(keyVerificationDialogComponent, { @@ -321,14 +331,14 @@ Kirigami.ApplicationWindow { id: createRoomDialog CreateRoomDialog { - connection: Controller.activeConnection + connection: root.connection } } Component { id: createSpaceDialog CreateSpaceDialog { - connection: Controller.activeConnection + connection: root.connection } } @@ -382,7 +392,7 @@ Kirigami.ApplicationWindow { Shortcut { sequence: "Ctrl+Shift+," onActivated: { - pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {connection: Controller.activeConnection}, { title: i18n("Configure") }) + pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {connection: root.connection}, { title: i18n("Configure") }) } } }