From 5bc71c24f7b92e469ecd167b3141aa2de54f775b 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: Sat, 22 Jun 2024 17:25:11 +0800
Subject: [PATCH] merge
---
.../gui/setting_display_text.py | 4 +
.../LunaTranslator/rendertext/textbrowser.py | 12 ++-
.../rendertext/textbrowser_imp/miaobian1.py | 5 +-
.../rendertext/textbrowser_imp/miaobian2.py | 7 --
.../LunaTranslator/rendertext/webview.html | 26 +++----
.../LunaTranslator/rendertext/webview.py | 17 ++++-
.../files/defaultconfig/config.json | 74 +++----------------
.../files/defaultconfig/static_data.json | 6 +-
LunaTranslator/files/lang/ar.json | 3 +-
LunaTranslator/files/lang/cht.json | 3 +-
LunaTranslator/files/lang/en.json | 3 +-
LunaTranslator/files/lang/es.json | 3 +-
LunaTranslator/files/lang/fr.json | 3 +-
LunaTranslator/files/lang/it.json | 3 +-
LunaTranslator/files/lang/ja.json | 3 +-
LunaTranslator/files/lang/ko.json | 3 +-
LunaTranslator/files/lang/pl.json | 3 +-
LunaTranslator/files/lang/ru.json | 3 +-
LunaTranslator/files/lang/th.json | 3 +-
LunaTranslator/files/lang/tr.json | 3 +-
LunaTranslator/files/lang/uk.json | 3 +-
LunaTranslator/files/lang/vi.json | 3 +-
LunaTranslator/files/lang/zh.json | 3 +-
23 files changed, 81 insertions(+), 115 deletions(-)
delete mode 100644 LunaTranslator/LunaTranslator/rendertext/textbrowser_imp/miaobian2.py
diff --git a/LunaTranslator/LunaTranslator/gui/setting_display_text.py b/LunaTranslator/LunaTranslator/gui/setting_display_text.py
index 9ece8c6d..3a157159 100644
--- a/LunaTranslator/LunaTranslator/gui/setting_display_text.py
+++ b/LunaTranslator/LunaTranslator/gui/setting_display_text.py
@@ -14,6 +14,7 @@ from gui.usefulwidget import (
D_getIconButton,
D_getcolorbutton,
getcolorbutton,
+ MySwitch,
D_getsimpleswitch,
selectcolor,
FocusFontCombo,
@@ -177,6 +178,9 @@ def createinternalfontsettings(self, forml, group, _type):
lineW.setSingleStep(line.get("step", 1))
lineW.setValue(dd[key])
lineW.valueChanged.connect(functools.partial(dd.__setitem__, key))
+ elif _type == "switch":
+ lineW = MySwitch(sign=dd[key])
+ lineW.clicked.connect(functools.partial(dd.__setitem__, key))
forml.addRow(
_TR(name),
lineW,
diff --git a/LunaTranslator/LunaTranslator/rendertext/textbrowser.py b/LunaTranslator/LunaTranslator/rendertext/textbrowser.py
index b1852c48..c380df96 100644
--- a/LunaTranslator/LunaTranslator/rendertext/textbrowser.py
+++ b/LunaTranslator/LunaTranslator/rendertext/textbrowser.py
@@ -1,5 +1,5 @@
from qtsymbols import *
-from myutils.config import globalconfig
+from myutils.config import globalconfig, static_data
from rendertext.somefunctions import dataget
import gobject, functools, importlib
from traceback import print_exc
@@ -105,9 +105,13 @@ class TextBrowser(QWidget, dataget):
def resets1(self):
self.currenttype = globalconfig["rendertext_using_internal"]["textbrowser"]
- __ = importlib.import_module(
- f"rendertext.textbrowser_imp.{self.currenttype}"
- )
+ if self.currenttype not in static_data["textrender"]["textbrowser"]:
+ self.currenttype = static_data["textrender"]["textbrowser"][0]
+ globalconfig["rendertext_using_internal"]["textbrowser"] = static_data[
+ "textrender"
+ ]["textbrowser"][0]
+
+ __ = importlib.import_module(f"rendertext.textbrowser_imp.{self.currenttype}")
self.currentclass = functools.partial(__.TextLine, self.currenttype)
diff --git a/LunaTranslator/LunaTranslator/rendertext/textbrowser_imp/miaobian1.py b/LunaTranslator/LunaTranslator/rendertext/textbrowser_imp/miaobian1.py
index 6fc7091e..951a369c 100644
--- a/LunaTranslator/LunaTranslator/rendertext/textbrowser_imp/miaobian1.py
+++ b/LunaTranslator/LunaTranslator/rendertext/textbrowser_imp/miaobian1.py
@@ -20,7 +20,10 @@ class TextLine(base):
return (fontOutLineWidth, fontOutLineWidth)
def colorpair(self):
- return QColor(self.config["fillcolor"]), QColor(self.basecolor)
+ _ = QColor(self.config["fillcolor"]), QColor(self.basecolor)
+ if self.config["reverse"]:
+ _ = reversed(_)
+ return _
def paintText(self, painter: QPainter):
self.m_outLineColor, self.m_contentColor = self.colorpair()
diff --git a/LunaTranslator/LunaTranslator/rendertext/textbrowser_imp/miaobian2.py b/LunaTranslator/LunaTranslator/rendertext/textbrowser_imp/miaobian2.py
deleted file mode 100644
index c3a2a141..00000000
--- a/LunaTranslator/LunaTranslator/rendertext/textbrowser_imp/miaobian2.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from qtsymbols import *
-from rendertext.textbrowser_imp.miaobian1 import TextLine as TB1
-
-
-class TextLine(TB1):
- def colorpair(self):
- return QColor(self.basecolor), QColor(self.config["fillcolor"])
diff --git a/LunaTranslator/LunaTranslator/rendertext/webview.html b/LunaTranslator/LunaTranslator/rendertext/webview.html
index ce972abe..141d7767 100644
--- a/LunaTranslator/LunaTranslator/rendertext/webview.html
+++ b/LunaTranslator/LunaTranslator/rendertext/webview.html
@@ -14,8 +14,9 @@
margin-bottom: 0;
/* word-break: break-all; */
}
+
body::-webkit-scrollbar {
- display: none;
+ display: none;
}