Skip to content

Commit

Permalink
unify setting items location
Browse files Browse the repository at this point in the history
  • Loading branch information
yedpodtrzitko committed May 9, 2024
1 parent 6d1e0f2 commit 9e3f736
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions tagstudio/src/core/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ def refresh_dir(self):
if (end_time - start_time) > 0.034:
yield self.dir_file_count
start_time = time.time()
# print('')

# Sorts the files by date modified, descending.
if len(self.files_not_in_library) <= 100000:
Expand Down
1 change: 0 additions & 1 deletion tagstudio/src/core/ts_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
BACKUP_FOLDER_NAME: str = "backups"
COLLAGE_FOLDER_NAME: str = "collages"
LIBRARY_FILENAME: str = "ts_library.json"
SETTINGS_LIBS_LIST: str = "libraries"

# TODO: Turn this whitelist into a user-configurable blacklist.
IMAGE_TYPES: list[str] = [
Expand Down
18 changes: 10 additions & 8 deletions tagstudio/src/qt/ts_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from datetime import datetime as dt
from hashlib import sha1
from pathlib import Path
from queue import Queue
from queue import Empty, Queue
from typing import Optional

from PIL import Image
Expand Down Expand Up @@ -72,7 +72,6 @@
TS_FOLDER_NAME,
VERSION_BRANCH,
VERSION,
SETTINGS_LIBS_LIST,
)
from src.core.utils.web import strip_web_protocol
from src.qt.flowlayout import FlowLayout
Expand Down Expand Up @@ -117,8 +116,9 @@
class SettingItems(str, enum.Enum):
"""List of setting item names."""

START_LIBS_LIST = "start_libs_list"
START_SHOW_LIBS = "start_show_libs"
LAST_LIBRARY = "last_library"
LIBS_LIST = "libs_list"


class NavigationState:
Expand Down Expand Up @@ -376,11 +376,11 @@ def start(self):
check_action = QAction("List Libraries on Start", self)
check_action.setCheckable(True)
check_action.setChecked(
self.settings.value(SettingItems.START_LIBS_LIST, False, type=bool)
self.settings.value(SettingItems.START_SHOW_LIBS, False, type=bool)
)
check_action.triggered.connect(
lambda checked: self.settings.setValue(
SettingItems.START_LIBS_LIST, checked
SettingItems.START_SHOW_LIBS, checked
)
)
edit_menu.addAction(check_action)
Expand Down Expand Up @@ -479,12 +479,14 @@ def start(self):

if self.args.open:
self.open_library(self.args.open)
elif self.settings.value(SettingItems.START_LIBS_LIST, type=bool):
self.settings.beginGroup(SETTINGS_LIBS_LIST)
elif self.settings.value(SettingItems.START_SHOW_LIBS, type=bool):
self.settings.beginGroup(SettingItems.LIBS_LIST)
lib_items = {x: self.settings.value(x) for x in self.settings.allKeys()}
if lib_items:
self.settings.endGroup()
self.list_libraries_panel(lib_items)
else:
self.init_library_window()
elif lib := self.settings.value(SettingItems.LAST_LIBRARY):
self.splash.showMessage(
f'Opening Library "{lib}"...',
Expand Down Expand Up @@ -1331,7 +1333,7 @@ def filter_items(self, query=""):
)

def update_libs_list(self, library_path: str):
self.settings.beginGroup(SETTINGS_LIBS_LIST)
self.settings.beginGroup(SettingItems.LIBS_LIST)
path_hash = sha1(library_path.encode("utf-8")).hexdigest()
self.settings.setValue(path_hash, library_path)
self.settings.endGroup()
Expand Down

0 comments on commit 9e3f736

Please sign in to comment.