From ea1c25672c397945e834bffa386b11d77c8270a4 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Wed, 29 Nov 2023 00:40:27 -0700 Subject: [PATCH 1/2] Dialogs: Call setMinimumSize and adjustSize Fix an issue with PySide 6.6.0 where dialogs are spawned with minimal size, in each case far too small. --- angrmanagement/ui/dialogs/analysis_options.py | 4 +++- angrmanagement/ui/dialogs/assemble_patch.py | 5 ++--- angrmanagement/ui/dialogs/command_palette.py | 5 ++++- angrmanagement/ui/dialogs/function.py | 7 +++---- angrmanagement/ui/dialogs/xref.py | 6 ++++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/angrmanagement/ui/dialogs/analysis_options.py b/angrmanagement/ui/dialogs/analysis_options.py index 3fa5df1fe..cf90ad405 100644 --- a/angrmanagement/ui/dialogs/analysis_options.py +++ b/angrmanagement/ui/dialogs/analysis_options.py @@ -210,8 +210,10 @@ def __init__(self, analyses: AnalysesConfiguration, workspace: "Workspace", pare self._workspace: Workspace = workspace self._analyses: AnalysesConfiguration = analyses self._mappers: Sequence[AnalysisOptionWidgetMapper] = [] - self.setWindowTitle("Run Analysis") self._init_widgets() + self.setWindowTitle("Run Analysis") + self.setMinimumSize(self.sizeHint()) + self.adjustSize() def sizeHint(self, *args, **kwargs): # pylint: disable=unused-argument,no-self-use return QSize(800, 600) diff --git a/angrmanagement/ui/dialogs/assemble_patch.py b/angrmanagement/ui/dialogs/assemble_patch.py index e900a76e3..49699f323 100644 --- a/angrmanagement/ui/dialogs/assemble_patch.py +++ b/angrmanagement/ui/dialogs/assemble_patch.py @@ -54,9 +54,8 @@ def __init__(self, address: int, instance: "Instance", parent=None): self._init_widgets() self.setWindowTitle(f"Assemble Patch at {self._patch_addr:#x}") - - def sizeHint(self): # pylint:disable=no-self-use - return QSize(400, 150) + self.setMinimumWidth(500) + self.adjustSize() # # Private methods diff --git a/angrmanagement/ui/dialogs/command_palette.py b/angrmanagement/ui/dialogs/command_palette.py index cff848725..4d6149842 100644 --- a/angrmanagement/ui/dialogs/command_palette.py +++ b/angrmanagement/ui/dialogs/command_palette.py @@ -221,13 +221,16 @@ class PaletteDialog(QDialog): def __init__(self, model, delegate=None, parent=None): super().__init__(parent) - self.setWindowTitle("Palette") self._model = model self._delegate = delegate or PaletteItemDelegate() self._init_widgets() self.selected_item = None + self.setWindowTitle("Palette") + self.setMinimumSize(self.sizeHint()) + self.adjustSize() + def sizeHint(self): # pylint:disable=no-self-use return QSize(500, 400) diff --git a/angrmanagement/ui/dialogs/function.py b/angrmanagement/ui/dialogs/function.py index 382d2e5e3..c7a014c24 100644 --- a/angrmanagement/ui/dialogs/function.py +++ b/angrmanagement/ui/dialogs/function.py @@ -29,12 +29,11 @@ def __init__(self, function, parent=None): super().__init__(parent) self.workspace = GlobalInfo.main_window.workspace self.function = function + self._init_widgets() self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.setWindowTitle(f"Function {self.function.name}") - self._init_widgets() - - def sizeHint(self, *args, **kwargs): # pylint: disable=unused-argument,no-self-use - return QSize(600, 300) + self.setMinimumWidth(600) + self.adjustSize() def _init_widgets(self): font = QFont(Conf.disasm_font) diff --git a/angrmanagement/ui/dialogs/xref.py b/angrmanagement/ui/dialogs/xref.py index 1b139ee1c..4791d6561 100644 --- a/angrmanagement/ui/dialogs/xref.py +++ b/angrmanagement/ui/dialogs/xref.py @@ -27,8 +27,6 @@ def __init__( ): super().__init__(parent) - self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint | Qt.WindowCloseButtonHint) - self._variable_manager = variable_manager self._variable = variable self._xrefs_manager = xrefs_manager @@ -54,6 +52,10 @@ def __init__( self._init_widgets() + self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint | Qt.WindowCloseButtonHint) + self.setMinimumSize(self.sizeHint()) + self.adjustSize() + def sizeHint(self, *args, **kwargs): # pylint: disable=unused-argument,no-self-use return QSize(600, 400) From f8d9d72e05689cada69680db5d10ad3e72d73d80 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 29 Nov 2023 08:07:53 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- angrmanagement/ui/dialogs/assemble_patch.py | 1 - angrmanagement/ui/dialogs/function.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/angrmanagement/ui/dialogs/assemble_patch.py b/angrmanagement/ui/dialogs/assemble_patch.py index 49699f323..f16eb640f 100644 --- a/angrmanagement/ui/dialogs/assemble_patch.py +++ b/angrmanagement/ui/dialogs/assemble_patch.py @@ -6,7 +6,6 @@ from typing import TYPE_CHECKING, Optional -from PySide6.QtCore import QSize from PySide6.QtGui import QFont from PySide6.QtWidgets import ( QCheckBox, diff --git a/angrmanagement/ui/dialogs/function.py b/angrmanagement/ui/dialogs/function.py index c7a014c24..fa21e71d2 100644 --- a/angrmanagement/ui/dialogs/function.py +++ b/angrmanagement/ui/dialogs/function.py @@ -1,7 +1,7 @@ from pygments.lexers.c_cpp import CLexer from pyqodeng.core.api import CodeEdit from pyqodeng.core.modes import PygmentsSyntaxHighlighter -from PySide6.QtCore import QSize, Qt +from PySide6.QtCore import Qt from PySide6.QtGui import QFont from PySide6.QtWidgets import ( QCheckBox,