From b1595a4556df7083931b3b30c5c900db3623b580 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 16 Feb 2026 15:41:19 -0500 Subject: [PATCH] Ensure most of our dialogs have cancel buttons on the right This is standard for KDE dialogs, but we weren't super consistent about it. Most of this is porting to DialogButtonBox, and using buttonRole. I also made sure the close button is hidden in cases where we have a cancel button already. I also took the time to clean out some cruft like manually calling close() and such. I probably missed a lot more spots, but this is a good improvement. --- src/app/qml/ConfirmLeaveDialog.qml | 15 +++-- src/app/qml/ConfirmLogoutDialog.qml | 14 ++--- src/app/qml/ConfirmUrlDialog.qml | 9 +-- src/app/qml/ManualRoomDialog.qml | 62 ++++++++++--------- src/app/qml/ManualUserDialog.qml | 27 ++++---- src/app/qml/MeetingDialog.qml | 16 +++-- src/chatbar/NewPollDialog.qml | 30 ++++----- src/chatbar/VoiceMessageDialog.qml | 6 +- src/libneochat/qml/CreateRoomDialog.qml | 24 ++++--- src/libneochat/qml/CreateSpaceDialog.qml | 24 ++++--- .../ConfirmDeactivateAccountDialog.qml | 13 ++-- src/settings/ConfirmEncryptionDialog.qml | 14 ++--- src/settings/DeviceDelegate.qml | 21 ++++--- src/settings/SelectParentDialog.qml | 27 ++++---- 14 files changed, 162 insertions(+), 140 deletions(-) diff --git a/src/app/qml/ConfirmLeaveDialog.qml b/src/app/qml/ConfirmLeaveDialog.qml index 4912df3ff..9ae1a51f8 100644 --- a/src/app/qml/ConfirmLeaveDialog.qml +++ b/src/app/qml/ConfirmLeaveDialog.qml @@ -16,19 +16,18 @@ Kirigami.PromptDialog { title: root.room.isSpace ? i18nc("@title:dialog", "Confirm Leaving Space") : i18nc("@title:dialog", "Confirm Leaving Room") subtitle: root.room ? i18nc("Do you really want to leave ?", "Do you really want to leave %1?", root.room.displayNameForHtml) : "" dialogType: Kirigami.PromptDialog.Warning + standardButtons: QQC2.Dialog.Cancel - onRejected: { - root.close(); - } + onAccepted: root.room.forget() footer: QQC2.DialogButtonBox { - standardButtons: QQC2.Dialog.Cancel - QQC2.Button { - text: i18nc("@action:button", "Leave Room") - QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole + text: i18nc("@action:button Leave this room/space", "Leave") icon.name: "arrow-left-symbolic" - onClicked: root.room.forget(); + + onClicked: root.accept() + + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole } } } diff --git a/src/app/qml/ConfirmLogoutDialog.qml b/src/app/qml/ConfirmLogoutDialog.qml index d872a5bd7..7a3a2c717 100644 --- a/src/app/qml/ConfirmLogoutDialog.qml +++ b/src/app/qml/ConfirmLogoutDialog.qml @@ -15,22 +15,16 @@ Kirigami.PromptDialog { title: i18nc("@title:dialog", "Sign out") subtitle: i18n("Are you sure you want to sign out?") dialogType: Kirigami.PromptDialog.Warning + standardButtons: QQC2.Dialog.Cancel - onRejected: { - root.close(); - } + onAccepted: root.connection.logout(true) footer: QQC2.DialogButtonBox { - standardButtons: QQC2.Dialog.Cancel - QQC2.Button { text: i18nc("@action:button", "Sign out") + onClicked: root.accept() + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole - onClicked: { - root.connection.logout(true); - root.close(); - root.accepted(); - } } } } diff --git a/src/app/qml/ConfirmUrlDialog.qml b/src/app/qml/ConfirmUrlDialog.qml index abf6ddb0b..819fe771c 100644 --- a/src/app/qml/ConfirmUrlDialog.qml +++ b/src/app/qml/ConfirmUrlDialog.qml @@ -17,12 +17,5 @@ Kirigami.PromptDialog { standardButtons: QQC2.DialogButtonBox.Open | QQC2.DialogButtonBox.Cancel - onAccepted: { - Qt.openUrlExternally(root.link); - root.close(); - } - - onRejected: { - root.close(); - } + onAccepted: Qt.openUrlExternally(root.link) } diff --git a/src/app/qml/ManualRoomDialog.qml b/src/app/qml/ManualRoomDialog.qml index bfe2be897..aa0d0984a 100644 --- a/src/app/qml/ManualRoomDialog.qml +++ b/src/app/qml/ManualRoomDialog.qml @@ -4,6 +4,7 @@ import QtQuick import QtQuick.Window import QtQuick.Layouts +import QtQuick.Controls as QQC2 import org.kde.kirigami as Kirigami import org.kde.kirigamiaddons.formcard as FormCard @@ -24,6 +25,8 @@ Kirigami.Dialog { signal roomSelected(string roomId, string displayName, url avatarUrl, string alias, string topic, int memberCount, bool isJoined) title: i18nc("@title", "Manually Enter a Room") + showCloseButton: false + standardButtons: QQC2.Dialog.Cancel width: Math.min(root.Window.window.width, Kirigami.Units.gridUnit * 24) leftPadding: 0 @@ -31,35 +34,26 @@ Kirigami.Dialog { topPadding: 0 bottomPadding: 0 - standardButtons: Kirigami.Dialog.Cancel - customFooterActions: [ - Kirigami.Action { - enabled: roomIdAliasText.isValidText - text: i18n("OK") - icon.name: "dialog-ok" - onTriggered: { - // We don't necessarily have all the info so fill out the best we can. - let roomId = roomIdAliasText.isAlias() ? "" : roomIdAliasText.text; - let displayName = ""; - let avatarUrl = ""; - let alias = roomIdAliasText.isAlias() ? roomIdAliasText.text : ""; - let topic = ""; - let memberCount = -1; - let isJoined = false; - if (roomIdAliasText.room) { - roomId = roomIdAliasText.room.id; - displayName = roomIdAliasText.room.displayName; - avatarUrl = roomIdAliasText.room.avatarUrl.toString().length > 0 ? connection.makeMediaUrl(roomIdAliasText.room.avatarUrl) : ""; - alias = roomIdAliasText.room.canonicalAlias; - topic = roomIdAliasText.room.topic; - memberCount = roomIdAliasText.room.joinedCount; - isJoined = true; - } - root.roomSelected(roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined); - root.close(); - } + onAccepted: { + // We don't necessarily have all the info so fill out the best we can. + let roomId = roomIdAliasText.isAlias() ? "" : roomIdAliasText.text; + let displayName = ""; + let avatarUrl = ""; + let alias = roomIdAliasText.isAlias() ? roomIdAliasText.text : ""; + let topic = ""; + let memberCount = -1; + let isJoined = false; + if (roomIdAliasText.room) { + roomId = roomIdAliasText.room.id; + displayName = roomIdAliasText.room.displayName; + avatarUrl = roomIdAliasText.room.avatarUrl.toString().length > 0 ? connection.makeMediaUrl(roomIdAliasText.room.avatarUrl) : ""; + alias = roomIdAliasText.room.canonicalAlias; + topic = roomIdAliasText.room.topic; + memberCount = roomIdAliasText.room.joinedCount; + isJoined = true; } - ] + root.roomSelected(roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined); + } contentItem: ColumnLayout { spacing: 0 @@ -110,4 +104,16 @@ Kirigami.Dialog { roomIdAliasText.forceActiveFocus(); timer.restart(); } + + footer: QQC2.DialogButtonBox { + QQC2.Button { + text: i18nc("@action:button Join this room/space", "Join") + icon.name: "checkmark" + enabled: roomIdAliasText.isValidText + + onClicked: root.accept() + + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole + } + } } diff --git a/src/app/qml/ManualUserDialog.qml b/src/app/qml/ManualUserDialog.qml index 54410a740..efb9324b7 100644 --- a/src/app/qml/ManualUserDialog.qml +++ b/src/app/qml/ManualUserDialog.qml @@ -24,25 +24,16 @@ Kirigami.Dialog { signal userSelected(string userId) title: i18nc("@title", "User ID") + showCloseButton: false width: Math.min(QQC2.ApplicationWindow.window.width, Kirigami.Units.gridUnit * 24) leftPadding: 0 rightPadding: 0 topPadding: 0 bottomPadding: 0 + standardButtons: QQC2.Dialog.Cancel - standardButtons: Kirigami.Dialog.Cancel - customFooterActions: [ - Kirigami.Action { - enabled: userIdText.isValidText - text: i18n("OK") - icon.name: "dialog-ok" - onTriggered: { - root.userSelected(userIdText.text) - root.accept(); - } - } - ] + onAccepted: root.userSelected(userIdText.text) contentItem: ColumnLayout { spacing: 0 @@ -79,4 +70,16 @@ Kirigami.Dialog { userIdText.forceActiveFocus(); timer.restart(); } + + footer: QQC2.DialogButtonBox { + QQC2.Button { + text: i18nc("@action:button Perform an action with this user ID", "Ok") + icon.name: "checkmark" + enabled: userIdText.isValidText + + onClicked: root.accept() + + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole + } + } } diff --git a/src/app/qml/MeetingDialog.qml b/src/app/qml/MeetingDialog.qml index fb79711d0..3354b813a 100644 --- a/src/app/qml/MeetingDialog.qml +++ b/src/app/qml/MeetingDialog.qml @@ -4,6 +4,7 @@ pragma ComponentBehavior: Bound import QtQuick +import QtQuick.Controls as QQC2 import org.kde.kirigami as Kirigami @@ -14,11 +15,16 @@ Kirigami.PromptDialog { title: hasExistingMeeting ? i18nc("@title", "Join Meeting") : i18nc("@title", "Start Meeting") subtitle: hasExistingMeeting ? i18nc("@info:label", "You are about to join a Jitsi meeting in your web browser.") : i18nc("@info:label", "You are about to start a new Jitsi meeting in your web browser.") - standardButtons: Kirigami.Dialog.Cancel + standardButtons: QQC2.Dialog.Cancel - customFooterActions: Kirigami.Action { - icon.name: "camera-video-symbolic" - text: root.hasExistingMeeting ? i18nc("@action:button Join the Jitsi meeting", "Join") : i18nc("@action:button Start a new Jitsi meeting", "Start") - onTriggered: root.accept() + footer: QQC2.DialogButtonBox { + QQC2.Button { + icon.name: "camera-video-symbolic" + text: root.hasExistingMeeting ? i18nc("@action:button Join the Jitsi meeting", "Join") : i18nc("@action:button Start a new Jitsi meeting", "Start") + + onClicked: root.accept() + + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole + } } } diff --git a/src/chatbar/NewPollDialog.qml b/src/chatbar/NewPollDialog.qml index 980ae3b72..f857f11df 100644 --- a/src/chatbar/NewPollDialog.qml +++ b/src/chatbar/NewPollDialog.qml @@ -19,22 +19,12 @@ Kirigami.Dialog { required property NeoChatRoom room - standardButtons: Kirigami.Dialog.Cancel - - customFooterActions: [ - Kirigami.Action { - enabled: optionModel.allValuesSet && questionTextField.text.length > 0 - text: i18nc("@action:button", "Send") - icon.name: "document-send" - onTriggered: { - root.room.postPoll(pollTypeCombo.currentValue, questionTextField.text, optionModel.values()) - root.close() - } - } - ] - width: Math.min(QQC2.ApplicationWindow.window.width, Kirigami.Units.gridUnit * 24) title: i18nc("@title: create new poll in the room", "Create Poll") + showCloseButton: false + standardButtons: QQC2.Dialog.Cancel + + onAccepted: root.room.postPoll(pollTypeCombo.currentValue, questionTextField.text, optionModel.values()) contentItem: ColumnLayout { spacing: 0 @@ -148,4 +138,16 @@ Kirigami.Dialog { onClicked: optionModel.append({optionText: ""}) } } + + footer: QQC2.DialogButtonBox { + QQC2.Button { + enabled: optionModel.allValuesSet && questionTextField.text.length > 0 + text: i18nc("@action:button", "Send") + icon.name: "document-send" + + onClicked: root.accept() + + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole + } + } } diff --git a/src/chatbar/VoiceMessageDialog.qml b/src/chatbar/VoiceMessageDialog.qml index 2c6df941f..7beb9aa7e 100644 --- a/src/chatbar/VoiceMessageDialog.qml +++ b/src/chatbar/VoiceMessageDialog.qml @@ -60,9 +60,11 @@ QQC2.Dialog { QQC2.Button { text: i18nc("@action:button Send the voice message", "Send") icon.name: "document-send" - QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole - onClicked: voiceRecorder.send() enabled: !voiceRecorder.recording && voiceRecorder.recorder.duration > 0 && voiceRecorder.isSupported + + onClicked: voiceRecorder.send() + + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole } } } diff --git a/src/libneochat/qml/CreateRoomDialog.qml b/src/libneochat/qml/CreateRoomDialog.qml index 9306be63f..4d64a2e14 100644 --- a/src/libneochat/qml/CreateRoomDialog.qml +++ b/src/libneochat/qml/CreateRoomDialog.qml @@ -3,6 +3,7 @@ import QtQuick import QtQuick.Layouts +import QtQuick.Controls as QQC2 import org.kde.kirigami as Kirigami import org.kde.kirigamiaddons.formcard as FormCard @@ -20,20 +21,25 @@ Kirigami.Dialog { title: i18nc("@title", "Create Room") implicitWidth: Kirigami.Units.gridUnit * 20 - standardButtons: Kirigami.Dialog.Cancel + showCloseButton: false + standardButtons: QQC2.Dialog.Cancel - customFooterActions: [ - Kirigami.Action { + onAccepted: { + root.connection.createRoom(roomNameField.text, "", root.parentId, false); + root.newChild(roomNameField.text); + } + + footer: QQC2.DialogButtonBox { + QQC2.Button { icon.name: "list-add-symbolic" text: i18nc("@action:button Create new room", "Create") enabled: roomNameField.text.length > 0 - onTriggered: { - root.connection.createRoom(roomNameField.text, "", root.parentId, false); - root.newChild(roomNameField.text); - root.close(); - } + + onClicked: root.accept() + + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole } - ] + } Component.onCompleted: roomNameField.forceActiveFocus() diff --git a/src/libneochat/qml/CreateSpaceDialog.qml b/src/libneochat/qml/CreateSpaceDialog.qml index 17ddb19f5..c0dfab88f 100644 --- a/src/libneochat/qml/CreateSpaceDialog.qml +++ b/src/libneochat/qml/CreateSpaceDialog.qml @@ -3,6 +3,7 @@ import QtQuick import QtQuick.Layouts +import QtQuick.Controls as QQC2 import org.kde.kirigami as Kirigami import org.kde.kirigamiaddons.formcard as FormCard @@ -20,22 +21,27 @@ Kirigami.Dialog { title: i18nc("@title", "Create a Space") implicitWidth: Kirigami.Units.gridUnit * 20 - standardButtons: Kirigami.Dialog.Cancel + showCloseButton: false + standardButtons: QQC2.Dialog.Cancel Component.onCompleted: roomNameField.forceActiveFocus() - customFooterActions: [ - Kirigami.Action { + onAccepted: { + root.connection.createSpace(roomNameField.text, "", root.parentId, newOfficialCheck.checked); + root.newChild(roomNameField.text); + } + + footer: QQC2.DialogButtonBox { + QQC2.Button { icon.name: "list-add-symbolic" text: i18nc("@action:button Create new space", "Create") enabled: roomNameField.text.length > 0 - onTriggered: { - root.connection.createSpace(roomNameField.text, "", root.parentId, newOfficialCheck.checked); - root.newChild(roomNameField.text); - root.close(); - } + + onClicked: root.accept() + + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole } - ] + } ColumnLayout { spacing: Kirigami.Units.largeSpacing diff --git a/src/settings/ConfirmDeactivateAccountDialog.qml b/src/settings/ConfirmDeactivateAccountDialog.qml index f7e933b4b..ac14a7c63 100644 --- a/src/settings/ConfirmDeactivateAccountDialog.qml +++ b/src/settings/ConfirmDeactivateAccountDialog.qml @@ -18,6 +18,9 @@ Kirigami.PromptDialog { 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.") dialogType: Kirigami.PromptDialog.Warning + standardButtons: QQC2.Dialog.Cancel + + onAccepted: root.connection.deactivateAccount(passwordField.text, eraseDelegate.checked) mainItem: ColumnLayout { FormCard.FormTextFieldDelegate { @@ -37,16 +40,14 @@ Kirigami.PromptDialog { } footer: QQC2.DialogButtonBox { - standardButtons: QQC2.Dialog.Cancel - QQC2.Button { text: i18n("Deactivate account") icon.name: "emblem-warning" enabled: passwordField.text.length > 0 - onClicked: { - root.connection.deactivateAccount(passwordField.text, eraseDelegate.checked); - root.closeDialog(); - } + + onClicked: root.accept() + + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole } } } diff --git a/src/settings/ConfirmEncryptionDialog.qml b/src/settings/ConfirmEncryptionDialog.qml index 445ccc555..40551670b 100644 --- a/src/settings/ConfirmEncryptionDialog.qml +++ b/src/settings/ConfirmEncryptionDialog.qml @@ -14,23 +14,19 @@ Kirigami.PromptDialog { 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 + standardButtons: QQC2.Dialog.Cancel property NeoChatRoom room - onRejected: { - root.close(); - } + onAccepted: root.room.activateEncryption() footer: QQC2.DialogButtonBox { - standardButtons: QQC2.Dialog.Cancel - QQC2.Button { text: i18n("Activate Encryption") + + onClicked: root.accept() + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole - onClicked: { - root.room.activateEncryption(); - root.close(); - } } } } diff --git a/src/settings/DeviceDelegate.qml b/src/settings/DeviceDelegate.qml index 1bd592b61..36d74b487 100644 --- a/src/settings/DeviceDelegate.qml +++ b/src/settings/DeviceDelegate.qml @@ -154,16 +154,21 @@ FormCard.AbstractFormDelegate { label: i18n("Password:") echoMode: TextInput.Password } - customFooterActions: [ - Kirigami.Action { + + onAccepted: { + root.devicesModel.logout(passwordSheet.deviceId, passwordField.text); + passwordField.text = ""; + } + + footer: QQC2.DialogButtonBox { + QQC2.Button { text: i18nc("@action:button As in 'Remove this device'", "Remove") icon.name: "delete" - onTriggered: { - root.devicesModel.logout(passwordSheet.deviceId, passwordField.text); - passwordField.text = ""; - passwordSheet.close(); - } + + onClicked: passwordSheet.close() + + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole } - ] + } } } diff --git a/src/settings/SelectParentDialog.qml b/src/settings/SelectParentDialog.qml index a2918a3cb..ea3ae812e 100644 --- a/src/settings/SelectParentDialog.qml +++ b/src/settings/SelectParentDialog.qml @@ -23,6 +23,8 @@ Kirigami.Dialog { required property NeoChatRoom room title: i18nc("@title", "Select new official parent") + showCloseButton: false + standardButtons: QQC2.Dialog.Cancel width: Math.min(QQC2.ApplicationWindow.window.width, Kirigami.Units.gridUnit * 24) leftPadding: 0 @@ -30,18 +32,7 @@ Kirigami.Dialog { topPadding: 0 bottomPadding: 0 - standardButtons: Kirigami.Dialog.Cancel - customFooterActions: [ - Kirigami.Action { - enabled: chosenRoomDelegate.visible && root.room.canModifyParent(chosenRoomDelegate.roomId) - text: i18n("OK") - icon.name: "dialog-ok" - onTriggered: { - root.room.addParent(chosenRoomDelegate.roomId, makeCanonicalCheck.checked, existingOfficialCheck.checked); - root.close(); - } - } - ] + onAccepted: root.room.addParent(chosenRoomDelegate.roomId, makeCanonicalCheck.checked, existingOfficialCheck.checked); contentItem: ColumnLayout { spacing: 0 @@ -172,4 +163,16 @@ Kirigami.Dialog { enabled: chosenRoomDelegate.visible } } + + footer: QQC2.DialogButtonBox { + QQC2.Button { + enabled: chosenRoomDelegate.visible && root.room.canModifyParent(chosenRoomDelegate.roomId) + text: i18nc("@action:button", "Ok") + icon.name: "dialog-ok" + + onClicked: root.accept() + + QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole + } + } }