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.
This commit is contained in:
Joshua Goins
2026-02-16 15:41:19 -05:00
parent 436b3a1008
commit b1595a4556
14 changed files with 162 additions and 140 deletions

View File

@@ -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 <room name>?", "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
}
}
}

View File

@@ -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();
}
}
}
}

View File

@@ -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)
}

View File

@@ -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
}
}
}

View File

@@ -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
}
}
}

View File

@@ -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
}
}
}

View File

@@ -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
}
}
}

View File

@@ -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
}
}
}

View File

@@ -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()

View File

@@ -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

View File

@@ -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
}
}
}

View File

@@ -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();
}
}
}
}

View File

@@ -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
}
]
}
}
}

View File

@@ -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
}
}
}