y2: fix some bug

1. Fixed a bug where the login window was not destroyed when switching languages;
2. Fixed the display issue when the model does not have the corresponding picture;
3. Fix button display problem when the local device has no IP address.
This commit is contained in:
wjyLearn
2024-07-29 10:53:47 +08:00
parent 4bdb7b76df
commit 146a4a15ed
9 changed files with 45 additions and 10 deletions

View File

@@ -1957,6 +1957,16 @@ void GUI_App::ShowUserLogin(bool show)
} }
} }
// y2
void GUI_App::shutdown()
{
if (login_dlg != nullptr) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(": destroy login dialog");
delete login_dlg;
login_dlg = nullptr;
}
}
void GUI_App::SetOnlineLogin(bool status) void GUI_App::SetOnlineLogin(bool status)
{ {
mainframe->m_printer_view->SetLoginStatus(status); mainframe->m_printer_view->SetLoginStatus(status);

View File

@@ -201,6 +201,7 @@ public:
// Process command line parameters cached in this->init_params, // Process command line parameters cached in this->init_params,
// load configs, STLs etc. // load configs, STLs etc.
void post_init(); void post_init();
void shutdown();
// If formatted for github, plaintext with OpenGL extensions enclosed into <details>. // If formatted for github, plaintext with OpenGL extensions enclosed into <details>.
// Otherwise HTML formatted for the system info dialog. // Otherwise HTML formatted for the system info dialog.
static std::string get_gl_info(bool for_github); static std::string get_gl_info(bool for_github);

View File

@@ -677,6 +677,8 @@ void MainFrame::shutdown()
// to avoid any manipulations with them from App->wxEVT_IDLE after of the mainframe closing // to avoid any manipulations with them from App->wxEVT_IDLE after of the mainframe closing
wxGetApp().tabs_list.clear(); wxGetApp().tabs_list.clear();
wxGetApp().plater_ = nullptr; wxGetApp().plater_ = nullptr;
// y2
wxGetApp().shutdown();
} }
GalleryDialog* MainFrame::gallery_dialog() GalleryDialog* MainFrame::gallery_dialog()

View File

@@ -878,7 +878,7 @@ void PrintHostQueueDialog::on_error(Event &evt)
if(isAws != std::string::npos) if(isAws != std::string::npos)
code_msg += _L("Unable to get required resources from AWS server, please check your network settings."); code_msg += _L("Unable to get required resources from AWS server, please check your network settings.");
else else
code_msg += _L("Unable to get required resources from ESC server, please check your network settings."); code_msg += _L("Unable to get required resources from Aliyun server, please check your network settings.");
} }
else else
code_msg = _L("Network connection times out. Please check the device network Settings."); code_msg = _L("Network connection times out. Please check the device network Settings.");

View File

@@ -339,6 +339,10 @@ void PrinterWebView::SetPresetChanged(bool status) {
model_id = "my_printer"; model_id = "my_printer";
else else
model_id = preset->config.opt_string("printer_model"); model_id = preset->config.opt_string("printer_model");
}
// y2
else {
model_id = "my_printer";
} }
const DynamicPrintConfig *cfg_t = &(it->config); const DynamicPrintConfig *cfg_t = &(it->config);
@@ -449,10 +453,23 @@ void PrinterWebView::AddButton(const wxString & device_name,
#if QDT_RELEASE_TO_PUBLIC #if QDT_RELEASE_TO_PUBLIC
void PrinterWebView::AddNetButton(const Device device) void PrinterWebView::AddNetButton(const Device device)
{ {
// y2
const Preset preset = wxGetApp().preset_bundle->prints.get_edited_preset();
bool isQIDI = false;
auto models = preset.vendor->models;
for (auto model : models) {
std::string model_id = model.id;
if (device.device_name.find(model_id) != std::string::npos) {
isQIDI = true;
break;
}
}
std::size_t found = device.device_name.find('@'); std::size_t found = device.device_name.find('@');
wxString Machine_Name; wxString Machine_Name;
wxString device_name; wxString device_name;
if (found != std::string::npos) { // y2
if (found != std::string::npos && isQIDI) {
std::string extracted = device.device_name.substr(found + 1); std::string extracted = device.device_name.substr(found + 1);
Machine_Name = Machine_Name.Format("%s%s", extracted, "_thumbnail"); Machine_Name = Machine_Name.Format("%s%s", extracted, "_thumbnail");
device_name = device_name.Format("%s", device.device_name.substr(0, found)); device_name = device_name.Format("%s", device.device_name.substr(0, found));

View File

@@ -45,6 +45,7 @@ DeviceButton::DeviceButton(wxWindow *parent,
wxString ip_text) wxString ip_text)
: DeviceButton(name_text,ip_text) : DeviceButton(name_text,ip_text)
{ {
m_icon_text = icon;
Create(parent, text, icon, style, iconSize); Create(parent, text, icon, style, iconSize);
} }
@@ -250,7 +251,9 @@ void DeviceButton::render(wxDC &dc)
if (GetLabel() == "") { if (GetLabel() == "") {
dc.DrawBitmap(icon.get_bitmap(), rcContent.x/2+1, rcContent.y/2); dc.DrawBitmap(icon.get_bitmap(), rcContent.x/2+1, rcContent.y/2);
} else if (m_ip_text == "") { }
// y2
else if (m_ip_text == "" && m_name_text == "") {
//dc.DrawBitmap(icon.get_bitmap(), 10, (GetSize().GetHeight() - icon.get_bitmap().GetHeight()) / 2); //dc.DrawBitmap(icon.get_bitmap(), 10, (GetSize().GetHeight() - icon.get_bitmap().GetHeight()) / 2);
if (m_isSimpleMode) { if (m_isSimpleMode) {
dc.SetFont(wxFont(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD)); dc.SetFont(wxFont(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
@@ -327,7 +330,7 @@ void DeviceButton::messureSize()
wxSize szContent = textSize; wxSize szContent = textSize;
if (this->active_icon.bmp().IsOk()) { if (this->active_icon.bmp().IsOk()) {
if (szContent.y > 0) { if (szContent.y > 0) {
//BBS norrow size between text and icon //QDS norrow size between text and icon
szContent.x += 5; szContent.x += 5;
} }
wxSize szIcon = this->active_icon.GetSize(); wxSize szIcon = this->active_icon.GetSize();
@@ -336,9 +339,10 @@ void DeviceButton::messureSize()
szContent.y = szIcon.y; szContent.y = szIcon.y;
} }
wxSize size = szContent + paddingSize * 2; wxSize size = szContent + paddingSize * 2;
if (m_isSimpleMode && m_ip_text != "") // y2
if (m_isSimpleMode && m_icon_text.find("_thumbnail") != std::string::npos)
size.x = 180; size.x = 180;
else if (m_ip_text != "") else if (m_icon_text.find("_thumbnail") != std::string::npos)
size.x = 290; size.x = 290;
if (minSize.GetHeight() > 0) if (minSize.GetHeight() > 0)
size.SetHeight(minSize.GetHeight()); size.SetHeight(minSize.GetHeight());

View File

@@ -101,6 +101,7 @@ private:
wxString m_name_text; wxString m_name_text;
wxString m_ip_text; wxString m_ip_text;
wxString m_icon_text;
wxString m_state_text = "standby"; wxString m_state_text = "standby";
wxString m_progress_text = "(0%)"; wxString m_progress_text = "(0%)";
bool m_isSimpleMode = true; bool m_isSimpleMode = true;

View File

@@ -134,7 +134,7 @@ bool AstroBox::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error
if(body.find("AWS") != std::string::npos) if(body.find("AWS") != std::string::npos)
body += ("Unable to get required resources from AWS server, please check your network settings."); body += ("Unable to get required resources from AWS server, please check your network settings.");
else else
body += ("Unable to get required resources from ESC server, please check your network settings."); body += ("Unable to get required resources from Aliyun server, please check your network settings.");
} }
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error uploading file: %2%, HTTP %3%, body: `%4%`") % name % error % status % body; BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error uploading file: %2%, HTTP %3%, body: `%4%`") % name % error % status % body;
error_fn(format_error(body, error, status)); error_fn(format_error(body, error, status));

View File

@@ -175,7 +175,7 @@ std::string Moonraker::get_status(wxString &msg) const
if(body.find("AWS") != std::string::npos) if(body.find("AWS") != std::string::npos)
body += ("Unable to get required resources from AWS server, please check your network settings."); body += ("Unable to get required resources from AWS server, please check your network settings.");
else else
body += ("Unable to get required resources from ESC server, please check your network settings."); body += ("Unable to get required resources from Aliyun server, please check your network settings.");
} }
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting version: %2%, HTTP %3%, body: `%4%`") % name % error % status % BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting version: %2%, HTTP %3%, body: `%4%`") % name % error % status %
body; body;
@@ -245,7 +245,7 @@ float Moonraker::get_progress(wxString &msg) const
if(body.find("AWS") != std::string::npos) if(body.find("AWS") != std::string::npos)
body += ("Unable to get required resources from AWS server, please check your network settings."); body += ("Unable to get required resources from AWS server, please check your network settings.");
else else
body += ("Unable to get required resources from ESC server, please check your network settings."); body += ("Unable to get required resources from Aliyun server, please check your network settings.");
} }
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting version: %2%, HTTP %3%, body: `%4%`") % name % error % status % BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting version: %2%, HTTP %3%, body: `%4%`") % name % error % status %
body; body;
@@ -369,7 +369,7 @@ bool Moonraker::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Erro
if(body.find("AWS") != std::string::npos) if(body.find("AWS") != std::string::npos)
body += ("Unable to get required resources from AWS server, please check your network settings."); body += ("Unable to get required resources from AWS server, please check your network settings.");
else else
body += ("Unable to get required resources from ESC server, please check your network settings."); body += ("Unable to get required resources from Aliyun server, please check your network settings.");
} }
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error uploading file: %2%, HTTP %3%, body: `%4%`") % name % error % status % body; BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error uploading file: %2%, HTTP %3%, body: `%4%`") % name % error % status % body;
error_fn(format_error(body, error, status)); error_fn(format_error(body, error, status));