mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-01 09:22:58 -05:00
Run commands, tools and the plugin API through one operations layer
A Speed Dial command, the MCP tool that does the same thing and the plugin API's preset calls now run one shared operation, so every route accepts and refuses the same states, with one wording and a code for each refusal. An import by a command or a tool is one undo step, and import_file adds geometry only. The cases where two routes behaved differently now behave the same: a project is not saved under a .gcode.3mf name, an empty project exports as .3mf but not as STL, arrange runs from any view and with a gizmo open, a mixed-colour filament slot is refused as one, a hidden preset is shown before it is selected, and a layer is refused while the Preview has none.
This commit is contained in:
1 parent
a9c73c76b2
commit
0616068e26
84 files changed
+6416
-1093
No files matched your search
+25
-7
@@ -8404,6 +8404,25 @@ bool Tab::save_preset(std::string name /*= ""*/, bool detach, bool save_to_proje
|
||||
return true;
|
||||
}
|
||||
|
||||
Tab::DeleteBlock Tab::can_delete_preset(const PresetCollection& presets, const Preset& preset, std::vector<std::string>* inherited_by)
|
||||
{
|
||||
std::vector<std::string> children;
|
||||
// Only a base preset is inherited from: the presets under it would no longer load.
|
||||
if (presets.get_preset_base(preset) == &preset)
|
||||
for (const Preset& other : presets)
|
||||
if (other.inherits() == preset.name)
|
||||
children.push_back(other.name);
|
||||
const bool inherited = !children.empty();
|
||||
if (inherited_by != nullptr)
|
||||
*inherited_by = std::move(children);
|
||||
// Preset::can_overwrite(), which shows the Delete button, is these two.
|
||||
if (preset.is_system || preset.is_default)
|
||||
return DeleteBlock::System;
|
||||
if (preset.is_from_bundle())
|
||||
return DeleteBlock::FromBundle;
|
||||
return inherited ? DeleteBlock::InheritedFrom : DeleteBlock::None;
|
||||
}
|
||||
|
||||
// Called for a currently selected preset.
|
||||
void Tab::delete_preset(bool ask)
|
||||
{
|
||||
@@ -8434,13 +8453,12 @@ void Tab::delete_preset(bool ask)
|
||||
confirm_delete_third_party_printer = true;
|
||||
}
|
||||
}
|
||||
int count = 0;
|
||||
wxString presets;
|
||||
for (auto &preset2 : *m_presets)
|
||||
if (preset2.inherits() == current_preset.name) {
|
||||
++count;
|
||||
presets += "\n - " + from_u8(preset2.name);
|
||||
}
|
||||
std::vector<std::string> inherited_by;
|
||||
can_delete_preset(*m_presets, current_preset, &inherited_by);
|
||||
const int count = int(inherited_by.size());
|
||||
wxString presets;
|
||||
for (const std::string& name : inherited_by)
|
||||
presets += "\n - " + from_u8(name);
|
||||
if (count > 0) {
|
||||
msg = _L("Presets inherited by other presets cannot be deleted!");
|
||||
msg += "\n";
|
||||
|
||||
Reference in new issue
Block a user