mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
fix
This commit is contained in:
parent
7205bc8f87
commit
67072b4936
@ -1194,7 +1194,9 @@ class MAINUI:
|
||||
self.parsedefaultfont()
|
||||
self.loadmetadatas()
|
||||
self.translation_ui = QUnFrameWindow()
|
||||
winsharedutils.showintab(int(self.translation_ui.winId()), globalconfig["showintab"])
|
||||
winsharedutils.showintab(
|
||||
int(self.translation_ui.winId()), globalconfig["showintab"]
|
||||
)
|
||||
self.translation_ui.show()
|
||||
self.translation_ui.aftershowdosomething()
|
||||
self.mainuiloadafter()
|
||||
@ -1234,8 +1236,11 @@ class MAINUI:
|
||||
|
||||
def installeventfillter(self):
|
||||
class WindowEventFilter(QObject):
|
||||
def eventFilter(_, obj, event):
|
||||
if event.type() == QEvent.Type.WinIdChange:
|
||||
def eventFilter(_, obj: QObject, event: QEvent):
|
||||
if event.type() == QEvent.Type.LanguageChange:
|
||||
if "updatelangtext" in dir(obj):
|
||||
obj.updatelangtext()
|
||||
elif event.type() == QEvent.Type.WinIdChange:
|
||||
|
||||
hwnd = obj.winId()
|
||||
if hwnd: # window create/destroy,when destroy winId is None
|
||||
|
@ -2,17 +2,7 @@ from myutils.config import _TR, _TRL
|
||||
from qtsymbols import *
|
||||
|
||||
|
||||
class LBase(QWidget):
|
||||
|
||||
def changeEvent(self, e: QEvent):
|
||||
if e.type() == QEvent.Type.LanguageChange:
|
||||
self.updatelangtext()
|
||||
super().changeEvent(e)
|
||||
|
||||
def updatelangtext(self): ...
|
||||
|
||||
|
||||
class LLabel(QLabel, LBase):
|
||||
class LLabel(QLabel):
|
||||
def __init__(self, s=None):
|
||||
super().__init__(_TR(s) if s else None)
|
||||
self.__s = s
|
||||
@ -26,7 +16,7 @@ class LLabel(QLabel, LBase):
|
||||
super().setText(_TR(self.__s))
|
||||
|
||||
|
||||
class LMessageBox(QMessageBox, LBase):
|
||||
class LMessageBox(QMessageBox):
|
||||
def __init__(self, *argc, **kwarg):
|
||||
super().__init__(*argc, **kwarg)
|
||||
self._title = None
|
||||
@ -47,7 +37,7 @@ class LMessageBox(QMessageBox, LBase):
|
||||
super().setText(_TR(self._text))
|
||||
|
||||
|
||||
class LPushButton(QPushButton, LBase):
|
||||
class LPushButton(QPushButton):
|
||||
def __init__(self, *argc):
|
||||
self._text = None
|
||||
self._ToolTip = None
|
||||
@ -90,14 +80,14 @@ class LAction(QAction):
|
||||
super().__init__(*newarg, **kwargv)
|
||||
|
||||
|
||||
class LMenu(QMenu, LBase):
|
||||
class LMenu(QMenu):
|
||||
def updatelangtext(self):
|
||||
for action in self.actions():
|
||||
if isinstance(action, LAction):
|
||||
action.updatelangtext()
|
||||
|
||||
|
||||
class LCheckBox(QCheckBox, LBase):
|
||||
class LCheckBox(QCheckBox):
|
||||
def __init__(self, text):
|
||||
super().__init__(_TR(text))
|
||||
self._text = text
|
||||
@ -121,11 +111,6 @@ class LGroupBox(QGroupBox):
|
||||
if self._text:
|
||||
super().setTitle(_TR(self._text))
|
||||
|
||||
def changeEvent(self, e: QEvent):
|
||||
if e.type() == QEvent.Type.LanguageChange:
|
||||
self.updatelangtext()
|
||||
super().changeEvent(e)
|
||||
|
||||
|
||||
class LListWidgetItem(QListWidgetItem):
|
||||
def __init__(self, text):
|
||||
@ -136,7 +121,7 @@ class LListWidgetItem(QListWidgetItem):
|
||||
self.setText(_TR(self.__text))
|
||||
|
||||
|
||||
class LListWidget(QListWidget, LBase):
|
||||
class LListWidget(QListWidget):
|
||||
def updatelangtext(self):
|
||||
for i in range(self.count()):
|
||||
item = self.item(i)
|
||||
@ -154,7 +139,7 @@ class LFormLayout(QFormLayout):
|
||||
super().addRow(*argc)
|
||||
|
||||
|
||||
class LDialog(QDialog, LBase):
|
||||
class LDialog(QDialog):
|
||||
|
||||
def __init__(self, *argc, **kwarg):
|
||||
super().__init__(*argc, **kwarg)
|
||||
@ -169,7 +154,7 @@ class LDialog(QDialog, LBase):
|
||||
super().setWindowTitle(_TR(self._title))
|
||||
|
||||
|
||||
class LMainWindow(QMainWindow, LBase):
|
||||
class LMainWindow(QMainWindow):
|
||||
|
||||
def __init__(self, *argc, **kwarg):
|
||||
super().__init__(*argc, **kwarg)
|
||||
@ -184,7 +169,7 @@ class LMainWindow(QMainWindow, LBase):
|
||||
super().setWindowTitle(_TR(self._title))
|
||||
|
||||
|
||||
class LRadioButton(QRadioButton, LBase):
|
||||
class LRadioButton(QRadioButton):
|
||||
def __init__(self, t):
|
||||
self.__t = t
|
||||
super().__init__(_TR(t))
|
||||
@ -193,7 +178,7 @@ class LRadioButton(QRadioButton, LBase):
|
||||
self.setText(_TR(self.__t))
|
||||
|
||||
|
||||
class LTabBar(QTabBar, LBase):
|
||||
class LTabBar(QTabBar):
|
||||
def __init__(self, *argc, **kwarg):
|
||||
super().__init__(*argc, **kwarg)
|
||||
self.__titles = []
|
||||
@ -215,7 +200,7 @@ class LTabBar(QTabBar, LBase):
|
||||
self.setTabText(i, _TR(self.__titles[i]))
|
||||
|
||||
|
||||
class LTabWidget(QTabWidget, LBase):
|
||||
class LTabWidget(QTabWidget):
|
||||
def __init__(self, *argc, **kwarg):
|
||||
super().__init__(*argc, **kwarg)
|
||||
self.__titles = []
|
||||
@ -229,7 +214,7 @@ class LTabWidget(QTabWidget, LBase):
|
||||
self.setTabText(i, _TR(self.__titles[i]))
|
||||
|
||||
|
||||
class LStandardItemModel(QStandardItemModel, LBase):
|
||||
class LStandardItemModel(QStandardItemModel):
|
||||
def __init__(self, *argc, **kwarg):
|
||||
super().__init__(*argc, **kwarg)
|
||||
self.__ls = []
|
||||
|
@ -17,7 +17,6 @@ from gui.dynalang import (
|
||||
LPushButton,
|
||||
LAction,
|
||||
LGroupBox,
|
||||
LBase,
|
||||
LFormLayout,
|
||||
LTabWidget,
|
||||
LStandardItemModel,
|
||||
@ -40,7 +39,7 @@ class FocusCombo(QComboBox):
|
||||
return super().wheelEvent(e)
|
||||
|
||||
|
||||
class LFocusCombo(FocusCombo, LBase):
|
||||
class LFocusCombo(FocusCombo):
|
||||
def __init__(self, parent: QWidget = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.__items = None
|
||||
@ -91,7 +90,7 @@ class FocusDoubleSpin(QDoubleSpinBox):
|
||||
return super().wheelEvent(e)
|
||||
|
||||
|
||||
class TableViewW(QTableView, LBase):
|
||||
class TableViewW(QTableView):
|
||||
def setIndexWidget(self, index: QModelIndex, w: QWidget):
|
||||
super().setIndexWidget(index, w)
|
||||
if self.rowHeight(index.row()) < w.height():
|
||||
|
Loading…
x
Reference in New Issue
Block a user