diff --git a/other/05_开发软件系统实践的汇报.pptx b/other/05_开发软件系统实践的汇报.pptx index bcd55cc..f8e990b 100644 Binary files a/other/05_开发软件系统实践的汇报.pptx and b/other/05_开发软件系统实践的汇报.pptx differ diff --git a/src/.idea/sonarlint/issuestore/2/d/2dcb75368db4cdc946a90104b4c7a65a3955cace b/src/.idea/sonarlint/issuestore/2/d/2dcb75368db4cdc946a90104b4c7a65a3955cace new file mode 100644 index 0000000..e69de29 diff --git a/src/.idea/sonarlint/issuestore/4/a/4a5fd090163cbe3d1c0f7f31e3d83cb85bede47d b/src/.idea/sonarlint/issuestore/4/a/4a5fd090163cbe3d1c0f7f31e3d83cb85bede47d new file mode 100644 index 0000000..efea462 --- /dev/null +++ b/src/.idea/sonarlint/issuestore/4/a/4a5fd090163cbe3d1c0f7f31e3d83cb85bede47d @@ -0,0 +1,3 @@ + +B python:S125*"Remove this commented out code.(˂8߫1 +r python:S117<"TRename this parameter "shotArea" to match the regular expression ^[_a-z][a-z0-9_]*$.(ީ8߫1 \ No newline at end of file diff --git a/src/.idea/sonarlint/issuestore/5/2/52ad1f28b8aa7c700b52cb65eb608df167a94ce6 b/src/.idea/sonarlint/issuestore/5/2/52ad1f28b8aa7c700b52cb65eb608df167a94ce6 index cbe82ae..9ac2ef0 100644 --- a/src/.idea/sonarlint/issuestore/5/2/52ad1f28b8aa7c700b52cb65eb608df167a94ce6 +++ b/src/.idea/sonarlint/issuestore/5/2/52ad1f28b8aa7c700b52cb65eb608df167a94ce6 @@ -1,2 +1,2 @@ -i python:S3457{"EAdd replacement fields or use a normal string instead of an f-string.(8᫹Ľ1 \ No newline at end of file +i python:S3457y"EAdd replacement fields or use a normal string instead of an f-string.(8Ž1 \ No newline at end of file diff --git a/src/.idea/sonarlint/issuestore/5/a/5a86cbad9020f564c5aad1242d2920c3cc3c46ca b/src/.idea/sonarlint/issuestore/5/a/5a86cbad9020f564c5aad1242d2920c3cc3c46ca index 47a4fb5..6c43c3a 100644 --- a/src/.idea/sonarlint/issuestore/5/a/5a86cbad9020f564c5aad1242d2920c3cc3c46ca +++ b/src/.idea/sonarlint/issuestore/5/a/5a86cbad9020f564c5aad1242d2920c3cc3c46ca @@ -1,6 +1,5 @@ -r python:S117"TRename this parameter "shotArea" to match the regular expression ^[_a-z][a-z0-9_]*$.(8Ľ1 -O python:S5806'"+Rename this variable; it shadows a builtin.(8Ľ1 -s python:S3776_"TRefactor this function to reduce its Cognitive Complexity from 27 to the 15 allowed.(8Ľ1 -< python:S125{"Remove this commented out code.(Ԁ8Ľ1 -C python:S125"Remove this commented out code.(8Ľ1 \ No newline at end of file +w python:S117"TRename this parameter "shotArea" to match the regular expression ^[_a-z][a-z0-9_]*$.(͠8߽ܰ1 +O python:S5806%"+Rename this variable; it shadows a builtin.(8Ĩ1 +s python:S3776]"TRefactor this function to reduce its Cognitive Complexity from 29 to the 15 allowed.(8ݰ߽1 +< python:S125y"Remove this commented out code.(Ԁ8ݰ߽1 \ No newline at end of file diff --git a/src/.idea/sonarlint/issuestore/index.pb b/src/.idea/sonarlint/issuestore/index.pb index 75e5360..956539e 100644 --- a/src/.idea/sonarlint/issuestore/index.pb +++ b/src/.idea/sonarlint/issuestore/index.pb @@ -38,4 +38,8 @@ V V &windows/control/database/sqdatabase.py,7\2\722c726e3ef8e8d6b9d762f20b7a983b977eadde [ -+windows/control/controltools/setShotArea.py,7\0\70b7ed00111901bd538e0f738417c6516e0761d8 \ No newline at end of file ++windows/control/controltools/setShotArea.py,7\0\70b7ed00111901bd538e0f738417c6516e0761d8 +N +windows/res/tools/translate.py,2\d\2dcb75368db4cdc946a90104b4c7a65a3955cace +? +windows/test.py,4\a\4a5fd090163cbe3d1c0f7f31e3d83cb85bede47d \ No newline at end of file diff --git a/src/.idea/sonarlint/securityhotspotstore/2/d/2dcb75368db4cdc946a90104b4c7a65a3955cace b/src/.idea/sonarlint/securityhotspotstore/2/d/2dcb75368db4cdc946a90104b4c7a65a3955cace new file mode 100644 index 0000000..e69de29 diff --git a/src/.idea/sonarlint/securityhotspotstore/4/a/4a5fd090163cbe3d1c0f7f31e3d83cb85bede47d b/src/.idea/sonarlint/securityhotspotstore/4/a/4a5fd090163cbe3d1c0f7f31e3d83cb85bede47d new file mode 100644 index 0000000..e69de29 diff --git a/src/.idea/sonarlint/securityhotspotstore/index.pb b/src/.idea/sonarlint/securityhotspotstore/index.pb index 75e5360..956539e 100644 --- a/src/.idea/sonarlint/securityhotspotstore/index.pb +++ b/src/.idea/sonarlint/securityhotspotstore/index.pb @@ -38,4 +38,8 @@ V V &windows/control/database/sqdatabase.py,7\2\722c726e3ef8e8d6b9d762f20b7a983b977eadde [ -+windows/control/controltools/setShotArea.py,7\0\70b7ed00111901bd538e0f738417c6516e0761d8 \ No newline at end of file ++windows/control/controltools/setShotArea.py,7\0\70b7ed00111901bd538e0f738417c6516e0761d8 +N +windows/res/tools/translate.py,2\d\2dcb75368db4cdc946a90104b4c7a65a3955cace +? +windows/test.py,4\a\4a5fd090163cbe3d1c0f7f31e3d83cb85bede47d \ No newline at end of file diff --git a/src/windows/control/controltools/__pycache__/regPictrue.cpython-311.pyc b/src/windows/control/controltools/__pycache__/regPictrue.cpython-311.pyc index 96fc30a..a3ec3ad 100644 Binary files a/src/windows/control/controltools/__pycache__/regPictrue.cpython-311.pyc and b/src/windows/control/controltools/__pycache__/regPictrue.cpython-311.pyc differ diff --git a/src/windows/control/controltools/regPictrue.py b/src/windows/control/controltools/regPictrue.py index 3b40814..e7d39ff 100644 --- a/src/windows/control/controltools/regPictrue.py +++ b/src/windows/control/controltools/regPictrue.py @@ -1,7 +1,6 @@ import hashlib import json import random -import time from _md5 import md5 from time import sleep @@ -18,15 +17,14 @@ class RegPictrue(QThread): translate_words = pyqtSignal(str) translate_language = pyqtSignal(str) - def __init__(self, shotArea, window): + def __init__(self, shotArea, language): super(RegPictrue, self).__init__() self.shotArea = shotArea self.ocr = PaddleOCR(use_angle_cls=False, det_db='ch_ppocr_server_v2.0_det_infer') - self.translate_window = window self.isOpen = True self.last_words = '' - self.language = 'zh' + self.language = language self.useTrans = 0 # 百度翻译 @@ -112,25 +110,23 @@ class RegPictrue(QThread): res = ''.join(idx[1][0]) # print(res, "\n") orgwords += res - self.org_words.emit(orgwords) - - + # self.org_words.emit(orgwords) + if orgwords != '': + self.org_words.emit(orgwords) + sleep(0.01) # 设置源语言和目标语言 from_language = 'auto' # 自动检测语言 to_language = self.getLanguage() # 翻译成各种语言 - print(to_language) if orgwords != self.last_words: # # 记录代码开始执行的时间 # start_time = time.time() # 调用翻译函数并输出结果 if self.useTrans == 0: - translated_text = self.translate_text_baidu(text=orgwords, from_lang=from_language, - to_lang=to) + to_lang=to_language) if translated_text == '翻译失败': - # self.useTrans += 1 - pass + self.useTrans += 1 elif self.useTrans == 1: translated_text = self.translate_text_jinshan(orgwords, from_language, to_language) if translated_text == '翻译失败': @@ -138,10 +134,10 @@ class RegPictrue(QThread): elif self.useTrans == 2: translated_text = self.translate_text_xiaoniu(orgwords, from_language, to_language) if translated_text == '翻译失败': - self.useTrans = 1 + self.useTrans = 0 else: translated_text = '翻译失败' - self.useTrans = 1 + self.useTrans = 0 self.translate_words.emit(translated_text) @@ -153,7 +149,7 @@ class RegPictrue(QThread): # print(f"代码执行时间:{execution_time}秒") self.last_words = orgwords - sleep(0.1) + sleep(0.01) def setLanguage(self, language): self.language = language diff --git a/src/windows/main_window.py b/src/windows/main_window.py index 7d27a35..f8941cc 100644 --- a/src/windows/main_window.py +++ b/src/windows/main_window.py @@ -1,4 +1,3 @@ - import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QListWidget, QListWidgetItem, QComboBox from PyQt5.QtCore import Qt @@ -16,6 +15,7 @@ from windows.res.tools.auto_game import autogame class MyApp(QMainWindow): + def __init__(self): super(QMainWindow, self).__init__() @@ -27,7 +27,7 @@ class MyApp(QMainWindow): self.shotArea = None # 默认识别区域 self.regPicture = None self.translate_state = False - self.select_language = '' + self.select_language = 'zh' self.translate_window = translate() self.setRule_window = settingrule(self) @@ -58,8 +58,6 @@ class MyApp(QMainWindow): self.listIndexs = self.get_item_indexs(self.ruleList) self.add_listitem() self.orgshow = True - self.transshow = True - def startgame(self, orderlist): # genrule_count = orderlist.count() # 获取 QListWidget 中的列表项数量 @@ -137,7 +135,6 @@ class MyApp(QMainWindow): self.ruleList.addItem(item) # self.ruleList.addItem('name') - def showTransText(self): window = tk.Tk() text = 'null' @@ -151,7 +148,6 @@ class MyApp(QMainWindow): self.shotArea = shot.setShotArea() def show_translate_window(self, index): - self.showMinimized() self.change_translate_state() # 结束翻译 if self.translate_state is False: @@ -164,10 +160,13 @@ class MyApp(QMainWindow): self.translate_window.show() # 调用截屏功能时 if self.shotArea is not None: - self.regPicture = RegPictrue(self.shotArea, self.translate_window) - self.regPicture.setLanguage(self.select_language) + self.regPicture = None + + self.regPicture = RegPictrue(self.shotArea, self.select_language) + self.regPicture.org_words.connect(self.orgWords) self.regPicture.translate_words.connect(self.translate_words) + self.regPicture.start() def orgWords(self, owords): @@ -177,14 +176,14 @@ class MyApp(QMainWindow): self.orgshow = True def translate_words(self, twords): - if self.transshow: - self.transshow = False + if self.orgshow: + self.orgshow = False self.translate_window.transwords.setText(twords) - self.transshow = True + self.orgshow = True def selectTransLanguage(self, index): # 各种语言选项的返回值 selected_language = self.language.itemText(index) - self.regPicture = RegPictrue(self.shotArea, self.translate_window) + if selected_language == "日语": self.select_language = "ja" elif selected_language == "法语":