From 8749a65520cd07deaca1c1cef2742f731f069650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:38:21 +0800 Subject: [PATCH] issues/639 --- LunaTranslator/LunaTranslator/gui/settin.py | 2 +- .../LunaTranslator/gui/translatorUI.py | 48 +++++++------------ LunaTranslator/LunaTranslator/windows.py | 1 - 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/settin.py b/LunaTranslator/LunaTranslator/gui/settin.py index da4b3045..a29cba43 100644 --- a/LunaTranslator/LunaTranslator/gui/settin.py +++ b/LunaTranslator/LunaTranslator/gui/settin.py @@ -147,7 +147,7 @@ class Settin(closeashidewindow): showAction = QAction( _TR("&显示"), self, - triggered=gobject.baseobject.translation_ui.show_and_enableautohide, + triggered=gobject.baseobject.translation_ui.show_, ) settingAction = QAction( _TR("&设置"), diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 5284e558..1d844053 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -50,19 +50,17 @@ class QUnFrameWindow(resizableframeless): if self._move_drag: return if code == 3: - if self.hideshownotauto: - self.show_() - try: - _h = windows.GetForegroundWindow() - _fpid = windows.GetWindowThreadProcessId(_h) - _hpid = windows.GetWindowThreadProcessId(other[0]) - if _fpid != _hpid: - windows.SetForegroundWindow(other[0]) - except: - pass + self.show_() + try: + _h = windows.GetForegroundWindow() + _fpid = windows.GetWindowThreadProcessId(_h) + _hpid = windows.GetWindowThreadProcessId(other[0]) + if _fpid != _hpid: + windows.SetForegroundWindow(other[0]) + except: + pass elif code == 4: - if self.hideshownotauto: - self.hide_() + self.hide_() elif code == 5: # print(self.pos()) # self.move(self.pos() + self._endPos)z @@ -283,13 +281,12 @@ class QUnFrameWindow(resizableframeless): self.translate_text.addsearchwordmask(hira, text, callback) if globalconfig["autodisappear"]: - if self.hideshownotauto: - flag = (self.showintab and self.isMinimized()) or ( - not self.showintab and self.isHidden() - ) + flag = (self.showintab and self.isMinimized()) or ( + not self.showintab and self.isHidden() + ) - if flag: - self.show_() + if flag: + self.show_() self.lastrefreshtime = time.time() self.autohidestart = True @@ -313,23 +310,15 @@ class QUnFrameWindow(resizableframeless): ) if flag: - self.show_and_enableautohide() + self.show_() else: - self.hide_and_disableautohide() + self.hide_() def leftclicktray(self, reason): # 鼠标左键点击 if reason == QSystemTrayIcon.Trigger: self.showhideui() - def hide_and_disableautohide(self): - self.hideshownotauto = False - self.hide_() - - def show_and_enableautohide(self): - self.hideshownotauto = True - self.show_() - def refreshtoolicon(self): iconstate = { @@ -491,7 +480,7 @@ class QUnFrameWindow(resizableframeless): ), ), ("ocr_once", self.ocr_once_signal.emit), - ("minmize", self.hide_and_disableautohide), + ("minmize", self.hide_), ("quit", self.close), ) adjast = {"minmize": -2, "quit": -1} @@ -613,7 +602,6 @@ class QUnFrameWindow(resizableframeless): self.muteprocessignal.connect(self.muteprocessfuntion) self.toolbarhidedelaysignal.connect(self.toolbarhidedelay) - self.hideshownotauto = True self.ocr_once_signal.connect(self.ocr_once_function) self.entersignal.connect(self.enterfunction) self.displaystatus.connect(self.showstatus) diff --git a/LunaTranslator/LunaTranslator/windows.py b/LunaTranslator/LunaTranslator/windows.py index 614724ab..168330a3 100644 --- a/LunaTranslator/LunaTranslator/windows.py +++ b/LunaTranslator/LunaTranslator/windows.py @@ -51,7 +51,6 @@ STARTF_USESHOWWINDOW = 1 SW_SHOWMINIMIZED = 2 SW_SHOWMAXIMIZED = 3 SW_MAXIMIZE = 3 -SW_SHOWNOACTIVATE = 4 EVENT_SYSTEM_MINIMIZESTART = 22 EVENT_SYSTEM_MINIMIZEEND = 23