feat(keyboard): wire custom shortcut CRUD on Wayland#3346
Conversation
There was a problem hiding this comment.
Sorry @yixinshark, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Wire the control center's add/modify/delete custom shortcut flows to the new dde-services Keybinding1 custom CRUD methods on Wayland, replacing the previous early-return stubs. Each Wayland call is observed with a QDBusPendingCallWatcher so failures trigger refreshShortcut()/onAdded/ onShortcutChanged instead of mutating the local model optimistically. Fetch a custom shortcut's command via the new GetShortcutCommand D-Bus method: requestShortcutCommand fires one async call per custom shortcut after ListAllShortcuts/SearchShortcuts/GetShortcut/ShortcutChanged, and onGetShortcutCommandFinished overlays the Exec field onto the already- built JSON object and re-emits shortcutQueried. The whole ShortcutInfo JSON is stashed on the watcher so the handler needs no field-by-field reconstruction. ShortcutModel::onKeyBindingChanged now handles insert-on-change for new ids arriving via ShortcutChanged: section-bearing configs are grouped into m_groupInfos, sectionless Custom configs get the legacy "Custom" group, and a dead unreachable tail (invalidateSystemShortcutNamesCache + addCustomInfo after two returning branches) is removed. Extract KeyboardWorker::callModifyCustomShortcut() so the Wayland modify path (modifyCustomShortcut and setNewCustomShortcut) shares one watcher/id/type/connect setup. setNewCustomShortcut keeps the X11 fallback calling ModifyCustomShortcut directly, since on X11 it is also invoked from onCustomConflictCleanFinished after conflict cleanup. 将控制中心自定义快捷键的增删改流程在 Wayland 下接入新的 dde-services Keybinding1 自定义增删改方法,替换原先的提前 return 桩。每次 Wayland 调用 均用 QDBusPendingCallWatcher 观察结果,失败时触发 refreshShortcut()/ onAdded/onShortcutChanged,而不再乐观地修改本地模型。 通过新增的 GetShortcutCommand D-Bus 方法获取自定义快捷键命令: requestShortcutCommand 在 ListAllShortcuts/SearchShortcuts/GetShortcut/ ShortcutChanged 之后对每个自定义快捷键发起一次异步调用, onGetShortcutCommandFinished 将 Exec 字段叠加到已构建好的 JSON 对象上并 重新发射 shortcutQueried。整个 ShortcutInfo JSON 暂存在 watcher 上,处理 函数无需逐字段重建。 ShortcutModel::onKeyBindingChanged 现支持通过 ShortcutChanged 到达的新 id 的"变更即插入":带 Section 的配置归入 m_groupInfos,无 Section 的 Custom 配置归入传统"Custom"分组,并删除了两个 return 分支之后不可达的死代码尾段。 抽取 KeyboardWorker::callModifyCustomShortcut(),让 Wayland 修改路径 (modifyCustomShortcut 与 setNewCustomShortcut)共用一份 watcher/id/type/ connect 设置。setNewCustomShortcut 保留 X11 直接调用 ModifyCustomShortcut 的兜底,因为 X11 下它也会在冲突清理完成后由 onCustomConflictCleanFinished 调用。 Log: feat(keyboard): wire custom shortcut CRUD on Wayland Change-Id: I793aa520968c92d03bb603721f00b1c7ac252fa5
b830d64 to
b9e77e2
Compare
deepin pr auto review★ 总体评分:78分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // keyboardcontroller.cpp — modifyCustomShortcut:补充Wayland分支的冲突处理
void KeyboardController::modifyCustomShortcut(const QString &id, const QString &name, const QString &cmd, const QString &accels)
{
ShortcutInfo *shortcut = m_shortcutModel->findInfoIf([id](ShortcutInfo *info){ return id == info->id; });
if (!shortcut) {
qWarning() << "shortcut not found..." << id << name;
return;
}
if (m_worker->isWayland()) {
// 补充:清理与目标快捷键冲突的现有快捷键
if (auto conflict = m_shortcutModel->getInfo(accels)) {
m_worker->onDisableShortcut(conflict);
}
ShortcutInfo updated = *shortcut;
updated.name = name;
updated.command = checkDesktopCmd(cmd);
updated.accels = accels;
m_worker->modifyCustomShortcut(&updated);
return;
}
// Clear conflicting shortcuts when modifying
if (auto conflict = m_shortcutModel->getInfo(accels)) {
m_worker->onDisableShortcut(conflict);
}
// ... X11 原有逻辑 ...
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, yixinshark The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Wire the control center's add/modify/delete custom shortcut flows to the
new dde-services Keybinding1 custom CRUD methods on Wayland, replacing
the previous early-return stubs. Each Wayland call is observed with a
QDBusPendingCallWatcher so failures trigger refreshShortcut()/onAdded/
onShortcutChanged instead of mutating the local model optimistically.
Fetch a custom shortcut's command via the new GetShortcutCommand D-Bus
method: requestShortcutCommand fires one async call per custom shortcut
after ListAllShortcuts/SearchShortcuts/GetShortcut/ShortcutChanged, and
onGetShortcutCommandFinished overlays the Exec field onto the already-
built JSON object and re-emits shortcutQueried. The whole ShortcutInfo
JSON is stashed on the watcher so the handler needs no field-by-field
reconstruction.
ShortcutModel::onKeyBindingChanged now handles insert-on-change for new
ids arriving via ShortcutChanged: section-bearing configs are grouped
into m_groupInfos, sectionless Custom configs get the legacy "Custom"
group, and a dead unreachable tail (invalidateSystemShortcutNamesCache
Extract KeyboardWorker::callModifyCustomShortcut() so the Wayland
modify path (modifyCustomShortcut and setNewCustomShortcut) shares one
watcher/id/type/connect setup. setNewCustomShortcut keeps the X11
fallback calling ModifyCustomShortcut directly, since on X11 it is also
invoked from onCustomConflictCleanFinished after conflict cleanup.
将控制中心自定义快捷键的增删改流程在 Wayland 下接入新的 dde-services
Keybinding1 自定义增删改方法,替换原先的提前 return 桩。每次 Wayland 调用
均用 QDBusPendingCallWatcher 观察结果,失败时触发 refreshShortcut()/
onAdded/onShortcutChanged,而不再乐观地修改本地模型。
通过新增的 GetShortcutCommand D-Bus 方法获取自定义快捷键命令:
requestShortcutCommand 在 ListAllShortcuts/SearchShortcuts/GetShortcut/
ShortcutChanged 之后对每个自定义快捷键发起一次异步调用,
onGetShortcutCommandFinished 将 Exec 字段叠加到已构建好的 JSON 对象上并
重新发射 shortcutQueried。整个 ShortcutInfo JSON 暂存在 watcher 上,处理
函数无需逐字段重建。
ShortcutModel::onKeyBindingChanged 现支持通过 ShortcutChanged 到达的新 id
的"变更即插入":带 Section 的配置归入 m_groupInfos,无 Section 的 Custom
配置归入传统"Custom"分组,并删除了两个 return 分支之后不可达的死代码尾段。
抽取 KeyboardWorker::callModifyCustomShortcut(),让 Wayland 修改路径
(modifyCustomShortcut 与 setNewCustomShortcut)共用一份 watcher/id/type/
connect 设置。setNewCustomShortcut 保留 X11 直接调用 ModifyCustomShortcut
的兜底,因为 X11 下它也会在冲突清理完成后由 onCustomConflictCleanFinished
调用。
Log: feat(keyboard): wire custom shortcut CRUD on Wayland
Change-Id: I793aa520968c92d03bb603721f00b1c7ac252fa5