Change pages organization
- UI (previously MainUI) is back to being the only component loaded as Window's child - UI has the background image previously only for the SignInPage - If there are no accounts, the UI Loader's initialItem is the SignInPage - The SidePane becomes visible when there's >=1 account connected
This commit is contained in:
parent
e09efaecda
commit
0db5a3233d
51
harmonyqml/components/UI.qml
Normal file
51
harmonyqml/components/UI.qml
Normal file
|
@ -0,0 +1,51 @@
|
|||
import QtQuick 2.7
|
||||
import QtQuick.Controls 1.4 as Controls1
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.4
|
||||
import "base" as Base
|
||||
import "sidePane" as SidePane
|
||||
import "chat" as Chat
|
||||
|
||||
Base.HImage {
|
||||
id: loginPage
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
source: "../images/login_background.jpg"
|
||||
anchors.fill: parent
|
||||
|
||||
property bool accountsLoggedIn: Backend.clientManager.clientCount > 0
|
||||
|
||||
//https://doc.qt.io/qt-5/qml-qtquick-controls-splitview.html
|
||||
Controls1.SplitView {
|
||||
anchors.fill: parent
|
||||
|
||||
SidePane.Root {
|
||||
Layout.minimumWidth: 36
|
||||
width: 200
|
||||
visible: accountsLoggedIn
|
||||
}
|
||||
|
||||
StackView {
|
||||
function showPage(path, properties) {
|
||||
pageStack.replace(path, properties || {})
|
||||
}
|
||||
|
||||
function showRoom(userId, roomId) {
|
||||
pageStack.replace(
|
||||
"chat/Root.qml", { userId: userId, roomId: roomId }
|
||||
)
|
||||
}
|
||||
|
||||
id: pageStack
|
||||
initialItem: accountsLoggedIn ? undefined : "pages/SignIn.qml"
|
||||
|
||||
onCurrentItemChanged: if (currentItem) {
|
||||
currentItem.forceActiveFocus()
|
||||
}
|
||||
|
||||
// Buggy
|
||||
replaceExit: null
|
||||
popExit: null
|
||||
pushExit: null
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,8 +9,7 @@ ApplicationWindow {
|
|||
|
||||
Loader {
|
||||
anchors.fill: parent
|
||||
source: Backend.clientManager.clientCount < 1 ?
|
||||
"pages/LoginPage/LoginPage.qml" : "pages/MainUI.qml"
|
||||
source: "UI.qml"
|
||||
objectName: "UILoader"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.4
|
||||
import "../../base" as Base
|
||||
|
||||
Base.HImage {
|
||||
id: loginPage
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
source: "../../../images/login_background.jpg"
|
||||
|
||||
Loader {
|
||||
anchors.centerIn: parent
|
||||
Component.onCompleted: setSource(
|
||||
"SignInBox.qml", { "container": loginPage }
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.4
|
||||
import "../../base" as Base
|
||||
|
||||
Base.HInterfaceBox {
|
||||
id: signInBox
|
||||
title: "Sign in"
|
||||
|
||||
property string loginWith: "username"
|
||||
|
||||
enterButtonTarget: "login"
|
||||
|
||||
buttonModel: [
|
||||
{ name: "register", text: qsTr("Register") },
|
||||
{ name: "login", text: qsTr("Login") },
|
||||
{ name: "forgot", text: qsTr("Forgot?") }
|
||||
]
|
||||
|
||||
buttonCallbacks: {
|
||||
"register": function(button) {},
|
||||
|
||||
"login": function(button) {
|
||||
button.loadingUntilFutureDone(
|
||||
Backend.clientManager.new(
|
||||
"matrix.org", identifierField.text, passwordField.text
|
||||
)
|
||||
)
|
||||
},
|
||||
|
||||
"forgot": function(button) {}
|
||||
}
|
||||
|
||||
Base.HRowLayout {
|
||||
spacing: signInBox.margins * 1.25
|
||||
Layout.margins: signInBox.margins
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
Repeater {
|
||||
model: ["username", "email", "phone"]
|
||||
|
||||
Base.HButton {
|
||||
iconName: modelData
|
||||
circle: true
|
||||
checked: loginWith == modelData
|
||||
autoExclusive: true
|
||||
onClicked: loginWith = modelData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Base.HTextField {
|
||||
id: identifierField
|
||||
placeholderText: qsTr(
|
||||
loginWith === "email" ? "Email" :
|
||||
loginWith === "phone" ? "Phone" :
|
||||
"Username"
|
||||
)
|
||||
onAccepted: signInBox.clickEnterButtonTarget()
|
||||
Component.onCompleted: forceActiveFocus()
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: signInBox.margins
|
||||
}
|
||||
|
||||
Base.HTextField {
|
||||
id: passwordField
|
||||
placeholderText: qsTr("Password")
|
||||
echoMode: TextField.Password
|
||||
onAccepted: signInBox.clickEnterButtonTarget()
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: signInBox.margins
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
import QtQuick 2.7
|
||||
import QtQuick.Controls 1.4 as Controls1
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.4
|
||||
import "../sidePane" as SidePane
|
||||
import "../chat" as Chat
|
||||
|
||||
//https://doc.qt.io/qt-5/qml-qtquick-controls-splitview.html
|
||||
Controls1.SplitView {
|
||||
anchors.fill: parent
|
||||
|
||||
SidePane.Root {
|
||||
Layout.minimumWidth: 36
|
||||
width: 200
|
||||
}
|
||||
|
||||
StackView {
|
||||
function showRoom(userId, roomId) {
|
||||
pageStack.replace(
|
||||
"../chat/Root.qml", { userId: userId, roomId: roomId }
|
||||
)
|
||||
}
|
||||
|
||||
id: pageStack
|
||||
|
||||
onCurrentItemChanged: if (currentItem) {
|
||||
currentItem.forceActiveFocus()
|
||||
}
|
||||
|
||||
initialItem: Item { // TODO: (test, remove)
|
||||
Keys.onEnterPressed: pageStack.showRoom(
|
||||
"@test_mary:matrix.org", "!TSXGsbBbdwsdylIOJZ:matrix.org"
|
||||
//"@test_mary:matrix.org", "!TEXkdeErtVCMqClNfb:matrix.org"
|
||||
)
|
||||
}
|
||||
|
||||
// Buggy
|
||||
replaceExit: null
|
||||
popExit: null
|
||||
pushExit: null
|
||||
}
|
||||
}
|
79
harmonyqml/components/pages/SignIn.qml
Normal file
79
harmonyqml/components/pages/SignIn.qml
Normal file
|
@ -0,0 +1,79 @@
|
|||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.4
|
||||
import "../base" as Base
|
||||
|
||||
Item {
|
||||
property string loginWith: "username"
|
||||
|
||||
onFocusChanged: identifierField.forceActiveFocus()
|
||||
|
||||
Base.HInterfaceBox {
|
||||
id: signInBox
|
||||
title: "Sign in"
|
||||
anchors.centerIn: parent
|
||||
|
||||
enterButtonTarget: "login"
|
||||
|
||||
buttonModel: [
|
||||
{ name: "register", text: qsTr("Register") },
|
||||
{ name: "login", text: qsTr("Login") },
|
||||
{ name: "forgot", text: qsTr("Forgot?") }
|
||||
]
|
||||
|
||||
buttonCallbacks: {
|
||||
"register": function(button) {},
|
||||
|
||||
"login": function(button) {
|
||||
button.loadingUntilFutureDone(
|
||||
Backend.clientManager.new(
|
||||
"matrix.org", identifierField.text, passwordField.text
|
||||
)
|
||||
)
|
||||
},
|
||||
|
||||
"forgot": function(button) {}
|
||||
}
|
||||
|
||||
Base.HRowLayout {
|
||||
spacing: signInBox.margins * 1.25
|
||||
Layout.margins: signInBox.margins
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
Repeater {
|
||||
model: ["username", "email", "phone"]
|
||||
|
||||
Base.HButton {
|
||||
iconName: modelData
|
||||
circle: true
|
||||
checked: loginWith == modelData
|
||||
autoExclusive: true
|
||||
onClicked: loginWith = modelData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Base.HTextField {
|
||||
id: identifierField
|
||||
placeholderText: qsTr(
|
||||
loginWith === "email" ? "Email" :
|
||||
loginWith === "phone" ? "Phone" :
|
||||
"Username"
|
||||
)
|
||||
onAccepted: signInBox.clickEnterButtonTarget()
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: signInBox.margins
|
||||
}
|
||||
|
||||
Base.HTextField {
|
||||
id: passwordField
|
||||
placeholderText: qsTr("Password")
|
||||
echoMode: TextField.Password
|
||||
onAccepted: signInBox.clickEnterButtonTarget()
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: signInBox.margins
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user