updated buttons in settings

This commit is contained in:
Kiwy Signage Player
2025-12-08 21:52:03 +02:00
parent 706af95557
commit f1a84d05d5
6 changed files with 161 additions and 33 deletions
+89 -2
View File
@@ -1126,8 +1126,8 @@ class SettingsPopup(Popup):
self.ids.edit_enabled_checkbox.active = self.player.config.get('edit_feature_enabled', True)
# Update status info
self.ids.playlist_info.text = f'Playlist Version: {self.player.playlist_version}'
self.ids.media_count_info.text = f'Media Count: {len(self.player.playlist)}'
self.ids.playlist_info.text = f'Playlist: v{self.player.playlist_version}'
self.ids.media_count_info.text = f'Media: {len(self.player.playlist)}'
self.ids.status_info.text = f'Status: {"Playing" if self.player.is_playing else "Paused" if self.player.is_paused else "Idle"}'
# Bind to dismiss event to manage cursor visibility and resume playback
@@ -1267,6 +1267,93 @@ class SettingsPopup(Popup):
else:
self.ids.connection_status.color = (1, 0, 0, 1) # Red
def reset_player_auth(self):
"""Reset player authentication by deleting player_auth.json"""
try:
auth_file = os.path.join(os.path.dirname(__file__), 'player_auth.json')
if os.path.exists(auth_file):
os.remove(auth_file)
Logger.info(f"SettingsPopup: Deleted authentication file: {auth_file}")
self._show_temp_message('✓ Authentication reset - will reauthenticate on restart', (0, 1, 0, 1))
else:
Logger.info("SettingsPopup: No authentication file found")
self._show_temp_message('No authentication file found', (1, 0.7, 0, 1))
except Exception as e:
Logger.error(f"SettingsPopup: Error resetting authentication: {e}")
self._show_temp_message(f'✗ Error: {str(e)}', (1, 0, 0, 1))
def reset_playlist_version(self):
"""Reset playlist version to 0 and rename playlist file"""
try:
playlists_dir = os.path.join(self.player.base_dir, 'playlists')
# Find current playlist file
import glob
playlist_files = glob.glob(os.path.join(playlists_dir, 'server_playlist_v*.json'))
if playlist_files:
# Get the first (should be only one) playlist file
current_playlist = playlist_files[0]
new_playlist = os.path.join(playlists_dir, 'server_playlist_v0.json')
# Rename to v0
os.rename(current_playlist, new_playlist)
Logger.info(f"SettingsPopup: Renamed {os.path.basename(current_playlist)} to server_playlist_v0.json")
# Update player's playlist version
self.player.playlist_version = 0
# Update display
self.ids.playlist_info.text = f'Playlist: v{self.player.playlist_version}'
self._show_temp_message('✓ Playlist reset to v0 - will resync from server', (0, 1, 0, 1))
else:
Logger.info("SettingsPopup: No playlist file found")
self._show_temp_message('No playlist file found', (1, 0.7, 0, 1))
except Exception as e:
Logger.error(f"SettingsPopup: Error resetting playlist: {e}")
self._show_temp_message(f'✗ Error: {str(e)}', (1, 0, 0, 1))
def restart_player(self):
"""Restart playlist from the first item"""
try:
Logger.info("SettingsPopup: Restarting player from first item")
# Reset to first item
self.player.current_index = 0
# Show message
self._show_temp_message('✓ Restarting playlist from beginning...', (0, 1, 0, 1))
# Close settings after a short delay
def close_and_restart(dt):
self.dismiss()
# Start playing from first item
self.player.play_current_media()
Clock.schedule_once(close_and_restart, 2)
except Exception as e:
Logger.error(f"SettingsPopup: Error restarting player: {e}")
self._show_temp_message(f'✗ Error: {str(e)}', (1, 0, 0, 1))
def _show_temp_message(self, message, color):
"""Show a temporary popup message for 2 seconds"""
from kivy.uix.popup import Popup
from kivy.uix.label import Label
popup = Popup(
title='',
content=Label(text=message, color=color),
size_hint=(0.6, 0.3),
auto_dismiss=True
)
popup.open()
# Auto-close after 2 seconds
Clock.schedule_once(lambda dt: popup.dismiss(), 2)
def save_and_close(self):
"""Save configuration and close popup"""
# Update config