25
25
import structlog
26
26
from humanfriendly import format_timespan
27
27
from PySide6 import QtCore
28
- from PySide6 .QtCore import (
29
- QObject ,
30
- QSettings ,
31
- Qt ,
32
- QThread ,
33
- QThreadPool ,
34
- QTimer ,
35
- Signal ,
36
- )
28
+ from PySide6 .QtCore import QObject , QSettings , Qt , QThread , QThreadPool , QTimer , Signal
37
29
from PySide6 .QtGui import (
38
30
QAction ,
39
31
QColor ,
@@ -264,15 +256,12 @@ def start(self) -> None:
264
256
265
257
file_menu = QMenu ("&File" , menu_bar )
266
258
edit_menu = QMenu ("&Edit" , menu_bar )
259
+ view_menu = QMenu ("&View" , menu_bar )
267
260
tools_menu = QMenu ("&Tools" , menu_bar )
268
261
macros_menu = QMenu ("&Macros" , menu_bar )
269
- window_menu = QMenu ("&Window" , menu_bar )
270
262
help_menu = QMenu ("&Help" , menu_bar )
271
263
272
264
# File Menu ============================================================
273
- # file_menu.addAction(QAction('&New Library', menu_bar))
274
- # file_menu.addAction(QAction('&Open Library', menu_bar))
275
-
276
265
open_library_action = QAction ("&Open/Create Library" , menu_bar )
277
266
open_library_action .triggered .connect (lambda : self .open_library_from_dialog ())
278
267
open_library_action .setShortcut (
@@ -302,8 +291,6 @@ def start(self) -> None:
302
291
303
292
file_menu .addSeparator ()
304
293
305
- # refresh_lib_action = QAction('&Refresh Directories', self.main_window)
306
- # refresh_lib_action.triggered.connect(lambda: self.lib.refresh_dir())
307
294
add_new_files_action = QAction ("&Refresh Directories" , menu_bar )
308
295
add_new_files_action .triggered .connect (
309
296
lambda : self .callback_library_needed_check (self .add_new_files_callback )
@@ -315,13 +302,23 @@ def start(self) -> None:
315
302
)
316
303
)
317
304
add_new_files_action .setStatusTip ("Ctrl+R" )
318
- # file_menu.addAction(refresh_lib_action)
319
305
file_menu .addAction (add_new_files_action )
320
306
file_menu .addSeparator ()
321
307
322
308
close_library_action = QAction ("&Close Library" , menu_bar )
323
309
close_library_action .triggered .connect (self .close_library )
324
310
file_menu .addAction (close_library_action )
311
+ file_menu .addSeparator ()
312
+
313
+ open_on_start_action = QAction ("Open Library on Start" , self )
314
+ open_on_start_action .setCheckable (True )
315
+ open_on_start_action .setChecked (
316
+ bool (self .settings .value (SettingItems .START_LOAD_LAST , defaultValue = True , type = bool ))
317
+ )
318
+ open_on_start_action .triggered .connect (
319
+ lambda checked : self .settings .setValue (SettingItems .START_LOAD_LAST , checked )
320
+ )
321
+ file_menu .addAction (open_on_start_action )
325
322
326
323
# Edit Menu ============================================================
327
324
new_tag_action = QAction ("New &Tag" , menu_bar )
@@ -364,15 +361,32 @@ def start(self) -> None:
364
361
tag_database_action .triggered .connect (lambda : self .show_tag_database ())
365
362
edit_menu .addAction (tag_database_action )
366
363
367
- check_action = QAction ("Open library on start" , self )
368
- check_action .setCheckable (True )
369
- check_action .setChecked (
370
- bool (self .settings .value (SettingItems .START_LOAD_LAST , defaultValue = True , type = bool ))
364
+ # View Menu ============================================================
365
+ show_libs_list_action = QAction ("Show Recent Libraries" , menu_bar )
366
+ show_libs_list_action .setCheckable (True )
367
+ show_libs_list_action .setChecked (
368
+ bool (self .settings .value (SettingItems .WINDOW_SHOW_LIBS , defaultValue = True , type = bool ))
371
369
)
372
- check_action .triggered .connect (
373
- lambda checked : self .settings .setValue (SettingItems .START_LOAD_LAST , checked )
370
+ show_libs_list_action .triggered .connect (
371
+ lambda checked : (
372
+ self .settings .setValue (SettingItems .WINDOW_SHOW_LIBS , checked ),
373
+ self .toggle_libs_list (checked ),
374
+ )
374
375
)
375
- window_menu .addAction (check_action )
376
+ view_menu .addAction (show_libs_list_action )
377
+
378
+ show_filenames_action = QAction ("Show Filenames in Grid" , menu_bar )
379
+ show_filenames_action .setCheckable (True )
380
+ show_filenames_action .setChecked (
381
+ bool (self .settings .value (SettingItems .SHOW_FILENAMES , defaultValue = True , type = bool ))
382
+ )
383
+ show_filenames_action .triggered .connect (
384
+ lambda checked : (
385
+ self .settings .setValue (SettingItems .SHOW_FILENAMES , checked ),
386
+ self .show_grid_filenames (checked ),
387
+ )
388
+ )
389
+ view_menu .addAction (show_filenames_action )
376
390
377
391
# Tools Menu ===========================================================
378
392
def create_fix_unlinked_entries_modal ():
@@ -407,19 +421,6 @@ def create_dupe_files_modal():
407
421
)
408
422
macros_menu .addAction (self .autofill_action )
409
423
410
- show_libs_list_action = QAction ("Show Recent Libraries" , menu_bar )
411
- show_libs_list_action .setCheckable (True )
412
- show_libs_list_action .setChecked (
413
- bool (self .settings .value (SettingItems .WINDOW_SHOW_LIBS , defaultValue = True , type = bool ))
414
- )
415
- show_libs_list_action .triggered .connect (
416
- lambda checked : (
417
- self .settings .setValue (SettingItems .WINDOW_SHOW_LIBS , checked ),
418
- self .toggle_libs_list (checked ),
419
- )
420
- )
421
- window_menu .addAction (show_libs_list_action )
422
-
423
424
def create_folders_tags_modal ():
424
425
if not hasattr (self , "folders_modal" ):
425
426
self .folders_modal = FoldersToTagsModal (self .lib , self )
@@ -429,7 +430,7 @@ def create_folders_tags_modal():
429
430
folders_to_tags_action .triggered .connect (create_folders_tags_modal )
430
431
macros_menu .addAction (folders_to_tags_action )
431
432
432
- # Help Menu ==========================================================
433
+ # Help Menu ============================================================
433
434
self .repo_action = QAction ("Visit GitHub Repository" , menu_bar )
434
435
self .repo_action .triggered .connect (
435
436
lambda : webbrowser .open ("https://github.com/TagStudioDev/TagStudio" )
@@ -439,9 +440,9 @@ def create_folders_tags_modal():
439
440
440
441
menu_bar .addMenu (file_menu )
441
442
menu_bar .addMenu (edit_menu )
443
+ menu_bar .addMenu (view_menu )
442
444
menu_bar .addMenu (tools_menu )
443
445
menu_bar .addMenu (macros_menu )
444
- menu_bar .addMenu (window_menu )
445
446
menu_bar .addMenu (help_menu )
446
447
447
448
self .main_window .searchField .textChanged .connect (self .update_completions_list )
@@ -551,6 +552,10 @@ def toggle_libs_list(self, value: bool):
551
552
self .preview_panel .libs_flow_container .hide ()
552
553
self .preview_panel .update ()
553
554
555
+ def show_grid_filenames (self , value : bool ):
556
+ for thumb in self .item_thumbs :
557
+ thumb .set_filename_visibility (value )
558
+
554
559
def callback_library_needed_check (self , func ):
555
560
"""Check if loaded library has valid path before executing the button function."""
556
561
if self .lib .library_dir :
@@ -833,9 +838,9 @@ def thumb_size_callback(self, index: int):
833
838
it .thumb_button .setIcon (blank_icon )
834
839
it .resize (self .thumb_size , self .thumb_size )
835
840
it .thumb_size = (self .thumb_size , self .thumb_size )
836
- it .setMinimumSize (self .thumb_size , self .thumb_size )
837
- it .setMaximumSize (self .thumb_size , self .thumb_size )
841
+ it .setFixedSize (self .thumb_size , self .thumb_size )
838
842
it .thumb_button .thumb_size = (self .thumb_size , self .thumb_size )
843
+ it .set_filename_visibility (it .show_filename_label )
839
844
self .flow_container .layout ().setSpacing (
840
845
min (self .thumb_size // spacing_divisor , min_spacing )
841
846
)
@@ -883,7 +888,14 @@ def _init_thumb_grid(self):
883
888
# TODO - init after library is loaded, it can have different page_size
884
889
for grid_idx in range (self .filter .page_size ):
885
890
item_thumb = ItemThumb (
886
- None , self .lib , self , (self .thumb_size , self .thumb_size ), grid_idx
891
+ None ,
892
+ self .lib ,
893
+ self ,
894
+ (self .thumb_size , self .thumb_size ),
895
+ grid_idx ,
896
+ bool (
897
+ self .settings .value (SettingItems .SHOW_FILENAMES , defaultValue = True , type = bool )
898
+ ),
887
899
)
888
900
889
901
layout .addWidget (item_thumb )
0 commit comments