From bd4b88102a3c231ed4e4d1a7fd3ab76fef112deb Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 22 Feb 2023 18:57:39 +0100 Subject: [PATCH] graph title is displayed when maximized --- src/gui_qt/graphs/graphwindow.py | 13 +++++++++++++ src/gui_qt/main/mainwindow.py | 1 + 2 files changed, 14 insertions(+) diff --git a/src/gui_qt/graphs/graphwindow.py b/src/gui_qt/graphs/graphwindow.py index e0a63f0..2f44954 100644 --- a/src/gui_qt/graphs/graphwindow.py +++ b/src/gui_qt/graphs/graphwindow.py @@ -131,6 +131,8 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): @title.setter def title(self, value): + if self.graph_label.text() != '': + self.graph_label.setText(str(value)) self.setWindowTitle(str(value)) @property @@ -349,6 +351,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): self.graphic.addItem(obj.drawing) def closeEvent(self, evt: QtGui.QCloseEvent): + print(self.parent()) if not self.closable: evt.ignore() return @@ -746,3 +749,13 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): temp = self._fgcolor, self._bgcolor self.set_color(foreground=self._prev_colors[0], background=self._prev_colors[1]) self._prev_colors = temp + + + @QtCore.pyqtSlot(QtCore.Qt.WindowStates, QtCore.Qt.WindowStates) + def state_changed(self, old_state: QtCore.Qt.WindowStates, new_state: QtCore.Qt.WindowStates): + old_maximized = old_state & QtCore.Qt.WindowMaximized + new_maximized = new_state & QtCore.Qt.WindowMaximized + if old_maximized and not new_maximized: + self.graph_label.setText('') + elif not old_maximized and new_maximized: + self.graph_label.setText(self.title) \ No newline at end of file diff --git a/src/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py index 1cb92b6..4e5e2ec 100644 --- a/src/gui_qt/main/mainwindow.py +++ b/src/gui_qt/main/mainwindow.py @@ -397,6 +397,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): subwindow.setOption(QtWidgets.QMdiSubWindow.RubberBandResize, True) subwindow.setMinimumHeight(400) subwindow.setMinimumWidth(600) + subwindow.windowStateChanged.connect(w.state_changed) self.datawidget.blockSignals(True)