UnsavedChangesDialog improvements:

* Changed some labels on buttons. The Dialog name shows a purpose now
 * SaveDialog is called, when UnsavedChangesDialog is shown.
 * Added prototype for the "exit" icon

+ Fixed layout for the "Machine limits" page
This commit is contained in:
YuSanka 2020-10-03 03:15:54 +02:00
parent 8df01818dd
commit 6255792181
6 changed files with 102 additions and 59 deletions

20
resources/icons/exit.svg Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="520.349px" height="520.349px" viewBox="0 0 520.349 520.349" style="enable-background:new 0 0 520.349 520.349;"
xml:space="preserve">
<g>
<path fill="#ED6B21" d="M445.223,0H142.589c-6.683,0-12.105,5.423-12.105,12.105v180.979h16.65c-5.006-6.392-7.725-14.224-7.725-22.467
c-0.006-9.764,3.8-18.943,10.708-25.845c1.421-1.421,2.973-2.687,4.583-3.845V24.211h278.417v8.697l-127.104,92.285v395.155
l127.796-92.787c1.626,4.77,6.095,8.228,11.414,8.228c6.685,0,12.105-5.426,12.105-12.105V12.105
C457.328,5.417,451.907,0,445.223,0z M354.031,331.973c-5.71,0-10.468-7.046-11.691-16.485h-13.63v-10.592h13.819
c1.448-8.86,6.017-15.38,11.49-15.38c6.638,0,12.011,9.498,12.011,21.231C366.042,322.468,360.663,331.973,354.031,331.973z
M150.122,314.471c1.424,1.412,2.967,2.678,4.572,3.824v105.389c0,6.68-5.426,12.105-12.105,12.105
c-6.683,0-12.105-5.426-12.105-12.105V266.139h16.65C135.948,280.466,136.935,301.271,150.122,314.471z M236.706,218.385
c4.817,4.817,4.817,12.608,0,17.425l-58.995,59.001c-2.403,2.394-5.556,3.605-8.709,3.611c-3.153-0.006-6.307-1.206-8.71-3.611
c-4.811-4.817-4.805-12.613,0-17.419l37.974-37.977H75.336c-6.803,0-12.315-5.512-12.315-12.315
c0-6.803,5.506-12.318,12.321-12.318h122.917l-37.968-37.974c-4.805-4.805-4.811-12.608,0-17.413
c4.812-4.812,12.614-4.812,17.425,0L236.706,218.385z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -1526,41 +1526,8 @@ bool GUI_App::check_unsaved_changes(const wxString &header)
if (dlg.save_preset()) // save selected changes
{
struct NameType
{
std::string name;
Preset::Type type {Preset::TYPE_INVALID};
};
std::vector<NameType> names_and_types;
// for system/default/external presets we should take an edited name
std::vector<Preset::Type> types;
for (Tab* tab : tabs_list)
if (tab->supports_printer_technology(printer_technology) && tab->current_preset_is_dirty())
{
const Preset& preset = tab->get_presets()->get_edited_preset();
if (preset.is_system || preset.is_default || preset.is_external)
types.emplace_back(preset.type);
names_and_types.emplace_back(NameType{ preset.name, preset.type });
}
if (!types.empty()) {
SavePresetDialog save_dlg(types);
if (save_dlg.ShowModal() != wxID_OK)
return false;
for (NameType& nt : names_and_types) {
const std::string name = save_dlg.get_name(nt.type);
if (!name.empty())
nt.name = name;
}
}
for (const NameType& nt : names_and_types)
preset_bundle->save_changes_for_preset(nt.name, nt.type, dlg.get_unselected_options(nt.type));
for (const std::pair<std::string, Preset::Type>& nt : dlg.get_names_and_types())
preset_bundle->save_changes_for_preset(nt.first, nt.second, dlg.get_unselected_options(nt.second));
// if we saved changes to the new presets, we should to
// synchronize config.ini with the current selections.

View File

@ -361,7 +361,7 @@ void MainFrame::update_layout()
fromDlg,
toDlg
};
State update_scaling_state = m_layout == ESettingsLayout::Unknown ? State::noUpdate : // don't scale settings dialog from the application start
State update_scaling_state = //m_layout == ESettingsLayout::Unknown ? State::noUpdate : // don't scale settings dialog from the application start
m_layout == ESettingsLayout::Dlg ? State::fromDlg :
layout == ESettingsLayout::Dlg ? State::toDlg : State::noUpdate;
#endif //__WXMSW__

View File

