mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-15 03:41:28 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5165c3e75 | ||
|
|
0a336941f4 |
@@ -10,6 +10,11 @@ function OnInit()
|
|||||||
// Orca: fallback timeout in case the C++ -> JS signal fails (e.g., WebKit issues).
|
// Orca: fallback timeout in case the C++ -> JS signal fails (e.g., WebKit issues).
|
||||||
// Jump to the target page after 3 minutes so slow computers don't get stuck on a partially loaded page.
|
// Jump to the target page after 3 minutes so slow computers don't get stuck on a partially loaded page.
|
||||||
setTimeout("JumpToTarget()",180*1000);
|
setTimeout("JumpToTarget()",180*1000);
|
||||||
|
|
||||||
|
var tSend={};
|
||||||
|
tSend['sequence_id']=Math.round(new Date() / 1000);
|
||||||
|
tSend['command']="userguide_loading_page_ready";
|
||||||
|
SendWXMessage(JSON.stringify(tSend));
|
||||||
}
|
}
|
||||||
|
|
||||||
function HandleStudio( pVal )
|
function HandleStudio( pVal )
|
||||||
|
|||||||
@@ -450,6 +450,16 @@ void GuideFrame::on_profile_loaded()
|
|||||||
SaveProfileData();
|
SaveProfileData();
|
||||||
const std::string strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
|
const std::string strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished, json contents:\n" << strAll;
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished, json contents:\n" << strAll;
|
||||||
|
m_profile_ready = true;
|
||||||
|
notify_profile_loaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The data is often ready before the loading page has run its scripts, and a
|
||||||
|
// call into a page without HandleStudio is lost, so the message waits for both.
|
||||||
|
void GuideFrame::notify_profile_loaded()
|
||||||
|
{
|
||||||
|
if (!m_profile_ready || !m_page_ready)
|
||||||
|
return;
|
||||||
json res;
|
json res;
|
||||||
res["command"] = "userguide_profile_load_finish";
|
res["command"] = "userguide_profile_load_finish";
|
||||||
res["sequence_id"] = "10001";
|
res["sequence_id"] = "10001";
|
||||||
@@ -545,7 +555,11 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
|
|||||||
wxString strCmd = j["command"];
|
wxString strCmd = j["command"];
|
||||||
BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;Command:" << strCmd;
|
BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;Command:" << strCmd;
|
||||||
|
|
||||||
if (strCmd == "close_page") {
|
if (strCmd == "userguide_loading_page_ready") {
|
||||||
|
m_page_ready = true;
|
||||||
|
notify_profile_loaded();
|
||||||
|
}
|
||||||
|
else if (strCmd == "close_page") {
|
||||||
this->EndModal(wxID_CANCEL);
|
this->EndModal(wxID_CANCEL);
|
||||||
}
|
}
|
||||||
if (strCmd == "user_clause") {
|
if (strCmd == "user_clause") {
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ public:
|
|||||||
int LoadProfileFamily(std::string strVendor, std::string strFilePath);
|
int LoadProfileFamily(std::string strVendor, std::string strFilePath);
|
||||||
void init_guide_paths();
|
void init_guide_paths();
|
||||||
void on_profile_loaded();
|
void on_profile_loaded();
|
||||||
|
void notify_profile_loaded();
|
||||||
bool BuildProfileJson(const PresetBundle& bundle, bool require_all_resource_vendors);
|
bool BuildProfileJson(const PresetBundle& bundle, bool require_all_resource_vendors);
|
||||||
bool BuildProfileDataFromPresetBundle();
|
bool BuildProfileDataFromPresetBundle();
|
||||||
bool BuildProfileDataFromVendors();
|
bool BuildProfileDataFromVendors();
|
||||||
@@ -142,6 +143,10 @@ private:
|
|||||||
|
|
||||||
//First Load
|
//First Load
|
||||||
bool bFirstComplete{false};
|
bool bFirstComplete{false};
|
||||||
|
// The loading page gets userguide_profile_load_finish once both are true;
|
||||||
|
// every instance of it reports in, so the flag is never reset.
|
||||||
|
bool m_profile_ready{false};
|
||||||
|
bool m_page_ready{false};
|
||||||
// Set once in the destructor. Read through `this` by the loading thread
|
// Set once in the destructor. Read through `this` by the loading thread
|
||||||
// (joined before `this` dies) and captured as the shared_ptr by CallAfter
|
// (joined before `this` dies) and captured as the shared_ptr by CallAfter
|
||||||
// lambdas so they don't touch `this` after the object is freed.
|
// lambdas so they don't touch `this` after the object is freed.
|
||||||
|
|||||||
@@ -56,7 +56,12 @@ namespace fs = boost::filesystem;
|
|||||||
#define WEBKIT_API
|
#define WEBKIT_API
|
||||||
struct WebKitWebView;
|
struct WebKitWebView;
|
||||||
struct WebKitJavascriptResult;
|
struct WebKitJavascriptResult;
|
||||||
|
struct WebKitSettings;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
WEBKIT_API WebKitSettings *
|
||||||
|
webkit_settings_new (void);
|
||||||
|
WEBKIT_API const gchar *
|
||||||
|
webkit_settings_get_user_agent (WebKitSettings *settings);
|
||||||
WEBKIT_API void
|
WEBKIT_API void
|
||||||
webkit_web_view_run_javascript (WebKitWebView *web_view,
|
webkit_web_view_run_javascript (WebKitWebView *web_view,
|
||||||
const gchar *script,
|
const gchar *script,
|
||||||
@@ -284,6 +289,23 @@ static WebViewRef *webview_ref(wxWebView *webView)
|
|||||||
return webView ? static_cast<WebViewRef *>(webView->GetRefData()) : nullptr;
|
return webView ? static_cast<WebViewRef *>(webView->GetRefData()) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
// WebKitGTK's own User-Agent with the tags the bundled pages (globalapi.js) and Bambu's cloud read
|
||||||
|
// appended. wx's GTK backend cannot report the stock string, so it comes from a throwaway settings object.
|
||||||
|
static wxString linux_user_agent()
|
||||||
|
{
|
||||||
|
static const wxString stock = [] {
|
||||||
|
WebKitSettings *settings = webkit_settings_new();
|
||||||
|
wxString ua = wxString::FromUTF8(webkit_settings_get_user_agent(settings));
|
||||||
|
g_object_unref(settings);
|
||||||
|
return ua;
|
||||||
|
}();
|
||||||
|
return wxString::Format("%s BBL-Slicer/v%s (%s) BBL-Language/%s", stock, Slic3r::GUI::wxGetApp().get_bbl_client_version(),
|
||||||
|
Slic3r::GUI::wxGetApp().dark_mode() ? "dark" : "light",
|
||||||
|
Slic3r::GUI::wxGetApp().current_language_code().BeforeFirst('_'));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
|
wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
|
||||||
{
|
{
|
||||||
#if wxUSE_WEBVIEW_EDGE
|
#if wxUSE_WEBVIEW_EDGE
|
||||||
@@ -336,7 +358,9 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
|
|||||||
s_schemes_registered = true;
|
s_schemes_registered = true;
|
||||||
}
|
}
|
||||||
webView->Create(parent, wxID_ANY, url2, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
webView->Create(parent, wxID_ANY, url2, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||||
#ifndef __linux__
|
#ifdef __linux__
|
||||||
|
webView->SetUserAgent(linux_user_agent());
|
||||||
|
#else
|
||||||
webView->SetUserAgent(wxString::Format("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) BBL-Slicer/v%s (%s) BBL-Language/%s",
|
webView->SetUserAgent(wxString::Format("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) BBL-Slicer/v%s (%s) BBL-Language/%s",
|
||||||
Slic3r::GUI::wxGetApp().get_bbl_client_version(), Slic3r::GUI::wxGetApp().dark_mode() ? "dark" : "light", language_code.mb_str()));
|
Slic3r::GUI::wxGetApp().get_bbl_client_version(), Slic3r::GUI::wxGetApp().dark_mode() ? "dark" : "light", language_code.mb_str()));
|
||||||
#endif
|
#endif
|
||||||
@@ -472,7 +496,9 @@ void WebView::RecreateAll()
|
|||||||
wxString language_code = Slic3r::GUI::wxGetApp().current_language_code().BeforeFirst('_');
|
wxString language_code = Slic3r::GUI::wxGetApp().current_language_code().BeforeFirst('_');
|
||||||
language_code = language_code.ToStdString();
|
language_code = language_code.ToStdString();
|
||||||
for (auto webView : g_webviews) {
|
for (auto webView : g_webviews) {
|
||||||
#ifndef __linux__
|
#ifdef __linux__
|
||||||
|
webView->SetUserAgent(linux_user_agent());
|
||||||
|
#else
|
||||||
webView->SetUserAgent(wxString::Format("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) BBL-Slicer/v%s (%s) BBL-Language/%s",
|
webView->SetUserAgent(wxString::Format("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) BBL-Slicer/v%s (%s) BBL-Language/%s",
|
||||||
Slic3r::GUI::wxGetApp().get_bbl_client_version(), dark ? "dark" : "light", language_code.mb_str()));
|
Slic3r::GUI::wxGetApp().get_bbl_client_version(), dark ? "dark" : "light", language_code.mb_str()));
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user