From eaf17fcc4afea44d902fa041a3f161f07b6eaf22 Mon Sep 17 00:00:00 2001 From: Marie Backman Date: Fri, 14 Nov 2025 15:14:13 -0500 Subject: [PATCH] add a parent to the plots tab window to contain it inside the SasView GUI and make it minimize on close --- src/sas/qtgui/MainWindow/GuiManager.py | 3 ++- src/sas/qtgui/Plotting/TabbedPlotWidget.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/sas/qtgui/MainWindow/GuiManager.py b/src/sas/qtgui/MainWindow/GuiManager.py index fda8d8a7a0..d43201ca89 100644 --- a/src/sas/qtgui/MainWindow/GuiManager.py +++ b/src/sas/qtgui/MainWindow/GuiManager.py @@ -196,7 +196,8 @@ def addWidgets(self): self.FileConverter = FileConverterWidget(self) self.WhatsNew = WhatsNew(self._parent) - self.tabbedPlotWidget = TabbedPlotWidget(self) + self.tabbedPlotWidget = TabbedPlotWidget(self._parent) + self.tabbedPlotWidgetSubWindow = self._workspace.workspace.addSubWindow(self.tabbedPlotWidget) def loadAllPerspectives(self): """ Load all the perspectives""" diff --git a/src/sas/qtgui/Plotting/TabbedPlotWidget.py b/src/sas/qtgui/Plotting/TabbedPlotWidget.py index 8381a360ea..6105d3f671 100644 --- a/src/sas/qtgui/Plotting/TabbedPlotWidget.py +++ b/src/sas/qtgui/Plotting/TabbedPlotWidget.py @@ -1,4 +1,5 @@ from PySide6 import QtCore, QtGui, QtWidgets +from PySide6.QtGui import QCloseEvent from sas.qtgui.Plotting.SubTabs import SubTabs from sas.qtgui.Utilities import GuiUtils @@ -9,7 +10,7 @@ class TabbedPlotWidget(QtWidgets.QTabWidget): Central plot widget that holds tabs and subtabs for all existing plots """ def __init__(self, parent=None): - super(TabbedPlotWidget, self).__init__() + super(TabbedPlotWidget, self).__init__(parent) # the manager/parent of this class is the GuiManager self.manager = parent @@ -25,7 +26,7 @@ def __init__(self, parent=None): self.inv_tab_fitpage_dict = {} self._set_icon() - self.setWindowTitle('TabbedPlotWidget') + self.setWindowTitle('PlotViewer') self.setMinimumSize(500, 500) self.hide() @@ -50,7 +51,7 @@ def show_or_activate(self): def add_tab_to_dict(self, tab_id: int) -> int: """ - This method handles the bookkeeping for the existing tabs and there respective fitpages. + This method handles the bookkeeping for the existing tabs and their respective fitpages. Only adds the tab_id to the dict, if it does not already exist in there. Returns the tab index of the existing or newly added tab. """ @@ -102,4 +103,9 @@ def get_subtab_by_tab_id(self, tab_id: int): else: return None - + def closeEvent(self, event: QCloseEvent): + """ + Overwrite the close event and minimize the window instead of closing it + """ + self.setWindowState(QtCore.Qt.WindowMinimized) + event.ignore()