From 7abc23f1710a7c61074fc86a7b4efdd3c540b3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Sun, 3 Nov 2024 23:33:55 +0800 Subject: [PATCH] autohide --- src/LunaTranslator/gui/translatorUI.py | 17 +++++++++++++---- src/plugins/CMakeLists.txt | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/LunaTranslator/gui/translatorUI.py b/src/LunaTranslator/gui/translatorUI.py index 40b5715f..649d2ca9 100644 --- a/src/LunaTranslator/gui/translatorUI.py +++ b/src/LunaTranslator/gui/translatorUI.py @@ -405,7 +405,7 @@ class TranslatorWindow(resizableframeless): iter_res_status = 0 if iter_res_status: self.translate_text.iter_append( - iter_context_class, origin, atcenter,name, text, color + iter_context_class, origin, atcenter, name, text, color ) else: self.translate_text.append( @@ -430,12 +430,21 @@ class TranslatorWindow(resizableframeless): @threader def autohidedelaythread(self): while True: + # 当鼠标悬停,或前景窗口为当前进程的其他窗口时,禁止自动隐藏 + if self.geometry().contains(QCursor.pos()) or ( + windows.GetForegroundWindow() != self.winid + and windows.GetWindowThreadProcessId(windows.GetForegroundWindow()) + == os.getpid() + ): + self.lastrefreshtime = time.time() + continue if globalconfig["autodisappear"] and self.autohidestart: - tnow = time.time() - if tnow - self.lastrefreshtime >= globalconfig["disappear_delay"]: + if ( + time.time() - self.lastrefreshtime + >= globalconfig["disappear_delay"] + ): self.hidesignal.emit() self.autohidestart = False - self.lastrefreshtime = tnow time.sleep(0.5) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 2bb48bdb..f43c7c9c 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -29,7 +29,7 @@ include(generate_product_version) set(VERSION_MAJOR 5) set(VERSION_MINOR 53) -set(VERSION_PATCH 12) +set(VERSION_PATCH 13) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)