@@ -93,7 +93,6 @@ def __init__(
9393 self .applied_config = None
9494 self .applied_config_name = None
9595
96- self .compact_mode = None
9796 self .style_dark = True
9897
9998 self .timer = None
@@ -106,16 +105,10 @@ def __init__(
106105
107106 self ._init_managers ()
108107
109- (self .compact_mode ,
110- self .use_images ,
111- self .snap ,
112- self .details ,
113- self .hotkey ,
114- self .layouts ,
115- self .overrides ,
116- self .ignored_windows ) = self .cfg_man .load_settings ()
108+ self .settings = self .cfg_man .load_settings ()
117109
118- self .win_man .ignored_windows = self .ignored_windows
110+ low_ignore_list = [item .lower () for item in self .settings .ignored_windows ]
111+ self .win_man .ignored_windows = low_ignore_list
119112
120113 self ._init_screen ()
121114 self ._init_ui_containers ()
@@ -125,7 +118,7 @@ def __init__(
125118 self .reapply_timer ()
126119 self .managed_widget .installEventFilter (self )
127120
128- global_hotkeys .register_hotkey (self .hotkey , self .toggle_always_on_top , None )
121+ global_hotkeys .register_hotkey (self .settings . hotkey , self .toggle_always_on_top , None )
129122 global_hotkeys .start_checking_hotkeys ()
130123
131124 # Set window title with version
@@ -180,9 +173,9 @@ def _apply_snap_selection(self) -> None:
180173 """Set initial snap radio button based on snap value."""
181174 snap_left = 1
182175 snap_right = 2
183- if self .snap == snap_left :
176+ if self .settings . snap == snap_left :
184177 self .left_radio .setChecked (True )
185- elif self .snap == snap_right :
178+ elif self .settings . snap == snap_right :
186179 self .right_radio .setChecked (True )
187180 else :
188181 self .center_radio .setChecked (True )
@@ -202,7 +195,7 @@ def eventFilter(self, source: QObject, event: QWheelEvent) -> bool: # noqa: N80
202195 def get_geometry_and_minsize (self ) -> tuple [int , int , int , int ]:
203196 """Get the sizes needed to set geometry and minsize."""
204197 compact_height_factor = 1
205- if self .compact_mode :
198+ if self .settings . compact :
206199 width = UIConstants .COMPACT_WIDTH
207200 height = UIConstants .COMPACT_HEIGHT
208201 min_width = UIConstants .COMPACT_WIDTH
@@ -224,15 +217,15 @@ def toggle_elements(self, *, compact: bool, min_width: int) -> None:
224217 self .edit_config_button ,
225218 self .image_folder_button ,
226219 self .screenshot_button ,
227- self .details_switch ,
220+ self .settings . details_switch ,
228221 self .toggle_images_switch ,
229222 self .aot_label ,
230223 self .spacer_1 ,
231224 self .spacer_2 ,
232225 self .left_radio ,
233226 self .center_radio ,
234227 self .right_radio ,
235- self .snap_label ,
228+ self .settings . snap_label ,
236229 ]
237230
238231 resized_buttons = [
@@ -321,7 +314,7 @@ def _build_combo_row(self, min_width: int) -> None:
321314 combo_layout = QHBoxLayout ()
322315 combo_layout .setContentsMargins (10 , 0 , 10 , 0 )
323316 combo_layout .setSpacing (0 )
324- width = min_width - 20 if self .compact_mode else min_width / 2
317+ width = min_width - 20 if self .settings . compact else min_width / 2
325318
326319 self .combo_box = QComboBox (self )
327320 self .combo_box .setFixedWidth (width )
@@ -343,7 +336,7 @@ def _build_combo_row(self, min_width: int) -> None:
343336 def _build_managed_area (self ) -> None :
344337 """Create managed windows area with label and text edit."""
345338 self .managed_widget = QWidget (self )
346- self .managed_widget .setVisible (self .compact_mode )
339+ self .managed_widget .setVisible (self .settings . compact )
347340
348341 mf_layout = QVBoxLayout (self .managed_widget )
349342 mf_layout .setContentsMargins (10 , 0 , 10 , 0 )
@@ -369,7 +362,7 @@ def _build_layout_preview(self) -> None:
369362 self .res_y ,
370363 windows = [],
371364 assets_dir = self .assets_dir ,
372- window_details = self .details ,
365+ app_settings = self .settings ,
373366 )
374367 lc_layout .addWidget (self .layout_frame , 1 )
375368 self .main_layout .addLayout (lc_layout , 1 )
@@ -452,9 +445,9 @@ def _build_buttons_area(self) -> None:
452445 self .reapply_pause_label .setContentsMargins (10 , 0 , 10 , 0 )
453446 aot_bottom .addWidget (self .reapply_pause_label , alignment = Qt .AlignmentFlag .AlignLeft )
454447
455- self .snap_label = QLabel ("Application open position:" , self )
456- self .snap_label .setContentsMargins (10 , 0 , 50 , 0 )
457- aot_bottom .addWidget (self .snap_label , alignment = Qt .AlignmentFlag .AlignRight )
448+ self .settings . snap_label = QLabel ("Application open position:" , self )
449+ self .settings . snap_label .setContentsMargins (10 , 0 , 50 , 0 )
450+ aot_bottom .addWidget (self .settings . snap_label , alignment = Qt .AlignmentFlag .AlignRight )
458451
459452 self .main_layout .addLayout (aot_bottom )
460453
@@ -479,14 +472,14 @@ def _build_images_and_snap_row(self) -> None:
479472 img_l .setSpacing (20 )
480473
481474 self .auto_apply_switch = QCheckBox ("Auto re-apply" , self )
482- self .details_switch = QCheckBox ("Show window details" , self )
475+ self .settings . details_switch = QCheckBox ("Show window details" , self )
483476 self .toggle_images_switch = QCheckBox ("Images" , self )
484477
485- self .details_switch .setChecked (self .details )
486- self .toggle_images_switch .setChecked (self .use_images )
478+ self .settings . details_switch .setChecked (self . settings .details )
479+ self .toggle_images_switch .setChecked (self .settings . use_images )
487480
488481 img_l .addWidget (self .auto_apply_switch )
489- img_l .addWidget (self .details_switch )
482+ img_l .addWidget (self .settings . details_switch )
490483 img_l .addWidget (self .toggle_images_switch )
491484 img_l .addStretch () # push snap group right
492485
@@ -501,10 +494,10 @@ def _build_images_and_snap_row(self) -> None:
501494 for radio in [self .left_radio , self .center_radio , self .right_radio ]:
502495 radio .setFixedWidth (radio_width )
503496
504- self .snap_group = QButtonGroup (self )
505- self .snap_group .addButton (self .left_radio , 1 )
506- self .snap_group .addButton (self .center_radio , 0 )
507- self .snap_group .addButton (self .right_radio , 2 )
497+ self .settings . snap_group = QButtonGroup (self )
498+ self .settings . snap_group .addButton (self .left_radio , 1 )
499+ self .settings . snap_group .addButton (self .center_radio , 0 )
500+ self .settings . snap_group .addButton (self .right_radio , 2 )
508501
509502 for radio in [self .left_radio , self .center_radio , self .right_radio ]:
510503 snap_l .addWidget (radio )
@@ -532,19 +525,19 @@ def _connect_callbacks(self) -> None:
532525
533526 # Switches
534527 self .auto_apply_switch .stateChanged .connect (self ._on_reapply_toggle )
535- self .details_switch .stateChanged .connect (self ._on_details_toggle )
528+ self .settings . details_switch .stateChanged .connect (self ._on_details_toggle )
536529 self .toggle_images_switch .stateChanged .connect (self ._on_images_toggle )
537530
538531 self .filter_switch .stateChanged .connect (self .update_config_list )
539532 self .theme_switch .stateChanged .connect (self ._on_theme_toggle )
540533
541534 # Radio buttons
542- self .snap_group .buttonToggled .connect (self ._on_snap_toggle )
535+ self .settings . snap_group .buttonToggled .connect (self ._on_snap_toggle )
543536
544537 # ------------- Theme & toggles -------------
545538
546539 def _apply_theme (self ) -> None :
547- font_size = text_small .pointSize () if self .compact_mode else text_normal .pointSize ()
540+ font_size = text_small .pointSize () if self .settings . compact else text_normal .pointSize ()
548541 self .setStyleSheet (f"""
549542 QWidget {{
550543 background: { self .colors .BACKGROUND } ;
@@ -679,16 +672,7 @@ def invert_colors(self) -> None:
679672
680673 def _save_settings (self ) -> None :
681674 """Save GUI settings."""
682- self .cfg_man .save_settings (
683- compact_mode = self .compact_mode ,
684- use_images = self .use_images ,
685- snap = self .snap ,
686- details = self .details ,
687- hotkey = self .hotkey ,
688- layouts = self .layouts ,
689- overrides = self .overrides ,
690- ignored_windows = self .ignored_windows ,
691- )
675+ self .cfg_man .save_settings (self .settings )
692676
693677 def reapply_timer (self ) -> None :
694678 """Timer for auto reapply."""
@@ -939,20 +923,20 @@ def open_image_folder(self) -> None:
939923 def toggle_compact (self , startup : int = 0 ) -> None :
940924 """Toggle between compact and full mode."""
941925 if not startup :
942- self .compact_mode = not self .compact_mode
926+ self .settings . compact = not self .settings . compact
943927 self ._save_settings ()
944928
945- if self .compact_mode :
929+ if self .settings . compact :
946930 self .toggle_compact_button .setText ("Full mode" )
947931 self .aot_button .setText ("AOT" )
948932 self .detect_config_button .setText ("Detect" )
949933 else :
950934 self .toggle_compact_button .setText ("Compact mode" )
951- self .aot_button .setText (f"Toggle AOT ({ self .hotkey } )" )
935+ self .aot_button .setText (f"Toggle AOT ({ self .settings . hotkey } )" )
952936 self .detect_config_button .setText ("Detect config" )
953937
954938 width , height , min_width , min_height = self .get_geometry_and_minsize ()
955- self .toggle_elements (compact = self .compact_mode , min_width = min_width )
939+ self .toggle_elements (compact = self .settings . compact , min_width = min_width )
956940 self .setMinimumSize (min_width , min_height )
957941 self ._position_app_window ()
958942 self .on_config_select ()
@@ -963,11 +947,11 @@ def _position_app_window(self) -> None:
963947 width , height , _ , _ = self .get_geometry_and_minsize ()
964948 snap_left = 1
965949 snap_right = 2
966- if self .snap == 0 :
950+ if self .settings . snap == 0 :
967951 pos_x = (self .res_x // 2 ) - (width // 2 )
968- elif self .snap == snap_left :
952+ elif self .settings . snap == snap_left :
969953 pos_x = 0
970- elif self .snap == snap_right :
954+ elif self .settings . snap == snap_right :
971955 pos_x = self .res_x - width
972956 else :
973957 pos_x = 100
@@ -1009,28 +993,28 @@ def _on_reapply_toggle(self) -> None:
1009993 self .reapply = self .auto_apply_switch .isChecked ()
1010994
1011995 def _on_details_toggle (self ) -> None :
1012- self .details = self .details_switch .isChecked ()
996+ self .settings . details = self . settings .details_switch .isChecked ()
1013997 self ._save_settings ()
1014998 if self .layout_frame :
1015- self .layout_frame .window_details = self .details
999+ self .layout_frame .window_details = self .settings . details
10161000 self .layout_frame .update ()
10171001
10181002 def _on_images_toggle (self ) -> None :
1019- self .use_images = self .toggle_images_switch .isChecked ()
1003+ self .settings . use_images = self .toggle_images_switch .isChecked ()
10201004 self ._save_settings ()
10211005 if self .layout_frame :
1022- self .layout_frame .use_images = self .use_images
1006+ self .layout_frame .use_images = self .settings . use_images
10231007 self .layout_frame .update ()
10241008
10251009 # Radio button actions
10261010
10271011 def _on_snap_toggle (self , button : QRadioButton ) -> None :
10281012 if button == self .left_radio :
1029- self .snap = 1
1013+ self .settings . snap = 1
10301014 elif button == self .center_radio :
1031- self .snap = 0
1015+ self .settings . snap = 0
10321016 elif button == self .right_radio :
1033- self .snap = 2
1017+ self .settings . snap = 2
10341018
10351019 self ._position_app_window ()
10361020 self ._save_settings ()
@@ -1053,7 +1037,7 @@ def on_config_select(self) -> None:
10531037 self .config = None
10541038 missing = []
10551039
1056- if not self .compact_mode :
1040+ if not self .settings . compact :
10571041 self .update_window_layout (self .config , missing )
10581042 else :
10591043 self .update_managed_windows_list (self .config , missing )
0 commit comments