Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85640003
D351.1787011929.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D351.1787011929.diff
View Options
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -267,6 +267,7 @@
device-mgmt/DeviceList.qml
UserPage.qml
+ KazvAction.qml
shortcuts/ActionCollection.qml
shortcuts/ActionItem.qml
diff --git a/src/contents/ui/KazvAction.qml b/src/contents/ui/KazvAction.qml
new file mode 100644
--- /dev/null
+++ b/src/contents/ui/KazvAction.qml
@@ -0,0 +1,27 @@
+/*
+ * This file is part of kazv.
+ * SPDX-FileCopyrightText: 2026 nannanko <nannanko@kazv.moe>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+import QtQml
+
+import org.kde.kirigami as Kirigami
+
+Kirigami.Action {
+ id: action
+ property Kirigami.Action globalAction: actionCollection ? actionCollection.action(objectName) : null
+ icon.name: globalAction?.icon.name || ''
+ text: globalAction?.text || ''
+ shortcut: globalAction.shortcut
+
+ property var conn: Connections {
+ target: globalAction
+ function onTriggered() {
+ if (!action.enabled) {
+ return;
+ }
+ action.onTriggered();
+ }
+ }
+}
diff --git a/src/contents/ui/Main.qml b/src/contents/ui/Main.qml
--- a/src/contents/ui/Main.qml
+++ b/src/contents/ui/Main.qml
@@ -240,11 +240,38 @@
actions: Kirigami.Settings.isMobile ? (pageStack.currentItem?.actions || []) : []
}
+ property var roomPageActions: QtObject {
+ property list<Kirigami.Action> actions: [
+ Kirigami.Action {
+ objectName: 'send-message'
+ icon.name: 'document-send'
+ text: l10n.get('send-message-box-send')
+ property var defaultShortcut: 'Ctrl+Return'
+ },
+ Kirigami.Action {
+ objectName: 'send-file'
+ icon.name: 'document-open-data'
+ text: l10n.get('send-message-box-send-file')
+ },
+ Kirigami.Action {
+ objectName: 'send-stickers'
+ icon.name: 'smiley'
+ text: l10n.get('send-message-box-stickers')
+ },
+ Kirigami.Action {
+ objectName: 'remove-related-to-event'
+ icon.name: 'window-close-symbolic'
+ text: l10n.get('action-settings-remove-related-to-event-action')
+ }
+ ]
+ }
+
property var actionCollection: KazvShortcuts.ActionCollection {
id: globalActionCollection
children: [
root.globalDrawer,
root.contextDrawer,
+ root.roomPageActions
]
shortcutsConfig: kazvConfig
}
diff --git a/src/contents/ui/SendMessageBox.qml b/src/contents/ui/SendMessageBox.qml
--- a/src/contents/ui/SendMessageBox.qml
+++ b/src/contents/ui/SendMessageBox.qml
@@ -221,7 +221,6 @@
TextArea {
id: textArea
objectName: 'draftMessage'
- property var shortcutList: ["Ctrl+Return", "Ctrl+Enter"]
property var inhibitTyping: false
placeholderText: l10n.get('send-message-box-input-placeholder')
property string filter: getFilter()
@@ -273,14 +272,6 @@
}
}
- // Shortcut keys for sending messages (TODO: Shortcut keys customized by the user)
- Shortcut {
- sequences: textArea.shortcutList
- onActivated: {
- sendAction.trigger()
- }
- }
-
DropArea {
anchors.fill: parent
onDropped: (drag) => {
@@ -411,9 +402,9 @@
textArea.forceActiveFocus();
}
- Kirigami.Action {
+ Kazv.KazvAction {
id: removeRelatedToAction
- icon.name: 'window-close-symbolic'
+ objectName: 'remove-related-to-event'
text: getCancelRelationPrompt(sendMessageBox.draftRelType)
onTriggered: {
if (textArea.text) {
@@ -424,10 +415,9 @@
}
}
- Kirigami.Action {
+ Kazv.KazvAction {
id: sendAction
- icon.name: "document-send"
- text: l10n.get("send-message-box-send")
+ objectName: 'send-message'
onTriggered: {
room.setTyping(false);
room.sendTextMessage(textArea.text, draftRelType, draftRelatedTo);
@@ -436,10 +426,9 @@
}
enabled: textArea.text !== ''
}
- Kirigami.Action {
+ Kazv.KazvAction {
id: sendMediaFileAction
- icon.name: "document-open-data"
- text: l10n.get("send-message-box-send-file")
+ objectName: 'send-file'
onTriggered: {
fileDialog.open()
}
@@ -486,10 +475,9 @@
}
}
- Kirigami.Action {
+ Kazv.KazvAction {
id: stickersAction
- icon.name: 'smiley'
- text: l10n.get('send-message-box-stickers')
+ objectName: 'send-stickers'
onTriggered: stickerPopup.open()
}
}
diff --git a/src/contents/ui/shortcuts/ActionCollection.qml b/src/contents/ui/shortcuts/ActionCollection.qml
--- a/src/contents/ui/shortcuts/ActionCollection.qml
+++ b/src/contents/ui/shortcuts/ActionCollection.qml
@@ -81,7 +81,7 @@
allActions().forEach((action) => {
const name = action.objectName;
const shortcuts = shortcutsConfig.shortcutForAction(name);
- action.shortcut = shortcuts[0] || '';
+ action.shortcut = shortcuts.length ? shortcuts[0] || '' : action.defaultShortcut || '';
});
}
}
diff --git a/src/l10n/cmn-Hans/100-ui.ftl b/src/l10n/cmn-Hans/100-ui.ftl
--- a/src/l10n/cmn-Hans/100-ui.ftl
+++ b/src/l10n/cmn-Hans/100-ui.ftl
@@ -40,6 +40,7 @@
action-settings-shortcut-conflict = 快捷键 { $shortcut } 跟别的指令有冲突。<br>若要继续,别的指令的快捷键会被清除。<br><br>冲突的指令有:<br>{ $conflictingAction }
action-settings-shortcut-conflict-continue = 继续
action-settings-shortcut-conflict-cancel = 取消
+action-settings-remove-related-to-event-action = 取消回复或编辑
empty-room-page-title = 没有选中房间
empty-room-page-description = 当前没有选中的房间。
diff --git a/src/l10n/en/100-ui.ftl b/src/l10n/en/100-ui.ftl
--- a/src/l10n/en/100-ui.ftl
+++ b/src/l10n/en/100-ui.ftl
@@ -40,6 +40,7 @@
action-settings-shortcut-conflict = The shortcut { $shortcut } has conflicts with other actions. <br>If you continue, the shortcuts for other actions will be cleared. <br><br>Conflicting actions: <br>{ $conflictingAction }
action-settings-shortcut-conflict-continue = Continue
action-settings-shortcut-conflict-cancel = Cancel
+action-settings-remove-related-to-event-action = Cancel reply or edit
empty-room-page-title = No rooms selected
empty-room-page-description = There is no room selected now.
diff --git a/src/tests/quick-tests/tst_SendMessageBox.qml b/src/tests/quick-tests/tst_SendMessageBox.qml
--- a/src/tests/quick-tests/tst_SendMessageBox.qml
+++ b/src/tests/quick-tests/tst_SendMessageBox.qml
@@ -56,6 +56,26 @@
}
}
+ // Mirror the global action the application registers for the send
+ // shortcut, so that KazvAction in SendMessageBox can resolve it.
+ property var sendMessageGlobalAction: Kirigami.Action {
+ objectName: 'send-message'
+ shortcut: 'Ctrl+Enter'
+ }
+
+ property var actionCollection: QtObject {
+ property var actions: [item.sendMessageGlobalAction]
+
+ function action(name) {
+ for (let i = 0; i < actions.length; ++i) {
+ if (actions[i].objectName === name) {
+ return actions[i];
+ }
+ }
+ return null;
+ }
+ }
+
Kazv.SendMessageBox {
id: sendMessageBox
y: 400
@@ -208,12 +228,16 @@
verify(room.sendTextMessage.calledTimes() === 0);
const textArea = findChild(sendMessageBox, 'draftMessage');
- mouseClick(textArea);
- tryVerify(() => textArea.activeFocus);
- keySequence('Ctrl+Enter');
- verify(room.sendTextMessage.calledTimes() === 0);
- keySequence('Ctrl+Return');
+
+ // The configured send shortcut must not send an empty message.
+ item.sendMessageGlobalAction.trigger();
verify(room.sendTextMessage.calledTimes() === 0);
+
+ // It should send and clear the box once the input is non-empty.
+ textArea.text = 'some test';
+ item.sendMessageGlobalAction.trigger();
+ tryVerify(() => room.sendTextMessage.calledTimes() === 1);
+ verify(textArea.text === '');
}
function test_replyWithFile() {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Aug 17, 5:12 PM (21 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1731088
Default Alt Text
D351.1787011929.diff (7 KB)
Attached To
Mode
D351: Make shortcuts of SendMessageBox.qml configurable
Attached
Detach File
Event Timeline
Log In to Comment