FIX: unable to see filament group wiki in some cases
jira: NONE Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I4a36d2d89da42ded459680d402023a3e4e5d26f3
This commit is contained in:
parent
0dbd5417a8
commit
5fe05ffb53
|
@ -46,6 +46,50 @@ static void set_prefered_map_mode(FilamentMapMode mode)
|
|||
app_config->set("prefered_filament_map_mode", mode_str);
|
||||
}
|
||||
|
||||
bool play_dual_extruder_slice_video()
|
||||
{
|
||||
bool is_zh = wxGetApp().app_config->get("language") == "zh_CN";
|
||||
fs::path video_path;
|
||||
if (is_zh)
|
||||
video_path = fs::path(resources_dir()) / "videos/dual_extruder_slicing_zh.mp4";
|
||||
else
|
||||
video_path = fs::path(resources_dir()) / "videos/dual_extruder_slicing_en.mp4";
|
||||
wxString video_path_str = wxString::FromUTF8(video_path.string());
|
||||
|
||||
if (wxFileExists(video_path_str)) {
|
||||
if (wxLaunchDefaultApplication(video_path_str)) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("Video is being played using the system's default player.");
|
||||
return true;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("launch system's default player failed");
|
||||
return false;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("Video file does not exist: %s") % video_path_str.ToStdString();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool open_filament_group_wiki()
|
||||
{
|
||||
bool is_zh = wxGetApp().app_config->get("language") == "zh_CN";
|
||||
fs::path wiki_path;
|
||||
if (is_zh)
|
||||
wiki_path = fs::path(resources_dir()) / "/wiki/filament_group_wiki_zh.html";
|
||||
else
|
||||
wiki_path = fs::path(resources_dir()) / "/wiki/filament_group_wiki_en.html";
|
||||
|
||||
wxString wiki_path_str = wxString::FromUTF8(wiki_path.string());
|
||||
if (wxFileExists(wiki_path_str)) {
|
||||
if (wxLaunchDefaultBrowser(wiki_path_str)) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("Wiki is being displayed using the system's default browser.");
|
||||
return true;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("launch system's default browser failed");
|
||||
return false;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("Wiki file does not exist: %s") % wiki_path_str.ToStdString();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS)
|
||||
{
|
||||
|
@ -149,38 +193,15 @@ FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, w
|
|||
video_link->SetForegroundColour(GreenColor);
|
||||
video_link->SetFont(Label::Body_12.Underlined());
|
||||
video_link->SetCursor(wxCursor(wxCURSOR_HAND));
|
||||
video_link->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent &)
|
||||
{
|
||||
bool is_zh = wxGetApp().app_config->get("language") == "zh_CN";
|
||||
fs::path video_path;
|
||||
if (is_zh)
|
||||
video_path = fs::path(resources_dir()) / "videos/dual_extruder_slicing_zh.mp4";
|
||||
else
|
||||
video_path = fs::path(resources_dir()) / "videos/dual_extruder_slicing_en.mp4";
|
||||
wxString video_path_str = wxString::FromUTF8(video_path.string());
|
||||
|
||||
if (wxFileExists(video_path_str)) {
|
||||
if (wxLaunchDefaultApplication(video_path_str)) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("Video is being played using the system's default player.");
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("launch system's default player failed");
|
||||
}
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("Video file does not exist: %s")%video_path_str.ToStdString();
|
||||
}
|
||||
|
||||
wxGetApp().app_config->set("play_slicing_video", "false");
|
||||
});
|
||||
video_link->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent&)
|
||||
{
|
||||
play_dual_extruder_slice_video();
|
||||
wxGetApp().app_config->set("play_slicing_video", "false");
|
||||
});
|
||||
video_sizer->Add(video_link, 0, wxALIGN_CENTER | wxALL, FromDIP(3));
|
||||
button_sizer->Add(video_sizer, 0, wxLEFT, horizontal_margin);
|
||||
button_sizer->AddStretchSpacer();
|
||||
|
||||
bool is_zh = wxGetApp().app_config->get("language") == "zh_CN";
|
||||
std::string wiki_path;
|
||||
if(is_zh)
|
||||
wiki_path = Slic3r::resources_dir() + "/wiki/filament_group_wiki_zh.html";
|
||||
else
|
||||
wiki_path = Slic3r::resources_dir() + "/wiki/filament_group_wiki_en.html";
|
||||
|
||||
auto* wiki_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
wiki_link = new wxStaticText(this, wxID_ANY, _L("Learn more"));
|
||||
|
@ -188,7 +209,7 @@ FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, w
|
|||
wiki_link->SetForegroundColour(GreenColor);
|
||||
wiki_link->SetFont(Label::Body_12.Underlined());
|
||||
wiki_link->SetCursor(wxCursor(wxCURSOR_HAND));
|
||||
wiki_link->Bind(wxEVT_LEFT_DOWN, [wiki_path](wxMouseEvent &) { wxLaunchDefaultBrowser(wxString(wiki_path.c_str())); });
|
||||
wiki_link->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent&) { open_filament_group_wiki(); });
|
||||
wiki_sizer->Add(wiki_link, 0, wxALIGN_CENTER | wxALL, FromDIP(3));
|
||||
|
||||
button_sizer->Add(wiki_sizer, 0, wxLEFT, horizontal_margin);
|
||||
|
|
|
@ -10,6 +10,9 @@ class PartPlate;
|
|||
class Plater;
|
||||
|
||||
|
||||
bool play_dual_extruder_slice_video();
|
||||
bool open_filament_group_wiki();
|
||||
|
||||
class FilamentGroupPopup : public PopupWindow
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -4677,13 +4677,7 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding)
|
|||
// click behavior
|
||||
if (ImGui::IsMouseHoveringRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), true)) {
|
||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||
bool is_zh = wxGetApp().app_config->get("language") == "zh_CN";
|
||||
std::string wiki_path;
|
||||
if(is_zh)
|
||||
wiki_path = Slic3r::resources_dir() + "/wiki/filament_group_wiki_zh.html";
|
||||
else
|
||||
wiki_path = Slic3r::resources_dir() + "/wiki/filament_group_wiki_en.html";
|
||||
wxLaunchDefaultBrowser(wxString(wiki_path.c_str()));
|
||||
open_filament_group_wiki();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1659,35 +1659,16 @@ wxBoxSizer* MainFrame::create_side_tools()
|
|||
|
||||
if (slice) {
|
||||
std::string printer_model = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_string("printer_model");
|
||||
bool do_slicing = true;
|
||||
if ((wxGetApp().app_config->get("play_slicing_video") == "true") && (printer_model == "Bambu Lab H2D"))
|
||||
{
|
||||
if ((wxGetApp().app_config->get("play_slicing_video") == "true") && (printer_model == "Bambu Lab H2D")) {
|
||||
MessageDialog dlg(this, _L("This is your first time slicing with the H2D machine.\nWould you like to watch a quick tutorial video?"), _L("First Guide"), wxYES_NO);
|
||||
auto res = dlg.ShowModal();
|
||||
if (res == wxID_YES) {
|
||||
bool is_zh = wxGetApp().app_config->get("language") == "zh_CN";
|
||||
fs::path video_path;
|
||||
if (is_zh)
|
||||
video_path = fs::path(resources_dir()) / "videos/dual_extruder_slicing_zh.mp4";
|
||||
else
|
||||
video_path = fs::path(resources_dir()) / "videos/dual_extruder_slicing_en.mp4";
|
||||
wxString video_path_str = wxString::FromUTF8(video_path.string());
|
||||
|
||||
if (wxFileExists(video_path_str)) {
|
||||
if (wxLaunchDefaultApplication(video_path_str)) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("Video is being played using the system's default player.");
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("launch system's default player failed");
|
||||
}
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("Video file does not exist: %s")%video_path_str.ToStdString();
|
||||
}
|
||||
do_slicing = false;
|
||||
play_dual_extruder_slice_video();
|
||||
slice = false;
|
||||
}
|
||||
|
||||
wxGetApp().app_config->set("play_slicing_video", "false");
|
||||
}
|
||||
if (do_slicing) {
|
||||
if (slice) {
|
||||
if (m_slice_select == eSliceAll)
|
||||
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SLICE_ALL));
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue