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:
@@ -32,10 +32,13 @@ Kirigami.Page {
|
||||
readonly property RoomTreeModel roomTreeModel: RoomTreeModel {
|
||||
connection: root.connection
|
||||
}
|
||||
property bool spaceChanging: false
|
||||
|
||||
readonly property bool collapsed: Config.collapsed
|
||||
|
||||
onCurrentWidthChanged: pageStack.defaultColumnWidth = root.currentWidth
|
||||
Component.onCompleted: pageStack.defaultColumnWidth = root.currentWidth
|
||||
|
||||
|
||||
onCollapsedChanged: {
|
||||
if (collapsed) {
|
||||
sortFilterRoomTreeModel.filterText = "";
|
||||
@@ -87,6 +90,13 @@ Kirigami.Page {
|
||||
|
||||
padding: 0
|
||||
|
||||
Connections {
|
||||
target: RoomManager
|
||||
function onCurrentSpaceChanged() {
|
||||
treeView.expandRecursively();
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
@@ -98,7 +108,6 @@ Kirigami.Page {
|
||||
|
||||
connection: root.connection
|
||||
|
||||
onSelectionChanged: root.spaceChanging = true
|
||||
onSpacesUpdated: sortFilterRoomTreeModel.invalidate()
|
||||
}
|
||||
|
||||
@@ -127,31 +136,14 @@ Kirigami.Page {
|
||||
clip: true
|
||||
reuseItems: false
|
||||
|
||||
onLayoutChanged: {
|
||||
treeView.expandRecursively();
|
||||
if (sortFilterRoomTreeModel.filterTextJustChanged) {
|
||||
sortFilterRoomTreeModel.filterTextJustChanged = false;
|
||||
}
|
||||
if (root.spaceChanging) {
|
||||
if (spaceDrawer.showDirectChats || spaceDrawer.selectedSpaceId.length < 1) {
|
||||
const item = treeView.itemAtIndex(treeView.index(1, 0))
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
RoomManager.resolveResource(item.currentRoom.id);
|
||||
}
|
||||
root.spaceChanging = false;
|
||||
}
|
||||
}
|
||||
|
||||
model: SortFilterRoomTreeModel {
|
||||
id: sortFilterRoomTreeModel
|
||||
|
||||
property bool filterTextJustChanged: false
|
||||
|
||||
sourceModel: root.roomTreeModel
|
||||
activeSpaceId: spaceDrawer.selectedSpaceId
|
||||
mode: spaceDrawer.showDirectChats ? SortFilterRoomTreeModel.DirectChats : SortFilterRoomTreeModel.Rooms
|
||||
activeSpaceId: RoomManager.currentSpace
|
||||
mode: RoomManager.currentSpace === "DM" ? SortFilterRoomTreeModel.DirectChats : SortFilterRoomTreeModel.Rooms
|
||||
onRowsInserted: (index, first, last) => treeView.expandTo(index)
|
||||
onDataChanged: treeView.expandRecursively()
|
||||
}
|
||||
|
||||
selectionModel: ItemSelectionModel {}
|
||||
@@ -334,7 +326,7 @@ Kirigami.Page {
|
||||
|
||||
onTextChanged: newText => {
|
||||
sortFilterRoomTreeModel.filterText = newText;
|
||||
sortFilterRoomTreeModel.filterTextJustChanged = true;
|
||||
treeView.expandRecursively();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ Kirigami.Page {
|
||||
/// Disable cancel shortcut. Used by the separate window since it provides its own cancel implementation.
|
||||
property bool disableCancelShortcut: false
|
||||
|
||||
title: root.currentRoom.displayName
|
||||
title: root.currentRoom ? root.currentRoom.displayName : ""
|
||||
focus: true
|
||||
padding: 0
|
||||
|
||||
@@ -116,7 +116,7 @@ Kirigami.Page {
|
||||
Loader {
|
||||
id: timelineViewLoader
|
||||
anchors.fill: parent
|
||||
active: root.currentRoom && !root.currentRoom.isInvite && !root.loading
|
||||
active: root.currentRoom && !root.currentRoom.isInvite && !root.loading && !root.currentRoom.isSpace
|
||||
sourceComponent: TimelineView {
|
||||
id: timelineView
|
||||
currentRoom: root.currentRoom
|
||||
@@ -143,7 +143,23 @@ Kirigami.Page {
|
||||
}
|
||||
|
||||
Loader {
|
||||
active: root.loading && !invitationLoader.active
|
||||
id: spaceLoader
|
||||
active: root.currentRoom && root.currentRoom.isSpace
|
||||
anchors.fill: parent
|
||||
sourceComponent: SpaceHomePage {}
|
||||
}
|
||||
|
||||
Loader {
|
||||
active: !RoomManager.currentRoom
|
||||
anchors.centerIn: parent
|
||||
sourceComponent: Kirigami.PlaceholderMessage {
|
||||
icon.name: "org.kde.neochat"
|
||||
text: i18n("Welcome to NeoChat")
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
active: root.loading && !invitationLoader.active && RoomManager.currentRoom && !spaceLoader.active
|
||||
anchors.centerIn: parent
|
||||
sourceComponent: Kirigami.LoadingPlaceholder {
|
||||
anchors.centerIn: parent
|
||||
@@ -176,11 +192,7 @@ Kirigami.Page {
|
||||
Connections {
|
||||
target: RoomManager
|
||||
function onCurrentRoomChanged() {
|
||||
if (!RoomManager.currentRoom) {
|
||||
if (pageStack.lastItem === root) {
|
||||
pageStack.pop();
|
||||
}
|
||||
} else if (root.currentRoom.isInvite) {
|
||||
if (root.currentRoom && root.currentRoom.isInvite) {
|
||||
root.currentRoom.clearInvitationNotification();
|
||||
}
|
||||
}
|
||||
@@ -188,6 +200,10 @@ Kirigami.Page {
|
||||
function onWarning(title, message) {
|
||||
root.warning(title, message);
|
||||
}
|
||||
|
||||
function onGoToEvent(eventId) {
|
||||
(timelineViewLoader.item as TimelineView).goToEvent(eventId);
|
||||
}
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
|
||||
@@ -21,18 +21,6 @@ QQC2.Control {
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
|
||||
property string selectedSpaceId: RoomManager.lastSpaceId
|
||||
Connections {
|
||||
target: RoomManager
|
||||
function onConnectionChanged() {
|
||||
// We need to rebind as any previous change will have been overwritten.
|
||||
selectedSpaceId = RoomManager.lastSpaceId;
|
||||
}
|
||||
}
|
||||
|
||||
property bool showDirectChats: RoomManager.directChatsActive
|
||||
|
||||
signal selectionChanged
|
||||
signal spacesUpdated
|
||||
|
||||
contentItem: Loader {
|
||||
@@ -100,12 +88,9 @@ QQC2.Control {
|
||||
source: "user-home-symbolic"
|
||||
}
|
||||
|
||||
checked: root.selectedSpaceId === "" && root.showDirectChats === false
|
||||
checked: RoomManager.currentSpace.length === 0
|
||||
onClicked: {
|
||||
root.showDirectChats = false;
|
||||
RoomManager.directChatsActive = false;
|
||||
root.selectedSpaceId = "";
|
||||
RoomManager.lastSpaceId = "";
|
||||
RoomManager.currentSpace = "";
|
||||
root.selectionChanged();
|
||||
}
|
||||
|
||||
@@ -119,7 +104,7 @@ QQC2.Control {
|
||||
height: Kirigami.Units.iconSizes.smallMedium
|
||||
|
||||
text: root.connection.homeNotifications > 0 ? root.connection.homeNotifications : ""
|
||||
visible: root.connection.homeNotifications > 0 && (root.selectedSpaceId !== "" || root.showDirectChats === true)
|
||||
visible: root.connection.homeNotifications > 0 && (RoomManager.currentSpace.length > 0 || root.showDirectChats === true)
|
||||
color: Kirigami.Theme.textColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
background: Rectangle {
|
||||
@@ -149,12 +134,9 @@ QQC2.Control {
|
||||
source: "system-users"
|
||||
}
|
||||
|
||||
checked: root.showDirectChats === true
|
||||
checked: RoomManager.currentSpace === "DM"
|
||||
onClicked: {
|
||||
root.showDirectChats = true;
|
||||
RoomManager.directChatsActive = true;
|
||||
root.selectedSpaceId = "";
|
||||
RoomManager.lastSpaceId = "";
|
||||
RoomManager.currentSpace = "DM";
|
||||
root.selectionChanged();
|
||||
}
|
||||
|
||||
@@ -193,11 +175,6 @@ QQC2.Control {
|
||||
}
|
||||
onLayoutChanged: root.spacesUpdated()
|
||||
}
|
||||
onCountChanged: {
|
||||
if (!root.connection.room(root.selectedSpaceId)) {
|
||||
root.selectedSpaceId = "";
|
||||
}
|
||||
}
|
||||
|
||||
delegate: AvatarTabButton {
|
||||
id: spaceDelegate
|
||||
@@ -215,17 +192,11 @@ QQC2.Control {
|
||||
source: avatar ? ("image://mxc/" + avatar) : ""
|
||||
|
||||
onSelected: {
|
||||
root.showDirectChats = false;
|
||||
RoomManager.directChatsActive = false;
|
||||
if (!SpaceHierarchyCache.isSpaceChild(roomId, RoomManager.currentRoom.id) || root.selectedSpaceId == roomId) {
|
||||
RoomManager.resolveResource(currentRoom.id);
|
||||
} else {
|
||||
RoomManager.lastSpaceId = currentRoom.id;
|
||||
}
|
||||
root.selectedSpaceId = roomId;
|
||||
RoomManager.resolveResource(spaceDelegate.roomId);
|
||||
RoomManager.currentSpace = spaceDelegate.roomId;
|
||||
root.selectionChanged();
|
||||
}
|
||||
checked: root.selectedSpaceId === roomId
|
||||
checked: RoomManager.currentSpace === roomId
|
||||
onContextMenuRequested: root.createContextMenu(currentRoom)
|
||||
|
||||
QQC2.Label {
|
||||
@@ -238,7 +209,7 @@ QQC2.Control {
|
||||
height: Kirigami.Units.iconSizes.smallMedium
|
||||
|
||||
text: spaceDelegate.currentRoom.childrenNotificationCount > 0 ? spaceDelegate.currentRoom.childrenNotificationCount : ""
|
||||
visible: spaceDelegate.currentRoom.childrenNotificationCount > 0 && root.selectedSpaceId != spaceDelegate.roomId
|
||||
visible: spaceDelegate.currentRoom.childrenNotificationCount > 0 && RoomManager.currentSpace != spaceDelegate.roomId
|
||||
color: Kirigami.Theme.textColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
@@ -10,152 +10,153 @@ import org.kde.kirigami as Kirigami
|
||||
import org.kde.neochat
|
||||
import org.kde.neochat.settings
|
||||
|
||||
Kirigami.Page {
|
||||
ColumnLayout {
|
||||
id: root
|
||||
|
||||
readonly property NeoChatRoom currentRoom: RoomManager.currentRoom
|
||||
|
||||
padding: 0
|
||||
anchors.fill: parent
|
||||
|
||||
ColumnLayout {
|
||||
id: columnLayout
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
spacing: 0
|
||||
|
||||
Item {
|
||||
id: headerItem
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: Kirigami.Units.smallSpacing
|
||||
implicitHeight: headerColumn.implicitHeight
|
||||
QQC2.Control {
|
||||
id: headerItem
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: Kirigami.Units.smallSpacing
|
||||
implicitHeight: headerColumn.implicitHeight
|
||||
|
||||
ColumnLayout {
|
||||
id: headerColumn
|
||||
anchors.centerIn: headerItem
|
||||
width: sizeHelper.currentWidth
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
background: Rectangle {
|
||||
color: Kirigami.Theme.backgroundColor
|
||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||
Kirigami.Theme.inherit: false
|
||||
}
|
||||
|
||||
GroupChatDrawerHeader {
|
||||
id: header
|
||||
Layout.fillWidth: true
|
||||
room: root.currentRoom
|
||||
ColumnLayout {
|
||||
id: headerColumn
|
||||
anchors.centerIn: headerItem
|
||||
width: sizeHelper.currentWidth
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
|
||||
GroupChatDrawerHeader {
|
||||
id: header
|
||||
Layout.fillWidth: true
|
||||
room: root.currentRoom
|
||||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: Kirigami.Units.largeSpacing
|
||||
Layout.rightMargin: Kirigami.Units.largeSpacing
|
||||
QQC2.Button {
|
||||
visible: root.currentRoom.canSendState("invite")
|
||||
text: i18nc("@button", "Invite user to space")
|
||||
icon.name: "list-add-user"
|
||||
onClicked: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'InviteUserPage.qml'), {
|
||||
room: root.currentRoom
|
||||
}, {
|
||||
title: i18nc("@title", "Invite a User")
|
||||
})
|
||||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: Kirigami.Units.largeSpacing
|
||||
Layout.rightMargin: Kirigami.Units.largeSpacing
|
||||
QQC2.Button {
|
||||
visible: root.currentRoom.canSendState("invite")
|
||||
text: i18nc("@button", "Invite user to space")
|
||||
icon.name: "list-add-user"
|
||||
onClicked: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'InviteUserPage.qml'), {
|
||||
room: root.currentRoom
|
||||
}, {
|
||||
title: i18nc("@title", "Invite a User")
|
||||
})
|
||||
}
|
||||
QQC2.Button {
|
||||
visible: root.currentRoom.canSendState("m.space.child")
|
||||
text: i18nc("@button", "Add new room")
|
||||
icon.name: "list-add"
|
||||
onClicked: _private.createRoom(root.currentRoom.id)
|
||||
}
|
||||
QQC2.Button {
|
||||
text: i18nc("@button", "Leave the space")
|
||||
icon.name: "go-previous"
|
||||
onClicked: RoomManager.leaveRoom(root.currentRoom)
|
||||
}
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
QQC2.Button {
|
||||
text: i18nc("@button", "Space settings")
|
||||
icon.name: "settings-configure"
|
||||
display: QQC2.AbstractButton.IconOnly
|
||||
onClicked: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'RoomSettings.qml'), {
|
||||
room: root.currentRoom,
|
||||
connection: root.currentRoom.connection
|
||||
}, {
|
||||
title: i18n("Room Settings")
|
||||
})
|
||||
|
||||
QQC2.ToolTip.text: text
|
||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||
QQC2.ToolTip.visible: hovered
|
||||
}
|
||||
QQC2.Button {
|
||||
visible: root.currentRoom.canSendState("m.space.child")
|
||||
text: i18nc("@button", "Add new room")
|
||||
icon.name: "list-add"
|
||||
onClicked: _private.createRoom(root.currentRoom.id)
|
||||
}
|
||||
Kirigami.SearchField {
|
||||
QQC2.Button {
|
||||
text: i18nc("@button", "Leave the space")
|
||||
icon.name: "go-previous"
|
||||
onClicked: RoomManager.leaveRoom(root.currentRoom)
|
||||
}
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: Kirigami.Units.largeSpacing
|
||||
Layout.rightMargin: Kirigami.Units.largeSpacing
|
||||
Layout.bottomMargin: Kirigami.Units.largeSpacing
|
||||
onTextChanged: spaceChildSortFilterModel.filterText = text
|
||||
}
|
||||
QQC2.Button {
|
||||
text: i18nc("@button", "Space settings")
|
||||
icon.name: "settings-configure"
|
||||
display: QQC2.AbstractButton.IconOnly
|
||||
onClicked: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'RoomSettings.qml'), {
|
||||
room: root.currentRoom,
|
||||
connection: root.currentRoom.connection
|
||||
}, {
|
||||
title: i18n("Room Settings")
|
||||
})
|
||||
|
||||
QQC2.ToolTip.text: text
|
||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||
QQC2.ToolTip.visible: hovered
|
||||
}
|
||||
}
|
||||
DelegateSizeHelper {
|
||||
id: sizeHelper
|
||||
startBreakpoint: Kirigami.Units.gridUnit * 46
|
||||
endBreakpoint: Kirigami.Units.gridUnit * 66
|
||||
startPercentWidth: 100
|
||||
endPercentWidth: 85
|
||||
maxWidth: Kirigami.Units.gridUnit * 60
|
||||
|
||||
parentWidth: columnLayout.width
|
||||
Kirigami.SearchField {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: Kirigami.Units.largeSpacing
|
||||
Layout.rightMargin: Kirigami.Units.largeSpacing
|
||||
Layout.bottomMargin: Kirigami.Units.largeSpacing
|
||||
onTextChanged: spaceChildSortFilterModel.filterText = text
|
||||
}
|
||||
}
|
||||
Kirigami.Separator {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
QQC2.ScrollView {
|
||||
id: hierarchyScrollView
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
visible: !spaceChildrenModel.loading
|
||||
DelegateSizeHelper {
|
||||
id: sizeHelper
|
||||
startBreakpoint: Kirigami.Units.gridUnit * 46
|
||||
endBreakpoint: Kirigami.Units.gridUnit * 66
|
||||
startPercentWidth: 100
|
||||
endPercentWidth: 85
|
||||
maxWidth: Kirigami.Units.gridUnit * 60
|
||||
|
||||
TreeView {
|
||||
id: spaceTree
|
||||
columnWidthProvider: function (column) {
|
||||
return spaceTree.width;
|
||||
}
|
||||
|
||||
clip: true
|
||||
|
||||
model: SpaceChildSortFilterModel {
|
||||
id: spaceChildSortFilterModel
|
||||
sourceModel: SpaceChildrenModel {
|
||||
id: spaceChildrenModel
|
||||
space: root.currentRoom
|
||||
}
|
||||
}
|
||||
|
||||
delegate: SpaceHierarchyDelegate {
|
||||
onCreateRoom: _private.createRoom(roomId)
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: Kirigami.Theme.backgroundColor
|
||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||
}
|
||||
}
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
visible: spaceChildrenModel.loading
|
||||
|
||||
Loader {
|
||||
active: spaceChildrenModel.loading
|
||||
anchors.centerIn: parent
|
||||
sourceComponent: Kirigami.LoadingPlaceholder {}
|
||||
}
|
||||
parentWidth: root.width
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: Kirigami.Theme.backgroundColor
|
||||
Kirigami.Theme.inherit: false
|
||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||
Kirigami.Separator {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
QQC2.ScrollView {
|
||||
id: hierarchyScrollView
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
visible: !spaceChildrenModel.loading
|
||||
|
||||
TreeView {
|
||||
id: spaceTree
|
||||
columnWidthProvider: function (column) {
|
||||
return spaceTree.width;
|
||||
}
|
||||
|
||||
clip: true
|
||||
|
||||
model: SpaceChildSortFilterModel {
|
||||
id: spaceChildSortFilterModel
|
||||
sourceModel: SpaceChildrenModel {
|
||||
id: spaceChildrenModel
|
||||
space: root.currentRoom
|
||||
}
|
||||
}
|
||||
|
||||
delegate: SpaceHierarchyDelegate {
|
||||
onCreateRoom: _private.createRoom(roomId)
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: Kirigami.Theme.backgroundColor
|
||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||
}
|
||||
}
|
||||
QQC2.Control {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
visible: spaceChildrenModel.loading
|
||||
|
||||
background: Rectangle {
|
||||
color: Kirigami.Theme.backgroundColor
|
||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||
Kirigami.Theme.inherit: false
|
||||
}
|
||||
|
||||
Loader {
|
||||
active: spaceChildrenModel.loading
|
||||
anchors.centerIn: parent
|
||||
sourceComponent: Kirigami.LoadingPlaceholder {}
|
||||
}
|
||||
}
|
||||
QtObject {
|
||||
id: _private
|
||||
function createRoom(parentId) {
|
||||
@@ -182,3 +183,5 @@ Kirigami.Page {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -422,4 +422,8 @@ QQC2.ScrollView {
|
||||
function positionViewAtBeginning() {
|
||||
messageListView.positionViewAtBeginning();
|
||||
}
|
||||
|
||||
function goToEvent(eventId) {
|
||||
messageListView.goToEvent(eventId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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