UnsavedChangesDialog
* Fixed a crash on preset changing and press Cancel button in SavePresetDialog * Added Cancel button for MessageDialog after check "Remember my choice" SplashScreen * Set Version string in respect to the height of a Title string
This commit is contained in:
parent
1b2dcabf94
commit
772b0b760e
@ -127,7 +127,7 @@ public:
|
||||
|
||||
memDC.SetFont(m_action_font);
|
||||
memDC.SetTextForeground(wxColour(237, 107, 33));
|
||||
memDC.DrawText(text, int(m_scale * 55), int(m_scale * 265));
|
||||
memDC.DrawText(text, int(m_scale * 60), int(m_scale * 275));
|
||||
|
||||
memDC.SelectObject(wxNullBitmap);
|
||||
set_bitmap(bitmap);
|
||||
@ -185,7 +185,8 @@ public:
|
||||
|
||||
wxCoord margin = int(m_scale * 20);
|
||||
|
||||
const wxRect banner_rect(wxPoint(0, logo_size + margin * 2), wxPoint(width, bmp.GetHeight()));
|
||||
wxRect banner_rect(wxPoint(0, logo_size), wxPoint(width, bmp.GetHeight()));
|
||||
banner_rect.Deflate(margin, 2 * margin);
|
||||
|
||||
// use a memory DC to draw directly onto the bitmap
|
||||
wxMemoryDC memDc(bmp);
|
||||
@ -197,13 +198,17 @@ public:
|
||||
memDc.SetTextForeground(wxColour(255, 255, 255));
|
||||
|
||||
memDc.SetFont(m_constant_text.title_font);
|
||||
memDc.DrawLabel(m_constant_text.title, banner_rect.Deflate(margin, 0), wxALIGN_TOP | wxALIGN_LEFT);
|
||||
memDc.DrawLabel(m_constant_text.title, banner_rect, wxALIGN_TOP | wxALIGN_LEFT);
|
||||
|
||||
int title_height = memDc.GetTextExtent(m_constant_text.title).GetY();
|
||||
banner_rect.SetTop(banner_rect.GetTop() + title_height);
|
||||
banner_rect.SetHeight(banner_rect.GetHeight() - title_height);
|
||||
|
||||
memDc.SetFont(m_constant_text.version_font);
|
||||
memDc.DrawLabel(m_constant_text.version, banner_rect.Deflate(margin, 3 * margin), wxALIGN_TOP | wxALIGN_LEFT);
|
||||
memDc.DrawLabel(m_constant_text.version, banner_rect, wxALIGN_TOP | wxALIGN_LEFT);
|
||||
|
||||
memDc.SetFont(m_constant_text.credits_font);
|
||||
memDc.DrawLabel(m_constant_text.credits, banner_rect.Deflate(margin, 2 * margin), wxALIGN_BOTTOM | wxALIGN_LEFT);
|
||||
memDc.DrawLabel(m_constant_text.credits, banner_rect, wxALIGN_BOTTOM | wxALIGN_LEFT);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -211,7 +216,7 @@ private:
|
||||
wxFont m_action_font;
|
||||
float m_scale {1.0};
|
||||
|
||||
struct CONSTANT_TEXT
|
||||
struct ConstantText
|
||||
{
|
||||
wxString title;
|
||||
wxString version;
|
||||
|
@ -629,8 +629,8 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_
|
||||
|
||||
(*btn)->Bind(wxEVT_BUTTON, [this, close_act, dependent_presets](wxEvent&) {
|
||||
update_config(close_act);
|
||||
if (close_act == Action::Save)
|
||||
save(dependent_presets);
|
||||
if (close_act == Action::Save && !save(dependent_presets))
|
||||
return;
|
||||
close(close_act);
|
||||
});
|
||||
if (process_enable)
|
||||
@ -657,7 +657,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_
|
||||
|
||||
m_remember_choice = new wxCheckBox(this, wxID_ANY, _L("Remember my choice"));
|
||||
m_remember_choice->SetValue(wxGetApp().app_config->get(m_app_config_key) != "none");
|
||||
m_remember_choice->Bind(wxEVT_CHECKBOX, [type](wxCommandEvent& evt)
|
||||
m_remember_choice->Bind(wxEVT_CHECKBOX, [type, this](wxCommandEvent& evt)
|
||||
{
|
||||
if (!evt.IsChecked())
|
||||
return;
|
||||
@ -669,7 +669,9 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_
|
||||
"Visit \"Preferences\" and check \"%3%\"\n"
|
||||
"to be asked about unsaved changes again.")) % SLIC3R_APP_NAME % act % preferences_item).str();
|
||||
|
||||
wxMessageBox(from_u8(msg), _L("Note"),wxOK | wxICON_INFORMATION);
|
||||
wxMessageDialog dialog(nullptr, from_u8(msg), _L("Note"), wxOK | wxCANCEL | wxICON_INFORMATION);
|
||||
if (dialog.ShowModal() == wxID_CANCEL)
|
||||
m_remember_choice->SetValue(false);
|
||||
});
|
||||
|
||||
wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
|
||||
@ -773,7 +775,7 @@ void UnsavedChangesDialog::close(Action action)
|
||||
this->EndModal(wxID_CLOSE);
|
||||
}
|
||||
|
||||
void UnsavedChangesDialog::save(PresetCollection* dependent_presets)
|
||||
bool UnsavedChangesDialog::save(PresetCollection* dependent_presets)
|
||||
{
|
||||
names_and_types.clear();
|
||||
|
||||
@ -787,7 +789,7 @@ void UnsavedChangesDialog::save(PresetCollection* dependent_presets)
|
||||
SavePresetDialog save_dlg(preset.type);
|
||||
if (save_dlg.ShowModal() != wxID_OK) {
|
||||
m_exit_action = Action::Discard;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
name = save_dlg.get_name();
|
||||
}
|
||||
@ -815,7 +817,7 @@ void UnsavedChangesDialog::save(PresetCollection* dependent_presets)
|
||||
SavePresetDialog save_dlg(types_for_save);
|
||||
if (save_dlg.ShowModal() != wxID_OK) {
|
||||
m_exit_action = Action::Discard;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (std::pair<std::string, Preset::Type>& nt : names_and_types) {
|
||||
@ -825,6 +827,7 @@ void UnsavedChangesDialog::save(PresetCollection* dependent_presets)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
@ -253,7 +253,7 @@ public:
|
||||
void show_info_line(Action action, std::string preset_name = "");
|
||||
void update_config(Action action);
|
||||
void close(Action action);
|
||||
void save(PresetCollection* dependent_presets);
|
||||
bool save(PresetCollection* dependent_presets);
|
||||
|
||||
bool save_preset() const { return m_exit_action == Action::Save; }
|
||||
bool transfer_changes() const { return m_exit_action == Action::Transfer; }
|
||||
|
Loading…
Reference in New Issue
Block a user