This commit is contained in:
恍兮惚兮 2024-05-29 09:07:52 +08:00
parent c8edc14c1d
commit 5a719d16e5
3 changed files with 19 additions and 18 deletions

View File

@ -106,11 +106,12 @@ class rangeadjust(Mainw):
if rect: if rect:
(x1, y1), (x2, y2) = rect (x1, y1), (x2, y2) = rect
self.show() self.show()
r = self.devicePixelRatioF()
self.setGeometry( self.setGeometry(
x1 - globalconfig["ocrrangewidth"], x1 - int(globalconfig["ocrrangewidth"] * r),
y1 - globalconfig["ocrrangewidth"], y1 - int(globalconfig["ocrrangewidth"] * r),
x2 - x1 + 2 * globalconfig["ocrrangewidth"], x2 - x1 + int(2 * globalconfig["ocrrangewidth"] * r),
y2 - y1 + 2 * globalconfig["ocrrangewidth"], y2 - y1 + int(2 * globalconfig["ocrrangewidth"] * r),
) )
self._rect = rect self._rect = rect
# 由于使用movewindow而非qt函数导致内部执行绪有问题。 # 由于使用movewindow而非qt函数导致内部执行绪有问题。

View File

@ -258,8 +258,8 @@ class QUnFrameWindow(resizableframeless):
self.translate_text.addsearchwordmask(hira, text, callback) self.translate_text.addsearchwordmask(hira, text, callback)
if globalconfig["autodisappear"]: if globalconfig["autodisappear"]:
flag = (globalconfig['showintab'] and self.isMinimized()) or ( flag = (globalconfig["showintab"] and self.isMinimized()) or (
not globalconfig['showintab'] and self.isHidden() not globalconfig["showintab"] and self.isHidden()
) )
if flag: if flag:
@ -282,8 +282,8 @@ class QUnFrameWindow(resizableframeless):
if self._move_drag: if self._move_drag:
return return
flag = (globalconfig['showintab'] and self.isMinimized()) or ( flag = (globalconfig["showintab"] and self.isMinimized()) or (
not globalconfig['showintab'] and self.isHidden() not globalconfig["showintab"] and self.isHidden()
) )
if flag: if flag:
@ -481,13 +481,13 @@ class QUnFrameWindow(resizableframeless):
) )
def hide_(self): def hide_(self):
if globalconfig['showintab']: if globalconfig["showintab"]:
windows.ShowWindow(int(self.winId()), windows.SW_SHOWMINIMIZED) windows.ShowWindow(int(self.winId()), windows.SW_SHOWMINIMIZED)
else: else:
self.hide() self.hide()
def show_(self): def show_(self):
if globalconfig['showintab']: if globalconfig["showintab"]:
windows.ShowWindow(int(self.winId()), windows.SW_SHOWNOACTIVATE) windows.ShowWindow(int(self.winId()), windows.SW_SHOWNOACTIVATE)
else: else:
self.show() self.show()
@ -933,9 +933,7 @@ class QUnFrameWindow(resizableframeless):
for button in self.showbuttons: for button in self.showbuttons:
button.show() button.show()
self._TitleLabel.show() self._TitleLabel.show()
self.set_color_transparency()
if globalconfig["locktools"]:
return
def __(s): def __(s):
c = QCursor() c = QCursor()
@ -946,7 +944,6 @@ class QUnFrameWindow(resizableframeless):
s.toolbarhidedelaysignal.emit() s.toolbarhidedelaysignal.emit()
threading.Thread(target=lambda: __(self)).start() threading.Thread(target=lambda: __(self)).start()
self.set_color_transparency()
def resizeEvent(self, e): def resizeEvent(self, e):
super().resizeEvent(e) super().resizeEvent(e)

View File

@ -2,7 +2,7 @@ import time
from myutils.config import globalconfig from myutils.config import globalconfig
import winsharedutils import winsharedutils
from gui.rangeselect import rangeadjust 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 import time, gobject, os
from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QImage from PyQt5.QtGui import QImage
@ -69,8 +69,12 @@ class ocrtext(basetext):
def showhiderangeui(self, b): def showhiderangeui(self, b):
for _ in self.range_ui: for _ in self.range_ui:
if _.getrect(): if b:
_.setVisible(b) _r = _.getrect()
if _r:
_.setrect(_r)
else:
_.hide()
def gettextthread(self): def gettextthread(self):
if all([_.getrect() is None for _ in self.range_ui]): if all([_.getrect() is None for _ in self.range_ui]):
@ -163,7 +167,6 @@ class ocrtext(basetext):
__text.append(text) __text.append(text)
return "\n".join(__text) return "\n".join(__text)
def end(self): def end(self):
globalconfig["ocrregions"] = [_.getrect() for _ in self.range_ui] globalconfig["ocrregions"] = [_.getrect() for _ in self.range_ui]
[_.close() for _ in self.range_ui] [_.close() for _ in self.range_ui]