Port account editor to formcard

This commit is contained in:
Tobias Fella
2023-08-30 19:03:03 +02:00
parent a9965acdd3
commit 94c1b67ec9

View File

@@ -9,23 +9,16 @@ import Qt.labs.platform 1.1
import QtQuick.Window 2.15
import org.kde.kirigami 2.15 as Kirigami
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
import org.kde.kirigamiaddons.labs.components 1.0 as KirigamiComponents
import org.kde.neochat 1.0
Kirigami.ScrollablePage {
FormCard.FormCardPage {
id: root
title: i18n("Edit Account")
property NeoChatConnection connection
readonly property bool compact: width > Kirigami.Units.gridUnit * 30 ? 2 : 1
topPadding: 0
leftPadding: 0
rightPadding: 0
ColumnLayout {
spacing: 0
QQC2.RoundButton {
property var fileDialog: null;
@@ -95,40 +88,34 @@ Kirigami.ScrollablePage {
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
Component {
id: openFileDialog
OpenFileDialog {
folder: StandardPaths.writableLocation(StandardPaths.PicturesLocation)
parentWindow: root.Window.window
}
}
}
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
title: i18n("User information")
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormTextFieldDelegate {
FormCard.FormCard {
FormCard.FormTextFieldDelegate {
id: name
label: i18n("Name:")
text: root.connection ? root.connection.localUser.displayName : ""
}
MobileForm.FormDelegateSeparator {}
MobileForm.FormTextFieldDelegate {
FormCard.FormDelegateSeparator {}
FormCard.FormTextFieldDelegate {
id: accountLabel
label: i18n("Label:")
text: root.connection ? root.connection.label : ""
}
MobileForm.FormDelegateSeparator {}
MobileForm.AbstractFormDelegate {
Layout.fillWidth: true
background: null
padding: Kirigami.Units.smallSpacing
contentItem: RowLayout {
Item {
Layout.fillWidth: true
}
QQC2.Button {
FormCard.FormDelegateSeparator {}
FormCard.FormButtonDelegate {
text: i18n("Save")
Layout.bottomMargin: Kirigami.Units.smallSpacing
Layout.topMargin: Kirigami.Units.smallSpacing
onClicked: {
if (!root.connection.setAvatar(avatar.source)) {
showPassiveNotification("The Avatar could not be set");
@@ -142,62 +129,46 @@ Kirigami.ScrollablePage {
}
}
}
}
}
}
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
title: i18n("Password")
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormTextDelegate {
FormCard.FormCard {
FormCard.FormTextDelegate {
visible: root.connection !== undefined && root.connection.canChangePassword === false
text: i18n("Your server doesn't support changing your password")
}
MobileForm.FormDelegateSeparator { visible: root.connection !== undefined && root.connection.canChangePassword === false }
MobileForm.FormTextFieldDelegate {
FormCard.FormDelegateSeparator { visible: root.connection !== undefined && root.connection.canChangePassword === false }
FormCard.FormTextFieldDelegate {
id: currentPassword
label: i18n("Current Password:")
enabled: root.connection !== undefined && root.connection.canChangePassword !== false
echoMode: TextInput.Password
}
MobileForm.FormDelegateSeparator {}
MobileForm.FormTextFieldDelegate {
FormCard.FormDelegateSeparator {}
FormCard.FormTextFieldDelegate {
id: newPassword
label: i18n("New Password:")
enabled: root.connection !== undefined && root.connection.canChangePassword !== false
echoMode: TextInput.Password
}
MobileForm.FormDelegateSeparator {}
MobileForm.FormTextFieldDelegate {
FormCard.FormDelegateSeparator {}
FormCard.FormTextFieldDelegate {
id: confirmPassword
label: i18n("Confirm new Password:")
enabled: root.connection !== undefined && root.connection.canChangePassword !== false
echoMode: TextInput.Password
onTextChanged: if (newPassword.text !== confirmPassword.text && confirmPassword.text.length > 0) {
confirmPassword.status = MobileForm.AbstractFormDelegate.Status.Error;
confirmPassword.status = FormCard.AbstractFormDelegate.Status.Error;
confirmPassword.statusMessage = i18n("Passwords don't match");
} else {
confirmPassword.status = MobileForm.AbstractFormDelegate.Status.Default;
confirmPassword.status = FormCard.AbstractFormDelegate.Status.Default;
confirmPassword.statusMessage = '';
}
}
MobileForm.FormDelegateSeparator {}
MobileForm.AbstractFormDelegate {
Layout.fillWidth: true
background: null
contentItem: RowLayout {
Item {
Layout.fillWidth: true
}
QQC2.Button {
FormCard.FormDelegateSeparator {}
FormCard.FormButtonDelegate {
text: i18n("Save")
Layout.bottomMargin: Kirigami.Units.smallSpacing
Layout.topMargin: Kirigami.Units.smallSpacing
enabled: currentPassword.text.length > 0 && newPassword.text.length > 0 && confirmPassword.text.length > 0
onClicked: {
if (newPassword.text === confirmPassword.text) {
@@ -207,70 +178,42 @@ Kirigami.ScrollablePage {
}
}
}
QQC2.Button {
text: i18n("Cancel")
Layout.rightMargin: Kirigami.Units.smallSpacing
Layout.bottomMargin: Kirigami.Units.smallSpacing
Layout.topMargin: Kirigami.Units.smallSpacing
onClicked: root.closeDialog();
}
}
}
}
}
MobileForm.FormHeader {
FormCard.FormHeader {
Layout.fillWidth: true
title: i18n("Server Information")
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormTextDelegate {
FormCard.FormCard {
FormCard.FormTextDelegate {
text: i18n("Homeserver url")
description: root.connection.homeserver
}
/** TODO but needs first some api in Quotient
MobileForm.FormTextDelegate {
/* TODO but needs first some api in Quotient
FormCard.FormTextDelegate {
text: i18n("Server file upload limit")
description: root.connection.homeserver
}
MobileForm.FormTextDelegate {
FormCard.FormTextDelegate {
text: i18n("Server name")
description: root.connection.homeserver
}
MobileForm.FormTextDelegate {
FormCard.FormTextDelegate {
text: i18n("Server version")
description: root.connection.homeserver
}*/
}
}
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
title: i18nc("@title", "Account Management")
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormButtonDelegate {
FormCard.FormCard {
FormCard.FormButtonDelegate {
id: deactivateAccountButton
text: i18n("Deactivate Account")
onClicked: pageStack.pushDialogLayer("qrc:/ConfirmDeactivateAccountDialog.qml", {connection: root.connection}, {title: i18nc("@title", "Confirm Deactivating Account")})
}
}
}
}
Component {
id: openFileDialog
OpenFileDialog {
folder: StandardPaths.writableLocation(StandardPaths.PicturesLocation)
parentWindow: root.Window.window
}
}
}