Make the Controller a singleton

This commit is contained in:
Tobias Fella
2020-11-04 01:43:13 +00:00
committed by Nicolas Fella
parent 1739a454da
commit 2d1a7d6500
13 changed files with 42 additions and 66 deletions

View File

@@ -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)
}
}
}

View File

@@ -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 {