2020 QVBoxLayout ,
2121 QWidget ,
2222 QStackedLayout ,
23+ QScrollArea ,
2324)
2425
2526from .constants import (
4445from .console_window import ConsoleWindow
4546from .servers_page import ServersPage
4647from .skin_manager import SkinManagerPage
48+ from .toast_manager import ToastManager
4749
4850
4951class MainWindow (QMainWindow ):
@@ -77,7 +79,12 @@ def __init__(self):
7779 self .microsoft_auth .login_failed .connect (self .update_status )
7880
7981 self .init_ui ()
82+
83+ # Initialize Toast Manager
84+ self .toast_manager = ToastManager (self )
85+
8086 self .load_settings ()
87+
8188 self .apply_styles ()
8289 self .add_shadow_effects ()
8390 self .populate_versions ()
@@ -217,6 +224,7 @@ def init_ui(self):
217224 self .launch_page = LaunchPage ()
218225 self .settings_page = SettingsPage ()
219226 self .settings_page .settings_saved .connect (self .reload_background_settings )
227+ self .settings_page .settings_saved .connect (lambda : self .toast_manager .show_toast ("Settings have been saved." , "Settings Saved" , "SUCCESS" ))
220228 self .mods_page = ModsPage ()
221229 self .mod_browser_page = ModBrowserPage ()
222230 self .servers_page = ServersPage ()
@@ -303,21 +311,27 @@ def _create_slide_animation(self, new_index, old_index):
303311 anim_new = QPropertyAnimation (new_widget , b"pos" )
304312 anim_new .setDuration (300 )
305313 anim_new .setEndValue (self .stacked_widget .rect ().topLeft ())
306- anim_new .setEasingCurve (QEasingCurve .Type .OutCubic )
314+ anim_new .setEasingCurve (QEasingCurve .Type .InOutQuart )
307315
308316 # Old widget to slide out
309317 old_widget = self .stacked_widget .widget (old_index )
310318 anim_old = QPropertyAnimation (old_widget , b"pos" )
311319 anim_old .setDuration (300 )
312320 anim_old .setEndValue (QPoint (width if new_index < old_index else - width , 0 ))
313- anim_old .setEasingCurve (QEasingCurve .Type .OutCubic )
321+ anim_old .setEasingCurve (QEasingCurve .Type .InOutQuart )
314322
315323 anim_group = QParallelAnimationGroup ()
316324 anim_group .addAnimation (anim_new )
317325 anim_group .addAnimation (anim_old )
318326
319327 anim_group .finished .connect (lambda : self .on_animation_finished (new_index , old_widget ))
320328 return anim_group
329+
330+ def resizeEvent (self , event ):
331+ super ().resizeEvent (event )
332+ # Reposition toasts
333+ if hasattr (self , 'toast_manager' ):
334+ self .toast_manager .reposition_toasts ()
321335
322336 def on_animation_finished (self , new_index , old_widget ):
323337 self .stacked_widget .setCurrentIndex (new_index )
@@ -340,6 +354,7 @@ def start_microsoft_login(self):
340354
341355 def on_login_success (self , info : MicrosoftInfo ):
342356 self .minecraft_info = info
357+ self .toast_manager .show_toast (f"Logged in as { info ['username' ]} " , "Login Successful" , "SUCCESS" )
343358 self .update_status (f"Logged in as { info ['username' ]} " )
344359 self .launch_page .microsoft_login_button .setText (f"Logged in as { info ['username' ]} " )
345360 self .skin_manager_page .set_microsoft_info (info )
@@ -600,6 +615,8 @@ def start_launch(self):
600615 username = self .launch_page .username_input .text ().strip ()
601616 if not username :
602617 self .update_status ("⚠️ Please enter a username" )
618+ self .toast_manager .show_toast ("Please enter a username to continue." , "Username Required" , "WARNING" )
619+ self .launch_page .username_input .shake ()
603620 return
604621 options ["username" ] = username
605622 options ["uuid" ] = str (uuid .uuid4 ())
@@ -667,9 +684,15 @@ def on_launch_finished(self, success, message):
667684 self .launch_page .progress_bar .setValue (1 if success else 0 )
668685 self .launch_page .progress_bar .setFormat ("%p%" )
669686
670- if success and "Game closed" in message :
671- self .launch_page .progress_bar .setValue (0 )
672- self .launch_page .status_label .setText ("✓ Ready to launch" )
687+ if success :
688+ if "Game closed" in message :
689+ self .launch_page .progress_bar .setValue (0 )
690+ self .launch_page .status_label .setText ("✓ Ready to launch" )
691+ self .toast_manager .show_toast ("Minecraft session ended." , "Game Closed" , "INFO" )
692+ else :
693+ self .toast_manager .show_toast ("Minecraft launched successfully!" , "Launch Success" , "SUCCESS" )
694+ else :
695+ self .toast_manager .show_toast (message , "Launch Failed" , "ERROR" )
673696
674697 def cancel_launch (self ):
675698 if self .worker :
@@ -697,9 +720,9 @@ def clear_cache(self):
697720 try :
698721 if os .path .exists (ICON_CACHE_DIR ):
699722 shutil .rmtree (ICON_CACHE_DIR )
700- QMessageBox . information ( self , "Cache Cleared" , " The icon cache has been cleared." )
723+ self . toast_manager . show_toast ( " The icon cache has been cleared." , "Cache Cleared" , "SUCCESS " )
701724 else :
702- QMessageBox . information ( self , "Cache Cleared" , " No icon cache to clear." )
725+ self . toast_manager . show_toast ( " No icon cache to clear." , "Cache Empty" , "INFO " )
703726 except Exception as e :
704727 QMessageBox .critical (self , "Error" , f"Could not clear cache: { e } " )
705728
0 commit comments