From 81976cfd1ae5cf82bd0fce18b433e8b87578cfbd Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Mon, 23 Dec 2019 16:31:55 +0100 Subject: [PATCH 1/6] Add a few splash loading messages for a better sense of progress CURA-6823 --- cura/CuraApplication.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 93f7fa97ff..3f7fb4aa5e 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -745,6 +745,7 @@ class CuraApplication(QtApplication): super().run() Logger.log("i", "Initializing machine manager") + self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Initializing machine manager...")) self._machine_manager = MachineManager(self, parent = self) Logger.log("i", "Initializing container manager") @@ -861,6 +862,8 @@ class CuraApplication(QtApplication): # Initialize QML engine self.setMainQml(Resources.getPath(self.ResourceTypes.QmlFiles, "Cura.qml")) self._qml_import_paths.append(Resources.getPath(self.ResourceTypes.QmlFiles)) + self.getTheme() # preload + self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Initialize engine...")) self.initializeEngine() # Initialize UI state From 6a0fba060e704301601469089913a4374c9c7520 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Mon, 23 Dec 2019 17:32:20 +0100 Subject: [PATCH 2/6] Add loading hint for replacing the global stack Displayed as a splash message when the application is starting, logged (not displayed to the user) otherwise CURA-6823 --- cura/CuraApplication.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 3f7fb4aa5e..5df11279ee 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -637,6 +637,7 @@ class CuraApplication(QtApplication): @override(Application) def setGlobalContainerStack(self, stack: "GlobalStack") -> None: + self._setLoadingHint("Preparing Active Machine...") super().setGlobalContainerStack(stack) ## A reusable dialogbox @@ -741,6 +742,14 @@ class CuraApplication(QtApplication): self._plugins_loaded = True + ## Set a short, user-friendly hint about current loading status. + # The way this message is displayed depends on application state + def _setLoadingHint(self, hint: str): + if self.started: + Logger.info(hint) + else: + self.showSplashMessage(hint) + def run(self): super().run() From 07fb775ac1b318969e1fee0aa7f5c19353e6f7ab Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Tue, 24 Dec 2019 09:51:37 +0100 Subject: [PATCH 3/6] Preload theme in QtApplication Fixes an error where theme was loaded before the engine is initialized CURA-6823 --- cura/CuraApplication.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 5df11279ee..0ccb7c72a9 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -871,7 +871,6 @@ class CuraApplication(QtApplication): # Initialize QML engine self.setMainQml(Resources.getPath(self.ResourceTypes.QmlFiles, "Cura.qml")) self._qml_import_paths.append(Resources.getPath(self.ResourceTypes.QmlFiles)) - self.getTheme() # preload self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Initialize engine...")) self.initializeEngine() From d110d04c368a867487e8e690fa1dae74586091b9 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Tue, 24 Dec 2019 10:43:21 +0100 Subject: [PATCH 4/6] Make loading messages more consistent and cleanup usages. CURA-6823 --- cura/CuraApplication.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 0ccb7c72a9..2bb054d50d 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -508,14 +508,14 @@ class CuraApplication(QtApplication): self.getController().contextMenuRequested.connect(self._onContextMenuRequested) self.getCuraSceneController().activeBuildPlateChanged.connect(self.updatePlatformActivityDelayed) - self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Loading machines...")) + self._setLoadingHint(self._i18n_catalog.i18nc("@info:progress", "Loading machines...")) self._container_registry.allMetadataLoaded.connect(ContainerRegistry.getInstance) with self._container_registry.lockFile(): self._container_registry.loadAllMetadata() - self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Setting up preferences...")) + self._setLoadingHint(self._i18n_catalog.i18nc("@info:progress", "Setting up preferences...")) # Set the setting version for Preferences preferences = self.getPreferences() preferences.addPreference("metadata/setting_version", 0) @@ -637,7 +637,7 @@ class CuraApplication(QtApplication): @override(Application) def setGlobalContainerStack(self, stack: "GlobalStack") -> None: - self._setLoadingHint("Preparing Active Machine...") + self._setLoadingHint(self._i18n_catalog.i18nc("@info:progress", "Initializing Active Machine...")) super().setGlobalContainerStack(stack) ## A reusable dialogbox @@ -754,7 +754,7 @@ class CuraApplication(QtApplication): super().run() Logger.log("i", "Initializing machine manager") - self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Initializing machine manager...")) + self._setLoadingHint(self._i18n_catalog.i18nc("@info:progress", "Initializing machine manager...")) self._machine_manager = MachineManager(self, parent = self) Logger.log("i", "Initializing container manager") @@ -831,7 +831,7 @@ class CuraApplication(QtApplication): ## Run Cura with GUI (desktop mode). def runWithGUI(self): - self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Setting up scene...")) + self._setLoadingHint(self._i18n_catalog.i18nc("@info:progress", "Setting up scene...")) controller = self.getController() @@ -866,12 +866,12 @@ class CuraApplication(QtApplication): self._camera_animation = CameraAnimation.CameraAnimation() self._camera_animation.setCameraTool(self.getController().getTool("CameraTool")) - self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Loading interface...")) + self._setLoadingHint(self._i18n_catalog.i18nc("@info:progress", "Loading interface...")) # Initialize QML engine self.setMainQml(Resources.getPath(self.ResourceTypes.QmlFiles, "Cura.qml")) self._qml_import_paths.append(Resources.getPath(self.ResourceTypes.QmlFiles)) - self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Initialize engine...")) + self._setLoadingHint(self._i18n_catalog.i18nc("@info:progress", "Initializing engine...")) self.initializeEngine() # Initialize UI state From 41c953112ae6ef87eac3ca461b4b1a023435368d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 24 Dec 2019 12:53:19 +0100 Subject: [PATCH 5/6] Make animation time instead of update dependant CURA-6823 --- cura/UI/CuraSplashScreen.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cura/UI/CuraSplashScreen.py b/cura/UI/CuraSplashScreen.py index 70df454e7d..4074020865 100644 --- a/cura/UI/CuraSplashScreen.py +++ b/cura/UI/CuraSplashScreen.py @@ -9,6 +9,7 @@ from UM.Resources import Resources from UM.Application import Application from cura import ApplicationMetadata +import time class CuraSplashScreen(QSplashScreen): def __init__(self): @@ -34,15 +35,20 @@ class CuraSplashScreen(QSplashScreen): self._change_timer.setSingleShot(False) self._change_timer.timeout.connect(self.updateLoadingImage) + self._last_update_time = None + def show(self): super().show() + self._last_update_time = time.time() self._change_timer.start() def updateLoadingImage(self): if self._to_stop: return - - self._loading_image_rotation_angle -= 10 + time_since_last_update = time.time() - self._last_update_time + self._last_update_time = time.time() + # Since we don't know how much time actually passed, check how many intervals of 50 we had. + self._loading_image_rotation_angle -= 10 * (time_since_last_update * 1000 / 50) self.repaint() # Override the mousePressEvent so the splashscreen doesn't disappear when clicked From 62c54d3f3e2b34e3c1fcca08a112ce8b9bab5dfe Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 24 Dec 2019 13:36:04 +0100 Subject: [PATCH 6/6] Add few more processEvents to make updating of splashscreen a bit smoother CURA-6823 --- cura/CuraApplication.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 2bb054d50d..d51685ac29 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -756,13 +756,16 @@ class CuraApplication(QtApplication): Logger.log("i", "Initializing machine manager") self._setLoadingHint(self._i18n_catalog.i18nc("@info:progress", "Initializing machine manager...")) self._machine_manager = MachineManager(self, parent = self) + self.processEvents() Logger.log("i", "Initializing container manager") self._container_manager = ContainerManager(self) + self.processEvents() Logger.log("i", "Initializing machine error checker") self._machine_error_checker = MachineErrorChecker(self) self._machine_error_checker.initialize() + self.processEvents() # Check if we should run as single instance or not. If so, set up a local socket server which listener which # coordinates multiple Cura instances and accepts commands. @@ -770,6 +773,7 @@ class CuraApplication(QtApplication): self.__setUpSingleInstanceServer() # Setup scene and build volume + self._setLoadingHint(self._i18n_catalog.i18nc("@info:progress", "Initializing build volume...")) root = self.getController().getScene().getRoot() self._volume = BuildVolume.BuildVolume(self, root) Arrange.build_volume = self._volume @@ -777,13 +781,13 @@ class CuraApplication(QtApplication): # initialize info objects self._print_information = PrintInformation.PrintInformation(self) self._cura_actions = CuraActions.CuraActions(self) - + self.processEvents() # Initialize setting visibility presets model. self._setting_visibility_presets_model = SettingVisibilityPresetsModel(self.getPreferences(), parent = self) # Initialize Cura API self._cura_API.initialize() - + self.processEvents() self._output_device_manager.start() self._welcome_pages_model.initialize() self._add_printer_pages_model.initialize() @@ -843,7 +847,7 @@ class CuraApplication(QtApplication): # Set default background color for scene self.getRenderer().setBackgroundColor(QColor(245, 245, 245)) - + self.processEvents() # Initialize platform physics self._physics = PlatformPhysics.PlatformPhysics(controller, self._volume) @@ -1040,14 +1044,17 @@ class CuraApplication(QtApplication): super().registerObjects(engine) # global contexts + self.processEvents() engine.rootContext().setContextProperty("Printer", self) engine.rootContext().setContextProperty("CuraApplication", self) engine.rootContext().setContextProperty("PrintInformation", self._print_information) engine.rootContext().setContextProperty("CuraActions", self._cura_actions) engine.rootContext().setContextProperty("CuraSDKVersion", ApplicationMetadata.CuraSDKVersion) + self.processEvents() qmlRegisterUncreatableType(CuraApplication, "Cura", 1, 0, "ResourceTypes", "Just an Enum type") + self.processEvents() qmlRegisterSingletonType(CuraSceneController, "Cura", 1, 0, "SceneController", self.getCuraSceneController) qmlRegisterSingletonType(ExtruderManager, "Cura", 1, 0, "ExtruderManager", self.getExtruderManager) qmlRegisterSingletonType(MachineManager, "Cura", 1, 0, "MachineManager", self.getMachineManager) @@ -1056,16 +1063,16 @@ class CuraApplication(QtApplication): qmlRegisterSingletonType(SimpleModeSettingsManager, "Cura", 1, 0, "SimpleModeSettingsManager", self.getSimpleModeSettingsManager) qmlRegisterSingletonType(MachineActionManager.MachineActionManager, "Cura", 1, 0, "MachineActionManager", self.getMachineActionManager) + self.processEvents() qmlRegisterType(NetworkingUtil, "Cura", 1, 5, "NetworkingUtil") - qmlRegisterType(WelcomePagesModel, "Cura", 1, 0, "WelcomePagesModel") qmlRegisterType(WhatsNewPagesModel, "Cura", 1, 0, "WhatsNewPagesModel") qmlRegisterType(AddPrinterPagesModel, "Cura", 1, 0, "AddPrinterPagesModel") qmlRegisterType(TextManager, "Cura", 1, 0, "TextManager") qmlRegisterType(RecommendedMode, "Cura", 1, 0, "RecommendedMode") + self.processEvents() qmlRegisterType(NetworkMJPGImage, "Cura", 1, 0, "NetworkMJPGImage") - qmlRegisterType(ObjectsModel, "Cura", 1, 0, "ObjectsModel") qmlRegisterType(BuildPlateModel, "Cura", 1, 0, "BuildPlateModel") qmlRegisterType(MultiBuildPlateModel, "Cura", 1, 0, "MultiBuildPlateModel") @@ -1073,14 +1080,15 @@ class CuraApplication(QtApplication): qmlRegisterType(ExtrudersModel, "Cura", 1, 0, "ExtrudersModel") qmlRegisterType(GlobalStacksModel, "Cura", 1, 0, "GlobalStacksModel") + self.processEvents() qmlRegisterType(FavoriteMaterialsModel, "Cura", 1, 0, "FavoriteMaterialsModel") qmlRegisterType(GenericMaterialsModel, "Cura", 1, 0, "GenericMaterialsModel") qmlRegisterType(MaterialBrandsModel, "Cura", 1, 0, "MaterialBrandsModel") qmlRegisterSingletonType(QualityManagementModel, "Cura", 1, 0, "QualityManagementModel", self.getQualityManagementModel) qmlRegisterSingletonType(MaterialManagementModel, "Cura", 1, 5, "MaterialManagementModel", self.getMaterialManagementModel) + self.processEvents() qmlRegisterType(DiscoveredPrintersModel, "Cura", 1, 0, "DiscoveredPrintersModel") - qmlRegisterSingletonType(QualityProfilesDropDownMenuModel, "Cura", 1, 0, "QualityProfilesDropDownMenuModel", self.getQualityProfilesDropDownMenuModel) qmlRegisterSingletonType(CustomQualityProfilesDropDownMenuModel, "Cura", 1, 0, @@ -1089,6 +1097,7 @@ class CuraApplication(QtApplication): qmlRegisterType(IntentModel, "Cura", 1, 6, "IntentModel") qmlRegisterType(IntentCategoryModel, "Cura", 1, 6, "IntentCategoryModel") + self.processEvents() qmlRegisterType(MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler") qmlRegisterType(SettingVisibilityPresetsModel, "Cura", 1, 0, "SettingVisibilityPresetsModel") qmlRegisterType(QualitySettingsModel, "Cura", 1, 0, "QualitySettingsModel") @@ -1117,6 +1126,7 @@ class CuraApplication(QtApplication): continue qmlRegisterType(QUrl.fromLocalFile(path), "Cura", 1, 0, type_name) + self.processEvents() def onSelectionChanged(self): if Selection.hasSelection():