Make first slicing profile the default
We also reflect that in the Cura profile import dialog by checking and disabling modification of the corresponding checkbox if no profiles are yet available.
This commit is contained in:
parent
50983c8524
commit
01b3b8a0e0
3 changed files with 19 additions and 5 deletions
|
|
@ -24,6 +24,7 @@ $(function() {
|
|||
self.profileDescription = ko.observable();
|
||||
self.profileAllowOverwrite = ko.observable(true);
|
||||
self.profileMakeDefault = ko.observable(false);
|
||||
self.profileFirst = ko.observable(false);
|
||||
|
||||
// make sure to update form data if any of the metadata changes
|
||||
self.profileName.subscribe(function() { self.copyProfileMetadata(); });
|
||||
|
|
@ -134,7 +135,10 @@ $(function() {
|
|||
self.profileDisplayName(undefined);
|
||||
self.profileDescription(undefined);
|
||||
self.profileAllowOverwrite(true);
|
||||
self.profileMakeDefault(false);
|
||||
|
||||
var firstProfile = self.profiles.items().length === 0;
|
||||
self.profileMakeDefault(firstProfile);
|
||||
self.profileFirst(firstProfile);
|
||||
};
|
||||
|
||||
self.uploadElement.fileupload({
|
||||
|
|
|
|||
|
|
@ -37,15 +37,15 @@
|
|||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox" data-bind="enable: fieldsEnabled, css: {disabled: !fieldsEnabled()}">
|
||||
<input type="checkbox" data-bind="checked: profileMakeDefault"> {{ _('Make default profile') }}
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: profileMakeDefault, enable: fieldsEnabled() && !profileFirst(), css: {disabled: !fieldsEnabled() || profileFirst()}"> {{ _('Make default profile') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox" data-bind="enable: fieldsEnabled, css: {disabled: !fieldsEnabled()}">
|
||||
<input type="checkbox" data-bind="checked: profileAllowOverwrite"> {{ _('Overwrite existing file') }}
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: profileAllowOverwrite, enable: fieldsEnabled() && !profileFirst(), css: {disabled: !fieldsEnabled() || profileFirst()}"> {{ _('Overwrite existing file') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -377,6 +377,10 @@ class SlicingManager(object):
|
|||
|
||||
If it's a :class:`dict`, a new :class:`SlicingProfile` instance will be created with the supplied meta data and
|
||||
the profile data as the :attr:`~SlicingProfile.data` attribute.
|
||||
|
||||
.. note::
|
||||
|
||||
If the profile is the first profile to be saved for the slicer, it will automatically be marked as default.
|
||||
|
||||
Arguments:
|
||||
slicer (str): Identifier of the slicer for which to save the ``profile``.
|
||||
|
|
@ -414,6 +418,8 @@ class SlicingManager(object):
|
|||
if description is not None:
|
||||
profile.description = description
|
||||
|
||||
first_profile = len(self.all_profiles(slicer, require_configured=False)) == 0
|
||||
|
||||
path = self.get_profile_path(slicer, name)
|
||||
is_overwrite = os.path.exists(path)
|
||||
|
||||
|
|
@ -426,6 +432,10 @@ class SlicingManager(object):
|
|||
profile=name)
|
||||
event = octoprint.events.Events.SLICING_PROFILE_MODIFIED if is_overwrite else octoprint.events.Events.SLICING_PROFILE_ADDED
|
||||
octoprint.events.eventManager().fire(event, payload)
|
||||
|
||||
if first_profile:
|
||||
# enforce the first profile we add for this slicer is set as default
|
||||
self.set_default_profile(slicer, name)
|
||||
|
||||
return profile
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue