diff --git a/LunaTranslator/LunaTranslator/gui/rangeselect.py b/LunaTranslator/LunaTranslator/gui/rangeselect.py index c4963b1c..80331b2c 100644 --- a/LunaTranslator/LunaTranslator/gui/rangeselect.py +++ b/LunaTranslator/LunaTranslator/gui/rangeselect.py @@ -106,11 +106,12 @@ class rangeadjust(Mainw): if rect: (x1, y1), (x2, y2) = rect self.show() + r = self.devicePixelRatioF() self.setGeometry( - x1 - globalconfig["ocrrangewidth"], - y1 - globalconfig["ocrrangewidth"], - x2 - x1 + 2 * globalconfig["ocrrangewidth"], - y2 - y1 + 2 * globalconfig["ocrrangewidth"], + x1 - int(globalconfig["ocrrangewidth"] * r), + y1 - int(globalconfig["ocrrangewidth"] * r), + x2 - x1 + int(2 * globalconfig["ocrrangewidth"] * r), + y2 - y1 + int(2 * globalconfig["ocrrangewidth"] * r), ) self._rect = rect # 由于使用movewindow而非qt函数,导致内部执行绪有问题。 diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 056158d1..7af19f87 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -258,8 +258,8 @@ class QUnFrameWindow(resizableframeless): self.translate_text.addsearchwordmask(hira, text, callback) if globalconfig["autodisappear"]: - flag = (globalconfig['showintab'] and self.isMinimized()) or ( - not globalconfig['showintab'] and self.isHidden() + flag = (globalconfig["showintab"] and self.isMinimized()) or ( + not globalconfig["showintab"] and self.isHidden() ) if flag: @@ -282,8 +282,8 @@ class QUnFrameWindow(resizableframeless): if self._move_drag: return - flag = (globalconfig['showintab'] and self.isMinimized()) or ( - not globalconfig['showintab'] and self.isHidden() + flag = (globalconfig["showintab"] and self.isMinimized()) or ( + not globalconfig["showintab"] and self.isHidden() ) if flag: @@ -481,13 +481,13 @@ class QUnFrameWindow(resizableframeless): ) def hide_(self): - if globalconfig['showintab']: + if globalconfig["showintab"]: windows.ShowWindow(int(self.winId()), windows.SW_SHOWMINIMIZED) else: self.hide() def show_(self): - if globalconfig['showintab']: + if globalconfig["showintab"]: windows.ShowWindow(int(self.winId()), windows.SW_SHOWNOACTIVATE) else: self.show() @@ -933,9 +933,7 @@ class QUnFrameWindow(resizableframeless): for button in self.showbuttons: button.show() self._TitleLabel.show() - - if globalconfig["locktools"]: - return + self.set_color_transparency() def __(s): c = QCursor() @@ -946,7 +944,6 @@ class QUnFrameWindow(resizableframeless): s.toolbarhidedelaysignal.emit() threading.Thread(target=lambda: __(self)).start() - self.set_color_transparency() def resizeEvent(self, e): super().resizeEvent(e) diff --git a/LunaTranslator/LunaTranslator/textsource/ocrtext.py b/LunaTranslator/LunaTranslator/textsource/ocrtext.py index 73a867fd..7c51cd3b 100644 --- a/LunaTranslator/LunaTranslator/textsource/ocrtext.py +++ b/LunaTranslator/LunaTranslator/textsource/ocrtext.py @@ -2,7 +2,7 @@ import time from myutils.config import globalconfig import winsharedutils from gui.rangeselect import rangeadjust -from myutils.ocrutil import imageCut, ocr_run, ocr_end,qimage2binary +from myutils.ocrutil import imageCut, ocr_run, ocr_end, qimage2binary import time, gobject, os from PyQt5.QtWidgets import QApplication from PyQt5.QtGui import QImage @@ -69,8 +69,12 @@ class ocrtext(basetext): def showhiderangeui(self, b): for _ in self.range_ui: - if _.getrect(): - _.setVisible(b) + if b: + _r = _.getrect() + if _r: + _.setrect(_r) + else: + _.hide() def gettextthread(self): if all([_.getrect() is None for _ in self.range_ui]): @@ -163,7 +167,6 @@ class ocrtext(basetext): __text.append(text) return "\n".join(__text) - def end(self): globalconfig["ocrregions"] = [_.getrect() for _ in self.range_ui] [_.close() for _ in self.range_ui]