Rework roommanager for improved stability
Fixes #645 - Active space handling is moved from QML to RoomManager - Active tab in SpaceDrawer (space / no space / DM) is unified in a single variable - RoomList & RoomPage loading is simplified: We're always pushing a RoomPage now; if there is no room, a placeholder is shown - SpaceHomePage is moved into RoomPage; This replaces the entire push/replace room/spacehome logic - If the current room is a space, the space home is shown, otherwise the timeline - The concept of "previous room" is removed entirely. If we're leaving the active room, the placeholder room page is shown - When clicking on a space in the list, the space room list is switched and the space home page is shown In short, these changes should (after some initial regressions) lead to a less crashy NeoChat :)
This commit is contained in:
@@ -15,32 +15,20 @@ import org.kde.neochat.accounts
|
||||
Kirigami.ApplicationWindow {
|
||||
id: root
|
||||
|
||||
property int columnWidth: Kirigami.Units.gridUnit * 13
|
||||
|
||||
property RoomListPage roomListPage
|
||||
|
||||
property RoomPage roomPage
|
||||
property SpaceHomePage spaceHomePage
|
||||
|
||||
property NeoChatConnection connection: Controller.activeConnection
|
||||
|
||||
minimumWidth: Kirigami.Units.gridUnit * 20
|
||||
minimumHeight: Kirigami.Units.gridUnit * 15
|
||||
|
||||
visible: false // Will be overridden in Component.onCompleted
|
||||
wideScreen: width > columnWidth * 5
|
||||
wideScreen: width > Kirigami.Units.gridUnit * 65
|
||||
|
||||
pageStack {
|
||||
initialPage: WelcomePage {
|
||||
showExisting: true
|
||||
onConnectionChosen: {
|
||||
pageStack.replace(roomListComponent);
|
||||
roomListPage = pageStack.currentItem;
|
||||
RoomManager.loadInitialRoom();
|
||||
}
|
||||
onConnectionChosen: root.load()
|
||||
}
|
||||
globalToolBar.canContainHandles: true
|
||||
defaultColumnWidth: roomListPage ? roomListPage.currentWidth : 0
|
||||
globalToolBar {
|
||||
style: Kirigami.ApplicationHeaderStyle.ToolBar
|
||||
showNavigationButtons: pageStack.currentIndex > 0 || pageStack.layers.depth > 1 ? Kirigami.ApplicationHeaderStyle.ShowBackButton : 0
|
||||
@@ -59,9 +47,7 @@ Kirigami.ApplicationWindow {
|
||||
Connections {
|
||||
target: LoginHelper
|
||||
function onLoaded() {
|
||||
pageStack.replace(roomListComponent);
|
||||
roomListPage = pageStack.currentItem;
|
||||
RoomManager.loadInitialRoom();
|
||||
root.load();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,16 +108,6 @@ Kirigami.ApplicationWindow {
|
||||
Connections {
|
||||
target: RoomManager
|
||||
|
||||
function onPushRoom(room, event) {
|
||||
root.roomPage = pageStack.push(Qt.createComponent('org.kde.neochat', 'RoomPage.qml'), {
|
||||
connection: root.connection
|
||||
});
|
||||
root.roomPage.forceActiveFocus();
|
||||
if (event.length > 0) {
|
||||
roomPage.goToEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
function onAskJoinRoom(room) {
|
||||
joinRoomDialog.createObject(applicationWindow(), {
|
||||
room: room,
|
||||
@@ -143,27 +119,6 @@ Kirigami.ApplicationWindow {
|
||||
root.showUserDetail(user);
|
||||
}
|
||||
|
||||
function onPushSpaceHome(room) {
|
||||
root.spaceHomePage = pageStack.push(Qt.createComponent('org.kde.neochat', 'SpaceHomePage.qml'));
|
||||
root.spaceHomePage.forceActiveFocus();
|
||||
}
|
||||
|
||||
function onReplaceRoom(room, event) {
|
||||
if (root.roomPage) {
|
||||
pageStack.currentIndex = pageStack.depth - 1;
|
||||
} else {
|
||||
pageStack.pop();
|
||||
root.roomPage = pageStack.push(Qt.createComponent('org.kde.neochat', 'RoomPage.qml'), {
|
||||
connection: root.connection
|
||||
});
|
||||
root.spaceHomePage = null;
|
||||
}
|
||||
root.roomPage.forceActiveFocus();
|
||||
if (event.length > 0) {
|
||||
root.roomPage.goToEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
function onReplaceSpaceHome(room) {
|
||||
if (root.spaceHomePage) {
|
||||
pageStack.currentIndex = pageStack.depth - 1;
|
||||
@@ -314,7 +269,6 @@ Kirigami.ApplicationWindow {
|
||||
target: AccountRegistry
|
||||
function onRowsRemoved() {
|
||||
if (AccountRegistry.rowCount() === 0) {
|
||||
RoomManager.reset();
|
||||
pageStack.clear();
|
||||
pageStack.push(Qt.createComponent('org.kde.neochat', '.qml'));
|
||||
}
|
||||
@@ -490,6 +444,15 @@ Kirigami.ApplicationWindow {
|
||||
}).open();
|
||||
}
|
||||
|
||||
function load() {
|
||||
pageStack.replace(roomListComponent);
|
||||
RoomManager.loadInitialRoom();
|
||||
let roomPage = pageStack.push(Qt.createComponent('org.kde.neochat', 'RoomPage.qml'), {
|
||||
connection: root.connection
|
||||
});
|
||||
roomPage.forceActiveFocus();
|
||||
}
|
||||
|
||||
Component {
|
||||
id: userDetailDialog
|
||||
UserDetailDialog {}
|
||||
|
||||
Reference in New Issue
Block a user