gui: remember the ambient temperature in the user config
Persists whenever set via the entry, and re-applies automatically on connect - so it survives a server restart (which would otherwise fall back to config.json's ambient_temperature) without retyping it.
This commit is contained in:
@@ -382,6 +382,11 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
# on_sud_changed() routes the reply to update_sud_forecast() instead
|
# on_sud_changed() routes the reply to update_sud_forecast() instead
|
||||||
# of a save dialog.
|
# of a save dialog.
|
||||||
self.msg_sud.send({'Save': True})
|
self.msg_sud.send({'Save': True})
|
||||||
|
# Re-apply the last ambient temperature we set, in case the server
|
||||||
|
# restarted since (and so fell back to its own config.json default).
|
||||||
|
remembered_ambient = self.user_config.get('ambient_temperature')
|
||||||
|
if remembered_ambient is not None:
|
||||||
|
self.msg_system.send({'AmbientTemp': remembered_ambient})
|
||||||
|
|
||||||
def on_plot_timer(self):
|
def on_plot_timer(self):
|
||||||
self.plot.sample(
|
self.plot.sample(
|
||||||
@@ -517,6 +522,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
value = float(self.lineEdit_ambient.text())
|
value = float(self.lineEdit_ambient.text())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return
|
return
|
||||||
|
self.user_config.set('ambient_temperature', value)
|
||||||
self.msg_system.send({'AmbientTemp': value})
|
self.msg_system.send({'AmbientTemp': value})
|
||||||
|
|
||||||
def update_status_env_label(self):
|
def update_status_env_label(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user