Skip to content

Commit

Permalink
classes.info: Store, manage default paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Dec 9, 2021
1 parent db60cf1 commit f13df1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/classes/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
USER_DEFAULT_PROJECT = os.path.join(USER_PATH, "default.osp")
LEGACY_DEFAULT_PROJECT = USER_DEFAULT_PROJECT.replace(".osp", ".project")

# Back up "default" values for user paths
_path_defaults = {
k: v for k, v in locals().items()
if k.endswith("_PATH")
and v.startswith(USER_PATH)
}

try:
from PyQt5.QtCore import QSize

Expand Down
8 changes: 3 additions & 5 deletions src/classes/project_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,8 @@ def new(self):
self.current_filepath = None
self.has_unsaved_changes = False

# Reset info paths
info.THUMBNAIL_PATH = os.path.join(info.USER_PATH, "thumbnail")
info.TITLE_PATH = os.path.join(info.USER_PATH, "title")
info.BLENDER_PATH = os.path.join(info.USER_PATH, "blender")
# Reset info paths back to their default/initial values
info.reset_userdirs()

# Get default profile
s = get_app().get_settings()
Expand Down Expand Up @@ -392,7 +390,7 @@ def load(self, file_path, clear_thumbnails=True):
self.check_if_paths_are_valid()

# Clear old thumbnails
openshot_thumbnails = os.path.join(info.USER_PATH, "thumbnails")
openshot_thumbnails = info.get_default_path("THUMBNAIL_PATH")
if os.path.exists(openshot_thumbnails) and clear_thumbnails:
# Clear thumbnails
shutil.rmtree(openshot_thumbnails, True)
Expand Down

0 comments on commit f13df1e

Please sign in to comment.