@@ -182,9 +182,6 @@ def _setup_window(self) -> None:
182182 self .setGeometry (x , y , width , height )
183183 self .setMinimumSize (WINDOW_MIN_SIZE ["width" ], WINDOW_MIN_SIZE ["height" ])
184184
185- # Make window resizable
186- self .setWindowFlag (Qt .WindowType .WindowMaximizeButtonHint , True )
187-
188185 # Set smaller size for step 0 (mode selection)
189186 self ._update_window_size_for_step0 ()
190187
@@ -866,49 +863,81 @@ def _update_window_size_for_step0(self) -> None:
866863 self .setGeometry (x , y , compact_width , compact_height )
867864 self .setMinimumSize (compact_width , compact_height )
868865 self .setMaximumSize (compact_width , compact_height )
866+ self ._refresh_title_bar_maximize (enabled = False )
869867
870- def _update_window_size_for_main_workflow (self ) -> None :
871- """Restore normal window size for main workflow (steps 1+)."""
872- # Restore normal size policies and remove fixed constraints from step0
873- if hasattr (self , "stack" ):
874- self .stack .setSizePolicy (
875- QSizePolicy .Policy .Expanding , QSizePolicy .Policy .Minimum
876- )
877- self .stack .setMaximumWidth (16777215 ) # Remove fixed width
878- self .stack .setMaximumHeight (16777215 ) # Remove fixed height
868+ def _refresh_title_bar_maximize (self , * , enabled : bool ) -> None :
869+ """
870+ Enable or disable the native title-bar maximize button.
871+
872+ On Windows, fixed min/max sizing (step 0) removes WS_MAXIMIZEBOX from the
873+ native frame; ``setWindowFlag`` alone does not restore it — the frame must
874+ be recreated with ``setWindowFlags`` and ``show()``.
875+
876+ All standard title-bar hints must be set explicitly; otherwise Windows may
877+ drop the close or maximize button when the frame is recreated.
878+ """
879+ flags = (
880+ Qt .WindowType .Window
881+ | Qt .WindowType .WindowTitleHint
882+ | Qt .WindowType .WindowSystemMenuHint
883+ | Qt .WindowType .WindowMinimizeButtonHint
884+ | Qt .WindowType .WindowCloseButtonHint
885+ )
886+ if enabled :
887+ flags |= Qt .WindowType .WindowMaximizeButtonHint
888+
889+ geometry = self .geometry ()
890+ visible = self .isVisible ()
891+ self .setWindowFlags (flags )
892+ if visible :
893+ self .setGeometry (geometry )
894+ self .show ()
895+
896+ def _release_stack_size_constraints (self ) -> None :
897+ """Remove fixed sizes left over from step 0 so content can grow with the window."""
898+ if not hasattr (self , "stack" ):
899+ return
900+ self .stack .setSizePolicy (
901+ QSizePolicy .Policy .Expanding , QSizePolicy .Policy .Minimum
902+ )
903+ self .stack .setMinimumWidth (0 )
904+ self .stack .setMinimumHeight (0 )
905+ self .stack .setMaximumWidth (16777215 )
906+ self .stack .setMaximumHeight (16777215 )
879907 if hasattr (self , "stack_scroll_area" ):
880908 self .stack_scroll_area .setSizePolicy (
881909 QSizePolicy .Policy .Expanding , QSizePolicy .Policy .Expanding
882910 )
883911
884- # Get original normal size
912+ def _update_window_size_for_main_workflow (self ) -> None :
913+ """Restore normal window size for main workflow (steps 1+)."""
914+ self ._release_stack_size_constraints ()
915+
885916 screen = self .app .primaryScreen ()
886917 rect = screen .availableGeometry ()
887918 screen_width = rect .width ()
888919 screen_height = rect .height ()
889920
890- # Calculate desired window size with ratio
921+ min_width = min (WINDOW_MIN_SIZE ["width" ], screen_width )
922+ min_height = min (WINDOW_MIN_SIZE ["height" ], screen_height )
923+
891924 desired_width = int (screen_width * WINDOW_SIZE_RATIO ["width" ])
892925 desired_height = int (screen_height * WINDOW_SIZE_RATIO ["height" ])
926+ width = max (desired_width , min_width )
927+ height = max (desired_height , min_height )
893928
894- # Apply minimum size constraints
895- width = max (desired_width , WINDOW_MIN_SIZE ["width" ])
896- height = max (desired_height , WINDOW_MIN_SIZE ["height" ])
897-
898- # Center the normal window
899929 x = int ((screen_width - width ) / 2 )
900930 y = int ((screen_height - height ) / 2 )
901931
902- # Reset constraints first to avoid min/max conflicts
932+ # Reset constraints first to avoid min/max conflicts from step 0
903933 self .setMinimumSize (1 , 1 )
904- self .setMaximumSize (16777215 , 16777215 ) # Qt max size
934+ self .setMaximumSize (16777215 , 16777215 )
905935
906- # Apply new geometry and constraints (allow full maximization)
907936 self .setGeometry (x , y , width , height )
908- self .setMinimumSize (WINDOW_MIN_SIZE [ "width" ], WINDOW_MIN_SIZE [ "height" ] )
909- self . setMaximumSize (
910- screen_width , screen_height
911- ) # Allow full screen maximization
937+ self .setMinimumSize (min_width , min_height )
938+ # No practical max cap — lets the title-bar maximize button work on Windows
939+ self . setMaximumSize ( 16777215 , 16777215 )
940+ self . _refresh_title_bar_maximize ( enabled = True )
912941
913942 self ._clamp_to_screen ()
914943
0 commit comments