fix(editor): disable voice reading when TTS service is unavailable - #497
Conversation
There was a problem hiding this comment.
Sorry @tianming-1996, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts the text editor’s context menu logic so that the 'voice reading' action is disabled when the TTS service or audio output device is unavailable, fixing inconsistent enablement behavior when uos-ai is killed or no audio device is detected. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
The "Text to Speech" right-click menu item enablement logic had a mismatch between the normal path and the error-handling paths in TextEdit::popRightMenu(). The normal path checks hasSelection(), but both the DBus-failure branch and the no-audio-device branch bypassed this check, unconditionally calling setEnabled(true) — so the menu stayed enabled even with no text selected. The fix preserves the text-selection check in the error branches: when DBus fails or no audio device is present, the action is only enabled if the user has actually selected text (or has a column selection). slotVoiceReadingAction() already handles the unavailable service gracefully with a user-facing message. Log: 修复杀掉uos ai进程后,未选中文字时右键菜单"语音朗读"未置灰的问题 Bug: https://pms.uniontech.com/bug-view-372251.html
806d54b to
d2f1d65
Compare
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 - m_voiceReadingAction->setEnabled(true);
+ m_voiceReadingAction->setEnabled(textCursor().hasSelection() || m_hasColumnSelection); |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: max-lvs, tianming-1996 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 |
|
/merge |
Bug
https://pms.uniontech.com/bug-view-372251.html
问题现象
杀掉 uos-ai 进程后,文本编辑器未选中文字时右键菜单"语音朗读"未置灰,仍可点击。
根因
TextEdit::popRightMenu()中,当 DBus 调用com.iflytek.aiassistant的getTTSEnable失败时(uos-ai 进程被杀,服务消失),错误处理分支直接m_voiceReadingAction->setEnabled(true),跳过了文字选中状态检查,导致"语音朗读"菜单项在未选中文字时仍可点击。正常路径会检查
textCursor().hasSelection() && voiceReadingState,但 DBus 失败分支和无音频设备分支均无条件setEnabled(true),逻辑不一致。修复
将 DBus 失败分支和无音频设备分支的
setEnabled(true)改为setEnabled(false):服务不可用或无音频设备时,"语音朗读"功能无法工作,菜单项应置灰。Summary by Sourcery
Bug Fixes: