Merge remote-tracking branch 'origin/4.1'

This commit is contained in:
Lipu Fei 2019-04-24 08:25:29 +02:00
commit 73824939bb
3 changed files with 11 additions and 7 deletions

View file

@ -19,6 +19,7 @@ class AutoSave:
self._change_timer.setInterval(self._application.getPreferences().getValue("cura/autosave_delay")) self._change_timer.setInterval(self._application.getPreferences().getValue("cura/autosave_delay"))
self._change_timer.setSingleShot(True) self._change_timer.setSingleShot(True)
self._enabled = True
self._saving = False self._saving = False
def initialize(self): def initialize(self):
@ -32,6 +33,13 @@ class AutoSave:
if not self._saving: if not self._saving:
self._change_timer.start() self._change_timer.start()
def setEnabled(self, enabled: bool) -> None:
self._enabled = enabled
if self._enabled:
self._change_timer.start()
else:
self._change_timer.stop()
def _onGlobalStackChanged(self): def _onGlobalStackChanged(self):
if self._global_stack: if self._global_stack:
self._global_stack.propertyChanged.disconnect(self._triggerTimer) self._global_stack.propertyChanged.disconnect(self._triggerTimer)

View file

@ -51,8 +51,8 @@ class BackupsManager:
## Here we try to disable the auto-save plug-in as it might interfere with ## Here we try to disable the auto-save plug-in as it might interfere with
# restoring a back-up. # restoring a back-up.
def _disableAutoSave(self) -> None: def _disableAutoSave(self) -> None:
self._application.setSaveDataEnabled(False) self._application.getAutoSave().setEnabled(False)
## Re-enable auto-save after we're done. ## Re-enable auto-save after we're done.
def _enableAutoSave(self) -> None: def _enableAutoSave(self) -> None:
self._application.setSaveDataEnabled(True) self._application.getAutoSave().setEnabled(True)

View file

@ -258,7 +258,6 @@ class CuraApplication(QtApplication):
# Backups # Backups
self._auto_save = None self._auto_save = None
self._save_data_enabled = True
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
self._container_registry_class = CuraContainerRegistry self._container_registry_class = CuraContainerRegistry
@ -668,13 +667,10 @@ class CuraApplication(QtApplication):
self._message_box_callback(button, *self._message_box_callback_arguments) self._message_box_callback(button, *self._message_box_callback_arguments)
self._message_box_callback = None self._message_box_callback = None
self._message_box_callback_arguments = [] self._message_box_callback_arguments = []
def setSaveDataEnabled(self, enabled: bool) -> None:
self._save_data_enabled = enabled
# Cura has multiple locations where instance containers need to be saved, so we need to handle this differently. # Cura has multiple locations where instance containers need to be saved, so we need to handle this differently.
def saveSettings(self): def saveSettings(self):
if not self.started or not self._save_data_enabled: if not self.started:
# Do not do saving during application start or when data should not be saved on quit. # Do not do saving during application start or when data should not be saved on quit.
return return
ContainerRegistry.getInstance().saveDirtyContainers() ContainerRegistry.getInstance().saveDirtyContainers()