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