diff --git a/source/modules/_resources_rc.py b/source/modules/_resources_rc.py index cdb9bad2..7b6a1fba 100644 --- a/source/modules/_resources_rc.py +++ b/source/modules/_resources_rc.py @@ -11,15 +11,19 @@ try: import resources_rc + # Upon importing resources_rc, the :resources QIODevice should be open, # and the contained styles should be available for use. + RESOURCES_AVAILABLE = True except ImportError: + RESOURCES_AVAILABLE = False if is_frozen(): print("Failed to import cached resources! Blender-Launcher-V2 was built without resources.") elif (Path.cwd() / "build_style.py").exists(): # TODO: Attempt to build the style and check if it fails print("Resources were not built! Run python build_style.py to build the style.") + else: - raise + print("Resources were not built! build the style so the launcher looks right.") - sys.exit() + raise diff --git a/source/modules/settings.py b/source/modules/settings.py index 9e0c6262..5427056e 100644 --- a/source/modules/settings.py +++ b/source/modules/settings.py @@ -1,4 +1,5 @@ from __future__ import annotations + import contextlib import os import shutil @@ -126,6 +127,14 @@ def set_favorite_path(path): get_settings().setValue("Internal/favorite_path", path) +def get_dont_show_resource_warning(): + return get_settings().value("Internal/dont_show_resource_err_again", type=bool, defaultValue=False) + + +def set_dont_show_resource_warning(b: bool = True): + get_settings().setValue("Internal/dont_show_resource_err_again", b) + + def get_last_time_checked_utc(): v = get_settings().value("Internal/last_time_checked_utc", defaultValue=ISO_EPOCH) return datetime.fromisoformat(v) diff --git a/source/windows/main_window.py b/source/windows/main_window.py index 1accbb00..23a00353 100644 --- a/source/windows/main_window.py +++ b/source/windows/main_window.py @@ -25,6 +25,7 @@ get_default_downloads_page, get_default_library_page, get_default_tab, + get_dont_show_resource_warning, get_enable_download_notifications, get_enable_new_builds_notifications, get_enable_quick_launch_key_seq, @@ -44,6 +45,7 @@ get_use_system_titlebar, get_worker_thread_count, is_library_folder_valid, + set_dont_show_resource_warning, set_last_time_checked_utc, set_library_folder, set_tray_icon_notified, @@ -64,6 +66,7 @@ QWidget, ) from semver import Version +from modules._resources_rc import RESOURCES_AVAILABLE from threads.library_drawer import DrawLibraryTask from threads.remover import RemovalTask from threads.scraper import Scraper @@ -176,6 +179,17 @@ def __init__(self, app: QApplication, version: Version, offline: bool = False): # Vesrion Update self.pre_release_build = get_use_pre_release_builds + if not RESOURCES_AVAILABLE and not get_dont_show_resource_warning(): + dlg = DialogWindow( + parent=self, + title="Error", + text="Resources failed to load! The launcher will still work,
\ + but the style will be broken.", + accept_text="OK", + cancel_text="Don't Show Again", + ) + dlg.cancelled.connect(self.__dont_show_resources_warning_again) + # Check library folder if is_library_folder_valid() is False: self.dlg = DialogWindow( @@ -191,6 +205,11 @@ def __init__(self, app: QApplication, version: Version, offline: bool = False): create_library_folders(get_library_folder()) self.draw() + def __dont_show_resources_warning_again(self): + set_dont_show_resource_warning(True) + + + def prompt_library_folder(self): library_folder = get_cwd().as_posix() new_library_folder = FileDialogWindow().get_directory(self, "Select Library Folder", library_folder)