fix search bar

This commit is contained in:
remi durand 2021-05-29 00:27:31 +02:00
parent 7851f6e875
commit 370e9ca741
5 changed files with 52 additions and 28 deletions

View File

@ -2347,7 +2347,7 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionFloat(0)); def->set_default_value(new ConfigOptionFloat(0));
def = this->add("fan_speedup_overhangs", coBool); def = this->add("fan_speedup_overhangs", coBool);
def->label = L("Fan startup delay"); def->label = L("Allow fan delay on overhangs");
def->category = OptionCategory::firmware; def->category = OptionCategory::firmware;
def->tooltip = L("Will only take into account the delay for the cooling of overhangs."); def->tooltip = L("Will only take into account the delay for the cooling of overhangs.");
def->mode = comAdvanced; def->mode = comAdvanced;

View File

@ -1884,13 +1884,19 @@ void MainFrame::select_tab(Tab* tab)
{ {
if (!tab) if (!tab)
return; return;
std::vector<Tab*>& tabs_list = wxGetApp().tabs_list; ETabType tab_type = ETabType::LastSettings;
std::vector<Tab*>::iterator it_tab = std::find(tabs_list.begin(), tabs_list.end(), tab); switch (tab->type()) {
if (it_tab != tabs_list.end()) { case Preset::Type::TYPE_FILAMENT:
select_tab((ETabType)((uint8_t)ETabType::PrintSettings + uint8_t(it_tab - tabs_list.begin()))); case Preset::Type::TYPE_SLA_MATERIAL:
tab_type = ETabType::FilamentSettings;
case Preset::Type::TYPE_PRINT:
case Preset::Type::TYPE_SLA_PRINT:
tab_type = ETabType::PrintSettings;
case Preset::Type::TYPE_PRINTER:
tab_type = ETabType::PrinterSettings;
} }
select_tab(tab_type);
select_tab(ETabType::LastSettings);
} }
void MainFrame::select_tab(ETabType tab /* = Any*/, bool keep_tab_type) void MainFrame::select_tab(ETabType tab /* = Any*/, bool keep_tab_type)

View File

@ -108,6 +108,10 @@ void OptionsSearcher::append_options(DynamicPrintConfig* config, Preset::Type ty
wxString label = opt.full_label.empty() ? opt.label : opt.full_label; wxString label = opt.full_label.empty() ? opt.label : opt.full_label;
if (label_override.find(opt.opt_key) != label_override.end()) {
label = label_override[opt.opt_key][1].empty() ? label_override[opt.opt_key][0] : label_override[opt.opt_key][1];
}
if (cnt == 0) if (cnt == 0)
emplace(opt_key, label); emplace(opt_key, label);
else else
@ -185,34 +189,34 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/)
{ {
std::wstring out; std::wstring out;
out += marker_by_type(opt.type, printer_technology); out += marker_by_type(opt.type, printer_technology);
const std::wstring *prev = nullptr; const std::wstring* prev = nullptr;
for (const std::wstring * const s : { for (const std::wstring* const s : {
view_params.category ? &opt.category_local : nullptr, view_params.category ? &opt.category_local : nullptr,
&opt.group_local, &opt.label_local }) & opt.group_local, & opt.label_local })
if (s != nullptr && (prev == nullptr || *prev != *s)) { if (s != nullptr && (prev == nullptr || *prev != *s)) {
if (out.size()>2) if (out.size() > 2)
out += sep; out += sep;
out += *s; out += *s;
prev = s; prev = s;
} }
return out; return out;
}; };
auto get_label_english = [this, &sep](const Option& opt) auto get_label_english = [this, &sep](const Option& opt)
{ {
std::wstring out; std::wstring out;
out += marker_by_type(opt.type, printer_technology); out += marker_by_type(opt.type, printer_technology);
const std::wstring*prev = nullptr; const std::wstring* prev = nullptr;
for (const std::wstring * const s : { for (const std::wstring* const s : {
view_params.category ? &opt.category : nullptr, view_params.category ? &opt.category : nullptr,
&opt.group, &opt.label }) & opt.group, & opt.label })
if (s != nullptr && (prev == nullptr || *prev != *s)) { if (s != nullptr && (prev == nullptr || *prev != *s)) {
if (out.size()>2) if (out.size() > 2)
out += sep; out += sep;
out += *s; out += *s;
prev = s; prev = s;
} }
return out; return out;
}; };
auto get_tooltip = [this, &sep](const Option& opt) auto get_tooltip = [this, &sep](const Option& opt)

View File

@ -128,6 +128,13 @@ public:
std::sort(options.begin(), options.end(), [](const Option& o1, const Option& o2) { std::sort(options.begin(), options.end(), [](const Option& o1, const Option& o2) {
return o1.opt_key < o2.opt_key; }); return o1.opt_key < o2.opt_key; });
} }
static void register_label_override(t_config_option_key key, std::string label, std::string full_label, std::string tooltip) {
label_override.insert({ key, {label, full_label, tooltip} });
}
private:
inline static std::unordered_map< t_config_option_key, std::array<std::string, 3>> label_override;
}; };

View File

@ -48,6 +48,7 @@
#include "PhysicalPrinterDialog.hpp" #include "PhysicalPrinterDialog.hpp"
#include "UnsavedChangesDialog.hpp" #include "UnsavedChangesDialog.hpp"
#include "SavePresetDialog.hpp" #include "SavePresetDialog.hpp"
#include "Search.hpp"
#ifdef WIN32 #ifdef WIN32
#include <commctrl.h> #include <commctrl.h>
@ -1771,6 +1772,7 @@ bool Tab::create_pages(std::string setting_type_name, int idx_page)
if (current_group->sidetext_width >= 0) if (current_group->sidetext_width >= 0)
option.opt.sidetext_width = current_group->sidetext_width; option.opt.sidetext_width = current_group->sidetext_width;
bool need_to_notified_search = false;
bool colored = false; bool colored = false;
wxString label_path; wxString label_path;
for (int i = 1; i < params.size() - 1; i++) { for (int i = 1; i < params.size() - 1; i++) {
@ -1789,10 +1791,12 @@ bool Tab::create_pages(std::string setting_type_name, int idx_page)
else if (params[i] == "full_label") else if (params[i] == "full_label")
{ {
option.opt.label = option.opt.full_label; option.opt.label = option.opt.full_label;
need_to_notified_search = true;
} }
else if (params[i].find("label$") != std::string::npos) else if (params[i].find("label$") != std::string::npos)
{ {
option.opt.label = params[i].substr(6, params[i].size() - 6); option.opt.label = params[i].substr(6, params[i].size() - 6);
need_to_notified_search = true;
} }
else if (boost::starts_with(params[i], "label_width$")) { else if (boost::starts_with(params[i], "label_width$")) {
option.opt.label_width = atoi(params[i].substr(12, params[i].size() - 12).c_str()); option.opt.label_width = atoi(params[i].substr(12, params[i].size() - 12).c_str());
@ -1822,6 +1826,9 @@ bool Tab::create_pages(std::string setting_type_name, int idx_page)
} }
} }
if (need_to_notified_search)
Search::OptionsSearcher::register_label_override(option.opt.opt_key, option.opt.label, option.opt.full_label, option.opt.tooltip);
if(height>0) if(height>0)
option.opt.height = height; option.opt.height = height;