Skip to content

Commit

Permalink
Bugfix for recent library re-creating a library at the last library l…
Browse files Browse the repository at this point in the history
…ocation. (TagStudioDev#238)

* Prevent Automatic opening of a Library if the ".TagStudio" folder has been deleted.
If the library no longer has a `.TagStudio` folder clear the Last_Library value

* Add disabling recent libraries that are missing or have missing `.TagStudio` folders

* Fix bug where this would crash if an empty library was passed

* Grabbed the wrong color
  • Loading branch information
Andrew Arneson authored Jun 3, 2024
1 parent 0646508 commit 10b90dc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tagstudio/src/core/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ class Theme(str, enum.Enum):
COLOR_BG = "#65000000"
COLOR_HOVER = "#65AAAAAA"
COLOR_PRESSED = "#65EEEEEE"
COLOR_DISABLED = "#65F39CAA"
COLOR_DISABLED_BG = "#65440D12"
8 changes: 8 additions & 0 deletions tagstudio/src/qt/ts_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,14 @@ def start(self) -> None:
elif self.settings.value(SettingItems.START_LOAD_LAST, True, type=bool):
lib = self.settings.value(SettingItems.LAST_LIBRARY)

# TODO: Remove this check if the library is no longer saved with files
if lib and not (Path(lib) / TS_FOLDER_NAME).exists():
logging.error(
f"[QT DRIVER] {TS_FOLDER_NAME} folder in {lib} does not exist."
)
self.settings.setValue(SettingItems.LAST_LIBRARY, "")
lib = None

if lib:
self.splash.showMessage(
f'Opening Library "{lib}"...',
Expand Down
8 changes: 7 additions & 1 deletion tagstudio/src/qt/widgets/preview_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from src.core.enums import SettingItems, Theme
from src.core.library import Entry, ItemType, Library
from src.core.constants import VIDEO_TYPES, IMAGE_TYPES, RAW_IMAGE_TYPES
from src.core.constants import VIDEO_TYPES, IMAGE_TYPES, RAW_IMAGE_TYPES, TS_FOLDER_NAME
from src.qt.helpers.file_opener import FileOpenerLabel, FileOpenerHelper, open_file
from src.qt.modals.add_field import AddFieldModal
from src.qt.widgets.thumb_renderer import ThumbRenderer
Expand Down Expand Up @@ -298,6 +298,7 @@ def set_button_style(btn: QPushButton, extras: list[str] | None = None):
"}"
f"QPushButton::hover{{background-color:{Theme.COLOR_HOVER.value};}}"
f"QPushButton::pressed{{background-color:{Theme.COLOR_PRESSED.value};}}"
f"QPushButton::disabled{{background-color:{Theme.COLOR_DISABLED_BG.value};}}"
)
)
btn.setCursor(Qt.CursorShape.PointingHandCursor)
Expand All @@ -306,6 +307,11 @@ def set_button_style(btn: QPushButton, extras: list[str] | None = None):
button = QPushButton(text=cut_val)
button.setObjectName(f"path{item_key}")

lib = Path(full_val)
if not lib.exists() or not (lib / TS_FOLDER_NAME).exists():
button.setDisabled(True)
button.setToolTip("Location is missing")

def open_library_button_clicked(path):
return lambda: self.driver.open_library(Path(path))

Expand Down

0 comments on commit 10b90dc

Please sign in to comment.