Start print after upload button (instead of checkbox)
This commit is contained in:
parent
8ef03718d0
commit
87c2e90a5d
5 changed files with 57 additions and 36 deletions
|
@ -63,21 +63,26 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he
|
|||
SetSizerAndFit(main_sizer);
|
||||
}
|
||||
|
||||
void MsgDialog::add_btn(wxWindowID btn_id, bool set_focus /*= false*/, const wxString& label/* = wxString()*/)
|
||||
wxButton* MsgDialog::add_button(wxWindowID btn_id, bool set_focus /*= false*/, const wxString& label/* = wxString()*/)
|
||||
{
|
||||
wxButton* btn = new wxButton(this, btn_id, label);
|
||||
if (set_focus)
|
||||
btn->SetFocus();
|
||||
btn_sizer->Add(btn, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, HORIZ_SPACING);
|
||||
btn->Bind(wxEVT_BUTTON, [this, btn_id](wxCommandEvent&) { this->EndModal(btn_id); });
|
||||
return btn;
|
||||
};
|
||||
|
||||
wxButton* MsgDialog::get_button(wxWindowID btn_id){
|
||||
return static_cast<wxButton*>(FindWindowById(btn_id, this));
|
||||
}
|
||||
|
||||
void MsgDialog::apply_style(long style)
|
||||
{
|
||||
if (style & wxOK) add_btn(wxID_OK, true);
|
||||
if (style & wxYES) add_btn(wxID_YES, true);
|
||||
if (style & wxNO) add_btn(wxID_NO);
|
||||
if (style & wxCANCEL) add_btn(wxID_CANCEL);
|
||||
if (style & wxOK) add_button(wxID_OK, true);
|
||||
if (style & wxYES) add_button(wxID_YES, true);
|
||||
if (style & wxNO) add_button(wxID_NO);
|
||||
if (style & wxCANCEL) add_button(wxID_CANCEL);
|
||||
|
||||
logo->SetBitmap( create_scaled_bitmap(style & wxICON_WARNING ? "exclamation" :
|
||||
style & wxICON_INFORMATION ? "info" :
|
||||
|
|
|
@ -42,8 +42,10 @@ protected:
|
|||
};
|
||||
|
||||
MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, long style = wxOK, wxBitmap bitmap = wxNullBitmap);
|
||||
|
||||
void add_btn(wxWindowID btn_id, bool set_focus = false, const wxString& label = wxString());
|
||||
// returns pointer to created button
|
||||
wxButton* add_button(wxWindowID btn_id, bool set_focus = false, const wxString& label = wxString());
|
||||
// returns pointer to found button or NULL
|
||||
wxButton* get_button(wxWindowID btn_id);
|
||||
void apply_style(long style);
|
||||
void finalize();
|
||||
|
||||
|
|
|
@ -39,9 +39,8 @@ static const char *CONFIG_KEY_PRINT = "printhost_print";
|
|||
static const char *CONFIG_KEY_GROUP = "printhost_group";
|
||||
|
||||
PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, bool can_start_print, const wxArrayString &groups)
|
||||
: MsgDialog(static_cast<wxWindow*>(wxGetApp().mainframe), _L("Send G-Code to printer host"), _L("Upload to Printer Host with the following filename:"), wxOK | wxCANCEL)
|
||||
: MsgDialog(static_cast<wxWindow*>(wxGetApp().mainframe), _L("Send G-Code to printer host"), _L("Upload to Printer Host with the following filename:"))
|
||||
, txt_filename(new wxTextCtrl(this, wxID_ANY))
|
||||
, box_print(can_start_print ? new wxCheckBox(this, wxID_ANY, _L("Start printing after upload")) : nullptr)
|
||||
, combo_groups(!groups.IsEmpty() ? new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, groups, wxCB_READONLY) : nullptr)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
|
@ -55,10 +54,6 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, bool can_start_pr
|
|||
content_sizer->Add(txt_filename, 0, wxEXPAND);
|
||||
content_sizer->Add(label_dir_hint);
|
||||
content_sizer->AddSpacer(VERT_SPACING);
|
||||
if (box_print != nullptr) {
|
||||
content_sizer->Add(box_print, 0, wxBOTTOM, 2*VERT_SPACING);
|
||||
box_print->SetValue(app_config->get("recent", CONFIG_KEY_PRINT) == "1");
|
||||
}
|
||||
|
||||
if (combo_groups != nullptr) {
|
||||
// Repetier specific: Show a selection of file groups.
|
||||
|
@ -84,18 +79,37 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, bool can_start_pr
|
|||
|
||||
wxString suffix = recent_path.substr(recent_path.find_last_of('.'));
|
||||
|
||||
static_cast<wxButton*>(FindWindowById(wxID_OK, this))->Bind(wxEVT_BUTTON, [this, suffix](wxCommandEvent&) {
|
||||
wxString path = txt_filename->GetValue();
|
||||
// .gcode suffix control
|
||||
if (!path.Lower().EndsWith(suffix.Lower()))
|
||||
{
|
||||
MessageDialog msg_wingow(this, wxString::Format(_L("Upload filename doesn't end with \"%s\". Do you wish to continue?"), suffix), wxString(SLIC3R_APP_NAME), wxYES | wxNO);
|
||||
if (msg_wingow.ShowModal() == wxID_NO)
|
||||
return;
|
||||
}
|
||||
EndDialog(wxID_OK);
|
||||
});
|
||||
if (can_start_print) {
|
||||
auto* btn_print = add_button(wxID_YES, false, _L("Upload and Print"));
|
||||
btn_print->Bind(wxEVT_BUTTON, [this, suffix](wxCommandEvent&) {
|
||||
wxString path = txt_filename->GetValue();
|
||||
// .gcode suffix control
|
||||
if (!path.Lower().EndsWith(suffix.Lower()))
|
||||
{
|
||||
MessageDialog msg_wingow(this, wxString::Format(_L("Upload filename doesn't end with \"%s\". Do you wish to continue?"), suffix), wxString(SLIC3R_APP_NAME), wxYES | wxNO);
|
||||
if (msg_wingow.ShowModal() == wxID_NO)
|
||||
return;
|
||||
}
|
||||
start_print_selected = true;
|
||||
EndDialog(wxID_OK);
|
||||
});
|
||||
}
|
||||
add_button(wxID_CANCEL);
|
||||
|
||||
if (auto* btn_ok = get_button(wxID_NO); btn_ok != NULL) {
|
||||
btn_ok->SetLabel(_L("Upload"));
|
||||
btn_ok->Bind(wxEVT_BUTTON, [this, suffix](wxCommandEvent&) {
|
||||
wxString path = txt_filename->GetValue();
|
||||
// .gcode suffix control
|
||||
if (!path.Lower().EndsWith(suffix.Lower()))
|
||||
{
|
||||
MessageDialog msg_wingow(this, wxString::Format(_L("Upload filename doesn't end with \"%s\". Do you wish to continue?"), suffix), wxString(SLIC3R_APP_NAME), wxYES | wxNO);
|
||||
if (msg_wingow.ShowModal() == wxID_NO)
|
||||
return;
|
||||
}
|
||||
EndDialog(wxID_OK);
|
||||
});
|
||||
}
|
||||
finalize();
|
||||
|
||||
#ifdef __linux__
|
||||
|
@ -125,7 +139,7 @@ fs::path PrintHostSendDialog::filename() const
|
|||
|
||||
bool PrintHostSendDialog::start_print() const
|
||||
{
|
||||
return box_print != nullptr ? box_print->GetValue() : false;
|
||||
return start_print_selected;
|
||||
}
|
||||
|
||||
std::string PrintHostSendDialog::group() const
|
||||
|
|
|
@ -36,8 +36,8 @@ public:
|
|||
virtual void EndModal(int ret) override;
|
||||
private:
|
||||
wxTextCtrl *txt_filename;
|
||||
wxCheckBox *box_print;
|
||||
wxComboBox *combo_groups;
|
||||
bool start_print_selected { false };
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ MsgUpdateSlic3r::MsgUpdateSlic3r(const Semver &ver_current, const Semver &ver_on
|
|||
content_sizer->Add(cbox);
|
||||
content_sizer->AddSpacer(VERT_SPACING);
|
||||
|
||||
Fit();
|
||||
finalize();
|
||||
}
|
||||
|
||||
MsgUpdateSlic3r::~MsgUpdateSlic3r() {}
|
||||
|
@ -133,12 +133,12 @@ MsgUpdateConfig::MsgUpdateConfig(const std::vector<Update> &updates, bool force_
|
|||
content_sizer->Add(versions);
|
||||
content_sizer->AddSpacer(2*VERT_SPACING);
|
||||
|
||||
add_btn(wxID_OK, true, force_before_wizard ? _L("Install") : "OK");
|
||||
add_button(wxID_OK, true, force_before_wizard ? _L("Install") : "OK");
|
||||
if (force_before_wizard) {
|
||||
add_btn(wxID_CLOSE, false, _L("Don't install"));
|
||||
static_cast<wxButton*>(FindWindowById(wxID_CLOSE, this))->Bind(wxEVT_BUTTON, [this](const wxCommandEvent&) { this->EndModal(wxID_CLOSE); });
|
||||
auto* btn = add_button(wxID_CLOSE, false, _L("Don't install"));
|
||||
btn->Bind(wxEVT_BUTTON, [this](const wxCommandEvent&) { this->EndModal(wxID_CLOSE); });
|
||||
}
|
||||
add_btn(wxID_CANCEL);
|
||||
add_button(wxID_CANCEL);
|
||||
|
||||
finalize();
|
||||
}
|
||||
|
@ -190,9 +190,9 @@ MsgUpdateForced::MsgUpdateForced(const std::vector<Update>& updates) :
|
|||
content_sizer->Add(versions);
|
||||
content_sizer->AddSpacer(2 * VERT_SPACING);
|
||||
|
||||
add_btn(wxID_EXIT, false, wxString::Format(_L("Exit %s"), SLIC3R_APP_NAME));
|
||||
add_button(wxID_EXIT, false, wxString::Format(_L("Exit %s"), SLIC3R_APP_NAME));
|
||||
for (auto ID : { wxID_EXIT, wxID_OK })
|
||||
static_cast<wxButton*>(FindWindowById(ID, this))->Bind(wxEVT_BUTTON, [this](const wxCommandEvent& evt) { this->EndModal(evt.GetId()); });
|
||||
get_button(ID)->Bind(wxEVT_BUTTON, [this](const wxCommandEvent& evt) { this->EndModal(evt.GetId()); });
|
||||
|
||||
finalize();
|
||||
}
|
||||
|
@ -236,11 +236,11 @@ MsgDataIncompatible::MsgDataIncompatible(const std::unordered_map<std::string, w
|
|||
content_sizer->Add(versions);
|
||||
content_sizer->AddSpacer(2*VERT_SPACING);
|
||||
|
||||
add_btn(wxID_REPLACE, true, _L("Re-configure"));
|
||||
add_btn(wxID_EXIT, false, wxString::Format(_L("Exit %s"), SLIC3R_APP_NAME));
|
||||
add_button(wxID_REPLACE, true, _L("Re-configure"));
|
||||
add_button(wxID_EXIT, false, wxString::Format(_L("Exit %s"), SLIC3R_APP_NAME));
|
||||
|
||||
for (auto ID : {wxID_EXIT, wxID_REPLACE})
|
||||
static_cast<wxButton*>(FindWindowById(ID, this))->Bind(wxEVT_BUTTON, [this](const wxCommandEvent& evt) { this->EndModal(evt.GetId()); });
|
||||
get_button(ID)->Bind(wxEVT_BUTTON, [this](const wxCommandEvent& evt) { this->EndModal(evt.GetId()); });
|
||||
|
||||
finalize();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue