Cleanup buttons

Mostly removing the usage of the action property, since there's no point in using it. Also add some translation contexts and some other minor cleanup
This commit is contained in:
Tobias Fella
2025-08-13 17:34:08 +02:00
committed by Tobias Fella
parent 9b763daf52
commit 45b02ae34e
12 changed files with 235 additions and 271 deletions

View File

@@ -58,14 +58,18 @@ ColumnLayout {
QQC2.ToolButton {
id: cancelAttachmentButton
display: QQC2.AbstractButton.IconOnly
action: Kirigami.Action {
text: i18n("Cancel sending attachment")
text: i18nc("@action:button", "Cancel sending attachment")
icon.name: "dialog-close"
onTriggered: root.attachmentCancelled()
shortcut: "Escape"
}
onClicked: root.attachmentCancelled()
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
Kirigami.Action {
shortcut: "Escape"
onTriggered: cancelAttachmentButton.clicked()
}
}
}

View File

@@ -120,16 +120,12 @@ Kirigami.Dialog {
}
QQC2.ToolButton {
display: QQC2.AbstractButton.IconOnly
action: Kirigami.Action {
id: removeOptionAction
text: i18nc("@action:button", "Remove option")
icon.name: "edit-delete-remove"
onTriggered: optionModel.remove(optionDelegate.index)
}
QQC2.ToolTip {
text: removeOptionAction.text
delay: Kirigami.Units.toolTipDelay
}
onClicked: optionModel.remove(optionDelegate.index)
QQC2.ToolTip.text: text
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.visible: hovered
}
}
}

View File

@@ -142,23 +142,20 @@ Kirigami.Dialog {
FormCard.FormButtonDelegate {
visible: root.user.id !== root.connection.localUserId && !!root.user
action: Kirigami.Action {
text: !!root.user && root.connection.isIgnored(root.user.id) ? i18n("Unignore this user") : i18n("Ignore this user")
icon.name: "im-invisible-user"
onTriggered: {
onClicked: {
root.close();
root.connection.isIgnored(root.user.id) ? root.connection.removeFromIgnoredUsers(root.user.id) : root.connection.addToIgnoredUsers(root.user.id);
}
}
}
FormCard.FormButtonDelegate {
visible: root.room && root.user.id !== root.connection.localUserId && room.canSendState("kick") && room.containsUser(root.user.id) && room.memberEffectivePowerLevel(root.user.id) < room.memberEffectivePowerLevel(root.connection.localUserId)
action: Kirigami.Action {
text: i18n("Kick this user")
text: i18nc("@action:button", "Kick this user")
icon.name: "im-kick-user"
onTriggered: {
onClicked: {
let dialog = (root.QQC2.ApplicationWindow.window as Kirigami.ApplicationWindow).pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ReasonDialog'), {
title: i18nc("@title:dialog", "Kick User"),
placeholder: i18nc("@info:placeholder", "Reason for kicking this user"),
@@ -174,30 +171,26 @@ Kirigami.Dialog {
root.close();
}
}
}
FormCard.FormButtonDelegate {
visible: root.room && root.user.id !== root.connection.localUserId && room.canSendState("invite") && !room.containsUser(root.user.id)
action: Kirigami.Action {
enabled: root.room && !root.room.isUserBanned(root.user.id)
text: i18n("Invite this user")
text: i18nc("@action:button", "Invite this user")
icon.name: "list-add-user"
onTriggered: {
onClicked: {
root.room.inviteToRoom(root.user.id);
root.close();
}
}
}
FormCard.FormButtonDelegate {
visible: root.room && root.user.id !== root.connection.localUserId && room.canSendState("ban") && !room.isUserBanned(root.user.id) && room.memberEffectivePowerLevel(root.user.id) < room.memberEffectivePowerLevel(root.connection.localUserId)
action: Kirigami.Action {
text: i18n("Ban this user")
text: i18nc("@action:button", "Ban this user")
icon.name: "im-ban-user"
icon.color: Kirigami.Theme.negativeTextColor
onTriggered: {
onClicked: {
let dialog = (root.QQC2.ApplicationWindow.window as Kirigami.ApplicationWindow).pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ReasonDialog'), {
title: i18nc("@title:dialog", "Ban User"),
placeholder: i18nc("@info:placeholder", "Reason for banning this user"),
@@ -213,28 +206,24 @@ Kirigami.Dialog {
root.close();
}
}
}
FormCard.FormButtonDelegate {
visible: root.room && root.user.id !== root.connection.localUserId && room.canSendState("ban") && room.isUserBanned(root.user.id)
action: Kirigami.Action {
text: i18n("Unban this user")
text: i18nc("@action:button", "Unban this user")
icon.name: "im-irc"
icon.color: Kirigami.Theme.negativeTextColor
onTriggered: {
onClicked: {
root.room.unban(root.user.id);
root.close();
}
}
}
FormCard.FormButtonDelegate {
visible: root.room && root.room.canSendState("m.room.power_levels")
action: Kirigami.Action {
text: i18n("Set user power level")
text: i18nc("@action:button", "Set user power level")
icon.name: "visibility"
onTriggered: {
onClicked: {
let dialog = powerLevelDialog.createObject(this, {
room: root.room,
userId: root.user.id,
@@ -243,7 +232,6 @@ Kirigami.Dialog {
dialog.open();
root.close();
}
}
Component {
id: powerLevelDialog
@@ -256,11 +244,10 @@ Kirigami.Dialog {
FormCard.FormButtonDelegate {
visible: root.room && (root.user.id === root.connection.localUserId || room.canSendState("redact"))
action: Kirigami.Action {
text: i18nc("@action:button", "Remove recent messages by this user")
icon.name: "delete"
icon.color: Kirigami.Theme.negativeTextColor
onTriggered: {
onClicked: {
let dialog = pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ReasonDialog'), {
title: i18nc("@title:dialog", "Remove Messages"),
placeholder: i18nc("@info:placeholder", "Reason for removing this user's recent messages"),
@@ -276,28 +263,21 @@ Kirigami.Dialog {
root.close();
}
}
}
FormCard.FormButtonDelegate {
visible: root.user.id !== root.connection.localUserId
action: Kirigami.Action {
text: root.connection.directChatExists(root.user) ? i18nc("%1 is the name of the user.", "Chat with %1", root.room ? root.room.member(root.user.id).htmlSafeDisplayName : QmlUtils.escapeString(root.user.displayName)) : i18n("Invite to private chat")
icon.name: "document-send"
onTriggered: {
onClicked: {
root.connection.requestDirectChat(root.user.id);
root.close();
}
}
}
FormCard.FormButtonDelegate {
action: Kirigami.Action {
text: i18n("Copy link")
icon.name: "username-copy"
onTriggered: {
Clipboard.saveText("https://matrix.to/#/" + root.user.id);
}
}
onClicked: Clipboard.saveText("https://matrix.to/#/" + root.user.id)
}
}
}

View File

@@ -161,42 +161,45 @@ QQC2.Control {
QQC2.ToolButton {
visible: !root.isBusy
display: QQC2.AbstractButton.IconOnly
action: Kirigami.Action {
text: i18nc("@action:button", "Attach an image or file")
icon.name: "mail-attachment"
onTriggered: {
onClicked: {
let dialog = (Clipboard.hasImage ? attachDialog : openFileDialog).createObject(QQC2.Overlay.overlay);
dialog.chosen.connect(path => root.chatBarCache.attachmentPath = path);
dialog.open();
}
}
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
QQC2.ToolButton {
display: QQC2.AbstractButton.IconOnly
action: Kirigami.Action {
text: root.chatBarCache.isEditing ? i18nc("@action:button", "Confirm edit") : i18nc("@action:button", "Post message in thread")
icon.name: "document-send"
onTriggered: {
_private.post();
}
}
onClicked: _private.post()
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
QQC2.ToolButton {
id: cancelButton
display: QQC2.AbstractButton.IconOnly
action: Kirigami.Action {
text: i18nc("@action:button", "Cancel")
icon.name: "dialog-close"
onTriggered: {
onClicked: {
root.chatBarCache.clearRelations();
}
Kirigami.Action {
shortcut: "Escape"
onTriggered: cancelButton.clicked()
}
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
}
}

View File

@@ -370,15 +370,17 @@ Video {
id: maximizeButton
display: QQC2.AbstractButton.IconOnly
action: Kirigami.Action {
text: i18n("Maximize")
text: i18nc("@action:button", "Maximize")
icon.name: "view-fullscreen"
onTriggered: {
onClicked: {
root.Message.timeline.interactive = false;
root.pause();
RoomManager.maximizeMedia(root.eventId);
}
}
QQC2.ToolTip.text: text
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.visible: hovered
}
}
background: Kirigami.ShadowedRectangle {

View File

@@ -56,15 +56,13 @@ RowLayout {
Accessible.onPressAction: menuButton.action.trigger()
display: QQC2.AbstractButton.IconOnly
checkable: true
action: QQC2.Action {
text: i18nc("@action:button", "Show Menu")
icon.name: "application-menu-symbolic"
onTriggered: {
onClicked: {
const item = menu.createObject(menuButton);
item.closed.connect(menuButton.toggle);
item.open();
}
}
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.text: text
@@ -87,13 +85,15 @@ RowLayout {
QQC2.MenuItem {
text: i18n("Create a Room")
icon.name: "system-users-symbolic"
action: QQC2.Action {
shortcut: StandardKey.New
onTriggered: {
Qt.createComponent('org.kde.neochat', 'CreateRoomDialog').createObject(root, {
connection: root.connection
}).open();
}
Kirigami.Action {
shortcut: StandardKey.New
onTriggered: parent.trigger()
}
}

View File

@@ -138,11 +138,11 @@ Kirigami.NavigationTabBar {
ColumnLayout {
spacing: 0
Delegates.RoundedItemDelegate {
id: createRoomButton
Layout.fillWidth: true
action: Kirigami.Action {
text: i18n("Create a Room")
text: i18nc("@action:button", "Create a Room")
icon.name: "system-users-symbolic"
onTriggered: {
onClicked: {
pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'CreateRoomPage'), {
connection: root.connection
}, {
@@ -150,15 +150,17 @@ Kirigami.NavigationTabBar {
});
explorePopup.close();
}
Kirigami.Action {
shortcut: StandardKey.New
onTriggered: createRoomButton.clicked()
}
}
Delegates.RoundedItemDelegate {
Layout.fillWidth: true
action: Kirigami.Action {
text: i18n("Create a Space")
text: i18nc("@action:button", "Create a Space")
icon.name: "list-add"
onTriggered: {
onClicked: {
Qt.createComponent('org.kde.neochat', 'CreateSpaceDialog').createObject(root, {
connection: root.connection
}).open();
@@ -169,4 +171,3 @@ Kirigami.NavigationTabBar {
}
}
}
}

View File

@@ -91,13 +91,9 @@ RowLayout {
}
QQC2.ToolButton {
display: QQC2.Button.IconOnly
action: Kirigami.Action {
text: i18nc("@action:button", "Open Settings")
icon.name: "settings-configure-symbolic"
onTriggered: {
NeoChatSettingsView.open();
}
}
onClicked: NeoChatSettingsView.open()
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered

View File

@@ -86,32 +86,23 @@ FormCard.AbstractFormDelegate {
}
QQC2.ToolButton {
display: QQC2.AbstractButton.IconOnly
action: Kirigami.Action {
id: editDeviceAction
text: i18n("Edit device name")
text: i18nc("@action:button", "Edit device name")
icon.name: "document-edit"
onTriggered: root.editDeviceName = true
}
QQC2.ToolTip {
text: editDeviceAction.text
delay: Kirigami.Units.toolTipDelay
}
onClicked: root.editDeviceName = true
QQC2.ToolTip.text: text
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.visible: hovered
}
QQC2.ToolButton {
display: QQC2.AbstractButton.IconOnly
visible: root.showVerifyButton && (root.type !== DevicesModel.Verified || NeoChatConfig.alwaysVerifyDevice)
action: Kirigami.Action {
id: verifyDeviceAction
text: i18n("Verify device")
text: i18nc("@action:button", "Verify device")
icon.name: "security-low-symbolic"
onTriggered: {
devicesModel.connection.startKeyVerificationSession(devicesModel.connection.localUserId, root.id);
}
}
QQC2.ToolTip {
text: verifyDeviceAction.text
delay: Kirigami.Units.toolTipDelay
}
onClicked: devicesModel.connection.startKeyVerificationSession(devicesModel.connection.localUserId, root.id)
QQC2.ToolTip.text: text
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.visible: hovered
}
Kirigami.Icon {
visible: root.showVerifyButton && root.type === DevicesModel.Verified
@@ -130,19 +121,16 @@ FormCard.AbstractFormDelegate {
}
QQC2.ToolButton {
display: QQC2.AbstractButton.IconOnly
action: Kirigami.Action {
id: logoutDeviceAction
text: i18n("Logout device")
text: i18nc("@action:button", "Logout device")
icon.name: "edit-delete-remove"
onTriggered: {
onClicked: {
passwordSheet.deviceId = root.id;
passwordSheet.open();
}
}
QQC2.ToolTip {
text: logoutDeviceAction.text
delay: Kirigami.Units.toolTipDelay
}
QQC2.ToolTip.text: text
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.visible: hovered
}
}
}

View File

@@ -205,9 +205,7 @@ FormCard.FormCardPage {
}
}
action: Kirigami.Action {
id: editPowerLevelAction
onTriggered: {
onClicked: {
userListSearchPopup.close();
let dialog = powerLevelDialog.createObject(root.QQC2.Overlay.overlay, {
room: root.room,
@@ -216,7 +214,6 @@ FormCard.FormCardPage {
});
dialog.open();
}
}
Component {
id: powerLevelDialog

View File

@@ -271,16 +271,13 @@ FormCard.FormCardPage {
QQC2.ToolButton {
visible: root.room.canSendState("m.space.parent") && root.room.canonicalParent !== officalParentDelegate.modelData
display: QQC2.AbstractButton.IconOnly
action: Kirigami.Action {
id: canonicalParentAction
text: i18n("Make canonical parent")
text: i18nc("@action:button", "Make canonical parent")
icon.name: "checkmark"
onTriggered: root.room.canonicalParent = officalParentDelegate.modelData
}
QQC2.ToolTip {
text: canonicalParentAction.text
delay: Kirigami.Units.toolTipDelay
}
onClicked: root.room.canonicalParent = officalParentDelegate.modelData
QQC2.ToolTip.text: text
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.visible: hovered
}
QQC2.ToolButton {
visible: officalParentDelegate?.space.canSendState("m.space.child") && root.room.canSendState("m.space.parent")

View File

@@ -214,23 +214,22 @@ QQC2.ScrollView {
padding: Kirigami.Units.largeSpacing
z: 2
visible: (!_private.room?.partiallyReadStats.empty())
visible: !_private.room?.partiallyReadStats.empty()
text: _private.room.readMarkerLoaded ? i18n("Jump to first unread message") : i18n("Jump to oldest loaded message")
action: Kirigami.Action {
onTriggered: {
text: _private.room.readMarkerLoaded ? i18nc("@action:button", "Jump to first unread message") : i18nc("@action:button", "Jump to oldest loaded message")
icon.name: "go-up"
onClicked: {
goReadMarkerFab.textChanged()
root.goToEvent(_private.room.lastFullyReadEventId);
}
icon.name: "go-up"
Kirigami.Action {
shortcut: "Shift+PgUp"
onTriggered: goReadMarkerFab.clicked()
}
QQC2.ToolTip {
text: goReadMarkerFab.text
delay: Kirigami.Units.toolTipDelay
visible: goReadMarkerFab.hovered
}
QQC2.ToolTip.text: goReadMarkerFab.text
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.visible: goReadMarkerFab.hovered
}
KirigamiComponents.FloatingButton {
id: goMarkAsReadFab
@@ -248,21 +247,22 @@ QQC2.ScrollView {
z: 2
visible: !messageListView.atYEnd
text: i18n("Jump to latest message")
action: Kirigami.Action {
onTriggered: {
text: i18nc("@action:button", "Jump to latest message")
onClicked: {
messageListView.positionViewAtBeginning();
_private.room.markAllMessagesAsRead();
}
icon.name: "go-down"
Kirigami.Action {
shortcut: "Shift+PgDown"
onTriggered: goMarkAsReadFab.clicked()
}
QQC2.ToolTip {
text: goMarkAsReadFab.text
delay: Kirigami.Units.toolTipDelay
visible: goMarkAsReadFab.hovered
}
QQC2.ToolTip.text: goMarkAsReadFab.text
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.visible: goMarkAsReadFab.hovered
}
DropArea {