Split the settings and plotting menus

This commit is contained in:
atse 2023-07-26 13:50:29 +08:00
parent cbffb8d700
commit 5732bc951f
3 changed files with 26 additions and 6 deletions

View File

@ -280,10 +280,13 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self.thermostat_settings.setMenu(self.menu) 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) clear.triggered.connect(self.clear_graphs)
self.menu.addAction(clear) self.plot_menu.addAction(clear)
self.menu.clear = clear self.plot_menu.clear = clear
self.samples_spinbox = QtWidgets.QSpinBox() self.samples_spinbox = QtWidgets.QSpinBox()
self.samples_spinbox.setRange(2, 100000) 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.setValue(self.max_samples)
self.samples_spinbox.valueChanged.connect(self.set_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) limit_samples.setDefaultWidget(self.samples_spinbox)
self.menu.addAction(limit_samples) self.plot_menu.addAction(limit_samples)
self.menu.limit_samples = limit_samples self.plot_menu.limit_samples = limit_samples
self.toolButton_2.setMenu(self.plot_menu)
@pyqtSlot(int) @pyqtSlot(int)
def set_max_samples(self, samples: int): def set_max_samples(self, samples: int):

View File

@ -284,6 +284,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="toolButton_2">
<property name="text">
<string>...</string>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">

View File

@ -131,6 +131,10 @@ class Ui_MainWindow(object):
self.thermostat_settings.setPopupMode(QtWidgets.QToolButton.ToolButtonPopupMode.InstantPopup) self.thermostat_settings.setPopupMode(QtWidgets.QToolButton.ToolButtonPopupMode.InstantPopup)
self.thermostat_settings.setObjectName("thermostat_settings") self.thermostat_settings.setObjectName("thermostat_settings")
self.settings_layout.addWidget(self.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) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.settings_layout.addItem(spacerItem) self.settings_layout.addItem(spacerItem)
self.report_group = QtWidgets.QWidget(parent=self.bottom_settings_group) 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.ip_set_line.setPlaceholderText(_translate("MainWindow", "IP:port for the Thermostat"))
self.connect_btn.setText(_translate("MainWindow", "Connect")) self.connect_btn.setText(_translate("MainWindow", "Connect"))
self.status_lbl.setText(_translate("MainWindow", "Disconnected")) self.status_lbl.setText(_translate("MainWindow", "Disconnected"))
self.toolButton_2.setText(_translate("MainWindow", "..."))
self.report_lbl.setText(_translate("MainWindow", "Poll every: ")) self.report_lbl.setText(_translate("MainWindow", "Poll every: "))
self.report_refresh_spin.setSuffix(_translate("MainWindow", " s")) self.report_refresh_spin.setSuffix(_translate("MainWindow", " s"))
self.report_box.setText(_translate("MainWindow", "Report")) self.report_box.setText(_translate("MainWindow", "Report"))