@@ -323,7 +323,7 @@ def start(self) -> None:
323
323
file_menu .addSeparator ()
324
324
325
325
close_library_action = QAction ("&Close Library" , menu_bar )
326
- close_library_action .triggered .connect (lambda : self .close_library () )
326
+ close_library_action .triggered .connect (self .close_library )
327
327
file_menu .addAction (close_library_action )
328
328
329
329
# Edit Menu ============================================================
@@ -553,9 +553,7 @@ def handleSIGTERM(self):
553
553
554
554
def shutdown (self ):
555
555
"""Save Library on Application Exit"""
556
- if self .lib and self .lib .library_dir :
557
- self .settings .setValue (SettingItems .LAST_LIBRARY , self .lib .library_dir )
558
- self .settings .sync ()
556
+ self .close_library (is_shutdown = True )
559
557
logger .info ("[SHUTDOWN] Ending Thumbnail Threads..." )
560
558
for _ in self .thumb_threads :
561
559
self .thumb_job_queue .put (Consumer .MARKER_QUIT )
@@ -567,23 +565,29 @@ def shutdown(self):
567
565
568
566
QApplication .quit ()
569
567
570
- def close_library (self ):
571
- if not self .lib .library_dir :
568
+ def close_library (self , is_shutdown : bool = False ):
569
+ if not self .lib .folder :
572
570
logger .info ("No Library to Close" )
573
571
return
574
572
575
573
logger .info ("Closing Library..." )
576
574
self .main_window .statusbar .showMessage ("Closing Library..." )
577
575
start_time = time .time ()
576
+
578
577
self .settings .setValue (SettingItems .LAST_LIBRARY , self .lib .library_dir )
579
578
self .settings .sync ()
580
579
581
- title_text = f"{ self .base_title } "
582
- self .main_window .setWindowTitle (title_text )
580
+ self .lib .close ()
581
+
582
+ if is_shutdown :
583
+ # no need to do other things on shutdown
584
+ return
585
+
586
+ self .main_window .setWindowTitle (self .base_title )
583
587
584
588
self .selected = []
585
589
self .frame_content = []
586
- self . item_thumbs = [ ]
590
+ [ x . set_mode ( None ) for x in self . item_thumbs ]
587
591
588
592
self .preview_panel .update_widgets ()
589
593
self .main_window .toggle_landing_page (True )
@@ -841,15 +845,10 @@ def remove_grid_item(self, grid_idx: int):
841
845
self .item_thumbs [grid_idx ].hide ()
842
846
843
847
def _init_thumb_grid (self ):
844
- # logger.info('Initializing Thumbnail Grid...')
845
848
layout = FlowLayout ()
846
849
layout .setGridEfficiency (True )
847
- # layout.setContentsMargins(0,0,0,0)
848
850
layout .setSpacing (min (self .thumb_size // 10 , 12 ))
849
- # layout = QHBoxLayout()
850
- # layout.setSizeConstraint(QLayout.SizeConstraint.SetMaximumSize)
851
- # layout = QListView()
852
- # layout.setViewMode(QListView.ViewMode.IconMode)
851
+ layout .setAlignment (Qt .AlignmentFlag .AlignCenter )
853
852
854
853
# TODO - init after library is loaded, it can have different page_size
855
854
for grid_idx in range (self .filter .page_size ):
@@ -862,7 +861,6 @@ def _init_thumb_grid(self):
862
861
self .flow_container : QWidget = QWidget ()
863
862
self .flow_container .setObjectName ("flowContainer" )
864
863
self .flow_container .setLayout (layout )
865
- layout .setAlignment (Qt .AlignmentFlag .AlignCenter )
866
864
sa : QScrollArea = self .main_window .scrollArea
867
865
sa .setHorizontalScrollBarPolicy (Qt .ScrollBarPolicy .ScrollBarAlwaysOff )
868
866
sa .setWidgetResizable (True )
0 commit comments