Use a Loader instead of StackView for pageStack

This commit is contained in:
miruka 2019-08-19 15:37:48 -04:00
parent 99bbe7f3ee
commit 109082c8d8
11 changed files with 28 additions and 23 deletions

View File

@ -139,7 +139,6 @@
- Direct chats category
- Markdown: don't turn #things (no space) and `thing\n---` into title,
disable `__` syntax for bold/italic
- Push instead of replacing in stack view (remove getMemberFilter when done)
- `<pre>` scrollbar on overflow
- When inviting someone to direct chat, room is "Empty room" until accepted,
it should be the peer's display name instead.

View File

@ -24,7 +24,7 @@ Banner {
py.callClientCoro(
chatPage.userId, "room_forget", [chatPage.roomId], () => {
button.loading = false
Qt.callLater(pageStack.showPage, "Default")
Qt.callLater(pageLoader.showPage, "Default")
})
}
})

View File

@ -49,7 +49,7 @@ HRectangle {
Layout.fillWidth: true
Layout.minimumHeight: theme.baseElementsHeight
Layout.preferredHeight: areaScrollView.implicitHeight
Layout.maximumHeight: pageStack.height / 2
Layout.maximumHeight: pageLoader.height / 2
color: theme.chat.sendBox.background
HRowLayout {

View File

@ -42,7 +42,7 @@ HPage {
Layout.maximumWidth: Math.min(parent.width, 640)
Layout.preferredWidth:
pageStack.isWide ? parent.width : avatarPreferredSize
pageLoader.isWide ? parent.width : avatarPreferredSize
Layout.preferredHeight: childrenRect.height

View File

@ -24,7 +24,7 @@ HColumnLayout {
"rooms can be exported to a passphrase-protected file.%1" +
"You will then be able to import this file in another " +
"Matrix client."
).arg(pageStack.isWide ? "\n" :"\n\n")
).arg(pageLoader.isWide ? "\n" :"\n\n")
Layout.fillWidth: true
Layout.margins: currentSpacing

View File

@ -46,7 +46,7 @@ HGridLayout {
}
columns: 2
flow: pageStack.isWide ? GridLayout.LeftToRight : GridLayout.TopToBottom
flow: pageLoader.isWide ? GridLayout.LeftToRight : GridLayout.TopToBottom
rowSpacing: currentSpacing
Component.onCompleted: nameField.field.forceActiveFocus()

View File

@ -41,7 +41,7 @@ HPage {
(rememberAccount.checked ? "add": "delete"),
[data]
)
pageStack.showPage(
pageLoader.showPage(
"EditAccount/EditAccount", {userId: data}
)

View File

@ -37,7 +37,7 @@ HInteractiveRectangle {
}
function activate() {
pageStack.showPage(
pageLoader.showPage(
"EditAccount/EditAccount", { "userId": model.data.user_id }
)
}

View File

@ -33,7 +33,7 @@ HInteractiveRectangle {
}
function activate() {
pageStack.showRoom(model.user_id, model.data.room_id)
pageLoader.showRoom(model.user_id, model.data.room_id)
}

View File

@ -16,7 +16,7 @@ HRowLayout {
backgroundColor: theme.sidePane.settingsButton.background
Layout.preferredHeight: parent.height
onClicked: pageStack.showPage("SignIn")
onClicked: pageLoader.showPage("SignIn")
}
HTextField {

View File

@ -11,7 +11,7 @@ HRectangle {
Component.onCompleted: window.mainUI = mainUI
property alias sidePane: sidePane
property alias pageStack: pageStack
property alias pageLoader: pageLoader
property alias pressAnimation: _pressAnimation
SequentialAnimation {
@ -63,13 +63,13 @@ HRectangle {
Behavior on Layout.minimumWidth { HNumberAnimation {} }
}
StackView {
id: pageStack
HLoader {
id: pageLoader
property bool isWide: width > theme.contentIsWideAbove
Component.onCompleted: {
if (! py.startupAnyAccountsSaved) {
pageStack.showPage("SignIn")
pageLoader.showPage("SignIn")
return
}
@ -77,14 +77,14 @@ HRectangle {
let props = window.uiState.pageProperties
if (page == "Chat/Chat.qml") {
pageStack.showRoom(props.userId, props.roomId)
pageLoader.showRoom(props.userId, props.roomId)
} else {
pageStack._show(page, props)
pageLoader._show(page, props)
}
}
function _show(componentUrl, properties={}) {
pageStack.replace(componentUrl, properties)
pageLoader.setSource(componentUrl, properties)
}
function showPage(name, properties={}) {
@ -104,14 +104,20 @@ HRectangle {
window.uiStateChanged()
}
onCurrentItemChanged: if (currentItem) {
currentItem.forceActiveFocus()
onStatusChanged: if (status == Loader.Ready) {
item.forceActiveFocus()
appearAnimation.start()
}
// Buggy
replaceExit: null
popExit: null
pushExit: null
clip: appearAnimation.running
XAnimator {
id: appearAnimation
target: pageLoader.item
from: -300
to: 0
easing.type: Easing.OutBack
duration: theme.animationDuration * 2
}
}
}
}