@ -3336,17 +3336,8 @@ bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr
if (dlg.save_preset()) // save selected changes
{
std::vector<std::string> unselected_options = dlg.get_unselected_options(presets->type());
const Preset& preset = presets->get_edited_preset();
std::string name = preset.name;
// for system/default/external presets we should take an edited name
if (preset.is_system || preset.is_default || preset.is_external) {
SavePresetDialog save_dlg(preset.type);
if (save_dlg.ShowModal() != wxID_OK)
return false;
name = save_dlg.get_name();
}
const std::vector<std::string>& unselected_options = dlg.get_unselected_options(presets->type());
const std::string& name = dlg.get_preset_name();
if (m_type == presets->type()) // save changes for the current preset from this tab
{
@ -3358,9 +3349,9 @@ bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr
{
m_preset_bundle->save_changes_for_preset(name, presets->type(), unselected_options);
/* If filament preset is saved for multi-material printer preset,
* there are cases when filament comboboxs are updated for old (non-modified) colors,
* but in full_config a filament_colors option aren't.*/
// If filament preset is saved for multi-material printer preset,
// there are cases when filament comboboxs are updated for old (non-modified) colors,
// but in full_config a filament_colors option aren't.
if (presets->type() == Preset::TYPE_FILAMENT && wxGetApp().extruders_edited_cnt() > 1)
wxGetApp().plater()->force_filament_colors_update();
}
@ -3878,8 +3869,8 @@ void TabPrinter::update_machine_limits_description(const MachineLimitsUsage usag
text = _L("Machine limits will be emitted to G-code and used to estimate print time.");
break;
case MachineLimitsUsage::TimeEstimateOnly:
text = _L("Machine limits will NOT be emitted to G-code, however they will be used to estimate print time, \
which may herefore not be accurate as the printer may apply a different set of machine limits.");
text = _L("Machine limits will NOT be emitted to G-code, however they will be used to estimate print time, "
"which may herefore not be accurate as the printer may apply a different set of machine limits.");
break;
case MachineLimitsUsage::Ignore:
text = _L("Machine limits are not set, therefore the print time estimate may not be accurate.");
@ -3887,6 +3878,8 @@ void TabPrinter::update_machine_limits_description(const MachineLimitsUsage usag
default: assert(false);
}
m_machine_limits_description_line->SetText(text);
Layout();
}
void Tab::compatible_widget_reload(PresetDependencies &deps)

View File

@ -13,6 +13,7 @@
#include "Tab.hpp"
#include "ExtraRenderers.hpp"
#include "wxExtensions.hpp"
#include "PresetComboBoxes.hpp"
//#define FTS_FUZZY_MATCH_IMPLEMENTATION
//#include "fts_fuzzy_match.h"
@ -515,13 +516,13 @@ void UnsavedChangesModel::Rescale()
//------------------------------------------
UnsavedChangesDialog::UnsavedChangesDialog(const wxString& header)
: DPIDialog(nullptr, wxID_ANY, _L("Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
: DPIDialog(nullptr, wxID_ANY, _L("Close Aplication: Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
build(Preset::TYPE_INVALID, nullptr, "", header);
}
UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type, PresetCollection* dependent_presets, const std::string& new_selected_preset)
: DPIDialog(nullptr, wxID_ANY, _L("Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
: DPIDialog(nullptr, wxID_ANY, _L("Select New Preset: Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
build(type, dependent_presets, new_selected_preset);
}
@ -577,12 +578,12 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_
// Add Buttons
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxCANCEL);
auto add_btn = [this, buttons](ScalableButton** btn, int& btn_id, const std::string& icon_name, Action close_act, int idx, bool process_enable = true)
auto add_btn = [this, buttons, dependent_presets](ScalableButton** btn, int& btn_id, const std::string& icon_name, Action close_act, int idx, bool process_enable = true)
{
*btn = new ScalableButton(this, btn_id = NewControlId(), icon_name, "", wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, true);
buttons->Insert(idx, *btn, 0, wxLEFT, 5);
(*btn)->Bind(wxEVT_BUTTON, [this, close_act](wxEvent&) { close(close_act); });
(*btn)->Bind(wxEVT_BUTTON, [this, close_act, dependent_presets](wxEvent&) { close_act == Action::Save ? save_and_close(dependent_presets) : close(close_act); });
if (process_enable)
(*btn)->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(!m_empty_selection); });
(*btn)->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& e) { show_info_line(Action::Undef); e.Skip(); });
@ -596,7 +597,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_
dependent_presets->get_edited_preset().printer_technology() == dependent_presets->find_preset(new_selected_preset)->printer_technology() :
printers.get_edited_preset().printer_technology() == printers.find_preset(new_selected_preset)->printer_technology() ) )
add_btn(&m_move_btn, m_move_btn_id, "paste_menu", Action::Move, btn_idx++);
add_btn(&m_continue_btn, m_continue_btn_id, "cross", Action::Continue, btn_idx, false);
add_btn(&m_continue_btn, m_continue_btn_id, dependent_presets ? "cross" : "exit", Action::Continue, btn_idx, false);
m_info_line = new wxStaticText(this, wxID_ANY, "");
m_info_line->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold());
@ -667,7 +668,7 @@ void UnsavedChangesDialog::show_info_line(Action action, std::string preset_name
if (action == Action::Undef)
text = _L("Some fields are too long to fit. Right click on it to show full text.");
else if (action == Action::Continue)
text = _L("All changed options will be reverted.");
text = _L("All modified options will be reverted.");
else {
std::string act_string = action == Action::Save ? _u8L("save") : _u8L("move");
if (preset_name.empty())
@ -692,6 +693,58 @@ void UnsavedChangesDialog::close(Action action)
this->EndModal(wxID_CLOSE);
}
void UnsavedChangesDialog::save_and_close(PresetCollection* dependent_presets)
{
names_and_types.clear();
// save one preset
if (dependent_presets) {
const Preset& preset = dependent_presets->get_edited_preset();
std::string name = preset.name;
// for system/default/external presets we should take an edited name
if (preset.is_system || preset.is_default || preset.is_external) {
SavePresetDialog save_dlg(preset.type);
if (save_dlg.ShowModal() != wxID_OK)
return;
name = save_dlg.get_name();
}
names_and_types.emplace_back(make_pair(name, preset.type));
}
// save all presets
else
{
std::vector<Preset::Type> types_for_save;
PrinterTechnology printer_technology = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
for (Tab* tab : wxGetApp().tabs_list)
if (tab->supports_printer_technology(printer_technology) && tab->current_preset_is_dirty()) {
const Preset& preset = tab->get_presets()->get_edited_preset();
if (preset.is_system || preset.is_default || preset.is_external)
types_for_save.emplace_back(preset.type);
names_and_types.emplace_back(make_pair(preset.name, preset.type));
}
if (!types_for_save.empty()) {
SavePresetDialog save_dlg(types_for_save);
if (save_dlg.ShowModal() != wxID_OK)
return;
for (std::pair<std::string, Preset::Type>& nt : names_and_types) {
const std::string& name = save_dlg.get_name(nt.second);
if (!name.empty())
nt.first = name;
}
}
}
close(Action::Save);
}
template<class T>
wxString get_string_from_enum(const std::string& opt_key, const DynamicPrintConfig& config, bool is_infill = false)
{
@ -866,11 +919,11 @@ void UnsavedChangesDialog::update(Preset::Type type, PresetCollection* dependent
}
m_continue_btn ->Bind(wxEVT_ENTER_WINDOW, [this] (wxMouseEvent& e) { show_info_line(Action::Continue); e.Skip(); });
m_continue_btn->SetLabel(_L("Continue without changes"));
if (type == Preset::TYPE_INVALID) {
m_action_line ->SetLabel(header + "\n" + _L("Next presets have the following unsaved changes:"));
m_save_btn ->SetLabel(_L("Save selected"));
m_continue_btn ->SetLabel(_L("Close aplication without changes"));
}
else {
wxString action_msg;
@ -891,6 +944,7 @@ void UnsavedChangesDialog::update(Preset::Type type, PresetCollection* dependent
}
m_action_line->SetLabel(from_u8((boost::format(_utf8(L("Preset \"%1%\" %2%"))) % _utf8(presets->get_edited_preset().name) % action_msg).str()));
m_save_btn->SetLabel(from_u8((boost::format(_u8L("Save selected to preset: %1%")) % ("\"" + presets->get_selected_preset().name + "\"")).str()));
m_continue_btn->SetLabel(_L("Select new preset without changes"));
}
update_tree(type, presets);

View File

@ -227,6 +227,9 @@ class UnsavedChangesDialog : public DPIDialog
// tree items related to the options
std::map<wxDataViewItem, ItemData> m_items_map;
// preset names which are modified in SavePresetDialog and related types
std::vector<std::pair<std::string, Preset::Type>> names_and_types;
public:
UnsavedChangesDialog(const wxString& header);
UnsavedChangesDialog(Preset::Type type, PresetCollection* dependent_presets, const std::string& new_selected_preset);
@ -241,11 +244,17 @@ public:
void context_menu(wxDataViewEvent &event);
void show_info_line(Action action, std::string preset_name = "");
void close(Action action);
void save_and_close(PresetCollection* dependent_presets);
bool save_preset() const { return m_exit_action == Action::Save; }
bool move_preset() const { return m_exit_action == Action::Move; }
bool just_continue() const { return m_exit_action == Action::Continue; }
// get full bundle of preset names and types for saving
const std::vector<std::pair<std::string, Preset::Type>>& get_names_and_types() { return names_and_types; }
// short version of the previous function, for the case, when just one preset is modified
std::string get_preset_name() { return names_and_types[0].first; }
std::vector<std::string> get_unselected_options(Preset::Type type);
std::vector<std::string> get_selected_options();