1
0
forked from M-Labs/thermostat

Sensible names for views

This commit is contained in:
atse 2024-09-09 15:06:22 +08:00
parent 28a76d091d
commit fae9122ad5
4 changed files with 16 additions and 14 deletions

View File

@ -3,7 +3,7 @@ from PyQt6.QtCore import pyqtSlot
from pytec.gui.model.thermostat import ThermostatConnectionState from pytec.gui.model.thermostat import ThermostatConnectionState
class ConnMenu(QtWidgets.QMenu): class ConnectionDetailsMenu(QtWidgets.QMenu):
def __init__(self, thermostat, connect_btn): def __init__(self, thermostat, connect_btn):
super().__init__() super().__init__()
self._thermostat = thermostat self._thermostat = thermostat

View File

@ -6,7 +6,7 @@ from pytec.gui.view.net_settings_input_diag import NetSettingsInputDiag
from pytec.gui.model.thermostat import ThermostatConnectionState from pytec.gui.model.thermostat import ThermostatConnectionState
class ThermostatCtrlMenu(QtWidgets.QMenu): class ThermostatSettingsMenu(QtWidgets.QMenu):
def __init__(self, thermostat, info_box, style): def __init__(self, thermostat, info_box, style):
super().__init__() super().__init__()
self._thermostat = thermostat self._thermostat = thermostat

View File

@ -1,6 +1,6 @@
from pytec.gui.view.zero_limits_warning import ZeroLimitsWarningView from pytec.gui.view.zero_limits_warning_view import ZeroLimitsWarningView
from pytec.gui.view.thermostat_ctrl_menu import ThermostatCtrlMenu from pytec.gui.view.thermostat_settings_menu import ThermostatSettingsMenu
from pytec.gui.view.conn_menu import ConnMenu from pytec.gui.view.connection_details_menu import ConnectionDetailsMenu
from pytec.gui.view.plot_options_menu import PlotOptionsMenu from pytec.gui.view.plot_options_menu import PlotOptionsMenu
from pytec.gui.view.live_plot_view import LiveDataPlotter from pytec.gui.view.live_plot_view import LiveDataPlotter
from pytec.gui.view.ctrl_panel import CtrlPanel from pytec.gui.view.ctrl_panel import CtrlPanel
@ -107,19 +107,21 @@ class MainWindow(QtWidgets.QMainWindow):
) )
# Bottom bar menus # Bottom bar menus
self.conn_menu = ConnMenu(self._thermostat, self.connect_btn) self.connection_details_menu = ConnectionDetailsMenu(
self.connect_btn.setMenu(self.conn_menu) self._thermostat, self.connect_btn
)
self.connect_btn.setMenu(self.connection_details_menu)
self._thermostat_ctrl_menu = ThermostatCtrlMenu( self._thermostat_settings_menu = ThermostatSettingsMenu(
self._thermostat, self._info_box, self.style() self._thermostat, self._info_box, self.style()
) )
self.thermostat_settings.setMenu(self._thermostat_ctrl_menu) self.thermostat_settings.setMenu(self._thermostat_settings_menu)
self._plot_options_menu = PlotOptionsMenu(self._channel_graphs) self._plot_options_menu = PlotOptionsMenu(self._channel_graphs)
self.plot_settings.setMenu(self._plot_options_menu) self.plot_settings.setMenu(self._plot_options_menu)
# Status line # Status line
self._zero_limits_warning = ZeroLimitsWarningView( self._zero_limits_warning_view = ZeroLimitsWarningView(
self._thermostat, self.style(), self.limits_warning self._thermostat, self.style(), self.limits_warning
) )
self.loading_spinner.hide() self.loading_spinner.hide()
@ -189,8 +191,8 @@ class MainWindow(QtWidgets.QMainWindow):
case ThermostatConnectionState.DISCONNECTED: case ThermostatConnectionState.DISCONNECTED:
self._connecting_task = asyncio.create_task( self._connecting_task = asyncio.create_task(
self._thermostat.start_session( self._thermostat.start_session(
host=self.conn_menu.host_set_line.text(), host=self.connection_details_menu.host_set_line.text(),
port=self.conn_menu.port_set_spin.value(), port=self.connection_details_menu.port_set_spin.value(),
) )
) )
self._thermostat.connection_state = ThermostatConnectionState.CONNECTING self._thermostat.connection_state = ThermostatConnectionState.CONNECTING
@ -234,9 +236,9 @@ async def coro_main():
if args.connect: if args.connect:
if args.HOST: if args.HOST:
main_window.conn_menu.host_set_line.setText(args.HOST) main_window.connection_details_menu.host_set_line.setText(args.HOST)
if args.PORT: if args.PORT:
main_window.conn_menu.port_set_spin.setValue(int(args.PORT)) main_window.connection_details_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()