mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
Added reload profile (simply clears user instance container)
CURA-1278
This commit is contained in:
parent
11cb9af97f
commit
ad35c9f070
2 changed files with 25 additions and 2 deletions
|
@ -41,9 +41,15 @@ class MachineManagerModel(QObject):
|
||||||
activeVariantChanged = pyqtSignal()
|
activeVariantChanged = pyqtSignal()
|
||||||
activeQualityChanged = pyqtSignal()
|
activeQualityChanged = pyqtSignal()
|
||||||
|
|
||||||
|
globalPropertyChanged = pyqtSignal() # Emitted whenever a property inside global container is changed.
|
||||||
|
|
||||||
|
def _onGlobalPropertyChanged(self, key, property_name):
|
||||||
|
self.globalPropertyChanged.emit()
|
||||||
|
|
||||||
def _onGlobalContainerChanged(self):
|
def _onGlobalContainerChanged(self):
|
||||||
if self._global_container_stack:
|
if self._global_container_stack:
|
||||||
self._global_container_stack.containersChanged.disconnect(self._onInstanceContainersChanged)
|
self._global_container_stack.containersChanged.disconnect(self._onInstanceContainersChanged)
|
||||||
|
self._global_container_stack.propertyChanged.disconnect(self._onGlobalPropertyChanged)
|
||||||
|
|
||||||
self._global_container_stack = Application.getInstance().getGlobalContainerStack()
|
self._global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
self.globalContainerChanged.emit()
|
self.globalContainerChanged.emit()
|
||||||
|
@ -51,6 +57,7 @@ class MachineManagerModel(QObject):
|
||||||
if self._global_container_stack:
|
if self._global_container_stack:
|
||||||
Preferences.getInstance().setValue("cura/active_machine", self._global_container_stack.getId())
|
Preferences.getInstance().setValue("cura/active_machine", self._global_container_stack.getId())
|
||||||
self._global_container_stack.containersChanged.connect(self._onInstanceContainersChanged)
|
self._global_container_stack.containersChanged.connect(self._onInstanceContainersChanged)
|
||||||
|
self._global_container_stack.propertyChanged.connect(self._onGlobalPropertyChanged)
|
||||||
|
|
||||||
def _onInstanceContainersChanged(self, container):
|
def _onInstanceContainersChanged(self, container):
|
||||||
container_type = container.getMetaDataEntry("type")
|
container_type = container.getMetaDataEntry("type")
|
||||||
|
@ -160,6 +167,21 @@ class MachineManagerModel(QObject):
|
||||||
|
|
||||||
return unique_name
|
return unique_name
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def clearUserSettings(self):
|
||||||
|
if not self._global_container_stack:
|
||||||
|
return
|
||||||
|
user_settings = self._global_container_stack.getTop()
|
||||||
|
user_settings.clear()
|
||||||
|
|
||||||
|
@pyqtProperty(bool, notify = globalPropertyChanged)
|
||||||
|
def hasUserSettings(self):
|
||||||
|
if not self._global_container_stack:
|
||||||
|
return
|
||||||
|
|
||||||
|
user_settings = self._global_container_stack.getTop().findInstances(**{})
|
||||||
|
return len(user_settings) != 0
|
||||||
|
|
||||||
@pyqtProperty(str, notify = globalContainerChanged)
|
@pyqtProperty(str, notify = globalContainerChanged)
|
||||||
def activeMachineName(self):
|
def activeMachineName(self):
|
||||||
if self._global_container_stack:
|
if self._global_container_stack:
|
||||||
|
|
|
@ -6,6 +6,7 @@ pragma Singleton
|
||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
import QtQuick.Controls 1.1
|
import QtQuick.Controls 1.1
|
||||||
import UM 1.1 as UM
|
import UM 1.1 as UM
|
||||||
|
import Cura 1.0 as Cura
|
||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
|
@ -117,9 +118,9 @@ Item
|
||||||
Action
|
Action
|
||||||
{
|
{
|
||||||
id: resetProfileAction;
|
id: resetProfileAction;
|
||||||
enabled: UM.ActiveProfile.valid && UM.ActiveProfile.hasCustomisedValues
|
enabled: Cura.MachineManager.hasUserSettings
|
||||||
text: catalog.i18nc("@action:inmenu menubar:profile","&Reload Current Profile");
|
text: catalog.i18nc("@action:inmenu menubar:profile","&Reload Current Profile");
|
||||||
onTriggered: UM.ActiveProfile.discardChanges();
|
onTriggered: Cura.MachineManager.clearUserSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
Action
|
Action
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue