Add shared Qt widgets

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2024-04-28 20:04:13 +08:00
parent 6dae3c8077
commit 54f9255707
+20 -1
View File
@@ -33,7 +33,9 @@ import functools
__all__ = [
'moveToCenter',
'AppQCheckBox',
'AppQDialog',
'AppQDialogButtonBox',
'AppQGroupBox',
'AppQHeaderView',
'AppQLabel',
@@ -67,6 +69,14 @@ def moveToCenter(widget, parent=None):
widget.move(geometry.topLeft())
class AppQCheckBox(QTranslatable, QCheckBox):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def retranslate(self):
self.setText(_(self.text()))
class AppQDialog(QTranslatable, SupportConnectedCallback, QDialog):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -105,7 +115,7 @@ class AppQDialog(QTranslatable, SupportConnectedCallback, QDialog):
moveToCenter(self)
def retranslate(self):
pass
self.setWindowTitle(_(self.windowTitle()))
def disconnectedCallback(self):
self.setWindowIcon(AppHue.disconnectedWindowIcon())
@@ -114,6 +124,15 @@ class AppQDialog(QTranslatable, SupportConnectedCallback, QDialog):
self.setWindowIcon(AppHue.connectedWindowIcon())
class AppQDialogButtonBox(QTranslatable, QDialogButtonBox):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def retranslate(self):
for button in self.buttons():
button.setText(_(button.text()))
class AppQGroupBox(QTranslatable, QGroupBox):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)