From c6805dcce33f81e8e5cd61a5be0d50e92552b9c7 Mon Sep 17 00:00:00 2001
From: CBYellowstone <2844829687@qq.com>
Date: Sun, 24 Apr 2022 13:51:54 +0800
Subject: [PATCH] =?UTF-8?q?improve:=20=E7=AA=97=E4=BD=93=E5=A4=A7=E5=B0=8F?=
=?UTF-8?q?=E9=9A=8F=E7=BF=BB=E8=AF=91=E6=BA=90=E6=95=B0=E9=87=8F=E6=94=B9?=
=?UTF-8?q?=E5=8F=98;=20=E7=BF=BB=E8=AF=91=E6=BA=90=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E8=A6=81=E6=B1=82=E8=87=B3=E5=B0=91=E4=B8=80=E4=B8=AA;=20?=
=?UTF-8?q?=E7=BF=BB=E8=AF=91=E6=BA=90=E5=88=97=E8=A1=A8=E9=87=8D=E5=A4=8D?=
=?UTF-8?q?;?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
GUI.py | 23 ++++++++++++++++++-----
OCR_style.ui | 1 -
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/GUI.py b/GUI.py
index cfcd569..3c53fd6 100644
--- a/GUI.py
+++ b/GUI.py
@@ -79,6 +79,8 @@ def setupUi(self, Config):
Config.setWindowFlags(Qt.WindowType.WindowStaysOnTopHint)
def replaceWithCurrentConfig(self):
+ self.ListWidget_SelectableSource.clear()
+ self.ListWidget_SelectedSource.clear()
self.Label_ShortcutKeyText.setText(self.parent.Hotkey_OCR)
configDict = readConfig()
for each in self.LineEditMapping:
@@ -141,6 +143,9 @@ def cancelHotKey(self):
print('已取消更改热键')
def saveConfig(self):
+ if(not self.getCurrentSelectedTranslator()):
+ QtWidgets.QMessageBox.critical(self,"配置有误","至少选择一个翻译源!")
+ return
data = {each: self.LineEditMapping[each].text() for each in self.LineEditMapping}
data['SELECTED_TRANSLATORS'] = self.getCurrentSelectedTranslator()
data['Hotkey_OCR'] = self.Hotkey_OCR
@@ -251,6 +256,8 @@ def __init__(self):
self.selectionText = str()
self.OCRText = str()
self.setupUi(self)
+ self.defaultWidth, self.defaultHeight = self.width(), self.height()
+ self.defaultX, self.defaultY = self.geometry().x(), self.geometry().y()
self.OCRResultTextEdit.setPlainText('')
self.SplitMode = "sudachi"
self.Hotkey_OCR = self.ConfigDict['Hotkey_OCR']
@@ -321,7 +328,7 @@ def getScreenPos(self):
self.AreaInit = False
print('非法选区,请重选!')
QtWidgets.QMessageBox.critical(self,"非法选区","选区不合法,请重选!")
- self.OCRResultTextEdit.setPlaceholderText('')
+ if self.AreaInit: self.OCRResultTextEdit.setPlaceholderText('')
self.OCRButton.setEnabled(self.AreaInit)
self.OCRButtonPlus.setEnabled(self.AreaInit)
@@ -361,11 +368,17 @@ def updateResults(self):
def updateTranslatorList(self, _list:list):
self.TranslatorList = _list
print(f'当前翻译源为:{self.TranslatorList}')
- n = _list.__len__()
- if n < 4:
- (each.setEnabled(False) for each in self.resultTextEditList[n-4:])
+ [self.resultTextEditList[n].setPlaceholderText(eachTranslator) for n, eachTranslator in enumerate(self.TranslatorList)]
+ _len = _list.__len__()
+ if _len < 4:
+ [each.setVisible(False) for each in self.resultTextEditList[_len-4:]]
+ n = 80*(4-_list.__len__())
+ self.setFixedSize(self.defaultWidth, self.defaultHeight-n)
+ self.move(self.defaultX, self.defaultY+n)
else:
- (each.setEnabled(True) for each in self.resultTextEditList)
+ [each.setVisible(True) for each in self.resultTextEditList]
+ self.setFixedSize(self.defaultWidth, self.defaultHeight)
+ self.move(self.defaultX, self.defaultY)
def updateSplitMode(self, mode):
self.SplitMode = mode
diff --git a/OCR_style.ui b/OCR_style.ui
index 909388e..522fbe0 100644
--- a/OCR_style.ui
+++ b/OCR_style.ui
@@ -847,7 +847,6 @@
updateAutoTransBool(bool)
doAutoTrans()
updateSplitTextEdit()
- print()
updateOCRText()
getIntoHotKeyChangeMode()
confirmHotkey()