This commit is contained in:
恍兮惚兮 2024-08-02 22:47:31 +08:00
parent b97b97eee0
commit 7657b13c5f
3 changed files with 19 additions and 4 deletions

View File

@ -13,9 +13,11 @@ from gui.usefulwidget import (
getQMessageBox, getQMessageBox,
D_getspinbox, D_getspinbox,
D_getIconButton, D_getIconButton,
getboxlayout,
D_getcolorbutton, D_getcolorbutton,
getcolorbutton, getcolorbutton,
MySwitch, MySwitch,
getsimpleswitch,
D_getsimpleswitch, D_getsimpleswitch,
selectcolor, selectcolor,
listediter, listediter,
@ -246,8 +248,17 @@ def resetgroudswitchcallback(self, group):
self.seletengeinecombo.lastindex = self.seletengeinecombo.currentIndex() self.seletengeinecombo.lastindex = self.seletengeinecombo.currentIndex()
if group == "webview" or group == "QWebEngine": if group == "webview" or group == "QWebEngine":
_btn = LPushButton("额外的html") _btn = LPushButton("额外的html")
self.goodfontsettingsformlayout.addRow(_btn)
_btn.clicked.connect(lambda: extrahtml(self)) _btn.clicked.connect(lambda: extrahtml(self))
switch = getsimpleswitch(
globalconfig,
"useextrahtml",
callback=lambda x: [
gobject.baseobject.translation_ui.translate_text.textbrowser.loadextra(0),
_btn.setEnabled(x),
],
)
_btn.setEnabled(globalconfig["useextrahtml"])
self.goodfontsettingsformlayout.addRow(getboxlayout([_btn, switch]))
if group == "QWebEngine": if group == "QWebEngine":
group = "webview" group = "webview"
__form = LFormLayout() __form = LFormLayout()

View File

@ -109,10 +109,10 @@ class TextBrowser(QWidget, dataget):
if not isinstance(self.webivewwidget, WebivewWidget): if not isinstance(self.webivewwidget, WebivewWidget):
return return
self.isfirst = False self.isfirst = False
self.__loadextra(0) self.loadextra(0)
self.webivewwidget.on_load.connect(self.__loadextra) self.webivewwidget.on_load.connect(self.loadextra)
def __loadextra(self, _): def loadextra(self, _):
for _ in [ for _ in [
"userconfig/extrahtml.html", "userconfig/extrahtml.html",
r"LunaTranslator\rendertext\exampleextrahtml.html", r"LunaTranslator\rendertext\exampleextrahtml.html",
@ -136,6 +136,9 @@ class TextBrowser(QWidget, dataget):
self.debugeval(f"clear_all()") self.debugeval(f"clear_all()")
def set_extra_html(self, html): def set_extra_html(self, html):
if not globalconfig["useextrahtml"]:
self.debugeval(f'set_extra_html("")')
return
html = quote(html) html = quote(html)
self.debugeval(f'set_extra_html("{html}")') self.debugeval(f'set_extra_html("{html}")')

View File

@ -17,6 +17,7 @@
"read_translator": 0, "read_translator": 0,
"disappear_delay": 5, "disappear_delay": 5,
"network": 1, "network": 1,
"useextrahtml": true,
"network_websocket": 1, "network_websocket": 1,
"webview_textbrowser": false, "webview_textbrowser": false,
"imagewrapmode": 0, "imagewrapmode": 0,