FIX: label wrap all & ping test for liveview
Change-Id: I7767ed0740e20bb578b6ef9f5e9873c8c79d172a Jira: STUDIO-5821
This commit is contained in:
parent
2cc42a0fd9
commit
e917afe923
|
@ -147,6 +147,40 @@ namespace GUI {
|
|||
|
||||
class MainFrame;
|
||||
|
||||
void start_ping_test()
|
||||
{
|
||||
wxArrayString output;
|
||||
wxExecute("ping www.amazon.com", output, wxEXEC_NODISABLE);
|
||||
|
||||
wxString output_i;
|
||||
std::string output_temp;
|
||||
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
output_i = output[i].To8BitData();
|
||||
output_temp = output_i.ToStdString(wxConvUTF8);
|
||||
BOOST_LOG_TRIVIAL(info) << "ping amazon:" << output_temp;
|
||||
|
||||
}
|
||||
wxExecute("ping www.apple.com", output, wxEXEC_NODISABLE);
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
output_i = output[i].To8BitData();
|
||||
output_temp = output_i.ToStdString(wxConvUTF8);
|
||||
BOOST_LOG_TRIVIAL(info) << "ping www.apple.com:" << output_temp;
|
||||
}
|
||||
wxExecute("ping www.bambulab.com", output, wxEXEC_NODISABLE);
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
output_i = output[i].To8BitData();
|
||||
output_temp = output_i.ToStdString(wxConvUTF8);
|
||||
BOOST_LOG_TRIVIAL(info) << "ping bambulab:" << output_temp;
|
||||
}
|
||||
//Get GateWay IP
|
||||
wxExecute("ping 192.168.0.1", output, wxEXEC_NODISABLE);
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
output_i = output[i].To8BitData();
|
||||
output_temp = output_i.ToStdString(wxConvUTF8);
|
||||
BOOST_LOG_TRIVIAL(info) << "ping 192.168.0.1:" << output_temp;
|
||||
}
|
||||
}
|
||||
|
||||
std::string VersionInfo::convert_full_version(std::string short_version)
|
||||
{
|
||||
|
|
|
@ -737,7 +737,17 @@ void Slic3r::GUI::ImageGrid::renderText(wxDC &dc, wxString const &text, wxRect c
|
|||
dc.SetTextForeground(m_buttonTextColor.colorForStatesNoDark(states));
|
||||
wxRect rc({0, 0}, dc.GetTextExtent(text));
|
||||
rc = rc.CenterIn(rect);
|
||||
dc.DrawText(text, rc.GetTopLeft());
|
||||
float fontScale = float(rect.width - 8) / rc.width;
|
||||
if (fontScale < 1) {
|
||||
auto font = dc.GetFont();
|
||||
dc.SetFont(font.Scaled(fontScale));
|
||||
wxRect rc({0, 0}, dc.GetTextExtent(text));
|
||||
rc = rc.CenterIn(rect);
|
||||
dc.DrawText(text, rc.GetTopLeft());
|
||||
dc.SetFont(font);
|
||||
} else {
|
||||
dc.DrawText(text, rc.GetTopLeft());
|
||||
}
|
||||
}
|
||||
|
||||
void Slic3r::GUI::ImageGrid::renderText2(wxDC &dc, wxString text, wxRect const &rect)
|
||||
|
|
|
@ -337,6 +337,8 @@ void MediaPlayCtrl::Play()
|
|||
}
|
||||
}
|
||||
|
||||
void start_ping_test();
|
||||
|
||||
void MediaPlayCtrl::Stop(wxString const &msg)
|
||||
{
|
||||
int last_state = m_last_state;
|
||||
|
@ -358,6 +360,12 @@ void MediaPlayCtrl::Stop(wxString const &msg)
|
|||
if (m_last_state == wxMEDIASTATE_PLAYING)
|
||||
msg2 = _L("The printer has been logged out and cannot connect.");
|
||||
}
|
||||
#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__)
|
||||
if (m_failed_code < 0)
|
||||
boost::thread ping_thread = Slic3r::create_thread([] {
|
||||
start_ping_test();
|
||||
});
|
||||
#endif
|
||||
SetStatus(msg2);
|
||||
} else
|
||||
SetStatus(_L("Stopped."), false);
|
||||
|
|
|
@ -271,7 +271,7 @@ void OptionsGroup::activate_line(Line& line)
|
|||
// Set sidetext width for a better alignment of options in line
|
||||
// "m_show_modified_btns==true" means that options groups are in tabs
|
||||
if (option_set.size() > 1 && m_use_custom_ctrl) {
|
||||
// sublabel_width = Field::def_width();
|
||||
sublabel_width = Field::def_width() + 1;
|
||||
sidetext_width = Field::def_width_thinner();
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,11 @@ public:
|
|||
void Wrap(wxWindow *win, const wxString &text, int widthMax)
|
||||
{
|
||||
const wxClientDC dc(win);
|
||||
Wrap(dc, text, widthMax);
|
||||
}
|
||||
|
||||
void Wrap(wxDC const & dc, const wxString &text, int widthMax)
|
||||
{
|
||||
const wxArrayString ls = wxSplit(text, '\n', '\0');
|
||||
for (wxArrayString::const_iterator i = ls.begin(); i != ls.end(); ++i) {
|
||||
wxString line = *i;
|
||||
|
@ -210,6 +214,12 @@ private:
|
|||
class wxLabelWrapper2 : public wxTextWrapper2
|
||||
{
|
||||
public:
|
||||
void WrapLabel(wxDC const & dc, wxString const & label, int widthMax)
|
||||
{
|
||||
m_text.clear();
|
||||
Wrap(dc, label, widthMax);
|
||||
}
|
||||
|
||||
void WrapLabel(wxWindow *text, wxString const & label, int widthMax)
|
||||
{
|
||||
m_text.clear();
|
||||
|
@ -230,27 +240,9 @@ private:
|
|||
|
||||
wxSize Label::split_lines(wxDC &dc, int width, const wxString &text, wxString &multiline_text)
|
||||
{
|
||||
multiline_text = text;
|
||||
if (width > 0 && dc.GetTextExtent(text).x > width) {
|
||||
size_t start = 0;
|
||||
while (true) {
|
||||
size_t idx = size_t(-1);
|
||||
for (size_t i = start; i < multiline_text.Len(); i++) {
|
||||
if (multiline_text[i] == ' ') {
|
||||
if (dc.GetTextExtent(multiline_text.SubString(start, i)).x < width)
|
||||
idx = i;
|
||||
else {
|
||||
if (idx == size_t(-1)) idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (idx == size_t(-1)) break;
|
||||
multiline_text[idx] = '\n';
|
||||
start = idx + 1;
|
||||
if (dc.GetTextExtent(multiline_text.Mid(start)).x < width) break;
|
||||
}
|
||||
}
|
||||
wxLabelWrapper2 wrap;
|
||||
wrap.Wrap(dc, text, width);
|
||||
multiline_text = wrap.GetText();
|
||||
return dc.GetMultiLineTextExtent(multiline_text);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue