From aa6b2140dedf9d6dbd3620b2e40ad0c803372c78 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: Tue, 7 May 2024 16:44:22 +0800 Subject: [PATCH] issues/723 --- .../LunaTranslator/gui/textbrowser.py | 25 +++++-------------- .../LunaTranslator/gui/translatorUI.py | 7 ++++-- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/textbrowser.py b/LunaTranslator/LunaTranslator/gui/textbrowser.py index 9673d503..15bc16c9 100644 --- a/LunaTranslator/LunaTranslator/gui/textbrowser.py +++ b/LunaTranslator/LunaTranslator/gui/textbrowser.py @@ -105,21 +105,15 @@ class Textbrowser: self.toplabel.setMouseTracking(True) self.textbrowser.setStyleSheet( "border-width: 0;\ - border-style: outset;\ - border-top: 0px solid #e8f3f9;\ - color: white;\ - \ - background-color: rgba(%s, %s, %s, %s)" - % (0, 0, 0, 0) + border-style: outset;\ + color: rgba(0, 0, 0, 0);\ + background-color: rgba(0, 0, 0, 0)" ) self.textbrowserback.setStyleSheet( "border-width: 0;\ - border-style: outset;\ - border-top: 0px solid #e8f3f9;\ - color: white;\ - \ - background-color: rgba(%s, %s, %s, %s)" - % (0, 0, 0, 0) + border-style: outset;\ + color: rgba(0, 0, 0, 0);\ + background-color: rgba(0, 0, 0, 0)" ) self.textcursor = self.textbrowser.textCursor() @@ -266,14 +260,7 @@ class Textbrowser: self.movep(0, self.savey) if globalconfig["zitiyangshi"] == 3: - self.textbrowser.show() - self.textbrowserback.show() self.showyinyingtext(color, b1, b2) - self.textbrowser.hide() - self.textbrowserback.hide() - else: - self.textbrowser.show() - self.textbrowserback.show() def getcurrpointer(self): return self.textcursor.position() diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 50770a50..c0b29cca 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -8,7 +8,7 @@ from traceback import print_exc from PyQt5.QtCore import Qt, pyqtSignal import qtawesome from PyQt5.QtCore import pyqtSignal, Qt, QSize -from PyQt5.QtGui import QCursor +from PyQt5.QtGui import QCursor, QColor from PyQt5.QtWidgets import QLabel, QPushButton, QSystemTrayIcon import gobject from myutils.wrapper import threader, trypass @@ -219,7 +219,10 @@ class QUnFrameWindow(resizableframeless): elif globalconfig["zitiyangshi"] == 0: self.translate_text.simplecharformat(color) elif globalconfig["zitiyangshi"] == 3: - self.translate_text.simplecharformat(color) + # hide后无法重新计算布局。设置和背景相同的颜色和alpha来模拟hide + c = QColor(globalconfig["backcolor"]) + c.setAlpha(globalconfig["transparent"] * (not self.backtransparent) / 100) + self.translate_text.simplecharformat(c) if iter_context: iter_res_status, iter_context_class = iter_context