ConfigWizard: Bugfixes
This commit is contained in:
parent
b0f54e5709
commit
7d969a6f36
6 changed files with 96 additions and 56 deletions
|
@ -22,6 +22,7 @@
|
|||
#include "libslic3r/Utils.hpp"
|
||||
#include "PresetBundle.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "slic3r/Utils/PresetUpdater.hpp"
|
||||
|
||||
|
||||
|
@ -152,9 +153,11 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
|
|||
}
|
||||
|
||||
auto *title_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto *title_widget = new wxStaticText(this, wxID_ANY, title);
|
||||
title_widget->SetFont(font_title);
|
||||
title_sizer->Add(title_widget);
|
||||
if (! title.IsEmpty()) {
|
||||
auto *title_widget = new wxStaticText(this, wxID_ANY, title);
|
||||
title_widget->SetFont(font_title);
|
||||
title_sizer->Add(title_widget);
|
||||
}
|
||||
title_sizer->AddStretchSpacer();
|
||||
|
||||
if (titles.size() > 1) {
|
||||
|
@ -171,17 +174,6 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
|
|||
sizer->Add(title_sizer, 0, wxEXPAND | wxBOTTOM, BTN_SPACING);
|
||||
sizer->Add(printer_grid);
|
||||
|
||||
// auto *all_none_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
// auto *sel_all = new wxButton(this, wxID_ANY, _(L("Select all")));
|
||||
// auto *sel_none = new wxButton(this, wxID_ANY, _(L("Select none")));
|
||||
// sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(true); });
|
||||
// sel_none->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(false); });
|
||||
// all_none_sizer->AddStretchSpacer();
|
||||
// all_none_sizer->Add(sel_all);
|
||||
// all_none_sizer->Add(sel_none);
|
||||
// sizer->AddStretchSpacer();
|
||||
// sizer->Add(all_none_sizer, 0, wxEXPAND);
|
||||
|
||||
SetSizer(sizer);
|
||||
}
|
||||
|
||||
|
@ -268,12 +260,6 @@ void ConfigWizardPage::append_spacer(int space)
|
|||
content->AddSpacer(space);
|
||||
}
|
||||
|
||||
bool ConfigWizardPage::Show(bool show)
|
||||
{
|
||||
if (extra_buttons() != nullptr) { extra_buttons()->Show(show); }
|
||||
return wxPanel::Show(show);
|
||||
}
|
||||
|
||||
|
||||
// Wizard pages
|
||||
|
||||
|
@ -347,13 +333,25 @@ void PagePrinters::select_all(bool select)
|
|||
}
|
||||
|
||||
|
||||
const char *PageCustom::default_profile_name = "My Settings";
|
||||
|
||||
PageCustom::PageCustom(ConfigWizard *parent)
|
||||
: ConfigWizardPage(parent, _(L("Custom Printer Setup")), _(L("Custom Printer")))
|
||||
{
|
||||
cb_custom = new wxCheckBox(this, wxID_ANY, _(L("Define a custom printer profile")));
|
||||
tc_profile_name = new wxTextCtrl(this, wxID_ANY, "My Settings");
|
||||
tc_profile_name = new wxTextCtrl(this, wxID_ANY, default_profile_name);
|
||||
auto *label = new wxStaticText(this, wxID_ANY, _(L("Custom profile name:")));
|
||||
|
||||
tc_profile_name->Bind(wxEVT_KILL_FOCUS, [this](wxFocusEvent &evt) {
|
||||
if (tc_profile_name->GetValue().IsEmpty()) {
|
||||
if (profile_name_prev.IsEmpty()) { tc_profile_name->SetValue(default_profile_name); }
|
||||
else { tc_profile_name->SetValue(profile_name_prev); }
|
||||
} else {
|
||||
profile_name_prev = tc_profile_name->GetValue();
|
||||
}
|
||||
evt.Skip();
|
||||
});
|
||||
|
||||
cb_custom->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) {
|
||||
wizard_p()->on_custom_setup(custom_wanted());
|
||||
});
|
||||
|
@ -1022,24 +1020,40 @@ ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
|
|||
p->hscroll->SetScrollRate(30, 30);
|
||||
|
||||
// XXX: set size right away on windows, create util function
|
||||
Bind(wxEVT_CREATE, [this](wxWindowCreateEvent &event) {
|
||||
CallAfter([this]() {
|
||||
// Clamp the Wizard size based on screen dimensions
|
||||
// Note: Using EVT_SHOW + CallAfter because any sooner than this
|
||||
// on some Linux boxes wxDisplay::GetFromWindow() returns 0 no matter what.
|
||||
// Bind(wxEVT_CREATE, [this](wxWindowCreateEvent &event) {
|
||||
// CallAfter([this]() {
|
||||
// // Clamp the Wizard size based on screen dimensions
|
||||
// // Note: Using EVT_SHOW + CallAfter because any sooner than this
|
||||
// // on some Linux boxes wxDisplay::GetFromWindow() returns 0 no matter what.
|
||||
|
||||
const auto idx = wxDisplay::GetFromWindow(this);
|
||||
wxDisplay display(idx != wxNOT_FOUND ? idx : 0u);
|
||||
// const auto idx = wxDisplay::GetFromWindow(this);
|
||||
// wxDisplay display(idx != wxNOT_FOUND ? idx : 0u);
|
||||
|
||||
const auto disp_rect = display.GetClientArea();
|
||||
wxRect window_rect(
|
||||
disp_rect.x + disp_rect.width / 20,
|
||||
disp_rect.y + disp_rect.height / 20,
|
||||
9*disp_rect.width / 10,
|
||||
9*disp_rect.height / 10);
|
||||
// const auto disp_rect = display.GetClientArea();
|
||||
// wxRect window_rect(
|
||||
// disp_rect.x + disp_rect.width / 20,
|
||||
// disp_rect.y + disp_rect.height / 20,
|
||||
// 9*disp_rect.width / 10,
|
||||
// 9*disp_rect.height / 10);
|
||||
|
||||
SetSize(window_rect);
|
||||
});
|
||||
// SetSize(window_rect);
|
||||
// });
|
||||
// });
|
||||
|
||||
on_window_geometry(this, [this]() {
|
||||
// Clamp the Wizard size based on screen dimensions
|
||||
|
||||
const auto idx = wxDisplay::GetFromWindow(this);
|
||||
wxDisplay display(idx != wxNOT_FOUND ? idx : 0u);
|
||||
|
||||
const auto disp_rect = display.GetClientArea();
|
||||
wxRect window_rect(
|
||||
disp_rect.x + disp_rect.width / 20,
|
||||
disp_rect.y + disp_rect.height / 20,
|
||||
9*disp_rect.width / 10,
|
||||
9*disp_rect.height / 10);
|
||||
|
||||
SetSize(window_rect);
|
||||
});
|
||||
|
||||
p->btn_prev->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &) { this->p->index->go_prev(); });
|
||||
|
|
|
@ -90,9 +90,6 @@ struct ConfigWizardPage: wxPanel
|
|||
|
||||
ConfigWizard::priv *wizard_p() const { return parent->p.get(); }
|
||||
|
||||
virtual bool Show(bool show = true);
|
||||
virtual bool Hide() { return Show(false); }
|
||||
virtual wxPanel* extra_buttons() { return nullptr; } // XXX
|
||||
virtual void apply_custom_config(DynamicPrintConfig &config) {}
|
||||
};
|
||||
|
||||
|
@ -129,8 +126,11 @@ struct PageCustom: ConfigWizardPage
|
|||
std::string profile_name() const { return into_u8(tc_profile_name->GetValue()); }
|
||||
|
||||
private:
|
||||
static const char* default_profile_name;
|
||||
|
||||
wxCheckBox *cb_custom;
|
||||
wxTextCtrl *tc_profile_name;
|
||||
wxString profile_name_prev;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -351,21 +351,26 @@ void GUI_App::persist_window_geometry(wxTopLevelWindow *window)
|
|||
});
|
||||
|
||||
window_pos_restore(window, name);
|
||||
#ifdef _WIN32
|
||||
// On windows, the wxEVT_SHOW is not received if the window is created maximized
|
||||
// cf. https://groups.google.com/forum/#!topic/wx-users/c7ntMt6piRI
|
||||
// so we sanitize the position right away
|
||||
window_pos_sanitize(window);
|
||||
#else
|
||||
// On other platforms on the other hand it's needed to wait before the window is actually on screen
|
||||
// and some initial round of events is complete otherwise position / display index is not reported correctly.
|
||||
window->Bind(wxEVT_SHOW, [=](wxShowEvent &event) {
|
||||
CallAfter([=]() {
|
||||
window_pos_sanitize(window);
|
||||
});
|
||||
event.Skip();
|
||||
|
||||
// #ifdef _WIN32
|
||||
// // On windows, the wxEVT_SHOW is not received if the window is created maximized
|
||||
// // cf. https://groups.google.com/forum/#!topic/wx-users/c7ntMt6piRI
|
||||
// // so we sanitize the position right away
|
||||
// window_pos_sanitize(window);
|
||||
// #else
|
||||
// // On other platforms on the other hand it's needed to wait before the window is actually on screen
|
||||
// // and some initial round of events is complete otherwise position / display index is not reported correctly.
|
||||
// window->Bind(wxEVT_SHOW, [=](wxShowEvent &event) {
|
||||
// CallAfter([=]() {
|
||||
// window_pos_sanitize(window);
|
||||
// });
|
||||
// event.Skip();
|
||||
// });
|
||||
// #endif
|
||||
|
||||
on_window_geometry(window, [=]() {
|
||||
window_pos_sanitize(window);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void GUI_App::load_project(wxWindow *parent, wxString& input_file)
|
||||
|
|
|
@ -26,6 +26,22 @@ wxTopLevelWindow* find_toplevel_parent(wxWindow *window)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void on_window_geometry(wxTopLevelWindow *tlw, std::function<void()> callback)
|
||||
{
|
||||
tlw->Bind(wxEVT_CREATE, [=](wxWindowCreateEvent &event) {
|
||||
#ifdef __linux__
|
||||
// On Linux, the geometry is only available after wxEVT_CREATE + CallAfter
|
||||
// cf. https://groups.google.com/forum/?pli=1#!topic/wx-users/fERSXdpVwAI
|
||||
tlw->CallAfter([=]() {
|
||||
#endif
|
||||
callback();
|
||||
#ifdef __linux__
|
||||
});
|
||||
#endif
|
||||
event.Skip();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
CheckboxFileDialog::ExtraPanel::ExtraPanel(wxWindow *parent)
|
||||
: wxPanel(parent, wxID_ANY)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
#include <functional>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
|
@ -24,6 +25,8 @@ namespace GUI {
|
|||
|
||||
wxTopLevelWindow* find_toplevel_parent(wxWindow *window);
|
||||
|
||||
void on_window_geometry(wxTopLevelWindow *tlw, std::function<void()> callback);
|
||||
|
||||
|
||||
class EventGuard
|
||||
{
|
||||
|
|
|
@ -130,13 +130,15 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
|
|||
model.id = section.first.substr(printer_model_key.size());
|
||||
model.name = section.second.get<std::string>("name", model.id);
|
||||
|
||||
auto technology_field = section.second.get<std::string>("technology", "FFF");
|
||||
const char *technology_fallback = boost::algorithm::starts_with(model.id, "SL") ? "SLA" : "FFF";
|
||||
|
||||
auto technology_field = section.second.get<std::string>("technology", technology_fallback);
|
||||
if (! ConfigOptionEnum<PrinterTechnology>::from_string(technology_field, model.technology)) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: Invalid printer technology field: `%2%`") % id % technology_field;
|
||||
model.technology = ptFFF;
|
||||
}
|
||||
|
||||
model.family = section.second.get<std::string>("family", model.id);
|
||||
model.family = section.second.get<std::string>("family", std::string());
|
||||
#if 0
|
||||
// Remove SLA printers from the initial alpha.
|
||||
if (model.technology == ptSLA)
|
||||
|
@ -167,7 +169,7 @@ std::vector<std::string> VendorProfile::families() const
|
|||
unsigned num_familiies = 0;
|
||||
|
||||
for (auto &model : models) {
|
||||
if (!model.family.empty() && std::find(res.begin(), res.end(), model.family) == res.end()) {
|
||||
if (std::find(res.begin(), res.end(), model.family) == res.end()) {
|
||||
res.push_back(model.family);
|
||||
num_familiies++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue