Fixed a bug where the device list button could not be added properly when certain language characters were included

This commit is contained in:
sunsets
2024-03-28 13:51:08 +08:00
parent 6485825ad8
commit 58e2343a2e
3 changed files with 11 additions and 10 deletions

View File

@@ -2058,7 +2058,7 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
size_t new_selection = tab == (size_t)(-1) ? m_last_selected_tab : (m_layout == ESettingsLayout::Dlg && tab != 0) ? tab - 1 : tab;
//B4
if (m_tabpanel->GetSelection() == 4) {
//B45 //B58
//B45 //B59 //B60
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
const PhysicalPrinterCollection &ph_printers = preset_bundle.physical_printers;
struct PhysicalPrinterPresetData
@@ -2070,6 +2070,7 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
std::string model_id;
wxString host;
bool is_QIDI;
std::string preset_name;
};
std::vector<PhysicalPrinterPresetData> preset_data;
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
@@ -2084,7 +2085,7 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
else
model_id = preset->config.opt_string("printer_model");
}
//B58
//B59 //B60
wxStringTokenizer tokenizer(wxString::FromUTF8(it->get_full_name(preset_name)), "*");
std::string tem_name = (into_u8(tokenizer.GetNextToken().Trim().mb_str()));
auto * printer = preset_bundle.physical_printers.find_printer(tem_name);
@@ -2105,7 +2106,7 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
}
preset_data.push_back({printer_name, wxString::FromUTF8(preset_name),
wxString::FromUTF8(it->get_full_name(preset_name)), ph_printers.is_selected(it, preset_name),
model_id, host, (host_type == htMoonraker)});
model_id, host, (host_type == htMoonraker), preset_name});
}
}
}
@@ -2116,7 +2117,7 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
for (auto it = m_buttons.begin(); it != m_buttons.end();) {
bool foundPreset = false;
for (const PhysicalPrinterPresetData &data : preset_data) {
//B58
//B59
if ((*it)->getLabel() == data.fullname && (*it)->getIPLabel() == data.host && (*it)->getIsQIDI() == data.is_QIDI) {
foundPreset = true;
break;
@@ -2147,10 +2148,10 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
missingPresets.push_back(&data);
}
}
//B58
//B59 //B60
for (const PhysicalPrinterPresetData *data : missingPresets) {
Preset *preset = m_collection->find_preset((data->name).ToStdString());
Preset *preset = m_collection->find_preset((data->preset_name));
if (!preset || !preset->is_visible)
continue;
wxStringTokenizer tokenizer((data->fullname), "*");

View File

@@ -665,7 +665,7 @@ void PrinterWebView::OnEditButtonClick(wxCommandEvent &event) {
button->SetNameText((wxString::FromUTF8(printer_name)));
button->SetIPText(host);
button->SetLabel(fullname);
//B58
//B59
const auto opt = cfg_t->option<ConfigOptionEnum<PrintHostType>>("host_type");
const auto host_type = opt != nullptr ? opt->value : htOctoPrint;
bool isQIDI = (host_type == htMoonraker);
@@ -691,7 +691,7 @@ void PrinterWebView::OnEditButtonClick(wxCommandEvent &event) {
wxString Machine_Name = Machine_Name.Format("%s%s", model_id, "_thumbnail");
button->SetBitMap(get_bmp_bundle(std::string(Machine_Name.mb_str()), 80)->GetBitmapFor(this));
//B58
//B59
load_url(formattedHost);
UpdateLayout();
Refresh();

View File

@@ -94,7 +94,7 @@ public:
Refresh();
}
//B58
//B59
void SetIsQIDI(const bool &text)
{
m_is_QIDI = text;
@@ -226,7 +226,7 @@ private:
wxString m_state_text;
wxString m_progress_text;
std::function<void(wxMouseEvent &)> m_handlerl;
//B58
//B59
bool m_is_QIDI;
wxDECLARE_EVENT_TABLE();
};