- show toast notification when download completd but not open history
- move toast notification on top right corner
This commit is contained in:
skymike03
2025-10-20 21:07:08 +02:00
parent 059c38d8d6
commit edb331d053
3 changed files with 20 additions and 8 deletions

View File

@@ -928,7 +928,12 @@ async def main():
config.download_result_error = not success
config.download_progress.clear()
config.pending_download = None
config.menu_state = "history"
# Afficher un toast au lieu de changer de page
if success:
toast_msg = f"[OK] {game_name}\n{_('download_completed') if _ else 'Download completed'}"
else:
toast_msg = f"[ERROR] {game_name}\n{_('download_failed') if _ else 'Download failed'}"
show_toast(toast_msg, 3000)
config.needs_redraw = True
del config.download_tasks[task_id]
except Exception as e:
@@ -948,7 +953,9 @@ async def main():
config.download_result_error = True
config.download_progress.clear()
config.pending_download = None
config.menu_state = "history"
# Afficher un toast au lieu de changer de page
toast_msg = f"[ERROR] {game_name}\n{_('download_failed') if _ else 'Download failed'}"
show_toast(toast_msg, 3000)
config.needs_redraw = True
del config.download_tasks[task_id]
else:
@@ -982,9 +989,14 @@ async def main():
config.download_result_error = not success
config.download_progress.clear()
config.pending_download = None
config.menu_state = "history"
# Afficher un toast au lieu de changer de page
if success:
toast_msg = f"[OK] {game_name}\n{_('download_completed') if _ else 'Download completed'}"
else:
toast_msg = f"[ERROR] {game_name}\n{_('download_failed') if _ else 'Download failed'}"
show_toast(toast_msg, 3000)
config.needs_redraw = True
logger.debug(f"[DOWNLOAD_TASK] Menu state changed to history after completion, task_id={task_id}")
logger.debug(f"[DOWNLOAD_TASK] Toast displayed after completion, task_id={task_id}")
del config.download_tasks[task_id]
else:
downloaded, total_size = data[1], data[2]

View File

@@ -13,7 +13,7 @@ except Exception:
pygame = None # type: ignore
# Version actuelle de l'application
app_version = "2.3.0.1"
app_version = "2.3.0.2"
def get_application_root():

View File

@@ -2670,7 +2670,7 @@ def draw_popup(screen):
def draw_toast(screen):
"""Affiche une notification toast dans le coin inférieur droit (2s max).
"""Affiche une notification toast dans le coin supérieur droit (2s max).
Utilise config.toast_message pour le contenu.
Utilise config.toast_duration (par défaut 2000ms) pour la durée.
@@ -2716,10 +2716,10 @@ def draw_toast(screen):
toast_width = max_width
toast_height = len(wrapped_lines) * line_height + 2 * toast_padding
# Position: coin inférieur droit
# Position: coin supérieur droit
margin = 20
toast_x = config.screen_width - toast_width - margin
toast_y = config.screen_height - toast_height - margin
toast_y = margin
# Créer une surface avec transparence
toast_surface = pygame.Surface((toast_width, toast_height), pygame.SRCALPHA)