From 5732bc951fbbfca07c6033e42593d830373652e6 Mon Sep 17 00:00:00 2001 From: atse Date: Wed, 26 Jul 2023 13:50:29 +0800 Subject: [PATCH] Split the settings and plotting menus --- pytec/tec_qt.py | 17 +++++++++++------ pytec/tec_qt.ui | 10 ++++++++++ pytec/ui_tec_qt.py | 5 +++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 0469ca5..4c09280 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -280,10 +280,13 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.thermostat_settings.setMenu(self.menu) - clear = QtGui.QAction("Clear graphs", self.menu) + self.plot_menu = QtWidgets.QMenu() + self.plot_menu.setTitle("Plot Settings") + + clear = QtGui.QAction("Clear graphs", self.plot_menu) clear.triggered.connect(self.clear_graphs) - self.menu.addAction(clear) - self.menu.clear = clear + self.plot_menu.addAction(clear) + self.plot_menu.clear = clear self.samples_spinbox = QtWidgets.QSpinBox() self.samples_spinbox.setRange(2, 100000) @@ -291,10 +294,12 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.samples_spinbox.setValue(self.max_samples) self.samples_spinbox.valueChanged.connect(self.set_max_samples) - limit_samples = QtWidgets.QWidgetAction(self.menu) + limit_samples = QtWidgets.QWidgetAction(self.plot_menu) limit_samples.setDefaultWidget(self.samples_spinbox) - self.menu.addAction(limit_samples) - self.menu.limit_samples = limit_samples + self.plot_menu.addAction(limit_samples) + self.plot_menu.limit_samples = limit_samples + + self.toolButton_2.setMenu(self.plot_menu) @pyqtSlot(int) def set_max_samples(self, samples: int): diff --git a/pytec/tec_qt.ui b/pytec/tec_qt.ui index 3782127..a59870e 100644 --- a/pytec/tec_qt.ui +++ b/pytec/tec_qt.ui @@ -284,6 +284,16 @@ + + + + ... + + + QToolButton::InstantPopup + + + diff --git a/pytec/ui_tec_qt.py b/pytec/ui_tec_qt.py index 9a7cb61..2967d36 100644 --- a/pytec/ui_tec_qt.py +++ b/pytec/ui_tec_qt.py @@ -131,6 +131,10 @@ class Ui_MainWindow(object): self.thermostat_settings.setPopupMode(QtWidgets.QToolButton.ToolButtonPopupMode.InstantPopup) self.thermostat_settings.setObjectName("thermostat_settings") self.settings_layout.addWidget(self.thermostat_settings) + self.toolButton_2 = QtWidgets.QToolButton(parent=self.bottom_settings_group) + self.toolButton_2.setPopupMode(QtWidgets.QToolButton.ToolButtonPopupMode.InstantPopup) + self.toolButton_2.setObjectName("toolButton_2") + self.settings_layout.addWidget(self.toolButton_2) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.settings_layout.addItem(spacerItem) self.report_group = QtWidgets.QWidget(parent=self.bottom_settings_group) @@ -216,6 +220,7 @@ class Ui_MainWindow(object): self.ip_set_line.setPlaceholderText(_translate("MainWindow", "IP:port for the Thermostat")) self.connect_btn.setText(_translate("MainWindow", "Connect")) self.status_lbl.setText(_translate("MainWindow", "Disconnected")) + self.toolButton_2.setText(_translate("MainWindow", "...")) self.report_lbl.setText(_translate("MainWindow", "Poll every: ")) self.report_refresh_spin.setSuffix(_translate("MainWindow", " s")) self.report_box.setText(_translate("MainWindow", "Report"))