From 9b7cc6b173b7895675e663ee7c64e6980694c80d 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: Mon, 13 May 2024 15:26:48 +0800 Subject: [PATCH] yuan --- .../gui/settingpage_xianshishezhi.py | 7 ++ .../LunaTranslator/gui/translatorUI.py | 101 +++++++++++------- .../files/defaultconfig/config.json | 1 + LunaTranslator/files/lang/ar.json | 6 +- LunaTranslator/files/lang/cht.json | 6 +- LunaTranslator/files/lang/en.json | 6 +- LunaTranslator/files/lang/es.json | 6 +- LunaTranslator/files/lang/fr.json | 6 +- LunaTranslator/files/lang/it.json | 6 +- LunaTranslator/files/lang/ja.json | 6 +- LunaTranslator/files/lang/ko.json | 6 +- LunaTranslator/files/lang/pl.json | 6 +- LunaTranslator/files/lang/ru.json | 6 +- LunaTranslator/files/lang/th.json | 6 +- LunaTranslator/files/lang/tr.json | 6 +- LunaTranslator/files/lang/uk.json | 6 +- LunaTranslator/files/lang/vi.json | 6 +- LunaTranslator/files/lang/zh.json | 4 +- 18 files changed, 131 insertions(+), 66 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/settingpage_xianshishezhi.py b/LunaTranslator/LunaTranslator/gui/settingpage_xianshishezhi.py index 41c6648a..9860593f 100644 --- a/LunaTranslator/LunaTranslator/gui/settingpage_xianshishezhi.py +++ b/LunaTranslator/LunaTranslator/gui/settingpage_xianshishezhi.py @@ -460,6 +460,13 @@ def setTabThree_lazy(self): ), 2, ), + "", + ("圆角_合并", 4), + getsimpleswitch( + globalconfig, + "yuanjiao_merge", + callback=lambda _: gobject.baseobject.translation_ui.set_color_transparency(), + ), ], [], [ diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 3d5bd0ce..8dceb263 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -682,31 +682,67 @@ class QUnFrameWindow(resizableframeless): self.refreshtoolicon() self.thistimenotsetop = False + def createborderradiusstring(self, r, merge, top=False): + if merge: + if top: + return """ + border-top-left-radius: %spx; + border-top-right-radius: %spx; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + """ % ( + r, + r, + ) + else: + return """ + border-bottom-left-radius: %spx; + border-bottom-right-radius: %spx; + border-top-left-radius: 0; + border-top-right-radius: 0; + """ % ( + r, + r, + ) + else: + return "border-radius:%spx" % r + def set_color_transparency(self): - use_r = min( + + use_r1 = min( self.translate_text.textbrowser.height() // 2, self.translate_text.textbrowser.width() // 2, globalconfig["yuanjiao_r"], ) + use_r2 = min( + self._TitleLabel.height() // 2, + self._TitleLabel.width() // 2, + globalconfig["yuanjiao_r"], + ) + topr = self.createborderradiusstring( + use_r1, + globalconfig["yuanjiao_merge"] and self._TitleLabel.isVisible(), + False, + ) + bottomr2 = self.createborderradiusstring(use_r2, False) + bottomr = self.createborderradiusstring( + use_r2, globalconfig["yuanjiao_merge"], True + ) + self.translate_text.setStyleSheet( - "border-width: 0;border-radius:%spx;background-color: rgba(%s, %s, %s, %s)" + "border-width: 0;%s;background-color: rgba(%s, %s, %s, %s)" % ( - use_r, + topr, int(globalconfig["backcolor"][1:3], 16), int(globalconfig["backcolor"][3:5], 16), int(globalconfig["backcolor"][5:7], 16), globalconfig["transparent"] * (not self.backtransparent) / 100, ) ) - use_r = min( - self._TitleLabel.height() // 2, - self._TitleLabel.width() // 2, - globalconfig["yuanjiao_r"], - ) self._TitleLabel.setStyleSheet( - "border-width: 0;border-radius:%spx;background-color: rgba(%s, %s, %s, %s)" + "border-width: 0;%s;background-color: rgba(%s, %s, %s, %s)" % ( - use_r, + bottomr, int(globalconfig["backcolor"][1:3], 16), int(globalconfig["backcolor"][3:5], 16), int(globalconfig["backcolor"][5:7], 16), @@ -716,36 +752,25 @@ class QUnFrameWindow(resizableframeless): for _type in self.stylebuttons: style = """ QPushButton{ - background-color: rgba(255, 255, 255, 0); - color: black;border-radius:%spx; - border: 0px; - font: 100 10pt; - } - + background-color: rgba(255, 255, 255, 0); + color: black;%s; + border: 0px; + font: 100 10pt; + } + QPushButton:hover{ + background-color: %s; + border: 0px;%s; + font: 100 10pt; + } """ % ( - use_r, - ) - if _type == 1: - style += """ - QPushButton:hover{ - background-color: %s; - border: 0px;border-radius:%spx; - font: 100 10pt; - }""" % ( + bottomr2, + ( globalconfig["button_color_normal"], - use_r, - ) - elif _type == 2: - style += """ - QPushButton:hover{ - background-color: %s; - color: white;border-radius:%spx; - border: 0px; - font: 100 10pt; - }""" % ( globalconfig["button_color_close"], - use_r, - ) + )[_type - 1], + bottomr2, + ) + for btn in self.stylebuttons[_type]: btn.setStyleSheet(style) @@ -929,6 +954,7 @@ class QUnFrameWindow(resizableframeless): for button in self.buttons: button.hide() self._TitleLabel.hide() + self.set_color_transparency() def enterEvent(self, QEvent): self.enterfunction() @@ -951,6 +977,7 @@ class QUnFrameWindow(resizableframeless): s.toolbarhidedelaysignal.emit() threading.Thread(target=lambda: __(self)).start() + self.set_color_transparency() def resizeEvent(self, e): super().resizeEvent(e) diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index 364b6d39..747a57c3 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -78,6 +78,7 @@ "maxBufferSize": 3000, "maxHistorySize": 1000000, "yuanjiao_r": 0, + "yuanjiao_merge": false, "transuigeo": [ 500, 500, diff --git a/LunaTranslator/files/lang/ar.json b/LunaTranslator/files/lang/ar.json index d24295a7..312dad30 100644 --- a/LunaTranslator/files/lang/ar.json +++ b/LunaTranslator/files/lang/ar.json @@ -771,6 +771,8 @@ "投影距离": "المسافة المتوقعة", "最大缓冲区长度": "أقصى طول المخزن المؤقت", "最大缓存文本长度": "أقصى طول النص مخبأ", - "圆角半径": "نصف قطر فيليه", - "投影": "إسقاطات" + "投影": "إسقاطات", + "半径": "نصف قطر", + "圆角": "فيليه", + "合并": "دمج" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cht.json b/LunaTranslator/files/lang/cht.json index b82c1266..7bd04c7f 100644 --- a/LunaTranslator/files/lang/cht.json +++ b/LunaTranslator/files/lang/cht.json @@ -771,6 +771,8 @@ "投影距离": "投影距離", "最大缓冲区长度": "最大緩衝區長度", "最大缓存文本长度": "最大緩存文字長度", - "圆角半径": "圓角半徑", - "投影": "投影" + "投影": "投影", + "半径": "半徑", + "圆角": "圓角", + "合并": "合併" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/en.json b/LunaTranslator/files/lang/en.json index 4703189c..048d0e21 100644 --- a/LunaTranslator/files/lang/en.json +++ b/LunaTranslator/files/lang/en.json @@ -771,6 +771,8 @@ "投影距离": "Projection distance", "最大缓冲区长度": "Maximum buffer length", "最大缓存文本长度": "Maximum cached text length", - "圆角半径": "Round radius", - "投影": "projection" + "投影": "projection", + "半径": "radius", + "圆角": "fillet", + "合并": "merge" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/es.json b/LunaTranslator/files/lang/es.json index 76eb7e8b..2fd29332 100644 --- a/LunaTranslator/files/lang/es.json +++ b/LunaTranslator/files/lang/es.json @@ -771,6 +771,8 @@ "投影距离": "Distancia de proyección", "最大缓冲区长度": "Longitud máxima de la zona de amortiguación", "最大缓存文本长度": "Longitud máxima del texto en caché", - "圆角半径": "Radio redondeado", - "投影": "Proyección" + "投影": "Proyección", + "半径": "Radio", + "圆角": "Redondeado", + "合并": "Fusión" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/fr.json b/LunaTranslator/files/lang/fr.json index 6f1eeace..7f1f1de8 100644 --- a/LunaTranslator/files/lang/fr.json +++ b/LunaTranslator/files/lang/fr.json @@ -771,6 +771,8 @@ "投影距离": "Distance de projection", "最大缓冲区长度": "Longueur maximale du tampon", "最大缓存文本长度": "Longueur maximale du texte mis en cache", - "圆角半径": "Rayon des coins arrondis", - "投影": "Projection" + "投影": "Projection", + "半径": "Rayon", + "圆角": "Coins arrondis", + "合并": "Consolidation" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/it.json b/LunaTranslator/files/lang/it.json index be3db81b..c763b755 100644 --- a/LunaTranslator/files/lang/it.json +++ b/LunaTranslator/files/lang/it.json @@ -771,6 +771,8 @@ "投影距离": "Distanza di proiezione", "最大缓冲区长度": "Lunghezza massima del buffer", "最大缓存文本长度": "Lunghezza massima del testo memorizzato nella cache", - "圆角半径": "Raggio rotondo", - "投影": "proiezione" + "投影": "proiezione", + "半径": "raggio", + "圆角": "filetto", + "合并": "fusione" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ja.json b/LunaTranslator/files/lang/ja.json index a2fe0da9..4c9d85fb 100644 --- a/LunaTranslator/files/lang/ja.json +++ b/LunaTranslator/files/lang/ja.json @@ -771,6 +771,8 @@ "投影距离": "とうえいきょり", "最大缓冲区长度": "最大バッファ長", "最大缓存文本长度": "最大キャッシュテキスト長", - "圆角半径": "フィレット半径", - "投影": "投影" + "投影": "投影", + "半径": "半径はんけい", + "圆角": "フィレット", + "合并": "マージ" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ko.json b/LunaTranslator/files/lang/ko.json index db0ad8e3..a7be2a3d 100644 --- a/LunaTranslator/files/lang/ko.json +++ b/LunaTranslator/files/lang/ko.json @@ -771,6 +771,8 @@ "投影距离": "투영 거리", "最大缓冲区长度": "최대 버퍼 길이", "最大缓存文本长度": "최대 캐시 텍스트 길이", - "圆角半径": "필렛 반지름", - "投影": "투영" + "投影": "투영", + "半径": "반지름", + "圆角": "필렛", + "合并": "병합" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pl.json b/LunaTranslator/files/lang/pl.json index 893fc47d..b5709ba1 100644 --- a/LunaTranslator/files/lang/pl.json +++ b/LunaTranslator/files/lang/pl.json @@ -771,6 +771,8 @@ "投影距离": "Odległość projekcji", "最大缓冲区长度": "Maksymalna długość bufora", "最大缓存文本长度": "Maksymalna długość buforowanego tekstu", - "圆角半径": "Promień okrągły", - "投影": "projekcja" + "投影": "projekcja", + "半径": "promień", + "圆角": "filet", + "合并": "połączenie" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ru.json b/LunaTranslator/files/lang/ru.json index a359680d..aa76ddf5 100644 --- a/LunaTranslator/files/lang/ru.json +++ b/LunaTranslator/files/lang/ru.json @@ -771,6 +771,8 @@ "投影距离": "Расстояние проекции", "最大缓冲区长度": "Максимальная длина буфера", "最大缓存文本长度": "Максимальная длина текста кэша", - "圆角半径": "Круговой радиус", - "投影": "Проекция" + "投影": "Проекция", + "半径": "Радиус", + "圆角": "Круглый угол", + "合并": "Объединение" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/th.json b/LunaTranslator/files/lang/th.json index 24ebebdf..aee1e826 100644 --- a/LunaTranslator/files/lang/th.json +++ b/LunaTranslator/files/lang/th.json @@ -771,6 +771,8 @@ "投影距离": "ระยะการฉาย", "最大缓冲区长度": "ความยาวบัฟเฟอร์สูงสุด", "最大缓存文本长度": "ความยาวสูงสุดของข้อความแคช", - "圆角半径": "รัศมีมุมกลม", - "投影": "การฉายภาพ" + "投影": "การฉายภาพ", + "半径": "รัศมี", + "圆角": "มุมกลม", + "合并": "การควบรวมกิจการ" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/tr.json b/LunaTranslator/files/lang/tr.json index 5dae074d..2e4f5393 100644 --- a/LunaTranslator/files/lang/tr.json +++ b/LunaTranslator/files/lang/tr.json @@ -771,6 +771,8 @@ "投影距离": "Projeksyon mesafesi", "最大缓冲区长度": "Azamik buffer uzunluğu", "最大缓存文本长度": "Maximum cached text length", - "圆角半径": "Sıradan", - "投影": "projection" + "投影": "projection", + "半径": "radius", + "圆角": "fillet", + "合并": "birleştir" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/uk.json b/LunaTranslator/files/lang/uk.json index 1dc545d5..1aac97a6 100644 --- a/LunaTranslator/files/lang/uk.json +++ b/LunaTranslator/files/lang/uk.json @@ -771,6 +771,8 @@ "投影距离": "Відстань проекту", "最大缓冲区长度": "Максимальна довжина буфера", "最大缓存文本长度": "Максимальна довжина кешування тексту", - "圆角半径": "Округлий радіус", - "投影": "проекція" + "投影": "проекція", + "半径": "радіус", + "圆角": "філет", + "合并": "об’ єднати" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/vi.json b/LunaTranslator/files/lang/vi.json index 90026cb6..32bb71bc 100644 --- a/LunaTranslator/files/lang/vi.json +++ b/LunaTranslator/files/lang/vi.json @@ -771,6 +771,8 @@ "投影距离": "Khoảng cách chiếu", "最大缓冲区长度": "Chiều dài bộ đệm tối đa", "最大缓存文本长度": "Độ dài văn bản bộ nhớ cache tối đa", - "圆角半径": "Bán kính góc tròn", - "投影": "Chiếu" + "投影": "Chiếu", + "半径": "Bán kính", + "圆角": "Góc tròn", + "合并": "Hợp nhất" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/zh.json b/LunaTranslator/files/lang/zh.json index 322b9c3c..031b5e05 100644 --- a/LunaTranslator/files/lang/zh.json +++ b/LunaTranslator/files/lang/zh.json @@ -772,5 +772,7 @@ "投影距离": "", "最大缓冲区长度": "", "最大缓存文本长度": "", - "圆角半径": "" + "半径": "", + "圆角": "", + "合并": "" } \ No newline at end of file