Add a login page that appears if no account was configured
This commit is contained in:
@@ -1,81 +0,0 @@
|
|||||||
import QtQuick 2.12
|
|
||||||
import QtQuick.Controls 2.12
|
|
||||||
import QtQuick.Layouts 1.12
|
|
||||||
|
|
||||||
import Spectral.Component 2.0
|
|
||||||
|
|
||||||
Dialog {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
width: 360
|
|
||||||
|
|
||||||
id: root
|
|
||||||
|
|
||||||
title: "Login"
|
|
||||||
|
|
||||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
|
||||||
|
|
||||||
onAccepted: doLogin()
|
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
|
||||||
AutoTextField {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
id: serverField
|
|
||||||
|
|
||||||
placeholderText: "Server Address"
|
|
||||||
text: "https://matrix.org"
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoTextField {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
id: usernameField
|
|
||||||
|
|
||||||
placeholderText: "Username"
|
|
||||||
|
|
||||||
onAccepted: passwordField.forceActiveFocus()
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoTextField {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
id: passwordField
|
|
||||||
|
|
||||||
placeholderText: "Password"
|
|
||||||
echoMode: TextInput.Password
|
|
||||||
|
|
||||||
onAccepted: accessTokenField.forceActiveFocus()
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoTextField {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
id: accessTokenField
|
|
||||||
|
|
||||||
placeholderText: "Access Token (Optional)"
|
|
||||||
|
|
||||||
onAccepted: deviceNameField.forceActiveFocus()
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoTextField {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
id: deviceNameField
|
|
||||||
|
|
||||||
placeholderText: "Device Name (Optional)"
|
|
||||||
|
|
||||||
onAccepted: root.accept()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function doLogin() {
|
|
||||||
if (accessTokenField.text !== "") {
|
|
||||||
console.log("Login using access token.")
|
|
||||||
spectralController.loginWithAccessToken(serverField.text, usernameField.text, accessTokenField.text, deviceNameField.text)
|
|
||||||
} else {
|
|
||||||
spectralController.loginWithCredentials(serverField.text, usernameField.text, passwordField.text, deviceNameField.text)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onClosed: destroy()
|
|
||||||
}
|
|
||||||
10
qml/LoadingPage.qml
Normal file
10
qml/LoadingPage.qml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import org.kde.kirigami 2.12 as Kirigami
|
||||||
|
import QtQuick.Controls 2.12 as QQC2
|
||||||
|
|
||||||
|
Kirigami.Page {
|
||||||
|
title: i18n("Loading")
|
||||||
|
|
||||||
|
QQC2.BusyIndicator {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
}
|
||||||
|
}
|
||||||
63
qml/LoginPage.qml
Normal file
63
qml/LoginPage.qml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
|
||||||
|
* SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
|
||||||
|
*
|
||||||
|
* SPDX-LicenseIdentifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.12 as QQC2
|
||||||
|
import QtQuick.Layouts 1.12
|
||||||
|
|
||||||
|
import Spectral.Component 2.0
|
||||||
|
|
||||||
|
import org.kde.kirigami 2.12 as Kirigami
|
||||||
|
|
||||||
|
Kirigami.ScrollablePage {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
title: i18n("Login")
|
||||||
|
|
||||||
|
required property var spectralController
|
||||||
|
|
||||||
|
Kirigami.FormLayout {
|
||||||
|
id: formLayout
|
||||||
|
QQC2.TextField {
|
||||||
|
id: serverField
|
||||||
|
Kirigami.FormData.label: i18n("Server Address")
|
||||||
|
text: "https://matrix.org"
|
||||||
|
onAccepted: usernameField.forceActiveFocus()
|
||||||
|
}
|
||||||
|
QQC2.TextField {
|
||||||
|
id: usernameField
|
||||||
|
Kirigami.FormData.label: i18n("Username")
|
||||||
|
onAccepted: passwordField.forceActiveFocus()
|
||||||
|
}
|
||||||
|
Kirigami.PasswordField {
|
||||||
|
id: passwordField
|
||||||
|
Kirigami.FormData.label: i18n("Password")
|
||||||
|
onAccepted: accessTokenField.forceActiveFocus()
|
||||||
|
}
|
||||||
|
QQC2.TextField {
|
||||||
|
id: accessTokenField
|
||||||
|
Kirigami.FormData.label: i18n("Access Token (Optional)")
|
||||||
|
onAccepted: deviceNameField.forceActiveFocus()
|
||||||
|
}
|
||||||
|
QQC2.TextField {
|
||||||
|
id: deviceNameField
|
||||||
|
Kirigami.FormData.label: i18n("Device Name (Optional)")
|
||||||
|
onAccepted: doLogin()
|
||||||
|
}
|
||||||
|
QQC2.Button {
|
||||||
|
text: i18n("Login")
|
||||||
|
onClicked: doLogin()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function doLogin() {
|
||||||
|
if (accessTokenField.text.length > 0) {
|
||||||
|
spectralController.loginWithAccessToken(serverField.text, usernameField.text, accessTokenField.text, deviceNameField.text)
|
||||||
|
} else {
|
||||||
|
spectralController.loginWithCredentials(serverField.text, usernameField.text, passwordField.text, deviceNameField.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
48
qml/main.qml
48
qml/main.qml
@@ -6,6 +6,7 @@ import org.kde.kirigami 2.12 as Kirigami
|
|||||||
|
|
||||||
import Spectral 0.1
|
import Spectral 0.1
|
||||||
import Spectral.Component 2.0
|
import Spectral.Component 2.0
|
||||||
|
import Spectral.Dialog 2.0
|
||||||
import Spectral.Panel 2.0
|
import Spectral.Panel 2.0
|
||||||
|
|
||||||
Kirigami.ApplicationWindow {
|
Kirigami.ApplicationWindow {
|
||||||
@@ -15,28 +16,28 @@ Kirigami.ApplicationWindow {
|
|||||||
contextDrawer: RoomDrawer {
|
contextDrawer: RoomDrawer {
|
||||||
id: contextDrawer
|
id: contextDrawer
|
||||||
enabled: roomList.enteredRoom !== null
|
enabled: roomList.enteredRoom !== null
|
||||||
visible: enabled
|
|
||||||
room: root.currentRoom
|
room: root.currentRoom
|
||||||
}
|
}
|
||||||
|
|
||||||
pageStack.initialPage: RoomListPanel {
|
pageStack.initialPage: LoadingPage {}
|
||||||
id: roomList
|
|
||||||
roomListModel: spectralRoomListModel
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component {
|
||||||
applicationWindow().pageStack.push(roomPanelComponent, {"currentRoom": roomList.enteredRoom })
|
id: roomListComponent
|
||||||
}
|
RoomListPanel {
|
||||||
|
id: roomList
|
||||||
|
roomListModel: spectralRoomListModel
|
||||||
|
|
||||||
onEnterRoom: {
|
onEnterRoom: {
|
||||||
applicationWindow().pageStack.push(roomPanelComponent, {"currentRoom": room})
|
applicationWindow().pageStack.push(roomPanelComponent, {"currentRoom": room});
|
||||||
root.currentRoom = room
|
root.currentRoom = room;
|
||||||
|
|
||||||
}
|
}
|
||||||
onLeaveRoom: {
|
onLeaveRoom: {
|
||||||
var stack = applicationWindow().pageStack;
|
var stack = applicationWindow().pageStack;
|
||||||
roomList.enteredRoom = null
|
roomList.enteredRoom = null;
|
||||||
|
|
||||||
stack.removePage(stack.lastItem)
|
stack.removePage(stack.lastItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +47,23 @@ Kirigami.ApplicationWindow {
|
|||||||
quitOnLastWindowClosed: true
|
quitOnLastWindowClosed: true
|
||||||
|
|
||||||
onErrorOccured: showPassiveNotification(error + ": " + detail)
|
onErrorOccured: showPassiveNotification(error + ": " + detail)
|
||||||
|
|
||||||
|
onInitiated: {
|
||||||
|
if (spectralController.accountCount === 0) {
|
||||||
|
pageStack.replace("qrc:/qml/LoginPage.qml", {
|
||||||
|
'spectralController': spectralController
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
pageStack.replace(roomListComponent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onConnectionAdded: {
|
||||||
|
if (spectralController.accountCount === 1) {
|
||||||
|
console.log("roomListComponent")
|
||||||
|
pageStack.replace(roomListComponent);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Binding {
|
Binding {
|
||||||
|
|||||||
3
res.qrc
3
res.qrc
@@ -1,6 +1,8 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>qml/main.qml</file>
|
<file>qml/main.qml</file>
|
||||||
|
<file>qml/LoginPage.qml</file>
|
||||||
|
<file>qml/LoadingPage.qml</file>
|
||||||
<file>imports/Spectral/Component/Emoji/EmojiPicker.qml</file>
|
<file>imports/Spectral/Component/Emoji/EmojiPicker.qml</file>
|
||||||
<file>imports/Spectral/Component/Emoji/qmldir</file>
|
<file>imports/Spectral/Component/Emoji/qmldir</file>
|
||||||
<file>imports/Spectral/Component/Timeline/MessageDelegate.qml</file>
|
<file>imports/Spectral/Component/Timeline/MessageDelegate.qml</file>
|
||||||
@@ -38,7 +40,6 @@
|
|||||||
<file>imports/Spectral/Dialog/RoomSettingsDialog.qml</file>
|
<file>imports/Spectral/Dialog/RoomSettingsDialog.qml</file>
|
||||||
<file>imports/Spectral/Dialog/UserDetailDialog.qml</file>
|
<file>imports/Spectral/Dialog/UserDetailDialog.qml</file>
|
||||||
<file>imports/Spectral/Dialog/MessageSourceDialog.qml</file>
|
<file>imports/Spectral/Dialog/MessageSourceDialog.qml</file>
|
||||||
<file>imports/Spectral/Dialog/LoginDialog.qml</file>
|
|
||||||
<file>imports/Spectral/Dialog/CreateRoomDialog.qml</file>
|
<file>imports/Spectral/Dialog/CreateRoomDialog.qml</file>
|
||||||
<file>imports/Spectral/Dialog/JoinRoomDialog.qml</file>
|
<file>imports/Spectral/Dialog/JoinRoomDialog.qml</file>
|
||||||
<file>imports/Spectral/Dialog/InviteUserDialog.qml</file>
|
<file>imports/Spectral/Dialog/InviteUserDialog.qml</file>
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
app.setOrganizationName("ENCOM");
|
app.setOrganizationName("KDE");
|
||||||
app.setOrganizationDomain("encom.eu.org");
|
app.setOrganizationDomain("kde.org");
|
||||||
app.setApplicationName("Spectral");
|
app.setApplicationName("NeoChat");
|
||||||
app.setWindowIcon(QIcon(":/assets/img/icon.png"));
|
app.setWindowIcon(QIcon(":/assets/img/icon.png"));
|
||||||
|
|
||||||
qmlRegisterType<Controller>("Spectral", 0, 1, "Controller");
|
qmlRegisterType<Controller>("Spectral", 0, 1, "Controller");
|
||||||
|
|||||||
Reference in New Issue
Block a user