mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
ldis
This commit is contained in:
parent
00e7038e95
commit
72a75b1a4f
@ -2,7 +2,7 @@ from qtsymbols import *
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
def gen_html(configs, text, fm, fs, bold, atcenter, color):
|
def gen_html(configs, text, fm, fs, bold, atcenter, color, extra_space):
|
||||||
align = "text-align: center;" if atcenter else ""
|
align = "text-align: center;" if atcenter else ""
|
||||||
bold = "font-weight: bold;" if bold else ""
|
bold = "font-weight: bold;" if bold else ""
|
||||||
_id = f"luna_{uuid.uuid4()}"
|
_id = f"luna_{uuid.uuid4()}"
|
||||||
@ -19,7 +19,7 @@ def gen_html(configs, text, fm, fs, bold, atcenter, color):
|
|||||||
color:{configs['fillcolor']};
|
color:{configs['fillcolor']};
|
||||||
{bold}
|
{bold}
|
||||||
text-shadow:{ntimes};
|
text-shadow:{ntimes};
|
||||||
{align}
|
{align};
|
||||||
|
line-height: calc(1.5em + {extra_space}px);
|
||||||
}}</style>"""
|
}}</style>"""
|
||||||
|
|
||||||
return style + f'<div id="{_id}">{text}</div>'
|
return style + f'<div id="{_id}">{text}</div>'
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
from qtsymbols import *
|
from qtsymbols import *
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
def gen_html(configs, text, fm, fs, bold, atcenter, color):
|
|
||||||
|
def gen_html(configs, text, fm, fs, bold, atcenter, color, extra_space):
|
||||||
align = "text-align: center;" if atcenter else ""
|
align = "text-align: center;" if atcenter else ""
|
||||||
bold = "font-weight: bold;" if bold else ""
|
bold = "font-weight: bold;" if bold else ""
|
||||||
_id = f"luna_{uuid.uuid4()}"
|
_id = f"luna_{uuid.uuid4()}"
|
||||||
@ -12,6 +13,7 @@ def gen_html(configs, text, fm, fs, bold, atcenter, color):
|
|||||||
color:{color};
|
color:{color};
|
||||||
{bold}
|
{bold}
|
||||||
{align}
|
{align}
|
||||||
|
line-height: calc(1.5em + {extra_space}px);
|
||||||
}}</style>"""
|
}}</style>"""
|
||||||
|
|
||||||
return style + f'<div id="{_id}">{text}</div>'
|
return style + f'<div id="{_id}">{text}</div>'
|
||||||
|
@ -130,7 +130,7 @@ class TextBrowser(QWidget, dataget):
|
|||||||
def calllunaclickedword(self, packedwordinfo):
|
def calllunaclickedword(self, packedwordinfo):
|
||||||
gobject.baseobject.clickwordcallback(json.loads(unquote(packedwordinfo)), False)
|
gobject.baseobject.clickwordcallback(json.loads(unquote(packedwordinfo)), False)
|
||||||
|
|
||||||
def gen_html(self, text, fm, fs, bold, atcenter, color):
|
def gen_html(self, *args):
|
||||||
currenttype = globalconfig["rendertext_using_internal"]["webview"]
|
currenttype = globalconfig["rendertext_using_internal"]["webview"]
|
||||||
configs = globalconfig["rendertext"]["webview"][currenttype].get("args", {})
|
configs = globalconfig["rendertext"]["webview"][currenttype].get("args", {})
|
||||||
try:
|
try:
|
||||||
@ -140,7 +140,7 @@ class TextBrowser(QWidget, dataget):
|
|||||||
globalconfig["rendertext"]["webview"].keys()
|
globalconfig["rendertext"]["webview"].keys()
|
||||||
)[0]
|
)[0]
|
||||||
__ = importlib.import_module(f"rendertext.internal.webview.{currenttype}")
|
__ = importlib.import_module(f"rendertext.internal.webview.{currenttype}")
|
||||||
return __.gen_html(configs, text, fm, fs, bold, atcenter, color)
|
return __.gen_html(configs, *args)
|
||||||
|
|
||||||
def _webview_append(self, _id, origin, atcenter, text, tag, flags, color):
|
def _webview_append(self, _id, origin, atcenter, text, tag, flags, color):
|
||||||
text = text.replace("\n", "<br>").replace("\\", "\\\\")
|
text = text.replace("\n", "<br>").replace("\\", "\\\\")
|
||||||
@ -170,7 +170,15 @@ class TextBrowser(QWidget, dataget):
|
|||||||
if (word["orig"] != word["hira"]) and isshowhira:
|
if (word["orig"] != word["hira"]) and isshowhira:
|
||||||
text += (
|
text += (
|
||||||
f"<rt>"
|
f"<rt>"
|
||||||
+ self.gen_html(word["hira"], fm, fskana, bold, True, kanacolor)
|
+ self.gen_html(
|
||||||
|
word["hira"],
|
||||||
|
fm,
|
||||||
|
fskana,
|
||||||
|
bold,
|
||||||
|
True,
|
||||||
|
kanacolor,
|
||||||
|
globalconfig["extra_space"],
|
||||||
|
)
|
||||||
+ "</rt>"
|
+ "</rt>"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@ -178,13 +186,9 @@ class TextBrowser(QWidget, dataget):
|
|||||||
text = text + "</ruby>"
|
text = text + "</ruby>"
|
||||||
|
|
||||||
fm, fs, bold = self._getfontinfo(origin)
|
fm, fs, bold = self._getfontinfo(origin)
|
||||||
text = self.gen_html(text, fm, fs, bold, atcenter, color)
|
text = self.gen_html(
|
||||||
_id_wrap = f"luna_{uuid.uuid4()}"
|
text, fm, fs, bold, atcenter, color, globalconfig["extra_space"]
|
||||||
text = f"""<div id="{_id_wrap}">{text}</div><style>
|
)
|
||||||
#{_id_wrap}{{
|
|
||||||
margin-bottom:{globalconfig["extra_space"]}px
|
|
||||||
}}
|
|
||||||
</style>"""
|
|
||||||
self.testeval(f"document.getElementById(`{_id}`).innerHTML=`{text}`")
|
self.testeval(f"document.getElementById(`{_id}`).innerHTML=`{text}`")
|
||||||
self.internalheighchange()
|
self.internalheighchange()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user