diff --git a/LunaTranslator/LunaTranslator/rendertext/textbrowser.py b/LunaTranslator/LunaTranslator/rendertext/textbrowser.py index 6d8c4482..1e3cd17e 100644 --- a/LunaTranslator/LunaTranslator/rendertext/textbrowser.py +++ b/LunaTranslator/LunaTranslator/rendertext/textbrowser.py @@ -465,9 +465,9 @@ class TextBrowser(QWidget, dataget): def _showyinyingtext2(self, color, iter_context_class, pos, text, font): if iter_context_class not in self.iteryinyinglabelsave: self.iteryinyinglabelsave[iter_context_class] = [] - for label in self.iteryinyinglabelsave[iter_context_class]: label.hide() + maxh = self.maxvisheight subtext = [] subpos = [] @@ -486,20 +486,37 @@ class TextBrowser(QWidget, dataget): if text[i] != "\n": subtext[-1] += text[i] - + used = set() collects = [] for i in range(len(subtext)): - if i >= len(self.iteryinyinglabelsave[iter_context_class]): - self.iteryinyinglabelsave[iter_context_class].append( - self.currentclass(self.toplabel2) - ) - _ = self.iteryinyinglabelsave[iter_context_class][i] - _.setColor(color) - _.setText(subtext[i]) - _.setFont(font) - _.adjustSize() - _.move(subpos[i].x(), subpos[i].y() + self.labeloffset_y) - _.show() + + finded = -1 + for j in range(len(self.iteryinyinglabelsave[iter_context_class])): + if j in used: + continue + if ( + self.iteryinyinglabelsave[iter_context_class][j].text() + == subtext[i] + ): + finded = j + used.add(j) + break + if finded >= 0: + _ = self.iteryinyinglabelsave[iter_context_class][finded] + _.move(subpos[i].x(), subpos[i].y() + self.labeloffset_y) + _.show() + else: + if i >= len(self.iteryinyinglabelsave[iter_context_class]): + self.iteryinyinglabelsave[iter_context_class].append( + self.currentclass(self.toplabel2) + ) + _ = self.iteryinyinglabelsave[iter_context_class][i] + _.setColor(color) + _.setText(subtext[i]) + _.setFont(font) + _.adjustSize() + _.move(subpos[i].x(), subpos[i].y() + self.labeloffset_y) + _.show() self.textcursor.setPosition(pos) self.textbrowser.setTextCursor(self.textcursor) tl1 = self.textbrowser.cursorRect(self.textcursor).topLeft() diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index ecaa2fae..c3e47bdd 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -29,7 +29,7 @@ include(generate_product_version) set(VERSION_MAJOR 5) set(VERSION_MINOR 35) -set(VERSION_PATCH 5) +set(VERSION_PATCH 6) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)