forked from M-Labs/thermostat
Put UI changes into conn_menu
This commit is contained in:
parent
382e5d916f
commit
4c9df5e1a8
|
@ -1,9 +1,16 @@
|
|||
from PyQt6 import QtWidgets, QtCore
|
||||
from PyQt6.QtCore import pyqtSlot
|
||||
from pytec.gui.model.thermostat import ThermostatConnectionState
|
||||
|
||||
|
||||
class ConnMenu(QtWidgets.QMenu):
|
||||
def __init__(self):
|
||||
def __init__(self, thermostat):
|
||||
super().__init__()
|
||||
self._thermostat = thermostat
|
||||
self._thermostat.connection_state_changed.connect(
|
||||
self.thermostat_state_change_handler
|
||||
)
|
||||
|
||||
self.setTitle("Connection Settings")
|
||||
|
||||
self.host_set_line = QtWidgets.QLineEdit()
|
||||
|
@ -54,3 +61,12 @@ class ConnMenu(QtWidgets.QMenu):
|
|||
exit_action.setDefaultWidget(self.exit_button)
|
||||
self.addAction(exit_action)
|
||||
self.exit_action = exit_action
|
||||
|
||||
@pyqtSlot(ThermostatConnectionState)
|
||||
def thermostat_state_change_handler(self, state):
|
||||
self.host_set_line.setEnabled(
|
||||
state == ThermostatConnectionState.DISCONNECTED
|
||||
)
|
||||
self.port_set_spin.setEnabled(
|
||||
state == ThermostatConnectionState.DISCONNECTED
|
||||
)
|
||||
|
|
|
@ -112,7 +112,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||
self.plot_options_menu = PlotOptionsMenu(self.channel_graphs)
|
||||
self.plot_settings.setMenu(self.plot_options_menu)
|
||||
|
||||
self.conn_menu = ConnMenu()
|
||||
self.conn_menu = ConnMenu(self.thermostat)
|
||||
self.connect_btn.setMenu(self.conn_menu)
|
||||
|
||||
self.thermostat_ctrl_menu = ThermostatCtrlMenu(
|
||||
|
@ -129,12 +129,6 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||
self.thermostat_settings.setEnabled(
|
||||
state == ThermostatConnectionState.CONNECTED
|
||||
)
|
||||
self.conn_menu.host_set_line.setEnabled(
|
||||
state == ThermostatConnectionState.DISCONNECTED
|
||||
)
|
||||
self.conn_menu.port_set_spin.setEnabled(
|
||||
state == ThermostatConnectionState.DISCONNECTED
|
||||
)
|
||||
|
||||
match state:
|
||||
case ThermostatConnectionState.CONNECTED:
|
||||
|
|
Loading…
Reference in New Issue