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 94d2087
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 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
50 changes: 28 additions & 22 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 @@ -605,6 +604,7 @@ def shutdown(self):
"""Save Library on Application Exit"""
if self.lib.library_dir:
self.save_library()
self.lib.observer.stop()
self.settings.setValue(SettingItems.LAST_LIBRARY, self.lib.library_dir)
self.settings.sync()
logging.info("[SHUTDOWN] Ending Thumbnail Threads...")
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 @@ -1256,10 +1260,7 @@ def update_thumbs(self):
item_thumb.set_count(str(len(collation.e_ids_and_pages)))
item_thumb.update_clickable(
clickable=(
lambda checked=False,
filepath=filepath,
entry=cover_e,
collation=collation: (
lambda checked=False, filepath=filepath, entry=cover_e, collation=collation: (
self.expand_collation(collation.e_ids_and_pages)
)
)
Expand Down Expand Up @@ -1425,6 +1426,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 +1484,19 @@ 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 94d2087

Please sign in to comment.