Skip to content

Commit

Permalink
Pull latest and fix manual library opening
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgiest05 committed May 17, 2024
1 parent 2158e9d commit 07527cf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
5 changes: 2 additions & 3 deletions tagstudio/src/core/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ def __init__(self) -> None:

# Refresh on changes
self.observer = Observer()
self.observer.start()

def create_library(self, path) -> int:
"""
Expand Down Expand Up @@ -934,8 +935,7 @@ def clear_internal_vars(self):
self._tag_entry_ref_map.clear()

if self.observer.is_alive():
self.observer.stop()
self.observer.join()
self.observer.unschedule_all()

def refresh_dir(self) -> Generator:
"""Scans a directory for files, and adds those relative filenames to internal variables."""
Expand Down Expand Up @@ -1004,7 +1004,6 @@ def refresh_on_changes(self, callback: Callable[[], None]) -> None:
self.observer.schedule(
IsDirModifiedHandler(self, callback), path=self.library_dir, recursive=True
)
self.observer.start()

def refresh_missing_files(self):
"""Tracks the number of Entries that point to an invalid file path."""
Expand Down
47 changes: 29 additions & 18 deletions tagstudio/src/qt/ts_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ def start(self) -> None:
QColor("#9782ff"),
)
self.open_library(lib)
self.lib.refresh_on_changes(self.filter_items)

if self.args.ci:
# gracefully terminate the app in CI environment
Expand Down Expand Up @@ -603,6 +602,7 @@ def handleSIGTERM(self):

def shutdown(self):
"""Save Library on Application Exit"""
self.lib.observer.stop()
if self.lib.library_dir:
self.save_library()
self.settings.setValue(SettingItems.LAST_LIBRARY, self.lib.library_dir)
Expand Down Expand Up @@ -1218,14 +1218,18 @@ def update_thumbs(self):
lambda checked=False, entry=entry: self.select_item(
ItemType.ENTRY,
entry.id,
append=True
if QGuiApplication.keyboardModifiers()
== Qt.KeyboardModifier.ControlModifier
else False,
bridge=True
if QGuiApplication.keyboardModifiers()
== Qt.KeyboardModifier.ShiftModifier
else False,
append=(
True
if QGuiApplication.keyboardModifiers()
== Qt.KeyboardModifier.ControlModifier
else False
),
bridge=(
True
if QGuiApplication.keyboardModifiers()
== Qt.KeyboardModifier.ShiftModifier
else False
),
)
)
)
Expand Down Expand Up @@ -1425,6 +1429,7 @@ def open_library(self, path):
self.selected.clear()
self.preview_panel.update_widgets()
self.filter_items()
self.lib.refresh_on_changes(self.filter_items)

def create_collage(self) -> None:
"""Generates and saves an image collage based on Library Entries."""
Expand Down Expand Up @@ -1482,15 +1487,21 @@ def create_collage(self) -> None:
thumb_size: int = (
32
if (full_thumb_size == 0)
else 64
if (full_thumb_size == 1)
else 128
if (full_thumb_size == 2)
else 256
if (full_thumb_size == 3)
else 512
if (full_thumb_size == 4)
else 32
else (
64
if (full_thumb_size == 1)
else (
128
if (full_thumb_size == 2)
else (
256
if (full_thumb_size == 3)
else 512
if (full_thumb_size == 4)
else 32
)
)
)
)
thumb_size = 16

Expand Down

0 comments on commit 07527cf

Please sign in to comment.