Make the Controller a singleton
This commit is contained in:
committed by
Nicolas Fella
parent
1739a454da
commit
2d1a7d6500
@@ -8,6 +8,8 @@ import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
import QtQuick.Layouts 1.12
|
||||
|
||||
import Spectral 0.1
|
||||
|
||||
import Spectral.Component 2.0
|
||||
|
||||
import org.kde.kirigami 2.12 as Kirigami
|
||||
@@ -17,8 +19,6 @@ Kirigami.ScrollablePage {
|
||||
|
||||
title: i18n("Login")
|
||||
|
||||
required property var spectralController
|
||||
|
||||
Kirigami.FormLayout {
|
||||
id: formLayout
|
||||
QQC2.TextField {
|
||||
@@ -55,9 +55,9 @@ Kirigami.ScrollablePage {
|
||||
|
||||
function doLogin() {
|
||||
if (accessTokenField.text.length > 0) {
|
||||
spectralController.loginWithAccessToken(serverField.text, usernameField.text, accessTokenField.text, deviceNameField.text)
|
||||
Controller.loginWithAccessToken(serverField.text, usernameField.text, accessTokenField.text, deviceNameField.text)
|
||||
} else {
|
||||
spectralController.loginWithCredentials(serverField.text, usernameField.text, passwordField.text, deviceNameField.text)
|
||||
Controller.loginWithCredentials(serverField.text, usernameField.text, passwordField.text, deviceNameField.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
qml/main.qml
22
qml/main.qml
@@ -46,42 +46,36 @@ Kirigami.ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
Controller {
|
||||
id: spectralController
|
||||
|
||||
quitOnLastWindowClosed: true
|
||||
|
||||
onErrorOccured: showPassiveNotification(error + ": " + detail)
|
||||
Connections {
|
||||
target: Controller
|
||||
|
||||
onInitiated: {
|
||||
|
||||
if (spectralController.accountCount === 0) {
|
||||
pageStack.replace("qrc:/qml/LoginPage.qml", {
|
||||
'spectralController': spectralController
|
||||
});
|
||||
if (Controller.accountCount === 0) {
|
||||
pageStack.replace("qrc:/qml/LoginPage.qml", {});
|
||||
} else {
|
||||
pageStack.replace(roomListComponent);
|
||||
}
|
||||
}
|
||||
|
||||
onConnectionAdded: {
|
||||
if (spectralController.accountCount === 1) {
|
||||
if (Controller.accountCount === 1) {
|
||||
console.log("roomListComponent")
|
||||
pageStack.replace(roomListComponent);
|
||||
}
|
||||
}
|
||||
onErrorOccured: showPassiveNotification(error + ": " + detail)
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: imageProvider
|
||||
property: "connection"
|
||||
value: spectralController.connection
|
||||
value: Controller.connection
|
||||
}
|
||||
|
||||
RoomListModel {
|
||||
id: spectralRoomListModel
|
||||
|
||||
connection: spectralController.connection
|
||||
connection: Controller.connection
|
||||
}
|
||||
|
||||
Component {
|
||||
|
||||
Reference in New Issue
Block a user