forked from M-Labs/thermostat
Fix loading all channel settings would bring up 2 info boxes
This commit is contained in:
parent
ef86336b95
commit
7cf8d6ee70
@ -130,18 +130,12 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
||||
return await self._client.ipv4()
|
||||
|
||||
@asyncSlot()
|
||||
async def save_cfg(self, ch):
|
||||
async def save_cfg(self, ch=""):
|
||||
await self._client.save_config(ch)
|
||||
self.info_box_trigger.emit(
|
||||
"Settings saved", f"Channel {ch} Settings has been saved to flash."
|
||||
)
|
||||
|
||||
@asyncSlot()
|
||||
async def load_cfg(self, ch):
|
||||
async def load_cfg(self, ch=""):
|
||||
await self._client.load_config(ch)
|
||||
self.info_box_trigger.emit(
|
||||
"Settings loaded", f"Channel {ch} Settings has been loaded from flash."
|
||||
)
|
||||
|
||||
async def dfu(self):
|
||||
await self._client.dfu()
|
||||
|
@ -23,6 +23,7 @@ class CtrlPanel(QObject):
|
||||
self,
|
||||
thermostat,
|
||||
autotuners,
|
||||
info_box,
|
||||
trees_ui,
|
||||
param_tree,
|
||||
sigActivated_handles,
|
||||
@ -32,6 +33,7 @@ class CtrlPanel(QObject):
|
||||
|
||||
self.thermostat = thermostat
|
||||
self.autotuners = autotuners
|
||||
self.info_box = info_box
|
||||
self.trees_ui = trees_ui
|
||||
self.NUM_CHANNELS = len(trees_ui)
|
||||
|
||||
@ -60,10 +62,10 @@ class CtrlPanel(QObject):
|
||||
param.sigTreeStateChanged.connect(self.send_command)
|
||||
|
||||
param.child("save").sigActivated.connect(
|
||||
partial(self.thermostat.save_cfg, ch)
|
||||
partial(self.save_settings, ch)
|
||||
)
|
||||
param.child("load").sigActivated.connect(
|
||||
partial(self.thermostat.load_cfg, ch)
|
||||
partial(self.load_settings, ch)
|
||||
)
|
||||
for handle in sigActivated_handles[ch]:
|
||||
param.child(*handle[0]).sigActivated.connect(handle[1])
|
||||
@ -226,3 +228,19 @@ class CtrlPanel(QObject):
|
||||
self.params[channel].child("postfilter", "rate").set_value_with_lock(
|
||||
postfilter_params["rate"]
|
||||
)
|
||||
|
||||
@asyncSlot(int)
|
||||
async def load_settings(self, ch):
|
||||
await self.thermostat.load_cfg(ch)
|
||||
|
||||
self.info_box.display_info_box(
|
||||
"Config loaded", f"Channel {ch} Config has been loaded from flash."
|
||||
)
|
||||
|
||||
@asyncSlot(int)
|
||||
async def save_settings(self, ch):
|
||||
await self.thermostat.save_cfg(ch)
|
||||
|
||||
self.info_box.display_info_box(
|
||||
"Config saved", f"Channel {ch} Config has been saved from flash."
|
||||
)
|
||||
|
@ -8,9 +8,6 @@ from pytec.gui.view.net_settings_input_diag import NetSettingsInputDiag
|
||||
class ThermostatCtrlMenu(QtWidgets.QMenu):
|
||||
reset_act = pyqtSignal(bool)
|
||||
|
||||
load_cfg_act = pyqtSignal(int)
|
||||
save_cfg_act = pyqtSignal(int)
|
||||
|
||||
def __init__(self, thermostat, style):
|
||||
super().__init__()
|
||||
self._thermostat = thermostat
|
||||
@ -69,10 +66,10 @@ class ThermostatCtrlMenu(QtWidgets.QMenu):
|
||||
self.actionnet_settings_input_diag.triggered.connect(self.net_settings_request)
|
||||
self.addAction(self.actionnet_settings_input_diag)
|
||||
|
||||
@pyqtSlot(bool)
|
||||
def load(_):
|
||||
self.load_cfg_act.emit(0)
|
||||
self.load_cfg_act.emit(1)
|
||||
@asyncSlot(bool)
|
||||
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.")
|
||||
@ -83,10 +80,10 @@ class ThermostatCtrlMenu(QtWidgets.QMenu):
|
||||
self.actionLoad_all_configs.triggered.connect(load)
|
||||
self.addAction(self.actionLoad_all_configs)
|
||||
|
||||
@pyqtSlot(bool)
|
||||
def save(_):
|
||||
self.save_cfg_act.emit(0)
|
||||
self.save_cfg_act.emit(1)
|
||||
@asyncSlot(bool)
|
||||
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.")
|
||||
|
@ -90,11 +90,11 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
]
|
||||
for ch in range(self.NUM_CHANNELS)
|
||||
]
|
||||
self.thermostat.info_box_trigger.connect(self.info_box.display_info_box)
|
||||
|
||||
self.ctrl_panel_view = CtrlPanel(
|
||||
self.thermostat,
|
||||
self.autotuners,
|
||||
self.info_box,
|
||||
[self.ch0_tree, self.ch1_tree],
|
||||
get_ctrl_panel_config(args),
|
||||
param_tree_sigActivated_handles,
|
||||
@ -139,8 +139,6 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
self.thermostat_ctrl_menu = ThermostatCtrlMenu(self.thermostat, self.style())
|
||||
self.thermostat_ctrl_menu.reset_act.connect(self.reset_request)
|
||||
self.thermostat_ctrl_menu.save_cfg_act.connect(self.save_cfg_request)
|
||||
self.thermostat_ctrl_menu.load_cfg_act.connect(self.load_cfg_request)
|
||||
|
||||
self.thermostat.hw_rev_update.connect(self.thermostat_ctrl_menu.hw_rev)
|
||||
self.thermostat_settings.setMenu(self.thermostat_ctrl_menu)
|
||||
@ -292,18 +290,6 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.loading_spinner.start()
|
||||
self.loading_spinner.show()
|
||||
|
||||
@asyncSlot(int)
|
||||
async def save_cfg_request(self, ch):
|
||||
assert self.thermostat.connected()
|
||||
|
||||
await self.thermostat.save_cfg(str(ch))
|
||||
|
||||
@asyncSlot(int)
|
||||
async def load_cfg_request(self, ch):
|
||||
assert self.thermostat.connected()
|
||||
|
||||
await self.thermostat.load_cfg(str(ch))
|
||||
|
||||
@asyncSlot(bool)
|
||||
async def reset_request(self, _):
|
||||
assert self.thermostat.connected()
|
||||
|
Loading…
Reference in New Issue
Block a user