@@ -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,28 @@ 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
+
577
+ self .lib .close ()
578
+
578
579
self .settings .setValue (SettingItems .LAST_LIBRARY , self .lib .library_dir )
579
580
self .settings .sync ()
581
+ if is_shutdown :
582
+ # no need to do other things on shutdown
583
+ return
580
584
581
- title_text = f"{ self .base_title } "
582
- self .main_window .setWindowTitle (title_text )
585
+ self .main_window .setWindowTitle (self .base_title )
583
586
584
587
self .selected = []
585
588
self .frame_content = []
586
- self . item_thumbs = [ ]
589
+ [ x . set_mode ( None ) for x in self . item_thumbs ]
587
590
588
591
self .preview_panel .update_widgets ()
589
592
self .main_window .toggle_landing_page (True )
@@ -841,15 +844,10 @@ def remove_grid_item(self, grid_idx: int):
841
844
self .item_thumbs [grid_idx ].hide ()
842
845
843
846
def _init_thumb_grid (self ):
844
- # logger.info('Initializing Thumbnail Grid...')
845
847
layout = FlowLayout ()
846
848
layout .setGridEfficiency (True )
847
- # layout.setContentsMargins(0,0,0,0)
848
849
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)
850
+ layout .setAlignment (Qt .AlignmentFlag .AlignCenter )
853
851
854
852
# TODO - init after library is loaded, it can have different page_size
855
853
for grid_idx in range (self .filter .page_size ):
@@ -862,7 +860,6 @@ def _init_thumb_grid(self):
862
860
self .flow_container : QWidget = QWidget ()
863
861
self .flow_container .setObjectName ("flowContainer" )
864
862
self .flow_container .setLayout (layout )
865
- layout .setAlignment (Qt .AlignmentFlag .AlignCenter )
866
863
sa : QScrollArea = self .main_window .scrollArea
867
864
sa .setHorizontalScrollBarPolicy (Qt .ScrollBarPolicy .ScrollBarAlwaysOff )
868
865
sa .setWidgetResizable (True )
0 commit comments