FIX: file name is not fully displayed if it is too long

Jira: STUDIO-5230
Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com>
Change-Id: I992fa0c0575afbd2eecb2af02c8a305eda028f7f
(cherry picked from commit d0d7fb0b1394429ee9d28d8ef4060a286ba0112d)
This commit is contained in:
wenjie.guo 2023-12-11 14:19:55 +08:00 committed by Lane.Wei
parent 70fbd02c53
commit d15f49a7c0
2 changed files with 15 additions and 5 deletions

View File

@ -100,12 +100,14 @@ wxString ProgressDialog::FormatString(wxString title)
break;
}
}
// set mode
if (m_mode == 0) {
m_simplebook->SetSelection(0);
m_msg->SetLabel(title);
} else {
wxSize content_size = m_msg->GetTextExtent(title);
int resized_height = (int(content_size.x / PROGRESSDIALOG_GAUGE_SIZE.x) + 1) * content_size.y;
set_panel_height(resized_height);
m_simplebook->SetSelection(1);
m_msg_2line->SetLabel(title);
}
@ -188,7 +190,7 @@ bool ProgressDialog::Create(const wxString &title, const wxString &message, int
m_msg_2line->Wrap(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x);
m_msg_2line->SetFont(::Label::Body_13);
m_msg_2line->SetForegroundColour(PROGRESSDIALOG_GREY_700);
m_msg_2line->SetMaxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE);
m_msg_2line->SetMaxSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, -1));
sizer_2line->Add(m_msg_2line, 1, wxALL, 0);
m_panel_2line->SetSizer(sizer_2line);
m_panel_2line->Layout();
@ -684,6 +686,15 @@ void ProgressDialog::SetRange(int maximum)
SetMaximum(maximum);
}
void ProgressDialog::set_panel_height(int height) {
m_simplebook->SetSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, height));
m_simplebook->SetMinSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, height));
m_panel_2line->SetSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, height));
m_panel_2line->SetMinSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, height));
m_msg_2line->SetSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, height));
m_msg_2line->SetMinSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, height));
}
void ProgressDialog::SetMaximum(int maximum)
{
m_maximum = maximum;

View File

@ -47,7 +47,6 @@ public:
virtual wxString GetMessage() const;
virtual void SetRange(int maximum);
// Return whether "Cancel" or "Skip" button was pressed, always return
// false if the corresponding button is not shown.
virtual bool WasCancelled() const;
@ -89,7 +88,6 @@ protected:
// both this class and its derived classes that don't use m_gauge to
// display progress.
void SetMaximum(int maximum);
// Return the labels to use for showing the elapsed/estimated/remaining
// times respectively.
static wxString GetElapsedLabel() { return wxGetTranslation("Elapsed time:"); }
@ -103,6 +101,7 @@ protected:
// Return the progress dialog style. Prefer to use HasPDFlag() if possible.
int GetPDStyle() const { return m_pdStyle; }
void SetPDStyle(int pdStyle) { m_pdStyle = pdStyle; }
void set_panel_height(int height);
// Updates estimated times from a given progress bar value and stores the
// results in provided arguments.