fix: 长按 3s 立即复位 CapsLock,不等松开

CapsLock 语音输入流程调整为:
按下 CapsLock → 预录音 → 长按 3s → 立即复位 CapsLock → 正式录音 →
松开 → 停止录音 → 识别 → 注入文本

短按(< 3s)保持原有行为:模拟 CapsLock 切换大小写

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Alvin Young 2026-06-11 14:19:52 +08:00
parent cf44a23c57
commit 072a571a89
2 changed files with 8 additions and 8 deletions

View File

@ -45,6 +45,8 @@ VoiceInputService::VoiceInputService(ConfigManager* configManager,
// 长按超时仍未松开 → 确认为长按录音
if (!longPressDetected_) {
longPressDetected_ = true;
// 立即复位 CapsLock不等用户松开
simulateCapsLock();
emit statusChanged("正在录音...");
}
});
@ -150,9 +152,7 @@ void VoiceInputService::onHotkeyDeactivated() {
simulateCapsLock();
emit statusChanged("短按:切换 CapsLock");
} else {
// 长按 → 先恢复 CapsLock 状态,再开始识别
// 这样识别结果注入时 CapsLock 已恢复原始状态
simulateCapsLock();
// 长按 → CapsLock 已在长按阈值时复位,松开后直接开始识别
stopRecordingAndTranscribe();
}

View File

@ -19,10 +19,10 @@ class ConfigManager;
*
* STT
*
* 1.
* 2. 1
* 3.
* 4. < 1 CapsLock
* 1. CapsLock
* 2. 3s CapsLock
* 3. CapsLock
* 4. < CapsLock
*/
class VoiceInputService : public QObject {
Q_OBJECT
@ -44,7 +44,7 @@ public:
/** @brief 是否正在录音 */
bool isRecording() const { return recording_; }
/** @brief 长按阈值(毫秒),默认 1000ms */
/** @brief 长按阈值(毫秒),默认 3000ms */
void setLongPressThreshold(int ms) { longPressThreshold_ = ms; }
int longPressThreshold() const { return longPressThreshold_; }