ENH: remove placeholder '0' in version display

Change-Id: I6c0ffdd229a630a48a676c12a8f124f7a6e39f09
This commit is contained in:
tao.jin 2022-10-25 16:27:02 +08:00 committed by Lane.Wei
parent 99eee4a2d6
commit e22115bf9c
3 changed files with 29 additions and 6 deletions

View File

@ -244,10 +244,11 @@ AboutDialog::AboutDialog()
// version // version
{ {
vesizer->Add(0, FromDIP(165), 1, wxEXPAND, FromDIP(5)); vesizer->Add(0, FromDIP(165), 1, wxEXPAND, FromDIP(5));
auto version_text = GUI_App::format_display_version();
#if BBL_INTERNAL_TESTING #if BBL_INTERNAL_TESTING
auto version_string = _L("Internal Version") + " " + std::string(SLIC3R_VERSION); auto version_string = _L("Internal Version") + " " + std::string(version_text);
#else #else
auto version_string = _L("Version") + " " + std::string(SLIC3R_VERSION); auto version_string = _L("Version") + " " + std::string(version_text);
#endif #endif
wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize); wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize);
wxFont version_font = GetFont(); wxFont version_font = GetFont();
@ -416,7 +417,7 @@ void AboutDialog::onCopyrightBtn(wxEvent &)
void AboutDialog::onCopyToClipboard(wxEvent&) void AboutDialog::onCopyToClipboard(wxEvent&)
{ {
wxTheClipboard->Open(); wxTheClipboard->Open();
wxTheClipboard->SetData(new wxTextDataObject(_L("Version") + " " + std::string(SLIC3R_VERSION))); wxTheClipboard->SetData(new wxTextDataObject(_L("Version") + " " + GUI_App::format_display_version()));
wxTheClipboard->Close(); wxTheClipboard->Close();
} }

View File

@ -386,7 +386,7 @@ private:
title = wxGetApp().is_editor() ? SLIC3R_APP_FULL_NAME : GCODEVIEWER_APP_NAME; title = wxGetApp().is_editor() ? SLIC3R_APP_FULL_NAME : GCODEVIEWER_APP_NAME;
// dynamically get the version to display // dynamically get the version to display
version = _L("V") + " " + std::string(SLIC3R_VERSION); version = _L("V") + " " + GUI_App::format_display_version();
// credits infornation // credits infornation
credits = ""; credits = "";
@ -554,10 +554,11 @@ private:
title = wxGetApp().is_editor() ? SLIC3R_APP_FULL_NAME : GCODEVIEWER_APP_NAME; title = wxGetApp().is_editor() ? SLIC3R_APP_FULL_NAME : GCODEVIEWER_APP_NAME;
// dynamically get the version to display // dynamically get the version to display
auto version_text = GUI_App::format_display_version();
#if BBL_INTERNAL_TESTING #if BBL_INTERNAL_TESTING
version = _L("Internal Version") + " " + std::string(SLIC3R_VERSION); version = _L("Internal Version") + " " + std::string(version_text);
#else #else
version = _L("Version") + " " + std::string(SLIC3R_VERSION); version = _L("Version") + " " + std::string(version_text);
#endif #endif
// credits infornation // credits infornation
@ -3619,6 +3620,25 @@ void GUI_App::no_new_version()
GUI::wxGetApp().QueueEvent(evt); GUI::wxGetApp().QueueEvent(evt);
} }
std::string GUI_App::version_display = "";
std::string GUI_App::format_display_version()
{
if (!version_display.empty()) return version_display;
auto version_text = std::string(SLIC3R_VERSION);
int len = version_text.length();
for (int i = 0, j = 0; i < len; ++i) {
if (!(version_text[i] == '0' && j == 0))
version_display += version_text[i];
if (version_text[i] == '.')
j = 0;
else
++j;
}
return version_display;
}
void GUI_App::show_dialog(wxString msg) void GUI_App::show_dialog(wxString msg)
{ {
wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_DIALOG); wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_DIALOG);

View File

@ -266,6 +266,7 @@ private:
std::shared_ptr<UpgradeNetworkJob> m_upgrade_network_job; std::shared_ptr<UpgradeNetworkJob> m_upgrade_network_job;
VersionInfo version_info; VersionInfo version_info;
static std::string version_display;
HMSQuery *hms_query { nullptr }; HMSQuery *hms_query { nullptr };
boost::thread m_sync_update_thread; boost::thread m_sync_update_thread;
@ -397,6 +398,7 @@ public:
void enter_force_upgrade(); void enter_force_upgrade();
void set_skip_version(bool skip = true); void set_skip_version(bool skip = true);
void no_new_version(); void no_new_version();
static std::string format_display_version();
void show_dialog(wxString msg); void show_dialog(wxString msg);
void reload_settings(); void reload_settings();
void remove_user_presets(); void remove_user_presets();