Port all confirm dialogs to Kirigami.PromptDialog

This commit is contained in:
Carl Schwan
2024-05-10 12:54:13 +00:00
committed by Tobias Fella
parent 40d55805ff
commit f45226a680
7 changed files with 63 additions and 81 deletions

View File

@@ -2,35 +2,34 @@
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls as QQC2
import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.kirigami as Kirigami
import org.kde.neochat
FormCard.FormCardPage {
Kirigami.PromptDialog {
id: root
required property NeoChatConnection connection
title: i18nc("@title", "Deactivate Account")
title: i18nc("@title:dialog", "Confirm Account Deactivation")
subtitle: i18n("Your account will be permanently disabled.\nThis cannot be undone.\nYour Matrix ID will not be available for new accounts.\nYour messages will stay available.")
FormCard.FormHeader {
title: i18nc("@title", "Deactivate Account")
dialogType: Kirigami.PromptDialog.Warning
mainItem: FormCard.FormTextFieldDelegate {
id: passwordField
label: i18nc("@label:textbox", "Password")
echoMode: TextInput.Password
horizontalPadding: 0
bottomPadding: 0
}
FormCard.FormCard {
FormCard.FormTextDelegate {
text: i18nc("@title", "Warning")
description: i18n("Your account will be permanently disabled.\nThis cannot be undone.\nYour Matrix ID will not be available for new accounts.\nYour messages will stay available.")
}
FormCard.FormTextFieldDelegate {
id: passwordField
label: i18n("Password")
echoMode: TextInput.Password
}
footer: QQC2.DialogButtonBox {
standardButtons: QQC2.Dialog.Cancel
FormCard.FormButtonDelegate {
QQC2.Button {
text: i18n("Deactivate account")
icon.name: "emblem-warning"
enabled: passwordField.text.length > 0

View File

@@ -4,35 +4,25 @@
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.neochat
QQC2.Dialog {
Kirigami.PromptDialog {
id: root
title: i18nc("@title:dialog", "Activate Encryption")
subtitle: i18n("It will not be possible to deactivate the encryption after it is enabled.")
dialogType: Kirigami.PromptDialog.Warning
property NeoChatRoom room
ColumnLayout {
Kirigami.Heading {
text: i18n("Activate Encryption")
}
QQC2.Label {
text: i18n("It will not be possible to deactivate the encryption after it is enabled.")
}
onRejected: {
root.close();
}
x: Math.round((parent.width - width) / 2)
y: Math.round((parent.height - height) / 2)
modal: true
footer: QQC2.DialogButtonBox {
QQC2.Button {
text: i18n("Cancel")
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
onClicked: root.close()
}
standardButtons: QQC2.Dialog.Cancel
QQC2.Button {
text: i18n("Activate Encryption")

View File

@@ -5,28 +5,30 @@ import QtQuick
import QtQuick.Controls as QQC2
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.neochat
Kirigami.Dialog {
Kirigami.PromptDialog {
id: root
required property NeoChatRoom room
width: Kirigami.Units.gridUnit * 24
title: i18nc("@title:dialog", "Confirm Leaving Room")
subtitle: root.room ? i18nc("Do you really want to leave <room name>?", "Do you really want to leave %1?", root.room.displayNameForHtml) : ""
dialogType: Kirigami.PromptDialog.Warning
contentItem: FormCard.FormTextDelegate {
text: root.room ? i18nc("Do you really want to leave <room name>?", "Do you really want to leave %1?", root.room.displayNameForHtml) : ""
onRejected: {
root.close();
}
customFooterActions: [
Kirigami.Action {
footer: QQC2.DialogButtonBox {
standardButtons: QQC2.Dialog.Cancel
QQC2.Button {
text: i18nc("@action:button", "Leave Room")
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
icon.name: "arrow-left"
onTriggered: RoomManager.leaveRoom(root.room)
onClicked: RoomManager.leaveRoom(root.room)
}
]
}
}

View File

@@ -3,38 +3,28 @@
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.neochat
QQC2.Dialog {
Kirigami.PromptDialog {
id: root
required property NeoChatConnection connection
ColumnLayout {
Kirigami.Heading {
text: i18n("Sign out")
}
QQC2.Label {
text: i18n("Are you sure you want to sign out?")
}
title: i18nc("@title:dialog", "Sign out")
subtitle: i18n("Are you sure you want to sign out?")
dialogType: Kirigami.PromptDialog.Warning
onRejected: {
root.close();
}
x: parent ? Math.round((parent.width - width) / 2) : 0
y: parent ? Math.round((parent.height - height) / 2) : 0
modal: true
footer: QQC2.DialogButtonBox {
QQC2.Button {
text: i18n("Cancel")
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
onClicked: root.close()
}
standardButtons: QQC2.Dialog.Cancel
QQC2.Button {
text: i18n("Sign out")
text: i18nc("@action:button", "Sign out")
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
onClicked: {
root.connection.logout(true);

View File

@@ -6,28 +6,22 @@ import QtQuick.Controls as QQC2
import org.kde.kirigami as Kirigami
Kirigami.Dialog {
Kirigami.PromptDialog {
id: root
property url link
width: Kirigami.Units.gridUnit * 24
height: Kirigami.Units.gridUnit * 8
title: i18nc("@title:dialog", "Open URL")
subtitle: xi18nc("@info", "Do you want to open <link>%1</link>?", root.link)
dialogType: Kirigami.PromptDialog.Warning
title: i18nc("@title", "Open URL")
standardButtons: QQC2.DialogButtonBox.Open | QQC2.DialogButtonBox.Cancel
contentItem: QQC2.Label {
text: xi18nc("@info", "Do you want to open <link>%1</link>?", root.link)
wrapMode: QQC2.Label.Wrap
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
}
onAccepted: {
Qt.openUrlExternally(root.link);
root.close();
}
onRejected: {
root.close();
}

View File

@@ -123,7 +123,12 @@ Loader {
QQC2.MenuItem {
text: i18n("Leave Room")
icon.name: "go-previous"
onTriggered: RoomManager.leaveRoom(room)
onTriggered: {
Qt.createComponent('org.kde.neochat', 'ConfirmLeaveDialog').createObject(root.QQC2.ApplicationWindow.window, {
room: root.room
}).open();
}
}
onClosed: {

View File

@@ -239,11 +239,13 @@ FormCard.FormCardPage {
FormCard.FormButtonDelegate {
id: deactivateAccountButton
text: i18n("Deactivate Account")
onClicked: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ConfirmDeactivateAccountDialog'), {
connection: root.connection
}, {
title: i18nc("@title", "Confirm Deactivating Account")
})
onClicked: {
const component = Qt.createComponent('org.kde.neochat', 'ConfirmDeactivateAccountDialog');
const dialog = component.createObject(QQC2.ApplicationWindow.window, {
connection: root.connection,
});
dialog.open();
}
}
}