From 92295921d4d540e396d33149a4ab01cef917ef0a 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: Mon, 5 Aug 2024 20:20:15 +0800 Subject: [PATCH] fix --- .../LunaTranslator/gui/dialog_savedgame.py | 4 +-- LunaTranslator/LunaTranslator/gui/showword.py | 26 ++++++------------- .../LunaTranslator/gui/usefulwidget.py | 14 ++++++++++ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py index 48ee0313..ca83b543 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py @@ -77,7 +77,7 @@ from gui.usefulwidget import ( tabadd_lazy, getsimpleswitch, threebuttons, - getsimplekeyseq, + FQLineEdit, getspinbox, selectcolor, listediter, @@ -346,7 +346,7 @@ class TagWidget(QWidget): self.setLayout(layout) self.lineEdit = FocusCombo() - self.lineEdit.setLineEdit(QLineEdit()) + self.lineEdit.setLineEdit(FQLineEdit()) self.lineEdit.lineEdit().returnPressed.connect( lambda: self.linepressedenter.emit(self.lineEdit.currentText()) diff --git a/LunaTranslator/LunaTranslator/gui/showword.py b/LunaTranslator/LunaTranslator/gui/showword.py index 49335be9..563720f4 100644 --- a/LunaTranslator/LunaTranslator/gui/showword.py +++ b/LunaTranslator/LunaTranslator/gui/showword.py @@ -21,6 +21,8 @@ from gui.usefulwidget import ( getlineedit, listediter, listediterline, + FQPlainTextEdit, + FQLineEdit, getsimpleswitch, makesubtab_lazy, getIconButton, @@ -171,9 +173,9 @@ class AnkiWindow(QWidget): margin0=True, ) ) - self.fronttext = QPlainTextEdit1() - self.backtext = QPlainTextEdit1() - self.csstext = QPlainTextEdit1() + self.fronttext = FQPlainTextEdit() + self.backtext = FQPlainTextEdit() + self.csstext = FQPlainTextEdit() edittemptab.addTab(self.fronttext, "正面") edittemptab.addTab(self.backtext, "背面") edittemptab.addTab(self.csstext, "样式") @@ -375,14 +377,14 @@ class AnkiWindow(QWidget): self.editpath.setReadOnly(True) self.viewimagelabel = QLabel() self.editpath.textChanged.connect(self.wrappedpixmap) - self.example = QPlainTextEdit1() + self.example = FQPlainTextEdit() self.example.hiras = None def __(): self.example.hiras = None self.example.textChanged.connect(__) - self.remarks = QPlainTextEdit1() + self.remarks = FQPlainTextEdit() recordbtn1 = statusbutton(icons=["fa.microphone", "fa.stop"], colors=["", ""]) recordbtn1.statuschanged.connect( functools.partial(self.startorendrecord, self.audiopath) @@ -649,18 +651,6 @@ class CustomTabBar(LTabBar): return self.savesizehint -class QLineEdit1(QLineEdit): - def mousePressEvent(self, a0: QMouseEvent) -> None: - # 点击浏览器后,无法重新获取焦点。 - windows.SetFocus(int(self.winId())) - return super().mousePressEvent(a0) - -class QPlainTextEdit1(QPlainTextEdit): - def mousePressEvent(self, a0: QMouseEvent) -> None: - # 点击浏览器后,无法重新获取焦点。 - windows.SetFocus(int(self.winId())) - return super().mousePressEvent(a0) - class searchwordW(closeashidewindow): search_word = pyqtSignal(str, bool) @@ -725,7 +715,7 @@ class searchwordW(closeashidewindow): ww.setLayout(self.vboxlayout) self.searchlayout = QHBoxLayout() self.vboxlayout.addLayout(self.searchlayout) - self.searchtext = QLineEdit1() + self.searchtext = FQLineEdit() self.searchtext.textChanged.connect(self.ankiwindow.reset) self.history_last_btn = statusbutton( icons=["fa.arrow-left", "fa.arrow-left"], colors=["", ""] diff --git a/LunaTranslator/LunaTranslator/gui/usefulwidget.py b/LunaTranslator/LunaTranslator/gui/usefulwidget.py index 56da8326..90275eb3 100644 --- a/LunaTranslator/LunaTranslator/gui/usefulwidget.py +++ b/LunaTranslator/LunaTranslator/gui/usefulwidget.py @@ -2086,3 +2086,17 @@ def clearlayout(ll: QLayout): clearlayout(l) l.deleteLater() continue + + +class FQPlainTextEdit(QPlainTextEdit): + def mousePressEvent(self, a0: QMouseEvent) -> None: + # 点击浏览器后,无法重新获取焦点。 + windows.SetFocus(int(self.winId())) + return super().mousePressEvent(a0) + + +class FQLineEdit(QLineEdit): + def mousePressEvent(self, a0: QMouseEvent) -> None: + # 点击浏览器后,无法重新获取焦点。 + windows.SetFocus(int(self.winId())) + return super().mousePressEvent(a0)