Browse Source

Separate preset save and save-as. Resolves #2731.

This takes advantage of the fact that the `save_preset` function
accepts a name, which hasn't historically been used by the save button.

supermerill:
. redesigned the svg a bit to have a more recognizable "save" icon.
. add set this icon to save project as
. disable "save" when the preset is already saved or isn't modifiable.
. fix a bug with delete icon doesn't enable

supermerill/SuperSlicer#3806
supermerill/SuperSlicer#2731.
Adam Elnagger 1 year ago
parent
commit
797c469b6c
4 changed files with 53 additions and 9 deletions
  1. 34 0
      resources/icons/save_as.svg
  2. 1 1
      src/slic3r/GUI/MainFrame.cpp
  3. 17 8
      src/slic3r/GUI/Tab.cpp
  4. 1 0
      src/slic3r/GUI/Tab.hpp

+ 34 - 0
resources/icons/save_as.svg

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
+	y="0px" viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
+<g id="save_as">
+	<g>
+		<path fill="#808080" d="M12,2c1.44,0,2,0.56,2,2v10L2,14L2,2H12 M12,1H2C1.45,1,1,1.45,1,2V14c0,0.55,0.45,1,1,1h12
+			c0.55,0,1-0.45,1-1l0-10C15,2,14,1,12,1L12,1z"/>
+	</g>
+	<g>
+		<line fill="none" stroke="#808080" stroke-linecap="round" stroke-miterlimit="10" x1="3" y1="8" x2="10" y2="8"/>
+	</g>
+	<g>
+		<line fill="none" stroke="#808080" stroke-linecap="round" stroke-miterlimit="10" x1="3" y1="10" x2="10" y2="10"/>
+	</g>
+	<g>
+		<line fill="none" stroke="#808080" stroke-linecap="round" stroke-miterlimit="10" x1="3" y1="12" x2="7" y2="12"/>
+	</g>
+	<g>
+		<path fill="#2172eb" d="M11,1H5C4.45,1,4,1.45,4,2V5c0,0.55,0.45,1,1,1H11c0.55,0,1-0.45,1-1V2C12,1.45,11.55,1,11,1z M6,4.5
+			C6,4.78,5.78,5,5.5,5S5,4.78,5,4.5v-2C5,2.22,5.22,2,5.5,2S6,2.22,6,2.5V4.5z"/>
+	</g>
+	<g>
+		<line fill="none" stroke="#808080" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" x1="6" y1="10" x2="14" y2="10"/>
+		<line fill="none" stroke="#808080" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" x1="10" y1="6" x2="10" y2="14"/>
+
+	</g>
+	<g>
+		<line fill="none" stroke="#2172eb" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" x1="6" y1="10" x2="14" y2="10"/>
+
+		<line fill="none" stroke="#2172eb" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" x1="10" y1="6" x2="10" y2="14"/>
+
+	</g>
+</g>
+</svg>

+ 1 - 1
src/slic3r/GUI/MainFrame.cpp

@@ -1682,7 +1682,7 @@ void MainFrame::init_menubar_as_editor()
 #else
         append_menu_item(fileMenu, wxID_ANY, _L("Save Project &as") + dots + "\tCtrl+Alt+S", _L("Save current project file as"),
 #endif // __APPLE__
-            [this](wxCommandEvent&) { save_project_as(); }, "save", nullptr,
+            [this](wxCommandEvent&) { save_project_as(); }, "save_as", nullptr,
             [this](){return m_plater != nullptr && can_save_as(); }, this);
 
         fileMenu->AppendSeparator();

+ 17 - 8
src/slic3r/GUI/Tab.cpp

@@ -215,6 +215,7 @@ void Tab::create_preset_tab()
 
     add_scaled_button(panel, &m_btn_compare_preset, "compare");
     add_scaled_button(panel, &m_btn_save_preset, "save");
+    add_scaled_button(panel, &m_btn_save_preset_as, "save_as");
     add_scaled_button(panel, &m_btn_delete_preset, "cross");
     if (m_type == Preset::Type::TYPE_PRINTER)
         add_scaled_button(panel, &m_btn_edit_ph_printer, "cog");
@@ -228,8 +229,10 @@ void Tab::create_preset_tab()
     m_btn_compare_preset->SetToolTip(_L("Compare this preset with some another"));
     // TRN "Save current Settings"
     m_btn_save_preset->SetToolTip(from_u8((boost::format(_utf8(L("Save current %s"))) % m_title).str()));
+    m_btn_save_preset_as->SetToolTip(from_u8((boost::format(_utf8(L("Save current %s as new preset"))) % m_title).str()));
+
     m_btn_delete_preset->SetToolTip(_(L("Delete this preset")));
-    m_btn_delete_preset->Hide();
+    m_btn_delete_preset->Enable(false);
 
     add_scaled_button(panel, &m_question_btn, "question");
     m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information \n"
@@ -280,6 +283,8 @@ void Tab::create_preset_tab()
     m_hsizer->AddSpacer(int(4*scale_factor));
     m_hsizer->Add(m_btn_save_preset, 0, wxALIGN_CENTER_VERTICAL);
     m_hsizer->AddSpacer(int(4 * scale_factor));
+    m_hsizer->Add(m_btn_save_preset_as, 0, wxALIGN_CENTER_VERTICAL);
+    m_hsizer->AddSpacer(int(4 * scale_factor));
     m_hsizer->Add(m_btn_delete_preset, 0, wxALIGN_CENTER_VERTICAL);
     if (m_btn_edit_ph_printer) {
         m_hsizer->AddSpacer(int(4 * scale_factor));
@@ -370,7 +375,10 @@ void Tab::create_preset_tab()
     m_hsizer->Add(m_page_view, 1, wxEXPAND | wxLEFT, 5);
 
     m_btn_compare_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { compare_preset(); }));
-    m_btn_save_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { save_preset(); }));
+    m_btn_save_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) {
+                                save_preset(this->get_presets()->get_selected_preset_name());
+                            }));
+    m_btn_save_preset_as->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { save_preset(); }));
     m_btn_delete_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { delete_preset(); }));
     m_btn_hide_incompatible_presets->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) {
         toggle_show_hide_incompatible();
@@ -957,6 +965,7 @@ void Tab::update_changed_tree_ui()
         cur_item = next_item;
     }
     update_undo_buttons();
+    update_btns_enabling();
 }
 
 void Tab::update_undo_buttons()
@@ -3743,10 +3752,11 @@ void Tab::rebuild_page_tree()
 
 void Tab::update_btns_enabling()
 {
-    // we can delete any preset from the physical printer
-    // and any user preset
-        const Preset& preset = m_presets->get_edited_preset();
-    m_btn_delete_preset->Show((m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection())
+    const Preset &preset = m_presets->get_edited_preset();
+    // we can save any preset taht is not default/system and is modified.
+    m_btn_save_preset->Enable(!preset.is_default && !preset.is_system && preset.is_dirty && !preset.name.empty());
+    // we can delete any preset from the physical printer and any user preset
+    m_btn_delete_preset->Enable((m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection())
                               || (!preset.is_default && !preset.is_system));
 
     if (m_btn_edit_ph_printer)
@@ -4156,8 +4166,7 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach)
     // Update the selection boxes at the plater.
     on_presets_changed();
     // If current profile is saved, "delete preset" button have to be enabled
-    m_btn_delete_preset->Show();
-    m_btn_delete_preset->GetParent()->Layout();
+    update_btns_enabling();
 
     if (m_type == Preset::TYPE_PRINTER)
         static_cast<TabPrinter*>(this)->m_initial_extruders_count = static_cast<TabPrinter*>(this)->m_extruders_count;

+ 1 - 0
src/slic3r/GUI/Tab.hpp

@@ -172,6 +172,7 @@ protected:
 	ScalableButton*		m_search_btn;
 	ScalableButton*		m_btn_compare_preset;
 	ScalableButton*		m_btn_save_preset;
+	ScalableButton*		m_btn_save_preset_as;
 	ScalableButton*		m_btn_delete_preset;
 	ScalableButton*		m_btn_edit_ph_printer {nullptr};
 	ScalableButton*		m_btn_hide_incompatible_presets;