Support adding 3 PIDs
Implements part of network/neochat#565 Note the phone number stuff is untested as neither kde.org or matrix.org have them switched on.
This commit is contained in:
@@ -202,6 +202,7 @@ FormCard.FormCardPage {
|
||||
medium: "email"
|
||||
}
|
||||
ThreePIdCard {
|
||||
visible: Config.phone3PId
|
||||
connection: root.connection
|
||||
title: i18n("Phone Numbers")
|
||||
medium: "msisdn"
|
||||
|
||||
@@ -16,8 +16,25 @@ import org.kde.neochat
|
||||
FormCard.FormCardPage {
|
||||
id: root
|
||||
|
||||
property NeoChatConnection initialAccount
|
||||
|
||||
title: i18n("Accounts")
|
||||
|
||||
Component.onCompleted: if (initialAccount) {
|
||||
intialAccountTimer.restart()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: intialAccountTimer
|
||||
interval: 10
|
||||
running: false
|
||||
onTriggered: applicationWindow().pageStack.layers.push(Qt.createComponent('org.kde.neochat.settings', 'AccountEditorPage'), {
|
||||
connection: initialAccount
|
||||
}, {
|
||||
title: i18n("Account editor")
|
||||
})
|
||||
}
|
||||
|
||||
FormCard.FormHeader {
|
||||
title: i18n("Accounts")
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ qt_add_qml_module(settings
|
||||
EmoticonFormCard.qml
|
||||
IgnoredUsersDialog.qml
|
||||
NotificationRuleItem.qml
|
||||
PasswordSheet.qml
|
||||
ThemeRadioButton.qml
|
||||
ThreePIdCard.qml
|
||||
)
|
||||
|
||||
@@ -13,6 +13,8 @@ KirigamiSettings.CategorizedSettings {
|
||||
|
||||
property NeoChatConnection connection
|
||||
|
||||
property NeoChatConnection initialAccount
|
||||
|
||||
objectName: "settingsPage"
|
||||
actions: [
|
||||
KirigamiSettings.SettingAction {
|
||||
@@ -54,6 +56,11 @@ KirigamiSettings.CategorizedSettings {
|
||||
text: i18n("Accounts")
|
||||
icon.name: "preferences-system-users"
|
||||
page: Qt.resolvedUrl("AccountsPage.qml")
|
||||
initialProperties: {
|
||||
return {
|
||||
initialAccount: root.initialAccount
|
||||
};
|
||||
}
|
||||
},
|
||||
KirigamiSettings.SettingAction {
|
||||
actionName: "emoticons"
|
||||
|
||||
34
src/settings/PasswordSheet.qml
Normal file
34
src/settings/PasswordSheet.qml
Normal file
@@ -0,0 +1,34 @@
|
||||
// SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
|
||||
Kirigami.Dialog {
|
||||
id: root
|
||||
|
||||
signal submitPassword(string password)
|
||||
|
||||
title: i18nc("@title:dialog", "Enter password")
|
||||
|
||||
preferredWidth: Kirigami.Units.gridUnit * 24
|
||||
|
||||
standardButtons: QQC2.Dialog.Ok | QQC2.Dialog.Cancel
|
||||
onAccepted: {
|
||||
root.submitPassword(passwordField.text);
|
||||
passwordField.text = "";
|
||||
root.close();
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: passwordField
|
||||
label: i18nc("@label:textbox", "Password:")
|
||||
echoMode: TextInput.Password
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
@@ -18,8 +19,6 @@ ColumnLayout {
|
||||
required property string title
|
||||
required property string medium
|
||||
|
||||
visible: deviceRepeater.count > 0
|
||||
|
||||
FormCard.FormHeader {
|
||||
title: root.title
|
||||
}
|
||||
@@ -34,10 +33,124 @@ ColumnLayout {
|
||||
filterString: root.medium
|
||||
}
|
||||
|
||||
delegate: FormCard.FormTextDelegate {
|
||||
delegate: FormCard.AbstractFormDelegate {
|
||||
id: threePIdDelegate
|
||||
required property string address
|
||||
required property string medium
|
||||
|
||||
contentItem: RowLayout {
|
||||
QQC2.Label {
|
||||
Layout.fillWidth: true
|
||||
text: threePIdDelegate.address
|
||||
textFormat: Text.PlainText
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.Wrap
|
||||
maximumLineCount: 2
|
||||
color: Kirigami.Theme.textColor
|
||||
}
|
||||
QQC2.ToolButton {
|
||||
text: i18nc("@action:button", "Remove")
|
||||
icon.name: "edit-delete-remove"
|
||||
onClicked: threePIdAddHelper.remove3PId(threePIdDelegate.address, threePIdDelegate.medium)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
FormCard.FormTextDelegate {
|
||||
required property string address
|
||||
text: address
|
||||
}
|
||||
}
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: newCountryCode
|
||||
visible: root.medium === "msisdn"
|
||||
readOnly: threePIdAddHelper.newIdStatus == ThreePIdAddHelper.Verification ||
|
||||
threePIdAddHelper.newIdStatus == ThreePIdAddHelper.Authentication ||
|
||||
threePIdAddHelper.newIdStatus == ThreePIdAddHelper.AuthFailure ||
|
||||
threePIdAddHelper.newIdStatus == ThreePIdAddHelper.VerificationFailure
|
||||
label: i18nc("@label:textbox", "Country Code for new phone number")
|
||||
|
||||
Connections {
|
||||
target: root.connection.threePIdModel
|
||||
|
||||
function onModelReset() {
|
||||
newCountryCode.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: newId
|
||||
readOnly: threePIdAddHelper.newIdStatus == ThreePIdAddHelper.Verification ||
|
||||
threePIdAddHelper.newIdStatus == ThreePIdAddHelper.Authentication ||
|
||||
threePIdAddHelper.newIdStatus == ThreePIdAddHelper.AuthFailure ||
|
||||
threePIdAddHelper.newIdStatus == ThreePIdAddHelper.VerificationFailure
|
||||
label: root.medium === "email" ? i18nc("@label:textbox", "New email address") : i18nc("@label:textbox", "New phone number")
|
||||
|
||||
statusMessage: switch(threePIdAddHelper.newIdStatus) {
|
||||
case ThreePIdAddHelper.Verification:
|
||||
return i18n("%1. Please follow the instructions there and then click the button below", root.medium == "email" ? i18n("We've sent you an email") : i18n("We've sent you a text message"));
|
||||
case ThreePIdAddHelper.Invalid:
|
||||
return root.medium == "email" ? i18n("The entered email is not valid") : i18n("The entered phone number is not valid");
|
||||
case ThreePIdAddHelper.AuthFailure:
|
||||
return i18n("Incorrect password entered");
|
||||
case ThreePIdAddHelper.VerificationFailure:
|
||||
return root.medium == "email" ? i18n("The email has not been verified. Please go to the email and follow the instructions there and then click the button below") : i18n("The phone number has not been verified. Please go to the text message and follow the instructions there and then click the button below");
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
status: switch(threePIdAddHelper.newIdStatus) {
|
||||
case ThreePIdAddHelper.Invalid:
|
||||
case ThreePIdAddHelper.AuthFailure:
|
||||
return Kirigami.MessageType.Error;
|
||||
case ThreePIdAddHelper.VerificationFailure:
|
||||
return Kirigami.MessageType.Warning;
|
||||
default:
|
||||
return Kirigami.MessageType.Information;
|
||||
}
|
||||
|
||||
onAccepted: _private.openPasswordSheet()
|
||||
|
||||
Connections {
|
||||
target: root.connection.threePIdModel
|
||||
|
||||
function onModelReset() {
|
||||
newId.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
FormCard.FormButtonDelegate {
|
||||
text: threePIdAddHelper.newIdStatus == ThreePIdAddHelper.Ready ? i18nc("@action:button Add new email or phone number", "Add") : i18nc("@action:button", "Continue")
|
||||
onClicked: _private.openPasswordSheet()
|
||||
}
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: threePIdAddHelper.newIdStatus == ThreePIdAddHelper.Verification ||
|
||||
threePIdAddHelper.newIdStatus == ThreePIdAddHelper.Authentication ||
|
||||
threePIdAddHelper.newIdStatus == ThreePIdAddHelper.AuthFailure ||
|
||||
threePIdAddHelper.newIdStatus == ThreePIdAddHelper.VerificationFailure
|
||||
text: i18nc("@action:button As in 'go back'", "Back")
|
||||
onClicked: threePIdAddHelper.back()
|
||||
}
|
||||
}
|
||||
|
||||
ThreePIdAddHelper {
|
||||
id: threePIdAddHelper
|
||||
connection: root.connection
|
||||
medium: root.medium
|
||||
newId: newId.text
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: _private
|
||||
function openPasswordSheet() {
|
||||
if (threePIdAddHelper.newIdStatus == ThreePIdAddHelper.Ready) {
|
||||
threePIdAddHelper.initiateNewIdAdd();
|
||||
} else {
|
||||
let dialog = Qt.createComponent('org.kde.neochat.settings', 'PasswordSheet').createObject(root, {});
|
||||
dialog.submitPassword.connect(password => threePIdAddHelper.finalizeNewIdAdd(password));
|
||||
dialog.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user