49
src/qml/Component/Login/Captcha.qml
Normal file
49
src/qml/Component/Login/Captcha.qml
Normal file
@@ -0,0 +1,49 @@
|
||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick 2.14
|
||||
import QtQuick.Controls 2.14 as Controls
|
||||
import QtQuick.Layouts 1.14
|
||||
import QtWebView 1.15
|
||||
|
||||
import org.kde.kirigami 2.12 as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
||||
|
||||
import org.kde.neochat 1.0
|
||||
|
||||
LoginStep {
|
||||
id: root
|
||||
|
||||
FormCard.AbstractFormDelegate {
|
||||
background: null
|
||||
contentItem: WebView {
|
||||
id: webview
|
||||
url: "http://localhost:20847"
|
||||
implicitHeight: 500
|
||||
onLoadingChanged: {
|
||||
webview.runJavaScript("document.body.style.background = '" + Kirigami.Theme.backgroundColor + "'")
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: timer
|
||||
repeat: true
|
||||
running: true
|
||||
interval: 300
|
||||
onTriggered: {
|
||||
if(!webview.visible) {
|
||||
return
|
||||
}
|
||||
webview.runJavaScript("!!grecaptcha ? grecaptcha.getResponse() : \"\"", function(response){
|
||||
if(!webview.visible || !response)
|
||||
return
|
||||
timer.running = false;
|
||||
Registration.recaptchaResponse = response;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
previousAction: Kirigami.Action {
|
||||
onTriggered: root.processed("qrc:/Username.qml")
|
||||
}
|
||||
}
|
||||
59
src/qml/Component/Login/Email.qml
Normal file
59
src/qml/Component/Login/Email.qml
Normal file
@@ -0,0 +1,59 @@
|
||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
import QtQuick.Layouts 1.12
|
||||
|
||||
import org.kde.kirigami 2.12 as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
||||
|
||||
import org.kde.neochat 1.0
|
||||
|
||||
LoginStep {
|
||||
id: root
|
||||
|
||||
onActiveFocusChanged: if (activeFocus) emailField.forceActiveFocus()
|
||||
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: emailField
|
||||
label: i18n("Add an e-mail address:")
|
||||
placeholderText: "user@example.com"
|
||||
onTextChanged: Registration.email = text
|
||||
Keys.onReturnPressed: {
|
||||
if (root.nextAction.enabled) {
|
||||
root.nextAction.trigger()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormTextDelegate {
|
||||
id: confirmMessage
|
||||
text: i18n("Confirm e-mail address")
|
||||
visible: false
|
||||
description: i18n("A confirmation e-mail has been sent to your address. Please continue here <b>after</b> clicking on the confirmation link in the e-mail")
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
id: resendButton
|
||||
text: i18nc("@button", "Re-send confirmation e-mail")
|
||||
onClicked: Registration.registerEmail()
|
||||
visible: false
|
||||
}
|
||||
|
||||
nextAction: Kirigami.Action {
|
||||
enabled: emailField.text.length > 0
|
||||
onTriggered: {
|
||||
if (confirmMessage.visible) {
|
||||
Registration.registerAccount()
|
||||
} else {
|
||||
Registration.registerEmail()
|
||||
confirmMessage.visible = true
|
||||
resendButton.visible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
previousAction: Kirigami.Action {
|
||||
onTriggered: root.processed("qrc:/Username.qml")
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// SPDX-FileCopyrightText: 2020 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick 2.15
|
||||
@@ -6,56 +6,42 @@ import QtQuick.Controls 2.15 as QQC2
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import org.kde.kirigami 2.15 as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
||||
|
||||
import org.kde.neochat 1.0
|
||||
|
||||
LoginStep {
|
||||
id: root
|
||||
|
||||
readonly property var homeserver: customHomeserver.visible ? customHomeserver.text : serverCombo.currentText
|
||||
property bool loading: false
|
||||
onActiveFocusChanged: if (activeFocus) urlField.forceActiveFocus()
|
||||
|
||||
title: i18nc("@title", "Select a Homeserver")
|
||||
|
||||
action: Kirigami.Action {
|
||||
enabled: LoginHelper.homeserverReachable && !customHomeserver.visible || customHomeserver.acceptableInput
|
||||
onTriggered: {
|
||||
// TODO
|
||||
console.log("register todo")
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: urlField
|
||||
label: i18n("Server Url:")
|
||||
validator: RegularExpressionValidator {
|
||||
regularExpression: /([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9]+(:[0-9]+)?/
|
||||
}
|
||||
onTextChanged: timer.restart()
|
||||
statusMessage: Registration.status === Registration.ServerNoRegistration ? i18n("Registration is disabled on this server.") : ""
|
||||
Keys.onReturnPressed: {
|
||||
if (root.nextAction.enabled) {
|
||||
root.nextAction.trigger()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onHomeserverChanged: {
|
||||
LoginHelper.testHomeserver("@user:" + homeserver)
|
||||
Timer {
|
||||
id: timer
|
||||
interval: 500
|
||||
onTriggered: Registration.homeserver = urlField.text
|
||||
}
|
||||
|
||||
Kirigami.FormLayout {
|
||||
Component.onCompleted: Controller.testHomeserver(homeserver)
|
||||
|
||||
QQC2.ComboBox {
|
||||
id: serverCombo
|
||||
|
||||
Kirigami.FormData.label: i18n("Homeserver:")
|
||||
model: ["matrix.org", "kde.org", "tchncs.de", i18n("Other...")]
|
||||
}
|
||||
|
||||
QQC2.TextField {
|
||||
id: customHomeserver
|
||||
|
||||
Kirigami.FormData.label: i18n("Url:")
|
||||
visible: serverCombo.currentIndex === 3
|
||||
onTextChanged: {
|
||||
Controller.testHomeserver(text)
|
||||
}
|
||||
validator: RegularExpressionValidator {
|
||||
regularExpression: /([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9]+(:[0-9]+)?/
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.Button {
|
||||
id: continueButton
|
||||
text: i18nc("@action:button", "Continue")
|
||||
action: root.action
|
||||
}
|
||||
nextAction: Kirigami.Action {
|
||||
text: Registration.testing ? i18n("Loading") : null
|
||||
enabled: Registration.status > Registration.ServerNoRegistration
|
||||
onTriggered: root.processed("qrc:/Username.qml");
|
||||
}
|
||||
previousAction: Kirigami.Action {
|
||||
onTriggered: root.processed("qrc:/LoginRegister.qml")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,10 +47,9 @@ LoginStep {
|
||||
}
|
||||
enabled: LoginHelper.homeserverReachable
|
||||
}
|
||||
// TODO: enable once we have registration
|
||||
// previousAction: Kirigami.Action {
|
||||
// onTriggered: {
|
||||
// root.processed("qrc:/Login.qml")
|
||||
// }
|
||||
// }
|
||||
previousAction: Kirigami.Action {
|
||||
onTriggered: {
|
||||
root.processed("qrc:/LoginRegister.qml")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,12 @@ import org.kde.neochat 1.0
|
||||
LoginStep {
|
||||
id: root
|
||||
|
||||
onActiveFocusChanged: if (activeFocus) loginButton.forceActiveFocus()
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
id: loginButton
|
||||
text: i18nc("@action:button", "Login")
|
||||
onClicked: root.processed("qrc:/Login.qml")
|
||||
}
|
||||
|
||||
@@ -26,6 +26,6 @@ ColumnLayout {
|
||||
/// Show a message in a banner at the top of the page.
|
||||
signal showMessage(string message)
|
||||
|
||||
/// Clears any error messages currently being shown
|
||||
signal clearError()
|
||||
|
||||
}
|
||||
|
||||
51
src/qml/Component/Login/RegisterPassword.qml
Normal file
51
src/qml/Component/Login/RegisterPassword.qml
Normal file
@@ -0,0 +1,51 @@
|
||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
|
||||
import org.kde.kirigami 2.12 as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
||||
|
||||
import org.kde.neochat 1.0
|
||||
|
||||
LoginStep {
|
||||
id: root
|
||||
|
||||
onActiveFocusChanged: if (activeFocus) passwordField.forceActiveFocus()
|
||||
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: passwordField
|
||||
label: i18n("Password:")
|
||||
echoMode: TextInput.Password
|
||||
onTextChanged: Registration.password = text
|
||||
Keys.onReturnPressed: {
|
||||
confirmPasswordField.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: confirmPasswordField
|
||||
label: i18n("Confirm Password:")
|
||||
enabled: passwordField.enabled
|
||||
echoMode: TextInput.Password
|
||||
statusMessage: passwordField.text.length === confirmPasswordField.text.length && passwordField.text !== confirmPasswordField.text ? i18n("The passwords do not match.") : ""
|
||||
Keys.onReturnPressed: {
|
||||
if (root.nextAction.enabled) {
|
||||
root.nextAction.trigger()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nextAction: Kirigami.Action {
|
||||
onTriggered: {
|
||||
passwordField.enabled = false
|
||||
Registration.registerAccount()
|
||||
}
|
||||
enabled: passwordField.text === confirmPasswordField.text
|
||||
}
|
||||
|
||||
previousAction: Kirigami.Action {
|
||||
onTriggered: root.processed("qrc:/Username.qml")
|
||||
}
|
||||
}
|
||||
39
src/qml/Component/Login/Terms.qml
Normal file
39
src/qml/Component/Login/Terms.qml
Normal file
@@ -0,0 +1,39 @@
|
||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
import QtQuick.Layouts 1.12
|
||||
|
||||
import org.kde.kirigami 2.12 as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
||||
|
||||
import org.kde.neochat 1.0
|
||||
|
||||
LoginStep {
|
||||
id: root
|
||||
|
||||
noControls: true
|
||||
|
||||
FormCard.FormTextDelegate {
|
||||
text: i18n("Terms & Conditions")
|
||||
description: i18n("By continuing with the registration, you agree to the following terms and conditions:")
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: Registration.terms
|
||||
delegate: FormCard.FormTextDelegate {
|
||||
text: "<a href=\"" + modelData.url + "\">" + modelData.title + "</a>"
|
||||
onLinkActivated: Qt.openUrlExternally(modelData.url)
|
||||
}
|
||||
}
|
||||
|
||||
nextAction: Kirigami.Action {
|
||||
onTriggered: {
|
||||
Registration.registerAccount()
|
||||
}
|
||||
}
|
||||
previousAction: Kirigami.Action {
|
||||
onTriggered: root.processed("qrc:/Username.qml")
|
||||
}
|
||||
}
|
||||
46
src/qml/Component/Login/Username.qml
Normal file
46
src/qml/Component/Login/Username.qml
Normal file
@@ -0,0 +1,46 @@
|
||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
|
||||
import org.kde.kirigami 2.12 as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
||||
|
||||
import org.kde.neochat 1.0
|
||||
|
||||
LoginStep {
|
||||
id: root
|
||||
|
||||
onActiveFocusChanged: if (activeFocus) usernameField.forceActiveFocus()
|
||||
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: usernameField
|
||||
label: i18n("Username:")
|
||||
placeholderText: "user"
|
||||
onTextChanged: timer.restart()
|
||||
statusMessage: Registration.status === Registration.UsernameTaken ? i18n("Username unavailable") : ""
|
||||
Keys.onReturnPressed: {
|
||||
if (root.nextAction.enabled) {
|
||||
root.nextAction.trigger()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: timer
|
||||
interval: 500
|
||||
onTriggered: Registration.username = usernameField.text
|
||||
}
|
||||
|
||||
nextAction: Kirigami.Action {
|
||||
text: Registration.status === Registration.TestingUsername ? i18n("Loading") : null
|
||||
|
||||
onTriggered: root.processed("qrc:/RegisterPassword.qml")
|
||||
enabled: Registration.status === Registration.Ready
|
||||
}
|
||||
|
||||
previousAction: Kirigami.Action {
|
||||
onTriggered: root.processed("qrc:/Homeserver.qml")
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ FormCard.FormCardPage {
|
||||
|
||||
FormCard.FormTextDelegate {
|
||||
id: welcomeMessage
|
||||
text: AccountRegistry.accountCount > 0 ? i18n("Log in to a different account.") : i18n("Welcome to NeoChat! Continue by logging in.")
|
||||
text: AccountRegistry.accountCount > 0 ? i18n("Log in to a different account or create a new account.") : i18n("Welcome to NeoChat! Continue by logging in or creating a new account.")
|
||||
}
|
||||
|
||||
FormCard.FormDelegateSeparator {
|
||||
@@ -51,9 +51,10 @@ FormCard.FormCardPage {
|
||||
Loader {
|
||||
id: module
|
||||
Layout.fillWidth: true
|
||||
source: "qrc:/Login.qml"
|
||||
source: "qrc:/LoginRegister.qml"
|
||||
|
||||
Connections {
|
||||
id: stepConnections
|
||||
target: currentStep
|
||||
|
||||
function onProcessed(nextUrl) {
|
||||
@@ -76,6 +77,23 @@ FormCard.FormCardPage {
|
||||
headerMessage.visible = false;
|
||||
}
|
||||
}
|
||||
Connections {
|
||||
target: Registration
|
||||
function onNextStepChanged() {
|
||||
if (Registration.nextStep === "m.login.recaptcha") {
|
||||
stepConnections.onProcessed("qrc:/Captcha.qml")
|
||||
}
|
||||
if (Registration.nextStep === "m.login.terms") {
|
||||
stepConnections.onProcessed("qrc:/Terms.qml")
|
||||
}
|
||||
if (Registration.nextStep === "m.login.email.identity") {
|
||||
stepConnections.onProcessed("qrc:/Email.qml")
|
||||
}
|
||||
if (Registration.nextStep === "loading") {
|
||||
stepConnections.onProcessed("qrc:/Loading.qml")
|
||||
}
|
||||
}
|
||||
}
|
||||
Connections {
|
||||
target: LoginHelper
|
||||
function onErrorOccured(message) {
|
||||
@@ -92,7 +110,7 @@ FormCard.FormCardPage {
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
id: continueButton
|
||||
text: root.currentStep.nextAction ? root.currentStep.nextAction.text : i18nc("@action:button", "Continue")
|
||||
text: root.currentStep.nextAction && root.currentStep.nextAction.text ? root.currentStep.nextAction.text : i18nc("@action:button", "Continue")
|
||||
visible: root.currentStep.nextAction
|
||||
onClicked: root.currentStep.nextAction.trigger()
|
||||
icon.name: "arrow-right"
|
||||
@@ -111,5 +129,8 @@ FormCard.FormCardPage {
|
||||
Component.onCompleted: {
|
||||
LoginHelper.init()
|
||||
module.item.forceActiveFocus()
|
||||
Registration.username = ""
|
||||
Registration.password = ""
|
||||
Registration.email = ""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user