ENH: help video play failure
Change-Id: I5f847547877a82d626bffb78488e5f3d20cc56d0
This commit is contained in:
parent
6dc68c4c9e
commit
70de37d1ae
|
@ -19,11 +19,15 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
|
|||
m_button_play = new Button(this, "", "media_play", wxBORDER_NONE);
|
||||
m_button_play->SetCanFocus(false);
|
||||
|
||||
m_label_status = new Label(this);
|
||||
m_label_status = new Label(this, "", LB_HYPERLINK);
|
||||
|
||||
m_button_play->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](auto & e) { TogglePlay(); });
|
||||
|
||||
m_button_play->Bind(wxEVT_RIGHT_UP, [this](auto & e) { m_media_ctrl->Play(); });
|
||||
m_label_status->Bind(wxEVT_LEFT_UP, [this](auto &e) {
|
||||
auto url = wxString::Format(L"https://wiki.bambulab.com/%s/software/bambu-studio/faq/live-view", L"en");
|
||||
wxLaunchDefaultBrowser(url);
|
||||
});
|
||||
|
||||
Bind(wxEVT_RIGHT_UP, [this](auto & e) { wxClipboard & c = *wxTheClipboard; if (c.Open()) { c.SetData(new wxTextDataObject(m_url)); c.Close(); } });
|
||||
|
||||
|
@ -206,7 +210,11 @@ void MediaPlayCtrl::SetStatus(wxString const& msg2)
|
|||
OutputDebugStringA("\n");
|
||||
#endif // __WXMSW__
|
||||
m_label_status->SetLabel(msg);
|
||||
//m_label_status->SetForegroundColour(!msg.EndsWith("!") ? 0x42AE00 : 0x3B65E9);
|
||||
long style = m_label_status->GetWindowStyle() & ~LB_HYPERLINK;
|
||||
if (m_failed_code && msg != msg2) {
|
||||
style |= LB_HYPERLINK;
|
||||
}
|
||||
m_label_status->SetWindowStyle(style);
|
||||
Layout();
|
||||
}
|
||||
|
||||
|
@ -280,6 +288,8 @@ void MediaPlayCtrl::onStateChanged(wxMediaEvent& event)
|
|||
}
|
||||
else if (event.GetId()) {
|
||||
Stop();
|
||||
if (m_failed_code == 0)
|
||||
m_failed_code = 2;
|
||||
SetStatus(_L("Load failed [%d]!"));
|
||||
} else {
|
||||
m_last_state = last_state;
|
||||
|
|
|
@ -64,11 +64,36 @@ wxSize Label::split_lines(wxDC &dc, int width, const wxString &text, wxString &m
|
|||
return dc.GetMultiLineTextExtent(multiline_text);
|
||||
}
|
||||
|
||||
Label::Label(wxWindow *parent, wxString const &text) : Label(parent, Body_14, text) {}
|
||||
Label::Label(wxWindow *parent, wxString const &text, long style) : Label(parent, Body_14, text, style) {}
|
||||
|
||||
Label::Label(wxWindow *parent, wxFont const &font, wxString const &text)
|
||||
: wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, 0)
|
||||
Label::Label(wxWindow *parent, wxFont const &font, wxString const &text, long style)
|
||||
: wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, style)
|
||||
{
|
||||
this->font = font;
|
||||
SetFont(font);
|
||||
SetBackgroundColour(StaticBox::GetParentBackgroundColor(parent));
|
||||
Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
|
||||
if (GetWindowStyle() & LB_HYPERLINK) {
|
||||
SetFont(this->font.Underlined());
|
||||
Refresh();
|
||||
}
|
||||
});
|
||||
Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) {
|
||||
SetFont(this->font);
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
|
||||
void Label::SetWindowStyleFlag(long style)
|
||||
{
|
||||
wxStaticText::SetWindowStyleFlag(style);
|
||||
if (style & LB_HYPERLINK) {
|
||||
this->color = GetForegroundColour();
|
||||
static wxColor clr_url("#00AE42");
|
||||
SetForegroundColour(clr_url);
|
||||
} else {
|
||||
SetForegroundColour(this->color);
|
||||
SetFont(this->font);
|
||||
}
|
||||
Refresh();
|
||||
}
|
||||
|
|
|
@ -3,12 +3,21 @@
|
|||
|
||||
#include <wx/stattext.h>
|
||||
|
||||
#define LB_HYPERLINK 0x0001
|
||||
|
||||
|
||||
class Label : public wxStaticText
|
||||
{
|
||||
public:
|
||||
Label(wxWindow *parent, wxString const &text = {});
|
||||
Label(wxWindow *parent, wxString const &text = {}, long style = 0);
|
||||
|
||||
Label(wxWindow *parent, wxFont const &font, wxString const &text = {});
|
||||
Label(wxWindow *parent, wxFont const &font, wxString const &text = {}, long style = 0);
|
||||
|
||||
void SetWindowStyleFlag(long style) override;
|
||||
|
||||
private:
|
||||
wxFont font;
|
||||
wxColour color;
|
||||
|
||||
public:
|
||||
static wxFont Head_24;
|
||||
|
|
|
@ -237,6 +237,7 @@ Button *SpinInput::createButton(bool inc)
|
|||
});
|
||||
btn->Bind(wxEVT_LEFT_DCLICK, [=](auto &e) {
|
||||
delta = inc ? 1 : -1;
|
||||
btn->CaptureMouse();
|
||||
SetValue(val + delta);
|
||||
sendSpinEvent();
|
||||
});
|
||||
|
|
|
@ -38,7 +38,7 @@ void wxMediaCtrl2::Load(wxURI url)
|
|||
wxExecute("cmd /c start " + url, wxEXEC_HIDE_CONSOLE);
|
||||
}
|
||||
});
|
||||
m_error = 2;
|
||||
m_error = 100;
|
||||
wxMediaEvent event(wxEVT_MEDIA_STATECHANGED);
|
||||
event.SetId(GetId());
|
||||
event.SetEventObject(this);
|
||||
|
@ -56,7 +56,7 @@ void wxMediaCtrl2::Load(wxURI url)
|
|||
wxMessageBox(_L("Missing BambuSource component registered for media playing! Please re-install BambuStutio or seek after-sales help."), _L("Error"),
|
||||
wxOK);
|
||||
});
|
||||
m_error = clsid.IsEmpty() ? 100 : clsid != L"{233E64FB-2041-4A6C-AFAB-FF9BCF83E7AA}" ? 101 : 102;
|
||||
m_error = clsid != L"{233E64FB-2041-4A6C-AFAB-FF9BCF83E7AA}" ? 101 : path.empty() ? 102 : 103;
|
||||
wxMediaEvent event(wxEVT_MEDIA_STATECHANGED);
|
||||
event.SetId(GetId());
|
||||
event.SetEventObject(this);
|
||||
|
|
Loading…
Reference in New Issue