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 5694951a23
commit 446d5c4d22

View File

@ -64,7 +64,15 @@ class MainWindow(QtWidgets.QMainWindow):
self.info_box = InfoBox() self.info_box = InfoBox()
self.client = WrappedClient(self) 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.thermostat = Thermostat(
self, self.client, self.report_refresh_spin.value() self, self.client, self.report_refresh_spin.value()