diff --git a/LunaTranslator/LunaTranslator/gui/usefulwidget.py b/LunaTranslator/LunaTranslator/gui/usefulwidget.py index 1c528369..94f0de5e 100644 --- a/LunaTranslator/LunaTranslator/gui/usefulwidget.py +++ b/LunaTranslator/LunaTranslator/gui/usefulwidget.py @@ -1014,7 +1014,7 @@ class WebivewWidget(abstractwebview): webview_native_handle_kind_t.WEBVIEW_NATIVE_HANDLE_KIND_UI_WIDGET ) - def __init__(self, parent=None, debug=True) -> None: + def __init__(self, parent=None, debug=True, usedarklight=True) -> None: super().__init__(parent) declare_library_path( os.path.abspath( @@ -1036,13 +1036,13 @@ class WebivewWidget(abstractwebview): self.keepref = [zoomfunc] self.webview.bind("__on_load", self._on_load) self.webview.init("""window.__on_load(window.location.href)""") - - self.__darkstate = None - t = QTimer(self) - t.setInterval(100) - t.timeout.connect(self.__darkstatechecker) - t.timeout.emit() - t.start() + if usedarklight: + self.__darkstate = None + t = QTimer(self) + t.setInterval(100) + t.timeout.connect(self.__darkstatechecker) + t.timeout.emit() + t.start() def __darkstatechecker(self): dl = globalconfig["darklight2"] diff --git a/LunaTranslator/LunaTranslator/rendertext/webview.py b/LunaTranslator/LunaTranslator/rendertext/webview.py index ec871fd4..95c5f407 100644 --- a/LunaTranslator/LunaTranslator/rendertext/webview.py +++ b/LunaTranslator/LunaTranslator/rendertext/webview.py @@ -46,7 +46,7 @@ class TextBrowser(QWidget, dataget): self.webivewwidget.on_load.connect(self.__loadextra) else: # webview2当会执行alert之类的弹窗js时,若qt窗口不可视,会卡住 - self.webivewwidget = WebivewWidget(self) + self.webivewwidget = WebivewWidget(self, usedarklight=False) # webview2无法接收qt事件。 webviewhwnd = self.webivewwidget.get_hwnd()