From a17a4e0c012eee61c71d5dcecf9f79c14a7fb35a Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Tue, 21 Feb 2023 18:55:41 +0100 Subject: [PATCH] add graph title --- src/gui_qt/_py/graph.py | 20 +++++++++++++------- src/gui_qt/_py/guidelinewidget.py | 13 ++++++------- src/gui_qt/graphs/draw_objects.py | 2 +- src/gui_qt/main/mainwindow.py | 10 +++++++++- src/resources/_ui/graph.ui | 22 +++++++++++++++++++++- src/resources/_ui/guidelinewidget.ui | 20 ++++---------------- 6 files changed, 54 insertions(+), 33 deletions(-) diff --git a/src/gui_qt/_py/graph.py b/src/gui_qt/_py/graph.py index c11a052..0378429 100644 --- a/src/gui_qt/_py/graph.py +++ b/src/gui_qt/_py/graph.py @@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets class Ui_GraphWindow(object): def setupUi(self, GraphWindow): GraphWindow.setObjectName("GraphWindow") - GraphWindow.resize(680, 520) + GraphWindow.resize(865, 520) GraphWindow.setBaseSize(QtCore.QSize(300, 10)) self.verticalLayout = QtWidgets.QVBoxLayout(GraphWindow) self.verticalLayout.setContentsMargins(3, 3, 3, 3) @@ -96,6 +96,12 @@ class Ui_GraphWindow(object): self.horizontalLayout.addWidget(self.line_3) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) + self.graph_label = QtWidgets.QLabel(self.widget) + self.graph_label.setText("") + self.graph_label.setObjectName("graph_label") + self.horizontalLayout.addWidget(self.graph_label) + spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem1) self.limit_button = QtWidgets.QToolButton(self.widget) self.limit_button.setCheckable(True) self.limit_button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) @@ -139,8 +145,8 @@ class Ui_GraphWindow(object): self.xmax_lineedit = QtWidgets.QLineEdit(self.limit_widget) self.xmax_lineedit.setObjectName("xmax_lineedit") self.horizontalLayout_2.addWidget(self.xmax_lineedit) - spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.horizontalLayout_2.addItem(spacerItem1) + spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.horizontalLayout_2.addItem(spacerItem2) self.label_3 = QtWidgets.QLabel(self.limit_widget) self.label_3.setObjectName("label_3") self.horizontalLayout_2.addWidget(self.label_3) @@ -176,16 +182,16 @@ class Ui_GraphWindow(object): self.title_lineedit = QtWidgets.QLineEdit(self.label_widget) self.title_lineedit.setObjectName("title_lineedit") self.horizontalLayout_3.addWidget(self.title_lineedit) - spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.horizontalLayout_3.addItem(spacerItem2) + spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.horizontalLayout_3.addItem(spacerItem3) self.label_6 = QtWidgets.QLabel(self.label_widget) self.label_6.setObjectName("label_6") self.horizontalLayout_3.addWidget(self.label_6) self.xaxis_linedit = QtWidgets.QLineEdit(self.label_widget) self.xaxis_linedit.setObjectName("xaxis_linedit") self.horizontalLayout_3.addWidget(self.xaxis_linedit) - spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.horizontalLayout_3.addItem(spacerItem3) + spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.horizontalLayout_3.addItem(spacerItem4) self.label_7 = QtWidgets.QLabel(self.label_widget) self.label_7.setObjectName("label_7") self.horizontalLayout_3.addWidget(self.label_7) diff --git a/src/gui_qt/_py/guidelinewidget.py b/src/gui_qt/_py/guidelinewidget.py index 808ffa8..2f82e7f 100644 --- a/src/gui_qt/_py/guidelinewidget.py +++ b/src/gui_qt/_py/guidelinewidget.py @@ -18,13 +18,12 @@ class Ui_Form(object): self.verticalLayout_2 = QtWidgets.QVBoxLayout(Form) self.verticalLayout_2.setContentsMargins(3, 3, 3, 3) self.verticalLayout_2.setObjectName("verticalLayout_2") - self.treeWidget = QtWidgets.QTreeWidget(Form) - self.treeWidget.setRootIsDecorated(True) - self.treeWidget.setObjectName("treeWidget") - self.treeWidget.headerItem().setText(0, "1") - self.treeWidget.header().setVisible(False) - self.treeWidget.header().setHighlightSections(True) - self.verticalLayout_2.addWidget(self.treeWidget) + self.comboBox = QtWidgets.QComboBox(Form) + self.comboBox.setObjectName("comboBox") + self.verticalLayout_2.addWidget(self.comboBox) + self.listWidget = QtWidgets.QListWidget(Form) + self.listWidget.setObjectName("listWidget") + self.verticalLayout_2.addWidget(self.listWidget) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.newButton = QtWidgets.QPushButton(Form) diff --git a/src/gui_qt/graphs/draw_objects.py b/src/gui_qt/graphs/draw_objects.py index 2d18ee4..5b6fe8e 100644 --- a/src/gui_qt/graphs/draw_objects.py +++ b/src/gui_qt/graphs/draw_objects.py @@ -219,4 +219,4 @@ class Ellipse(GraphicsObject): self.log_mode = [x_mode, y_mode] - self.informViewBoundsChanged() \ No newline at end of file + self.informViewBoundsChanged() diff --git a/src/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py index 7212234..1cb92b6 100644 --- a/src/gui_qt/main/mainwindow.py +++ b/src/gui_qt/main/mainwindow.py @@ -341,6 +341,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): for w in self.area.subWindowList(): wdgt = w.widget() if wdgt.id == gid: + w.disconnect() wdgt.disconnect() wdgt.scene.disconnect() if wdgt == self.current_graph_widget: @@ -397,6 +398,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): subwindow.setMinimumHeight(400) subwindow.setMinimumWidth(600) + self.datawidget.blockSignals(True) self.datawidget.tree.blockSignals(True) self.datawidget.add_graph(w.id, w.title) @@ -413,11 +415,12 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): self.ptsselectwidget.set_graphs(graph_list) @QtCore.pyqtSlot(QtWidgets.QMdiSubWindow, name='on_area_subWindowActivated') - def change_window(self, wd): + def change_window(self, wd: QtWidgets.QMdiSubWindow | None): """ Called every time focus moves from or to a subwindow. Returns None if current focus is not on a subwindow""" if wd is not None: if self.current_graph_widget is not None: self.current_graph_widget.closable = True + self.current_graph_widget.graph_label.setText('') if self.ptsselectwidget.isVisible(): self._select_ptswidget(False, False, False) @@ -431,6 +434,11 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): self.change_mouse_mode(self.actionMouse_behaviour.isChecked()) + if wd.isMaximized(): + self.current_graph_widget.graph_label.setText(self.current_graph_widget.title) + else: + self.current_graph_widget.graph_label.setText('') + pick = False block = False if self.ptsselectwidget.isVisible(): diff --git a/src/resources/_ui/graph.ui b/src/resources/_ui/graph.ui index 7c829d1..12972ca 100644 --- a/src/resources/_ui/graph.ui +++ b/src/resources/_ui/graph.ui @@ -6,7 +6,7 @@ 0 0 - 680 + 865 520 @@ -250,6 +250,26 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + diff --git a/src/resources/_ui/guidelinewidget.ui b/src/resources/_ui/guidelinewidget.ui index ab2a49f..24e1cfb 100644 --- a/src/resources/_ui/guidelinewidget.ui +++ b/src/resources/_ui/guidelinewidget.ui @@ -27,22 +27,10 @@ 3 - - - true - - - false - - - true - - - - 1 - - - + + + +