|
|
|
|
@ -10,7 +10,7 @@ from PyQt5.QtCore import Qt, QThread, pyqtSignal, QTimer, QRect, QByteArray, QBu
|
|
|
|
|
from PyQt5.QtGui import QFont, QPalette, QColor, QIcon, QPixmap, QTextCharFormat, QTextCursor, QTextDocument, QImage, QTextImageFormat, QTextFormat
|
|
|
|
|
|
|
|
|
|
from ui.word_style_ui import (WordRibbon, WordStatusBar, WordTextEdit,
|
|
|
|
|
WordStyleToolBar)
|
|
|
|
|
)
|
|
|
|
|
from services.network_service import NetworkService
|
|
|
|
|
from typing_logic import TypingLogic
|
|
|
|
|
from ui.word_style_ui import WeatherAPI
|
|
|
|
|
@ -213,10 +213,6 @@ class WordStyleMainWindow(QMainWindow):
|
|
|
|
|
# 创建菜单栏
|
|
|
|
|
self.create_menu_bar()
|
|
|
|
|
|
|
|
|
|
# 创建快速访问工具栏
|
|
|
|
|
self.quick_toolbar = WordStyleToolBar()
|
|
|
|
|
self.addToolBar(Qt.TopToolBarArea, self.quick_toolbar)
|
|
|
|
|
|
|
|
|
|
# 创建Ribbon功能区
|
|
|
|
|
self.ribbon = WordRibbon()
|
|
|
|
|
|
|
|
|
|
@ -646,15 +642,21 @@ class WordStyleMainWindow(QMainWindow):
|
|
|
|
|
cursor.movePosition(cursor.End)
|
|
|
|
|
self.text_edit.setTextCursor(cursor)
|
|
|
|
|
|
|
|
|
|
# 更新打字逻辑(只检查已显示的部分)
|
|
|
|
|
# 更新打字逻辑(支持中文整词匹配)
|
|
|
|
|
if display_text:
|
|
|
|
|
result = self.typing_logic.check_input(display_text)
|
|
|
|
|
self.typing_logic.update_position(display_text)
|
|
|
|
|
|
|
|
|
|
# 错误处理
|
|
|
|
|
# 错误处理(支持中文整词显示)
|
|
|
|
|
if not result['correct'] and display_text:
|
|
|
|
|
expected_char = result.get('expected', '')
|
|
|
|
|
self.status_bar.showMessage(f"输入错误,期望字符: '{expected_char}'", 2000)
|
|
|
|
|
# 如果是中文文本,显示更友好的错误信息
|
|
|
|
|
if self.typing_logic._is_chinese_char(expected_char):
|
|
|
|
|
# 获取期望的中文词组
|
|
|
|
|
expected_word = self.typing_logic._get_chinese_word_at(result['position'])
|
|
|
|
|
self.status_bar.showMessage(f"输入错误,期望词组: '{expected_word}'", 3000)
|
|
|
|
|
else:
|
|
|
|
|
self.status_bar.showMessage(f"输入错误,期望字符: '{expected_char}'", 2000)
|
|
|
|
|
self.highlight_next_char(result['position'], expected_char)
|
|
|
|
|
|
|
|
|
|
# 更新统计信息
|
|
|
|
|
@ -747,10 +749,16 @@ class WordStyleMainWindow(QMainWindow):
|
|
|
|
|
result = self.typing_logic.check_input(current_text)
|
|
|
|
|
self.typing_logic.update_position(current_text)
|
|
|
|
|
|
|
|
|
|
# 错误处理
|
|
|
|
|
# 错误处理(支持中文整词显示)
|
|
|
|
|
if not result['correct']:
|
|
|
|
|
expected_char = result.get('expected', '')
|
|
|
|
|
self.status_bar.showMessage(f"输入错误,期望字符: '{expected_char}'", 2000)
|
|
|
|
|
# 如果是中文文本,显示更友好的错误信息
|
|
|
|
|
if self.typing_logic._is_chinese_char(expected_char):
|
|
|
|
|
# 获取期望的中文词组
|
|
|
|
|
expected_word = self.typing_logic._get_chinese_word_at(result['position'])
|
|
|
|
|
self.status_bar.showMessage(f"输入错误,期望词组: '{expected_word}'", 3000)
|
|
|
|
|
else:
|
|
|
|
|
self.status_bar.showMessage(f"输入错误,期望字符: '{expected_char}'", 2000)
|
|
|
|
|
self.highlight_next_char(result['position'], expected_char)
|
|
|
|
|
|
|
|
|
|
# 更新统计信息
|
|
|
|
|
@ -766,10 +774,16 @@ class WordStyleMainWindow(QMainWindow):
|
|
|
|
|
result = self.typing_logic.check_input(current_text)
|
|
|
|
|
self.typing_logic.update_position(current_text)
|
|
|
|
|
|
|
|
|
|
# 错误处理
|
|
|
|
|
# 错误处理(支持中文整词显示)
|
|
|
|
|
if not result['correct']:
|
|
|
|
|
expected_char = result.get('expected', '')
|
|
|
|
|
self.status_bar.showMessage(f"输入错误,期望字符: '{expected_char}'", 2000)
|
|
|
|
|
# 如果是中文文本,显示更友好的错误信息
|
|
|
|
|
if self.typing_logic._is_chinese_char(expected_char):
|
|
|
|
|
# 获取期望的中文词组
|
|
|
|
|
expected_word = self.typing_logic._get_chinese_word_at(result['position'])
|
|
|
|
|
self.status_bar.showMessage(f"输入错误,期望词组: '{expected_word}'", 3000)
|
|
|
|
|
else:
|
|
|
|
|
self.status_bar.showMessage(f"输入错误,期望字符: '{expected_char}'", 2000)
|
|
|
|
|
self.highlight_next_char(result['position'], expected_char)
|
|
|
|
|
|
|
|
|
|
# 更新统计信息
|
|
|
|
|
@ -842,10 +856,16 @@ class WordStyleMainWindow(QMainWindow):
|
|
|
|
|
result = self.typing_logic.check_input(display_text)
|
|
|
|
|
self.typing_logic.update_position(display_text)
|
|
|
|
|
|
|
|
|
|
# 错误处理
|
|
|
|
|
# 错误处理(支持中文整词显示)
|
|
|
|
|
if not result['correct'] and display_text:
|
|
|
|
|
expected_char = result.get('expected', '')
|
|
|
|
|
self.status_bar.showMessage(f"输入错误,期望字符: '{expected_char}'", 2000)
|
|
|
|
|
# 如果是中文文本,显示更友好的错误信息
|
|
|
|
|
if self.typing_logic._is_chinese_char(expected_char):
|
|
|
|
|
# 获取期望的中文词组
|
|
|
|
|
expected_word = self.typing_logic._get_chinese_word_at(result['position'])
|
|
|
|
|
self.status_bar.showMessage(f"输入错误,期望词组: '{expected_word}'", 3000)
|
|
|
|
|
else:
|
|
|
|
|
self.status_bar.showMessage(f"输入错误,期望字符: '{expected_char}'", 2000)
|
|
|
|
|
self.highlight_next_char(result['position'], expected_char)
|
|
|
|
|
|
|
|
|
|
# 更新统计信息
|
|
|
|
|
|