Make connection loss handling more elegant

Show an info box on connection lost informing the user that the
Thermostat was forcefully disconnected.
This commit is contained in:
atse 2024-06-20 15:25:04 +08:00
parent 31bdbf93c4
commit 8ab93591a3
1 changed files with 9 additions and 1 deletions

View File

@ -64,7 +64,15 @@ class MainWindow(QtWidgets.QMainWindow):
self.info_box = InfoBox()
self.client = WrappedClient(self)
self.client.connection_error.connect(self.bail)
def handle_connection_error():
self.info_box.display_info_box(
"Connection Error", "Thermostat connection lost. Is it unplugged?"
)
self.bail()
self.client.connection_error.connect(handle_connection_error)
self.thermostat = Thermostat(
self, self.client, self.report_refresh_spin.value()