From e68926806cebd25b8a4e709fe25f7cd3d8e105b2 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Fri, 13 Sep 2024 12:48:17 +0200 Subject: [PATCH] Show exit screen on window close --- sbapp/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sbapp/main.py b/sbapp/main.py index a9ff541..143e45e 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -303,6 +303,7 @@ class SidebandApp(MDApp): self.final_load_completed = False self.service_last_available = 0 + self.closing_app = False self.attach_path = None self.attach_type = None @@ -988,6 +989,11 @@ class SidebandApp(MDApp): ok_button.bind(on_release=dl_ok) dialog.open() + def close_requested(self, *args): + if not self.closing_app: + self.quit_action(None) + return True + def on_start(self): self.last_exit_event = time.time() self.root.ids.screen_manager.transition = self.slide_transition @@ -997,6 +1003,7 @@ class SidebandApp(MDApp): EventLoop.window.bind(on_keyboard=self.keyboard_event) EventLoop.window.bind(on_key_down=self.keydown_event) EventLoop.window.bind(on_key_up=self.keyup_event) + Window.bind(on_request_close=self.close_requested) if __variant__ != "": variant_str = " "+__variant__ @@ -1241,6 +1248,7 @@ class SidebandApp(MDApp): self.root.ids.nav_drawer.set_state("closed") def quit_action(self, sender): + self.closing_app = True self.root.ids.nav_drawer.set_state("closed") self.sideband.should_persist_data()