Skip to content

Commit d713203

Browse files
committed
feat(shortcut): add custom shortcut CRUD and display-only support
Add runtime custom shortcut CRUD (AddCustomShortcut/ModifyCustomShortcut/DeleteCustomShortcut) to KeybindingManager with input validation, conflict handling and commit-failure rollback. Add GetShortcutCommand so the control center can fetch a custom shortcut command separately. Persist runtime custom shortcuts through user-level DConfig plus a custom shortcut subpath registry. Keep Add on full save/create semantics, use updateCustomShortcut for Modify so existing entries update only changed fields, and roll back persisted state when registration or conflict persistence fails. Introduce display-only shortcut configs so modifiable shortcuts with no hotkey remain visible as "None" after their binding is taken. Keep these entries in the runtime map and expose them through ListAllShortcuts. Remove the unused checkConflictForConfig helper after conflict checks stayed on the actual LookupConflictShortcut/registerShortcut paths. 新增自定义快捷键运行时增删改(AddCustomShortcut/ModifyCustomShortcut/DeleteCustomShortcut),包含输入校验、冲突处理和提交失败回滚;新增 GetShortcutCommand,供控制中心单独获取自定义快捷键命令。 通过用户级 DConfig 和自定义快捷键 subpath 注册表持久化运行时自定义快捷键。Add 继续使用完整创建/保存语义,Modify 改用 updateCustomShortcut,仅更新已有条目的变化字段,并在注册或冲突持久化失败时回滚持久化状态。 引入 display-only 快捷键配置,使可修改但无热键的快捷键在绑定被其他快捷键占用后仍能以“无”显示。此类条目保留在运行时映射中,并通过 ListAllShortcuts 暴露。 删除未使用的 checkConflictForConfig 辅助函数,因为真实冲突检测仍走 LookupConflictShortcut/registerShortcut 路径。 Log: feat(shortcut): add custom shortcut CRUD and display-only support Change-Id: Ie59dd3cb4e2575eea15974b9454eefc0ff484bfa
1 parent 37ceced commit d713203

12 files changed

Lines changed: 1142 additions & 88 deletions

File tree

src/plugin-qt/shortcut/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ set(SHORTCUT_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
2727
set(SHORTCUT_COMMON_SOURCES
2828
${SHORTCUT_SRC_DIR}/core/shortcutmanager.cpp
2929
${SHORTCUT_SRC_DIR}/core/keybindingmanager.cpp
30+
${SHORTCUT_SRC_DIR}/core/customshortcuttransaction.cpp
3031
${SHORTCUT_SRC_DIR}/core/gesturemanager.cpp
3132
${SHORTCUT_SRC_DIR}/core/qkeysequenceconverter.cpp
3233
${SHORTCUT_SRC_DIR}/core/actionexecutor.cpp
3334
${SHORTCUT_SRC_DIR}/core/translationmanager.cpp
3435
${SHORTCUT_SRC_DIR}/config/configloader.cpp
36+
${SHORTCUT_SRC_DIR}/config/customshortcutstore.cpp
3537
${SHORTCUT_SRC_DIR}/backend/abstractkeyhandler.h
3638
${SHORTCUT_SRC_DIR}/backend/abstractgesturehandler.h
3739
${SHORTCUT_SRC_DIR}/backend/specialkeyhandler.cpp
@@ -113,6 +115,12 @@ foreach(SUBDIR_PATH ${SHORTCUT_CONFIG_SUBDIRS})
113115
)
114116
endforeach()
115117

118+
# install base json config
119+
dtk_add_config_meta_files(
120+
APPID "org.deepin.dde.keybinding"
121+
FILES "${CMAKE_CURRENT_SOURCE_DIR}/configs/org.deepin.shortcut.json"
122+
)
123+
116124
foreach(SUBDIR_PATH ${GESTURE_CONFIG_SUBDIRS})
117125
dtk_add_config_meta_files(
118126
APPID "org.deepin.dde.keybinding"

src/plugin-qt/shortcut/configs/org.deepin.dde.keybinding.shortcut.displayswitch/org.deepin.shortcut.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
"value": [
2727
"Meta+P"
2828
],
29-
"serial": 0,
29+
"serial": 1,
3030
"flags": [],
3131
"name": "hotkeys",
3232
"name[zh_CN]": "快捷键组合",
3333
"description": "切换显示模式快捷键组合",
34-
"permissions": "",
34+
"permissions": "readwrite",
3535
"visibility": "private"
3636
},
3737
"triggerType": {
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"magic": "dsg.config.meta",
3+
"version": "1.0",
4+
"contents": {
5+
"appId": {
6+
"value": "org.deepin.dde.keybinding",
7+
"serial": 0,
8+
"flags": [],
9+
"name": "appId",
10+
"name[zh_CN]": "提供快捷键应用Id",
11+
"description": "provide shortcut app id",
12+
"permissions": "readwrite",
13+
"visibility": "private"
14+
},
15+
"displayName": {
16+
"value": "",
17+
"serial": 0,
18+
"flags": [],
19+
"name": "displayName",
20+
"name[zh_CN]": "",
21+
"description": "",
22+
"permissions": "readwrite",
23+
"visibility": "private"
24+
},
25+
"hotkeys": {
26+
"value": [],
27+
"serial": 0,
28+
"flags": [],
29+
"name": "hotkeys",
30+
"name[zh_CN]": "快捷键组合",
31+
"description": "打开默认终端快捷键组合",
32+
"permissions": "readwrite",
33+
"visibility": "private"
34+
},
35+
"triggerType": {
36+
"value": 1,
37+
"serial": 0,
38+
"flags": [],
39+
"name": "triggerType",
40+
"name[zh_CN]": "快捷键触发动作类型",
41+
"description": "二进制command类型",
42+
"permissions": "readwrite",
43+
"visibility": "private"
44+
},
45+
"triggerValue": {
46+
"value": [],
47+
"serial": 0,
48+
"flags": [],
49+
"name": "triggerValue",
50+
"name[zh_CN]": "快捷键触发动作",
51+
"description": "",
52+
"permissions": "readwrite",
53+
"visibility": "private"
54+
},
55+
"category": {
56+
"value": "Custom",
57+
"serial": 1,
58+
"flags": [],
59+
"name": "category",
60+
"name[zh_CN]": "快捷键类别(Custom)",
61+
"description": "Custom shortcut category",
62+
"permissions": "readwrite",
63+
"visibility": "private"
64+
},
65+
"enabled": {
66+
"value": true,
67+
"serial": 0,
68+
"flags": [],
69+
"name": "enabled",
70+
"name[zh_CN]": "使能",
71+
"description": "是否启用快捷键",
72+
"permissions": "readwrite",
73+
"visibility": "private"
74+
},
75+
"modifiable": {
76+
"value": true,
77+
"serial": 0,
78+
"flags": [],
79+
"name": "modifiable",
80+
"name[zh_CN]": "能否修改快捷键",
81+
"description": "不能修改快捷键",
82+
"permissions": "readwrite",
83+
"visibility": "private"
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)