diff --git a/CHANGELOG b/CHANGELOG index f63d71b..c28811f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ - fix: polygon filters were not stored correctly in log mode - fix: several issues related to contour plots, contour spacing, and log-scales + - fix: subclass MDSubWindow and catch closeEvent (#29) - enh+docs: make Young's modulus computation more user convenient and update the section in the docs - docs: finish first draft of documentation diff --git a/shapeout2/gui/main.py b/shapeout2/gui/main.py index 326cf47..bfbebe9 100644 --- a/shapeout2/gui/main.py +++ b/shapeout2/gui/main.py @@ -20,6 +20,7 @@ from . import pipeline_plot from . import quick_view from . import update +from . import widgets from .. import pipeline from .. import session @@ -359,15 +360,12 @@ def add_plot_window(self, plot_id): sub = self.subwindows_plots[plot_id] else: # create subwindow - sub = QtWidgets.QMdiSubWindow(self) + sub = widgets.MDISubWindowWOButtons(self) pw = pipeline_plot.PipelinePlot(parent=sub, pipeline=self.pipeline, plot_id=plot_id) self.plots_changed.connect(pw.update_content) pw.update_content() - sub.setSystemMenu(None) - sub.setWindowFlags(QtCore.Qt.CustomizeWindowHint - | QtCore.Qt.WindowTitleHint) sub.setWidget(pw) self.mdiArea.addSubWindow(sub) self.subwindows_plots[plot_id] = sub @@ -375,12 +373,9 @@ def add_plot_window(self, plot_id): sub.show() def init_analysis_view(self): - sub = QtWidgets.QMdiSubWindow(self) + sub = widgets.MDISubWindowWOButtons(self) self.widget_ana_view = analysis.AnalysisView() self.subwindows["analysis_view"] = sub - sub.setSystemMenu(None) - sub.setWindowFlags(QtCore.Qt.CustomizeWindowHint - | QtCore.Qt.WindowTitleHint) sub.setWidget(self.widget_ana_view) sub.hide() self.mdiArea.addSubWindow(sub) @@ -390,16 +385,13 @@ def init_analysis_view(self): self.on_quickview_refresh) def init_quick_view(self): - sub = QtWidgets.QMdiSubWindow(self) + sub = widgets.MDISubWindowWOButtons(self) self.widget_quick_view = quick_view.QuickView() sub.setWidget(self.widget_quick_view) self.toolButton_quick_view.clicked.connect(self.on_quickview) self.subwindows["quick_view"] = sub # signals self.block_matrix.quickviewed.connect(self.on_quickview_show_dataset) - sub.setSystemMenu(None) - sub.setWindowFlags(QtCore.Qt.CustomizeWindowHint - | QtCore.Qt.WindowTitleHint) sub.hide() self.mdiArea.addSubWindow(sub) diff --git a/shapeout2/gui/widgets/__init__.py b/shapeout2/gui/widgets/__init__.py index 8c9003b..15db857 100644 --- a/shapeout2/gui/widgets/__init__.py +++ b/shapeout2/gui/widgets/__init__.py @@ -1,6 +1,7 @@ from .colorbar_widget import ColorBarWidget # noqa: F401 from .double_spin_box_nan import DoubleSpinBoxNan # noqa: F401 from .key_value_table_widget import KeyValueTableWidget # noqa: F401 +from .mdi_subwindow_wo_close import MDISubWindowWOButtons # noqa: F401 from .qrangeslider import QRangeSlider # noqa: F401 from .rangecontrol import RangeControl # noqa: F401 from .simple_image_view import SimpleImageView # noqa: F401 diff --git a/shapeout2/gui/widgets/mdi_subwindow_wo_close.py b/shapeout2/gui/widgets/mdi_subwindow_wo_close.py new file mode 100644 index 0000000..fb947f5 --- /dev/null +++ b/shapeout2/gui/widgets/mdi_subwindow_wo_close.py @@ -0,0 +1,12 @@ +from PyQt5 import QtCore, QtWidgets + + +class MDISubWindowWOButtons(QtWidgets.QMdiSubWindow): + def __init__(self, *args, **kwargs): + super(MDISubWindowWOButtons, self).__init__(*args, **kwargs) + self.setSystemMenu(None) + self.setWindowFlags(QtCore.Qt.CustomizeWindowHint + | QtCore.Qt.WindowTitleHint) + + def closeEvent(self, event): + event.ignore()