From d5e2abfac7c5b36df704b7509f0fb0bb8c7b65f5 Mon Sep 17 00:00:00 2001 From: atse Date: Tue, 27 Aug 2024 17:00:16 +0800 Subject: [PATCH] Fix info boxes for load/saving from flash --- pytec/pytec/gui/view/thermostat_ctrl_menu.py | 19 ++++++++----------- pytec/tec_qt.py | 4 +++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pytec/pytec/gui/view/thermostat_ctrl_menu.py b/pytec/pytec/gui/view/thermostat_ctrl_menu.py index 50455ef..f264b9f 100644 --- a/pytec/pytec/gui/view/thermostat_ctrl_menu.py +++ b/pytec/pytec/gui/view/thermostat_ctrl_menu.py @@ -6,9 +6,10 @@ from pytec.gui.view.net_settings_input_diag import NetSettingsInputDiag class ThermostatCtrlMenu(QtWidgets.QMenu): - def __init__(self, thermostat, style): + def __init__(self, thermostat, info_box, style): super().__init__() self._thermostat = thermostat + self._info_box = info_box self._style = style self.setTitle("Thermostat settings") @@ -69,11 +70,9 @@ class ThermostatCtrlMenu(QtWidgets.QMenu): async def load(_): await self._thermostat.load_cfg() - loaded = QtWidgets.QMessageBox(self) - loaded.setWindowTitle("Config loaded") - loaded.setText("All channel configs have been loaded from flash.") - loaded.setIcon(QtWidgets.QMessageBox.Icon.Information) - loaded.show() + self._info_box.display_info_box( + "Config loaded", "All channel configs have been loaded from flash." + ) self.actionLoad_all_configs = QtGui.QAction("Load Config", self) self.actionLoad_all_configs.triggered.connect(load) @@ -83,11 +82,9 @@ class ThermostatCtrlMenu(QtWidgets.QMenu): async def save(_): await self._thermostat.save_cfg() - saved = QtWidgets.QMessageBox(self) - saved.setWindowTitle("Config saved") - saved.setText("All channel configs have been saved to flash.") - saved.setIcon(QtWidgets.QMessageBox.Icon.Information) - saved.show() + self._info_box.display_info_box( + "Config saved", "All channel configs have been saved to flash." + ) self.actionSave_all_configs = QtGui.QAction("Save Config", self) self.actionSave_all_configs.triggered.connect(save) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index b4adf85..74db4dc 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -116,7 +116,9 @@ class MainWindow(QtWidgets.QMainWindow): self.conn_menu = ConnMenu() self.connect_btn.setMenu(self.conn_menu) - self.thermostat_ctrl_menu = ThermostatCtrlMenu(self.thermostat, self.style()) + self.thermostat_ctrl_menu = ThermostatCtrlMenu( + self.thermostat, self.info_box, self.style() + ) self.thermostat_settings.setMenu(self.thermostat_ctrl_menu) self.loading_spinner.hide()