forked from M-Labs/thermostat
Move plot_options_menu stuff into menu
This commit is contained in:
parent
0f117f8ee8
commit
a82e163d58
|
@ -2,18 +2,22 @@ from PyQt6 import QtWidgets, QtGui
|
||||||
|
|
||||||
|
|
||||||
class PlotOptionsMenu(QtWidgets.QMenu):
|
class PlotOptionsMenu(QtWidgets.QMenu):
|
||||||
def __init__(self, max_samples=1000):
|
def __init__(self, channel_graphs, max_samples=1000):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.channel_graphs = channel_graphs
|
||||||
|
|
||||||
self.setTitle("Plot Settings")
|
self.setTitle("Plot Settings")
|
||||||
|
|
||||||
clear = QtGui.QAction("Clear graphs", self)
|
clear = QtGui.QAction("Clear graphs", self)
|
||||||
self.addAction(clear)
|
self.addAction(clear)
|
||||||
self.clear = clear
|
self.clear = clear
|
||||||
|
self.clear.triggered.connect(self.channel_graphs.clear_graphs)
|
||||||
|
|
||||||
self.samples_spinbox = QtWidgets.QSpinBox()
|
self.samples_spinbox = QtWidgets.QSpinBox()
|
||||||
self.samples_spinbox.setRange(2, 100000)
|
self.samples_spinbox.setRange(2, 100000)
|
||||||
self.samples_spinbox.setSuffix(" samples")
|
self.samples_spinbox.setSuffix(" samples")
|
||||||
self.samples_spinbox.setValue(max_samples)
|
self.samples_spinbox.setValue(max_samples)
|
||||||
|
self.samples_spinbox.valueChanged.connect(self.channel_graphs.set_max_samples)
|
||||||
|
|
||||||
limit_samples = QtWidgets.QWidgetAction(self)
|
limit_samples = QtWidgets.QWidgetAction(self)
|
||||||
limit_samples.setDefaultWidget(self.samples_spinbox)
|
limit_samples.setDefaultWidget(self.samples_spinbox)
|
||||||
|
|
|
@ -124,11 +124,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
self.thermostat.report_update.connect(self.channel_graphs.update_report)
|
self.thermostat.report_update.connect(self.channel_graphs.update_report)
|
||||||
self.thermostat.pid_update.connect(self.channel_graphs.update_pid)
|
self.thermostat.pid_update.connect(self.channel_graphs.update_pid)
|
||||||
|
|
||||||
self.plot_options_menu = PlotOptionsMenu()
|
self.plot_options_menu = PlotOptionsMenu(self.channel_graphs)
|
||||||
self.plot_options_menu.clear.triggered.connect(self.clear_graphs)
|
|
||||||
self.plot_options_menu.samples_spinbox.valueChanged.connect(
|
|
||||||
self.channel_graphs.set_max_samples
|
|
||||||
)
|
|
||||||
self.plot_settings.setMenu(self.plot_options_menu)
|
self.plot_settings.setMenu(self.plot_options_menu)
|
||||||
|
|
||||||
self.conn_menu = ConnMenu()
|
self.conn_menu = ConnMenu()
|
||||||
|
@ -141,9 +137,6 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
|
|
||||||
self.loading_spinner.hide()
|
self.loading_spinner.hide()
|
||||||
|
|
||||||
def clear_graphs(self):
|
|
||||||
self.channel_graphs.clear_graphs()
|
|
||||||
|
|
||||||
@asyncSlot(ThermostatConnectionState)
|
@asyncSlot(ThermostatConnectionState)
|
||||||
async def _on_connection_changed(self, result):
|
async def _on_connection_changed(self, result):
|
||||||
match result:
|
match result:
|
||||||
|
@ -177,7 +170,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
self.loading_spinner.stop()
|
self.loading_spinner.stop()
|
||||||
self.thermostat_ctrl_menu.fan_pwm_warning.setPixmap(QtGui.QPixmap())
|
self.thermostat_ctrl_menu.fan_pwm_warning.setPixmap(QtGui.QPixmap())
|
||||||
self.thermostat_ctrl_menu.fan_pwm_warning.setToolTip("")
|
self.thermostat_ctrl_menu.fan_pwm_warning.setToolTip("")
|
||||||
self.clear_graphs()
|
self.channel_graphs.clear_graphs()
|
||||||
self.report_box.setChecked(False)
|
self.report_box.setChecked(False)
|
||||||
for ch in range(self.NUM_CHANNELS):
|
for ch in range(self.NUM_CHANNELS):
|
||||||
if self.autotuners.get_state(ch) != PIDAutotuneState.STATE_OFF:
|
if self.autotuners.get_state(ch) != PIDAutotuneState.STATE_OFF:
|
||||||
|
@ -317,9 +310,9 @@ async def coro_main():
|
||||||
|
|
||||||
if args.connect:
|
if args.connect:
|
||||||
if args.HOST:
|
if args.HOST:
|
||||||
main_window.host_set_line.setText(args.HOST)
|
main_window.conn_menu.host_set_line.setText(args.HOST)
|
||||||
if args.PORT:
|
if args.PORT:
|
||||||
main_window.port_set_spin.setValue(int(args.PORT))
|
main_window.conn_menu.port_set_spin.setValue(int(args.PORT))
|
||||||
main_window.connect_btn.click()
|
main_window.connect_btn.click()
|
||||||
|
|
||||||
await app_quit_event.wait()
|
await app_quit_event.wait()
|
||||||
|
|
Loading…
Reference in New Issue