Bugfix for recent library re-creating a library at the last library location. (#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
This commit is contained in:
Andrew Arneson
2024-06-02 23:53:42 -06:00
committed by GitHub
parent 0646508c24
commit 10b90dcc74
3 changed files with 17 additions and 1 deletions

View File

@@ -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"

View File

@@ -525,6 +525,14 @@ class QtDriver(QObject):
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}"...',

View File

@@ -30,7 +30,7 @@ from humanfriendly import format_size
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
@@ -298,6 +298,7 @@ class PreviewPanel(QWidget):
"}"
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)
@@ -306,6 +307,11 @@ class PreviewPanel(QWidget):
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))