Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F112509
D77.1732325600.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
D77.1732325600.diff
View Options
diff --git a/src/contents/ui/ActionSettingsPage.qml b/src/contents/ui/ActionSettingsPage.qml
--- a/src/contents/ui/ActionSettingsPage.qml
+++ b/src/contents/ui/ActionSettingsPage.qml
@@ -11,7 +11,7 @@
Kazv.ClosableScrollablePage {
id: page
- property alias actions: settings.actions
+ property alias actionsToConfigure: settings.actions
title: l10n.get('action-settings-page-title')
KazvShortcuts.ActionSettings {
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
@@ -207,7 +207,7 @@
function pushActionSettingsPage() {
pageStack.push(Qt.resolvedUrl("ActionSettingsPage.qml"), {
- actions: globalActionCollection.allActions(),
+ actionsToConfigure: globalActionCollection.allActions(),
});
}
diff --git a/src/contents/ui/shortcuts/ActionItem.qml b/src/contents/ui/shortcuts/ActionItem.qml
--- a/src/contents/ui/shortcuts/ActionItem.qml
+++ b/src/contents/ui/shortcuts/ActionItem.qml
@@ -1,6 +1,6 @@
/*
* This file is part of kazv.
- * SPDX-FileCopyrightText: 2020-2022 Tusooa Zhu <tusooa@kazv.moe>
+ * SPDX-FileCopyrightText: 2020-2024 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@@ -10,16 +10,16 @@
import org.kde.kirigami 2.13 as Kirigami
import '.' as KazvShortcuts
-Kirigami.BasicListItem {
+Control {
id: actionItem
property var action
- icon: action.icon.name || action.icon.source
- label: action.text
- subtitle: l10n.get(
- 'action-settings-shortcut-prompt', {
- shortcut: action.shortcut || l10n.get('action-settings-shortcut-none')
- }
- )
+
+ implicitHeight: layout.implicitHeight
+ implicitWidth: layout.implicitWidth
+
+ background: Rectangle {
+ color: actionItem.hovered ? Kirigami.Theme.hoverColor : Kirigami.Theme.backgroundColor
+ }
property var sheet: Kirigami.OverlaySheet {
id: popup
@@ -58,42 +58,74 @@
}
RowLayout {
- Button {
- id: editButton
- text: checked ? shortcutInput.partialResult : l10n.get('action-settings-shortcut-edit-action')
- checkable: true
- onClicked: {
- if (checked) {
- shortcutInput.startRecording();
- } else {
- shortcutInput.cancel();
- }
+ id: layout
+ anchors.fill: parent
+ Kirigami.Icon {
+ source: action.icon.name || action.icon.source
+ }
+
+ ColumnLayout {
+ Layout.alignment: Qt.AlignLeft
+ Layout.fillWidth: true
+ Label {
+ Layout.fillWidth: true
+ Layout.alignment: Qt.AlignLeft
+ text: action.text
+ }
+
+ Label {
+ Layout.fillWidth: true
+ Layout.alignment: Qt.AlignLeft
+ text: l10n.get(
+ 'action-settings-shortcut-prompt', {
+ shortcut: action.shortcut || l10n.get('action-settings-shortcut-none')
+ }
+ )
}
}
- Button {
- text: l10n.get('action-settings-shortcut-remove-action')
- onClicked: {
- setShortcut("");
+ RowLayout {
+ Layout.alignment: Qt.AlignRight
+ Layout.fillWidth: false
+ Button {
+ id: editButton
+ objectName: 'editButton'
+ text: checked ? shortcutInput.partialResult : l10n.get('action-settings-shortcut-edit-action')
+ checkable: true
+ onClicked: {
+ if (checked) {
+ shortcutInput.startRecording();
+ } else {
+ shortcutInput.cancel();
+ }
+ }
+ }
+
+ Button {
+ objectName: 'removeShortcutButton'
+ text: l10n.get('action-settings-shortcut-remove-action')
+ onClicked: {
+ setShortcut("");
+ }
}
}
- }
- KazvShortcuts.ShortcutInput {
- id: shortcutInput
-
- onFinalResult: {
- editButton.checked = false;
- const conflicts = actionSettings
- .findConflicts(sequence)
- .filter(a => a.objectName !== action.objectName);
- if (!conflicts.length) {
- setShortcut(sequence);
- } else {
- popup.shortcut = sequence;
- popup.conflictingActions = conflicts;
- popup.conflictsName = conflicts.map(a => a.text);
- popup.open();
+ KazvShortcuts.ShortcutInput {
+ id: shortcutInput
+
+ onFinalResult: {
+ editButton.checked = false;
+ const conflicts = actionSettings
+ .findConflicts(sequence)
+ .filter(a => a.objectName !== action.objectName);
+ if (!conflicts.length) {
+ setShortcut(sequence);
+ } else {
+ popup.shortcut = sequence;
+ popup.conflictingActions = conflicts;
+ popup.conflictsName = conflicts.map(a => a.text);
+ popup.open();
+ }
}
}
}
diff --git a/src/contents/ui/shortcuts/ActionSettings.qml b/src/contents/ui/shortcuts/ActionSettings.qml
--- a/src/contents/ui/shortcuts/ActionSettings.qml
+++ b/src/contents/ui/shortcuts/ActionSettings.qml
@@ -20,6 +20,7 @@
model: actions.length
delegate: KazvShortcuts.ActionItem {
+ width: actionSettings.width
action: actions[index]
}
diff --git a/src/tests/quick-tests/tst_kazvshortcutsActionItem.qml b/src/tests/quick-tests/tst_kazvshortcutsActionItem.qml
new file mode 100644
--- /dev/null
+++ b/src/tests/quick-tests/tst_kazvshortcutsActionItem.qml
@@ -0,0 +1,67 @@
+/*
+ * This file is part of kazv.
+ * SPDX-FileCopyrightText: 2020-2024 tusooa <tusooa@kazv.moe>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+import QtQuick 2.15
+import QtTest 1.0
+import org.kde.kirigami 2.13 as Kirigami
+import moe.kazv.mxc.kazv 0.0 as MK
+import '../../contents/ui/shortcuts' as KazvShortcuts
+import 'test-helpers' as TestHelpers
+import 'test-helpers.js' as JsHelpers
+
+Item {
+ id: item
+ width: 800
+ height: 600
+
+ property var l10n: JsHelpers.fluentMock
+
+ property var mockHelper: TestHelpers.MockHelper {}
+ property var actionSettings: QtObject {
+ property var purgeShortcutForActions: mockHelper.noop()
+ property var findConflicts: mockHelper.func((seq) => {
+ if (seq === 'Ctrl+X') {
+ return [{ name: 'action1' }];
+ }
+ return [];
+ })
+ property var setShortcutFor: mockHelper.noop()
+ }
+
+ KazvShortcuts.ActionItem {
+ id: actionItem
+ action: Kirigami.Action {
+ text: 'some action'
+ }
+ }
+
+ TestCase {
+ id: kazvshortcutsActionItemTest
+ name: 'KazvshortcutsActionItemTest'
+ when: windowShown
+
+ function init() {
+ actionItem.action.shortcut = '';
+ mockHelper.clearAll();
+ }
+
+ function test_setShortcut() {
+ const editButton = findChild(actionItem, 'editButton');
+ mouseClick(editButton);
+ keySequence('Ctrl+A,Ctrl+K');
+ tryVerify(() => actionSettings.setShortcutFor.calledTimes(), 2000);
+ compare(actionSettings.setShortcutFor.lastArgs()[1], 'Ctrl+A,Ctrl+K');
+ }
+
+ function test_eraseShortcut() {
+ actionItem.action.shortcut = 'Ctrl+A,Ctrl+K';
+ const button = findChild(actionItem, 'removeShortcutButton');
+ mouseClick(button);
+ tryVerify(() => actionSettings.setShortcutFor.calledTimes());
+ compare(actionSettings.setShortcutFor.lastArgs()[1], '');
+ }
+ }
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 5:33 PM (5 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39040
Default Alt Text
D77.1732325600.diff (7 KB)
Attached To
Mode
D77: Make KazvShortcuts work on KF6
Attached
Detach File
Event Timeline
Log In to Comment