prevent exit app

This commit is contained in:
2025-05-14 14:35:58 +03:00
parent 4a47775a9b
commit bdd8051747
3 changed files with 43 additions and 1 deletions

View File

@@ -20,3 +20,5 @@
2025-05-14 14:21:58 - STARTED: Operational_Plan_FY25-1.jpg
2025-05-14 14:22:13 - STARTED: Office_audit_overview_5S-1.jpg
2025-05-14 14:23:08 - STARTED: 03.03.2025_5S_Organigramm_Office-1.jpg
2025-05-14 14:35:11 - STARTED: Operational_Plan_FY25-1.jpg
2025-05-14 14:35:23 - STARTED: Office_audit_overview_5S-1.jpg

View File

@@ -156,4 +156,4 @@
text: "Exit App"
size_hint_y: None
height: 50
on_release: app.stop()
on_release: root.show_exit_popup()

View File

@@ -12,6 +12,11 @@ from kivy.uix.image import Image # Import Image widget for displaying images
from kivy.logger import Logger # Import Logger for logging messages
from kivy.lang import Builder # Import Builder for loading KV files
from kivy.animation import Animation # Import Animation for fade effects
from kivy.uix.popup import Popup
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
import os # Import os for file and directory operations
import json # Import json for handling JSON data
import datetime # Import datetime for timestamping logs
@@ -346,6 +351,41 @@ class SettingsScreen(Screen):
self.ids.server_ip_input.text = self.config_data.get("server_ip", "")
self.ids.port_input.text = self.config_data.get("port", "8080")
def show_exit_popup(self):
# Create the popup layout
layout = BoxLayout(orientation='vertical', spacing=10, padding=10)
# Add a label
label = Label(text="Enter Password to Exit", size_hint=(1, 0.3))
layout.add_widget(label)
# Add a password input field
password_input = TextInput(password=True, multiline=False, size_hint=(1, 0.3))
layout.add_widget(password_input)
# Add buttons for "OK" and "Cancel"
button_layout = BoxLayout(size_hint=(1, 0.3), spacing=10)
ok_button = Button(text="OK", on_release=lambda *args: self.validate_exit_password(password_input.text, popup))
cancel_button = Button(text="Cancel", on_release=lambda *args: popup.dismiss())
button_layout.add_widget(ok_button)
button_layout.add_widget(cancel_button)
layout.add_widget(button_layout)
# Create the popup
popup = Popup(title="Exit App", content=layout, size_hint=(0.8, 0.4))
popup.open()
def validate_exit_password(self, password, popup):
# Validate the entered password
quickconnect_key = self.config_data.get("quickconnect_key", "")
if password == quickconnect_key:
Logger.info("Password correct. Exiting app.")
App.get_running_app().stop() # Exit the app
else:
Logger.warning("Incorrect password. Returning to SettingsScreen.")
popup.dismiss() # Close the popup
class MediaPlayerApp(App):
"""Main application class."""