forked from M-Labs/thermostat
Refactor repeated stuff
This commit is contained in:
parent
94eb331c96
commit
ac9ddc92a6
@ -133,14 +133,20 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
|
|
||||||
@asyncSlot(ThermostatConnectionState)
|
@asyncSlot(ThermostatConnectionState)
|
||||||
async def _on_connection_changed(self, result):
|
async def _on_connection_changed(self, result):
|
||||||
|
self.graph_group.setEnabled(result == ThermostatConnectionState.CONNECTED)
|
||||||
|
self.report_group.setEnabled(result == ThermostatConnectionState.CONNECTED)
|
||||||
|
self.thermostat_settings.setEnabled(
|
||||||
|
result == ThermostatConnectionState.CONNECTED
|
||||||
|
)
|
||||||
|
self.conn_menu.host_set_line.setEnabled(
|
||||||
|
result != ThermostatConnectionState.DISCONNECTED
|
||||||
|
)
|
||||||
|
self.conn_menu.port_set_spin.setEnabled(
|
||||||
|
result != ThermostatConnectionState.DISCONNECTED
|
||||||
|
)
|
||||||
|
|
||||||
match result:
|
match result:
|
||||||
case ThermostatConnectionState.CONNECTED:
|
case ThermostatConnectionState.CONNECTED:
|
||||||
self.graph_group.setEnabled(True)
|
|
||||||
self.report_group.setEnabled(True)
|
|
||||||
self.thermostat_settings.setEnabled(True)
|
|
||||||
|
|
||||||
self.conn_menu.host_set_line.setEnabled(False)
|
|
||||||
self.conn_menu.port_set_spin.setEnabled(False)
|
|
||||||
self.connect_btn.setText("Disconnect")
|
self.connect_btn.setText("Disconnect")
|
||||||
hw_rev_d = await self.thermostat.get_hw_rev()
|
hw_rev_d = await self.thermostat.get_hw_rev()
|
||||||
self.status_lbl.setText(
|
self.status_lbl.setText(
|
||||||
@ -150,16 +156,8 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
case ThermostatConnectionState.CONNECTING:
|
case ThermostatConnectionState.CONNECTING:
|
||||||
self.status_lbl.setText("Connecting...")
|
self.status_lbl.setText("Connecting...")
|
||||||
self.connect_btn.setText("Stop")
|
self.connect_btn.setText("Stop")
|
||||||
self.conn_menu.host_set_line.setEnabled(False)
|
|
||||||
self.conn_menu.port_set_spin.setEnabled(False)
|
|
||||||
|
|
||||||
case ThermostatConnectionState.DISCONNECTED:
|
case ThermostatConnectionState.DISCONNECTED:
|
||||||
self.graph_group.setEnabled(False)
|
|
||||||
self.report_group.setEnabled(False)
|
|
||||||
self.thermostat_settings.setEnabled(False)
|
|
||||||
|
|
||||||
self.conn_menu.host_set_line.setEnabled(True)
|
|
||||||
self.conn_menu.port_set_spin.setEnabled(True)
|
|
||||||
self.connect_btn.setText("Connect")
|
self.connect_btn.setText("Connect")
|
||||||
|
|
||||||
self.status_lbl.setText("Disconnected")
|
self.status_lbl.setText("Disconnected")
|
||||||
|
Loading…
Reference in New Issue
Block a user