This commit is contained in:
enricoturri1966 2020-11-26 08:43:22 +01:00
commit 7da1622e76
12 changed files with 179 additions and 40 deletions

View file

@ -861,9 +861,15 @@ void Choice::BUILD() {
temp->SetItemBitmap(0, empty_bmp);
#endif
// temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
temp->Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_is_dropped = true; });
temp->Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) { m_is_dropped = false; });
temp->Bind(wxEVT_COMBOBOX_CLOSEUP, [this, temp](wxCommandEvent&) {
// EVT_COMBOBOX_CLOSEUP is called after EVT_COMBOBOX on Windows
// so, always set m_suppress_change to "true"
#ifndef __WXMSW__
if (m_last_selected == temp->GetSelection())
#endif //__WXMSW__
m_is_dropped = false;
});
temp->Bind(wxEVT_COMBOBOX, ([this, temp](wxCommandEvent evt) {
if (m_suppress_scroll) {
@ -874,6 +880,7 @@ void Choice::BUILD() {
m_last_selected = evt.GetSelection();
}
on_change_field();
m_is_dropped = false;
}), temp->GetId());
if (m_is_editable) {
@ -998,13 +1005,14 @@ void Choice::set_value(const boost::any& value, bool change_event)
else
text_value = boost::any_cast<wxString>(value);
size_t idx = 0;
for (auto el : m_opt.enum_values)
const std::vector<std::string>& enums = m_opt.enum_values.empty() ? m_opt.enum_labels : m_opt.enum_values;
for (auto el : enums)
{
if (el == text_value)
break;
++idx;
}
if (idx == m_opt.enum_values.size()) {
if (idx == enums.size()) {
// For editable Combobox under OSX is needed to set selection to -1 explicitly,
// otherwise selection doesn't be changed
field->SetSelection(-1);
@ -1012,7 +1020,7 @@ void Choice::set_value(const boost::any& value, bool change_event)
}
else
field->SetSelection(idx);
if (m_suppress_scroll && idx < m_opt.enum_values.size()) m_last_selected = idx;
if (m_suppress_scroll && idx < enums.size()) m_last_selected = idx;
break;
}
case coEnum: {

View file

@ -189,10 +189,10 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxWindow* parent, wxString printer_
}
else
{
m_printer = *printer;
const std::set<std::string>& preset_names = printer->get_preset_names();
for (const std::string& preset_name : preset_names)
m_presets.emplace_back(new PresetForPrinter(this, preset_name));
m_printer = *printer;
}
if (m_presets.size() == 1)

View file

@ -513,6 +513,10 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) :
m_og_sla->append_line(line);
m_og_sla->activate();
choice = dynamic_cast<Choice*>(m_og_sla->get_field("support"));
choice->suppress_scroll();
choice = dynamic_cast<Choice*>(m_og_sla->get_field("pad"));
choice->suppress_scroll();
m_sizer = new wxBoxSizer(wxVERTICAL);
m_sizer->Add(m_og->sizer, 0, wxEXPAND);

View file

@ -103,8 +103,15 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
// parameters for an icon's drawing
fill_width_height();
Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent& evt) { m_suppress_change = false; });
Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent& evt) { m_suppress_change = true ; });
Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_suppress_change = false; });
Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) {
// EVT_COMBOBOX_CLOSEUP is called after EVT_COMBOBOX on Windows
// so, always set m_suppress_change to "true"
#ifndef __WXMSW__
if (m_last_selected == this->GetSelection())
#endif //__WXMSW__
m_suppress_change = true;
});
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
@ -572,6 +579,7 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset
} else {
evt.StopPropagation();
}
m_suppress_change = true;
});
if (m_type == Preset::TYPE_FILAMENT)
@ -911,6 +919,7 @@ TabPresetComboBox::TabPresetComboBox(wxWindow* parent, Preset::Type preset_type)
}
evt.StopPropagation();
m_suppress_change = true;
});
}

View file

@ -448,6 +448,15 @@ Http& Http::auth_digest(const std::string &user, const std::string &password)
return *this;
}
Http& Http::auth_basic(const std::string &user, const std::string &password)
{
curl_easy_setopt(p->curl, CURLOPT_USERNAME, user.c_str());
curl_easy_setopt(p->curl, CURLOPT_PASSWORD, password.c_str());
curl_easy_setopt(p->curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
return *this;
}
Http& Http::ca_file(const std::string &name)
{
if (p && priv::ca_file_supported(p->curl)) {

View file

@ -67,6 +67,8 @@ public:
Http& remove_header(std::string name);
// Authorization by HTTP digest, based on RFC2617.
Http& auth_digest(const std::string &user, const std::string &password);
// Basic HTTP authorization
Http& auth_basic(const std::string &user, const std::string &password);
// Sets a CA certificate file for usage with HTTPS. This is only supported on some backends,
// specifically, this is supported with OpenSSL and NOT supported with Windows and OS X native certificate store.
// See also ca_file_supported().