diff --git a/LunaTranslator/LunaTranslator/gui/setting_display_text.py b/LunaTranslator/LunaTranslator/gui/setting_display_text.py index 16d78332..7ff3f31d 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_display_text.py +++ b/LunaTranslator/LunaTranslator/gui/setting_display_text.py @@ -186,16 +186,9 @@ def createinternalfontsettings(self, forml, group, _type): def resetgroudswitchcallback(self, group): clearlayout(self.goodfontsettingsformlayout) - if group == "QWebEngine": - group = "webview" - goodfontgroupswitch = FocusCombo() - if group == "webview": - _btn = QPushButton(_TR("额外的html")) - self.goodfontsettingsformlayout.addRow(_btn) - _btn.clicked.connect(lambda: extrahtml(self)) - elif group == "textbrowser": + if group == "textbrowser" or group == "QWebEngine": self.goodfontsettingsformlayout.addRow( _TR("可选取模式"), getsimpleswitch( @@ -204,6 +197,12 @@ def resetgroudswitchcallback(self, group): callback=lambda x: gobject.baseobject.translation_ui.translate_text.textbrowser.setselectable(), ), ) + if group == "webview" or group == "QWebEngine": + _btn = QPushButton(_TR("额外的html")) + self.goodfontsettingsformlayout.addRow(_btn) + _btn.clicked.connect(lambda: extrahtml(self)) + if group == "QWebEngine": + group = "webview" __form = QFormLayout() __form.addRow(_TR("字体样式"), goodfontgroupswitch) self.goodfontsettingsformlayout.addRow(__form) diff --git a/LunaTranslator/LunaTranslator/rendertext/webview.py b/LunaTranslator/LunaTranslator/rendertext/webview.py index 73191222..9b93d747 100644 --- a/LunaTranslator/LunaTranslator/rendertext/webview.py +++ b/LunaTranslator/LunaTranslator/rendertext/webview.py @@ -13,7 +13,11 @@ class TextBrowser(QWidget, dataget): contentsChanged = pyqtSignal(QSize) def resizeEvent(self, event: QResizeEvent): - self.webivewwidget.resize(event.size().width(), event.size().height()) + self.webivewwidget.resize(event.size()) + self.masklabel.resize(event.size()) + + def setselectable(self): + self.masklabel.setHidden(globalconfig["selectable"]) def __init__(self, parent) -> None: super().__init__(parent) @@ -24,6 +28,8 @@ class TextBrowser(QWidget, dataget): # webview2当会执行alert之类的弹窗js时,若qt窗口不可视,会卡住 self.webivewwidget = WebivewWidget(self) + self.masklabel = QLabel(self.webivewwidget) + self.masklabel.setMouseTracking(True) self.webivewwidget.navigate( os.path.abspath(r"LunaTranslator\rendertext\webview.html") ) @@ -33,6 +39,7 @@ class TextBrowser(QWidget, dataget): self.saveiterclasspointer = {} self.isfirst = True self._qweb_query_word() + self.setselectable() def showEvent(self, e): if not self.isfirst: