From 54f92557070b6ea4495d44e8b0ede513fa0d30e5 Mon Sep 17 00:00:00 2001 From: Loren Eteval Date: Sun, 28 Apr 2024 20:03:24 +0800 Subject: [PATCH] Add shared Qt widgets Signed-off-by: Loren Eteval --- Furious/QtFramework/QtWidgets.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Furious/QtFramework/QtWidgets.py b/Furious/QtFramework/QtWidgets.py index a40df9bc..13823249 100644 --- a/Furious/QtFramework/QtWidgets.py +++ b/Furious/QtFramework/QtWidgets.py @@ -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)