Skip to content

Commit ca08ce5

Browse files
ui: postpone creating modals (#425)
1 parent 7f3b3d0 commit ca08ce5

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

tagstudio/src/qt/ts_qt.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,24 @@ def start(self) -> None:
482482
window_menu.addAction(check_action)
483483

484484
# Tools Menu ===========================================================
485+
def create_fix_unlinked_entries_modal():
486+
"""Postpone the creation of the modal until it is needed."""
487+
if not hasattr(self, "unlinked_modal"):
488+
self.unlinked_modal = FixUnlinkedEntriesModal(self.lib, self)
489+
self.unlinked_modal.show()
490+
485491
fix_unlinked_entries_action = QAction("Fix &Unlinked Entries", menu_bar)
486-
fue_modal = FixUnlinkedEntriesModal(self.lib, self)
487-
fix_unlinked_entries_action.triggered.connect(lambda: fue_modal.show())
492+
fix_unlinked_entries_action.triggered.connect(create_fix_unlinked_entries_modal)
488493
tools_menu.addAction(fix_unlinked_entries_action)
489494

495+
def create_dupe_files_modal():
496+
"""Postpone the creation of the modal until it is needed."""
497+
if not hasattr(self, "dupe_modal"):
498+
self.dupe_modal = FixDupeFilesModal(self.lib, self)
499+
self.dupe_modal.show()
500+
490501
fix_dupe_files_action = QAction("Fix Duplicate &Files", menu_bar)
491-
fdf_modal = FixDupeFilesModal(self.lib, self)
492-
fix_dupe_files_action.triggered.connect(lambda: fdf_modal.show())
502+
fix_dupe_files_action.triggered.connect(create_dupe_files_modal)
493503
tools_menu.addAction(fix_dupe_files_action)
494504

495505
create_collage_action = QAction("Create Collage", menu_bar)
@@ -540,9 +550,14 @@ def start(self) -> None:
540550
)
541551
window_menu.addAction(show_libs_list_action)
542552

553+
def create_folders_tags_modal():
554+
"""Postpone the creation of the modal until it is needed."""
555+
if not hasattr(self, "folders_modal"):
556+
self.folders_modal = FoldersToTagsModal(self.lib, self)
557+
self.folders_modal.show()
558+
543559
folders_to_tags_action = QAction("Folders to Tags", menu_bar)
544-
ftt_modal = FoldersToTagsModal(self.lib, self)
545-
folders_to_tags_action.triggered.connect(lambda: ftt_modal.show())
560+
folders_to_tags_action.triggered.connect(create_folders_tags_modal)
546561
macros_menu.addAction(folders_to_tags_action)
547562

548563
# Help Menu ============================================================

0 commit comments

Comments
 (0)