From cf1b7c778c7b10909ce4c3d815232e08772b0002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gosselin?= Date: Fri, 17 Jan 2025 11:29:49 -0500 Subject: [PATCH 1/4] Add option to control min height --- qtapputils/widgets/configdialog.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qtapputils/widgets/configdialog.py b/qtapputils/widgets/configdialog.py index d15ad5c..207a30b 100644 --- a/qtapputils/widgets/configdialog.py +++ b/qtapputils/widgets/configdialog.py @@ -80,7 +80,8 @@ class ConfDialog(QDialog): A dialog window to manage app preferences. """ - def __init__(self, main, icon: QIcon = None, resizable: bool = True): + def __init__(self, main, icon: QIcon = None, resizable: bool = True, + min_height: int = None): super().__init__(main) self.main = main @@ -90,7 +91,8 @@ def __init__(self, main, icon: QIcon = None, resizable: bool = True): self.setWindowFlags( self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.setModal(True) - self.setMinimumHeight(500) + if min_height is not None: + self.setMinimumHeight(min_height) self.confpages_tabwidget = QTabWidget() self.confpages_tabwidget.setTabBar(HorizontalTabBar()) From 8b1d55dcd6aa42b13ea03cf283cb3c3dc99ab270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gosselin?= Date: Fri, 17 Jan 2025 11:30:30 -0500 Subject: [PATCH 2/4] Add option to add a message at the top of the dialog --- qtapputils/widgets/configdialog.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/qtapputils/widgets/configdialog.py b/qtapputils/widgets/configdialog.py index 207a30b..ce10cdb 100644 --- a/qtapputils/widgets/configdialog.py +++ b/qtapputils/widgets/configdialog.py @@ -17,7 +17,7 @@ from qtpy.QtWidgets import ( QAbstractButton, QApplication, QStyle, QStylePainter, QDialog, QPushButton, QDialogButtonBox, QWidget, QTabWidget, - QGridLayout, QTabBar, QStyleOptionTab) + QGridLayout, QTabBar, QStyleOptionTab, QLabel) class HorizontalTabBar(QTabBar): @@ -81,7 +81,7 @@ class ConfDialog(QDialog): """ def __init__(self, main, icon: QIcon = None, resizable: bool = True, - min_height: int = None): + min_height: int = None, sup_message: str = None): super().__init__(main) self.main = main @@ -119,9 +119,17 @@ def __init__(self, main, icon: QIcon = None, resizable: bool = True, # Setup the main layout. main_layout = QGridLayout(self) - main_layout.addWidget(self.confpages_tabwidget) - main_layout.addWidget(button_box) - main_layout.setRowStretch(0, 1) + + row = 0 + if sup_message is not None: + label = QLabel(sup_message) + label.setWordWrap(True) + label.setMargin(10) + main_layout.addWidget(label, row, 0) + row += 1 + main_layout.addWidget(self.confpages_tabwidget, row, 0) + main_layout.setRowStretch(row, 1) + main_layout.addWidget(button_box, row+1, 0) if resizable is False: main_layout.setSizeConstraint(main_layout.SetFixedSize) From 96279c9270e1238386a543530a22b96505f85f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gosselin?= Date: Fri, 17 Jan 2025 11:31:00 -0500 Subject: [PATCH 3/4] Add an option to change the button labels --- qtapputils/widgets/configdialog.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qtapputils/widgets/configdialog.py b/qtapputils/widgets/configdialog.py index ce10cdb..d93e8ca 100644 --- a/qtapputils/widgets/configdialog.py +++ b/qtapputils/widgets/configdialog.py @@ -81,7 +81,8 @@ class ConfDialog(QDialog): """ def __init__(self, main, icon: QIcon = None, resizable: bool = True, - min_height: int = None, sup_message: str = None): + min_height: int = None, sup_message: str = None, + btn_labels: dict = None): super().__init__(main) self.main = main @@ -100,13 +101,15 @@ def __init__(self, main, icon: QIcon = None, resizable: bool = True, self._confpages = {} # Setup the dialog button box. - self.ok_button = QPushButton('OK') + btn_labels = {} if btn_labels is None else btn_labels + + self.ok_button = QPushButton(btn_labels.get('ok', 'OK')) self.ok_button.setDefault(False) self.ok_button.setAutoDefault(False) - self.apply_button = QPushButton('Apply') + self.apply_button = QPushButton(btn_labels.get('apply', 'Apply')) self.apply_button.setDefault(True) self.apply_button.setEnabled(False) - self.cancel_button = QPushButton('Cancel') + self.cancel_button = QPushButton(btn_labels.get('cancel', 'Cancel')) self.cancel_button.setDefault(False) self.cancel_button.setAutoDefault(False) From fbb9ac472139f5959ff97cc502f97f5aa7fd85e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gosselin?= Date: Fri, 17 Jan 2025 11:31:24 -0500 Subject: [PATCH 4/4] Add option to set the title of the dialog window --- qtapputils/widgets/configdialog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qtapputils/widgets/configdialog.py b/qtapputils/widgets/configdialog.py index d93e8ca..aea5e58 100644 --- a/qtapputils/widgets/configdialog.py +++ b/qtapputils/widgets/configdialog.py @@ -82,11 +82,11 @@ class ConfDialog(QDialog): def __init__(self, main, icon: QIcon = None, resizable: bool = True, min_height: int = None, sup_message: str = None, - btn_labels: dict = None): + btn_labels: dict = None, win_title: str = 'Preferences'): super().__init__(main) self.main = main - self.setWindowTitle('Preferences') + self.setWindowTitle(win_title) if icon is not None: self.setWindowIcon(icon) self.setWindowFlags(