From 448fc1e89a8328c08ce1fd61bc3d52baa711ad6a 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, 31 Jul 2024 00:49:59 +0800 Subject: [PATCH] good --- .../LunaTranslator/rendertext/textbrowser.py | 22 ++++++++++++++++--- plugins/CMakeLists.txt | 4 ++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/LunaTranslator/LunaTranslator/rendertext/textbrowser.py b/LunaTranslator/LunaTranslator/rendertext/textbrowser.py index cd2b134e..b8c416ba 100644 --- a/LunaTranslator/LunaTranslator/rendertext/textbrowser.py +++ b/LunaTranslator/LunaTranslator/rendertext/textbrowser.py @@ -33,10 +33,14 @@ class Qlabel_c(QLabel): return super().mouseReleaseEvent(event) def enterEvent(self, a0) -> None: + if self.company: + self.company.setStyleSheet("background-color: rgba(0,0,0,0.5);") self.setStyleSheet("background-color: rgba(0,0,0,0.5);") return super().enterEvent(a0) def leaveEvent(self, a0) -> None: + if self.company: + self.company.setStyleSheet("background-color: rgba(0,0,0,0.01);") self.setStyleSheet("background-color: rgba(0,0,0,0.01);") return super().leaveEvent(a0) @@ -345,13 +349,16 @@ class TextBrowser(QWidget, dataget): if newtag[-1]["orig"] == newtag[-1]["hira"]: newtag[-1].update({"orig_X": sub, "hira": sub}) _tag = newtag[-1].copy() - _tag.update({"orig_X": end, "hira": end}) + _tag.update({"orig_X": end, "hira": end, "ref": True}) newtag.append({"orig_X": "\n", "orig": "\n", "hira": ""}) newtag.append(_tag) else: - newtag[-1].update({"orig_X": sub}) + hiras = [newtag[-1]["hira"], ""] + if len(sub) > len(end): + hiras = reversed(hiras) + newtag[-1].update({"orig_X": sub, "hira": hiras[0]}) _tag = newtag[-1].copy() - _tag.update({"orig_X": end}) + _tag.update({"orig_X": end, "hira": hiras[1], "ref": True}) newtag.append({"orig_X": "\n", "orig": "\n", "hira": ""}) newtag.append(_tag) else: @@ -601,6 +608,15 @@ class TextBrowser(QWidget, dataget): self._add_searchlabel( isfenciclick, isshow_fenci, labeli, pos1, callback, word, color ) + if word.get("ref", False): + self.searchmasklabels_clicked[labeli - 1].company = ( + self.searchmasklabels_clicked[labeli] + ) + self.searchmasklabels_clicked[labeli].company = ( + self.searchmasklabels_clicked[labeli - 1] + ) + else: + self.searchmasklabels_clicked[labeli].company = None labeli += 1 def _getfh(self, half, origin=True, getfm=False): diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 190e55f8..a69fbf6c 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -28,8 +28,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/version) include(generate_product_version) set(VERSION_MAJOR 5) -set(VERSION_MINOR 16) -set(VERSION_PATCH 7) +set(VERSION_MINOR 18) +set(VERSION_PATCH 0) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)