diff --git a/src/GUI/MainFrame.cpp b/src/GUI/MainFrame.cpp index fe7fba502..0c95505c9 100644 --- a/src/GUI/MainFrame.cpp +++ b/src/GUI/MainFrame.cpp @@ -51,17 +51,14 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si this->Show(); this->Layout(); } -/* - # declare events - EVT_CLOSE($self, sub { - my (undef, $event) = @_; - - if ($event->CanVeto) { - if (!$self->{plater}->prompt_unsaved_changes) { - $event->Veto; + // Set up event handlers. + this->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& e) { + if (e.CanVeto()) { + if (!this->plater->prompt_unsaved_changes()) { + e.Veto(); return; } - + /* if ($self->{controller} && $self->{controller}->printing) { my $confirm = Wx::MessageDialog->new($self, "You are currently printing. Do you want to stop printing and continue anyway?", 'Unfinished Print', wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT); @@ -70,10 +67,21 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si return; } } + + */ + // save window size + gui_config->save_window_pos(this, "main_frame"); + + // Propagate event + e.Skip(); } + }); +/* + # declare events + EVT_CLOSE($self, sub { + my (undef, $event) = @_; + - # save window size - wxTheApp->save_window_pos($self, "main_frame"); # propagate event $event->Skip; diff --git a/src/GUI/Plater.hpp b/src/GUI/Plater.hpp index 5068e788e..ecbec1048 100644 --- a/src/GUI/Plater.hpp +++ b/src/GUI/Plater.hpp @@ -35,6 +35,8 @@ public: Plater(wxWindow* parent, const wxString& title, std::shared_ptr _settings); void add(); + /// Ask if there are any unsaved changes. + bool prompt_unsaved_changes() { return true; } private: std::shared_ptr print {std::make_shared(Slic3r::Print())}; std::shared_ptr model {std::make_shared(Slic3r::Model())};