修复输入框聚焦时 Cmd+V 粘贴图片失效:按剪贴板内容分流
根因:⌘V 在 QML 里有两条互斥路径。焦点不在输入框时走顶层
Shortcut{StandardKey.Paste} 粘贴图片;焦点在 promptArea 里时,
编辑控件通过 Qt 的 ShortcutOverride 吞掉 ⌘V 走内置文本粘贴,
那个全局 Shortcut 永远拿不到事件 —— 而剪贴板里是图片、文本粘贴
贴不出东西,表现为"粘贴无效"。
按钮直接调 pasteFromClipboardAction
绕开按键路由,所以一直有效。
修复(按剪贴板内容分流,而非靠焦点状态):
- bridges/imagegen.py 新增 clipboardHasImage():只读 formats()/urls(),
无副作用、不写临时文件、macOS 不碰会崩的 imageData()。
- promptArea 加 Keys.onPressed:matches(StandardKey.Paste) 且剪贴板有图
→ 粘图 + event.accepted;否则放行给 TextArea 做文本粘贴。
文本粘贴行为不变(Never break userspace)。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Showing
2 changed files
with
40 additions
and
2 deletions
-
Please register or sign in to post a comment