mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 13:08:57 +08:00
Webview loading html page
This commit is contained in:
parent
8ee04288fb
commit
1d71b5338a
77
resources/web/connect_loading.html
Normal file
77
resources/web/connect_loading.html
Normal file
@ -0,0 +1,77 @@
|
||||
<!doctype html>
|
||||
<html lang='en'>
|
||||
<head>
|
||||
<meta charset='UTF-8' />
|
||||
<meta content='width=device-width, initial-scale=1.0' name='viewport' />
|
||||
<title>Connect-Slicer integration</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- This page is not served anywhere, only to be copy 'n' pasted into Slicer as a fallback loading screen. -->
|
||||
<div id='loading-screen' style='width: 100%; height: 100%'>
|
||||
<div style='position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center'>
|
||||
<p>
|
||||
<svg height='100%' style='width: 250px; fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'
|
||||
version='1.1' viewBox='0 0 10584 1835' width='100%'
|
||||
xml:space='preserve' xmlns='http://www.w3.org/2000/svg'
|
||||
>
|
||||
<path d='M 10485.267,532.67639 4431.78,535.92 v 1298.52 h 6058.92 l -5.433,-1301.76361 z M 0,535.92 H 4257.14 V 1834.44 H 0 Z m 427.69,409.16 h 142.58 c 65.02,0 114.07,29.65 114.07,107.22 0,74.14 -46.76,101.52 -114.07,101.52 H 427.69 Z m -212.17,644.48 h 212.17 v -271.48 h 174.52 c 179.09,0 294.3,-78.71 294.3,-280.61 0,-192.77 -142.59,-262.36 -294.3,-262.36 H 215.52 Z m 957.61,-644.48 h 168.82 c 59.32,0 107.22,27.37 107.22,87.83 0,62.74 -34.22,95.82 -98.09,95.82 h -177.95 z m -212.17,644.48 h 212.17 v -296.58 h 160.84 c 100.38,0 112.92,84.41 118.63,166.54 3.42,23.96 5.7,101.52 23.95,130.04 h 209.89 c -28.52,-31.94 -30.8,-148.29 -34.22,-183.65 -5.71,-77.57 -33.08,-173.38 -118.64,-195.06 v -2.28 c 86.7,-33.08 127.76,-116.35 127.76,-204.18 0,-164.26 -142.58,-229.28 -285.17,-229.28 H 960.96 Z M 2452.4,775.11 h -212.16 v 490.5 c 0,104.94 -37.65,158.55 -142.59,158.55 -104.94,0 -142.58,-53.61 -142.58,-158.55 V 775.11 H 1742.9 v 477.95 c 0,236.12 108.36,353.61 354.75,353.61 246.39,0 354.75,-117.49 354.75,-353.61 z m 58.75,540.69 c 0,208.74 167.68,290.87 353.61,290.87 179.08,0 354.75,-66.16 354.75,-272.62 0,-147.15 -118.63,-201.9 -236.12,-234.98 -118.63,-33.08 -236.12,-43.35 -236.12,-107.23 0,-53.61 57.03,-69.58 102.66,-69.58 63.88,0 134.6,25.1 131.18,98.1 h 212.16 c 0,-182.51 -165.4,-262.36 -326.23,-262.36 -152.85,0 -331.94,69.59 -331.94,247.53 0,150.57 123.19,201.9 238.4,234.98 117.49,33.08 233.84,45.63 233.84,118.63 0,60.46 -66.16,83.27 -130.04,83.27 -91.25,0 -149.43,-30.8 -153.99,-126.61 z m 688.39,273.76 h 217.87 l 51.33,-146.01 h 284.03 l 50.19,146.01 h 221.3 L 3719.69,775.11 h -215.58 z m 410.65,-588.59 h 2.28 l 90.11,285.17 h -184.79 z m 1840.23,65.02 C 5444.72,869.79 5255.37,758 5078.56,758 c -247.53,0 -406.08,188.22 -406.08,424.34 0,236.12 158.55,424.33 406.08,424.33 206.46,0 359.31,-122.05 371.86,-333.08 h -212.16 c -7.99,94.68 -63.88,150.57 -164.26,150.57 -136.88,0 -189.35,-119.77 -189.35,-241.82 0,-122.06 52.47,-241.83 189.35,-241.83 90.11,0 151.71,43.35 164.26,125.48 z m 258.37,116.35 c 0,-122.06 52.47,-241.83 189.35,-241.83 136.89,0 189.36,119.77 189.36,241.83 0,122.05 -52.47,241.82 -189.36,241.82 -136.88,0 -189.35,-119.77 -189.35,-241.82 z m -212.16,0 c 0,236.12 146,424.33 401.51,424.33 255.52,0 401.52,-188.21 401.52,-424.33 0,-236.12 -146,-424.34 -401.52,-424.34 -255.51,0 -401.51,188.22 -401.51,424.34 z m 880.03,407.22 h 199.62 v -507.6 h 2.28 l 282.89,507.6 h 217.87 V 775.11 H 6879.7 v 501.9 h -2.28 l -282.89,-501.9 h -217.87 z m 809.31,0 h 199.62 v -507.6 h 2.28 l 282.89,507.6 h 217.87 V 775.11 h -199.62 v 501.9 h -2.28 l -282.89,-501.9 h -217.87 z m 811.59,0 h 660.46 v -182.51 h -448.29 v -155.13 h 399.24 V 1087.66 H 8209.73 V 945.08 h 436.88 V 775.11 H 7997.56 Z M 9495.85,1065.99 C 9490.15,869.79 9300.8,758 9123.99,758 c -247.53,0 -406.08,188.22 -406.08,424.34 0,236.12 158.55,424.33 406.08,424.33 206.46,0 359.31,-122.05 371.86,-333.08 h -212.16 c -7.99,94.68 -63.88,150.57 -164.26,150.57 -136.88,0 -189.35,-119.77 -189.35,-241.82 0,-122.06 52.47,-241.83 189.35,-241.83 90.11,0 151.71,43.35 164.26,125.48 z m 722.65,-290.88 h -698.12 v 182.51 h 242.97 v 631.94 h 212.16 V 957.62 h 242.99 z'
|
||||
fill='var(--color-text)' />
|
||||
</svg>
|
||||
</p>
|
||||
<p>
|
||||
<svg style='width: 80px'
|
||||
viewBox='-250 -250 500 500' xmlns='http://www.w3.org/2000/svg'>
|
||||
<style type='text/css'>
|
||||
.filament {
|
||||
stroke: #FA6831;
|
||||
}
|
||||
|
||||
.spool {
|
||||
stroke: #231F20;
|
||||
fill: none;
|
||||
}
|
||||
|
||||
.filament line {
|
||||
stroke-linecap: round;
|
||||
}
|
||||
</style>
|
||||
<defs>
|
||||
<pattern class='spool' height='100' id='hexagon' patternTransform='scale(0.875)' patternUnits='userSpaceOnUse'
|
||||
viewBox='-0.866025 -1.5 1.73205 3'
|
||||
width='57.735'
|
||||
>
|
||||
<polygon fill='none' points='0,1 0.866025,0.5 0.866025,-0.5 0,-1 -0.866025,-0.5 -0.866025,0.5'
|
||||
stroke-width='0.34' />
|
||||
<line stroke-width='0.34' x1='0' x2='0' y1='1' y2='1.5'></line>
|
||||
<line stroke-width='0.34' x1='0' x2='0' y1='-1' y2='-1.5'></line>
|
||||
</pattern>
|
||||
</defs>
|
||||
<g class='filament'>
|
||||
<circle fill='none' r='145' stroke-width='130'>
|
||||
<animate attributeName='r' dur='6s' repeatCount='indefinite' values='145;80;145' />
|
||||
<animate attributeName='stroke-width' dur='6s' repeatCount='indefinite' values='130;0;130' />
|
||||
</circle>
|
||||
<line stroke-width='12' x1='204' x2='204' y1='0' y2='245'>
|
||||
<animate attributeName='x1' dur='6s' repeatCount='indefinite' values='204;74;204' />
|
||||
<animate attributeName='x2' dur='6s' repeatCount='indefinite' values='204;74;204' />
|
||||
</line>
|
||||
</g>
|
||||
<g class='spool'>
|
||||
<circle fill='none' r='157' stroke='url(#hexagon)' stroke-width='171' />
|
||||
<circle r='244' stroke-width='12' />
|
||||
<circle r='71' stroke-width='18' />
|
||||
<animateTransform
|
||||
attributeName='transform' begin='0s'
|
||||
dur='6s'
|
||||
fill='freeze'
|
||||
repeatCount='indefinite'
|
||||
type='rotate'
|
||||
values='0;540;0'
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
68
resources/web/loading.html
Normal file
68
resources/web/loading.html
Normal file
@ -0,0 +1,68 @@
|
||||
<!doctype html>
|
||||
<html lang='en'>
|
||||
<head>
|
||||
<meta charset='UTF-8' />
|
||||
<meta content='width=device-width, initial-scale=1.0' name='viewport' />
|
||||
<title>Connect-Slicer integration</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- This page is not served anywhere, only to be copy 'n' pasted into Slicer as a fallback loading screen. -->
|
||||
<div id='loading-screen' style='width: 100%; height: 100%'>
|
||||
<div style='position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center'>
|
||||
<p>
|
||||
<svg style='width: 80px'
|
||||
viewBox='-250 -250 500 500' xmlns='http://www.w3.org/2000/svg'>
|
||||
<style type='text/css'>
|
||||
.filament {
|
||||
stroke: #FA6831;
|
||||
}
|
||||
|
||||
.spool {
|
||||
stroke: #231F20;
|
||||
fill: none;
|
||||
}
|
||||
|
||||
.filament line {
|
||||
stroke-linecap: round;
|
||||
}
|
||||
</style>
|
||||
<defs>
|
||||
<pattern class='spool' height='100' id='hexagon' patternTransform='scale(0.875)' patternUnits='userSpaceOnUse'
|
||||
viewBox='-0.866025 -1.5 1.73205 3'
|
||||
width='57.735'
|
||||
>
|
||||
<polygon fill='none' points='0,1 0.866025,0.5 0.866025,-0.5 0,-1 -0.866025,-0.5 -0.866025,0.5'
|
||||
stroke-width='0.34' />
|
||||
<line stroke-width='0.34' x1='0' x2='0' y1='1' y2='1.5'></line>
|
||||
<line stroke-width='0.34' x1='0' x2='0' y1='-1' y2='-1.5'></line>
|
||||
</pattern>
|
||||
</defs>
|
||||
<g class='filament'>
|
||||
<circle fill='none' r='145' stroke-width='130'>
|
||||
<animate attributeName='r' dur='6s' repeatCount='indefinite' values='145;80;145' />
|
||||
<animate attributeName='stroke-width' dur='6s' repeatCount='indefinite' values='130;0;130' />
|
||||
</circle>
|
||||
<line stroke-width='12' x1='204' x2='204' y1='0' y2='245'>
|
||||
<animate attributeName='x1' dur='6s' repeatCount='indefinite' values='204;74;204' />
|
||||
<animate attributeName='x2' dur='6s' repeatCount='indefinite' values='204;74;204' />
|
||||
</line>
|
||||
</g>
|
||||
<g class='spool'>
|
||||
<circle fill='none' r='157' stroke='url(#hexagon)' stroke-width='171' />
|
||||
<circle r='244' stroke-width='12' />
|
||||
<circle r='71' stroke-width='18' />
|
||||
<animateTransform
|
||||
attributeName='transform' begin='0s'
|
||||
dur='6s'
|
||||
fill='freeze'
|
||||
repeatCount='indefinite'
|
||||
type='rotate'
|
||||
values='0;540;0'
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -22,9 +22,10 @@ namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
|
||||
WebViewPanel::WebViewPanel(wxWindow *parent, const wxString& default_url)
|
||||
WebViewPanel::WebViewPanel(wxWindow *parent, const wxString& default_url, const std::string& loading_html/* = "loading"*/)
|
||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
|
||||
, m_default_url (default_url)
|
||||
, m_loading_html(loading_html)
|
||||
{
|
||||
wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
|
||||
#ifdef DEBUG_URL_PANEL
|
||||
@ -69,7 +70,7 @@ WebViewPanel::WebViewPanel(wxWindow *parent, const wxString& default_url)
|
||||
SetSizer(topsizer);
|
||||
|
||||
// Create the webview
|
||||
m_browser = WebView::CreateWebView(this, /*m_default_url*/ GUI::format_wxstr("file://%1%/web/connection_failed.html", boost::filesystem::path(resources_dir()).generic_string()));
|
||||
m_browser = WebView::CreateWebView(this, /*m_default_url*/ GUI::format_wxstr("file://%1%/web/%2%.html", boost::filesystem::path(resources_dir()).generic_string(), m_loading_html));
|
||||
if (!m_browser) {
|
||||
wxStaticText* text = new wxStaticText(this, wxID_ANY, _L("Failed to load a web browser."));
|
||||
topsizer->Add(text, 0, wxALIGN_LEFT | wxBOTTOM, 10);
|
||||
@ -125,7 +126,6 @@ WebViewPanel::WebViewPanel(wxWindow *parent, const wxString& default_url)
|
||||
Bind(wxEVT_IDLE, &WebViewPanel::on_idle, this);
|
||||
Bind(wxEVT_CLOSE_WINDOW, &WebViewPanel::on_close, this);
|
||||
|
||||
m_LoginUpdateTimer = nullptr;
|
||||
}
|
||||
|
||||
WebViewPanel::~WebViewPanel()
|
||||
@ -133,12 +133,6 @@ WebViewPanel::~WebViewPanel()
|
||||
SetEvtHandlerEnabled(false);
|
||||
#ifdef DEBUG_URL_PANEL
|
||||
delete m_tools_menu;
|
||||
|
||||
if (m_LoginUpdateTimer != nullptr) {
|
||||
m_LoginUpdateTimer->Stop();
|
||||
delete m_LoginUpdateTimer;
|
||||
m_LoginUpdateTimer = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -549,7 +543,7 @@ void ConnectRequestHandler::on_request_config()
|
||||
}
|
||||
|
||||
ConnectWebViewPanel::ConnectWebViewPanel(wxWindow* parent)
|
||||
: WebViewPanel(parent, L"https://connect.prusa3d.com/connect-slicer-app/")
|
||||
: WebViewPanel(parent, L"https://connect.prusa3d.com/connect-slicer-app/", "connect_loading")
|
||||
{
|
||||
}
|
||||
|
||||
@ -651,14 +645,15 @@ void PrinterWebViewPanel::sys_color_changed()
|
||||
{
|
||||
}
|
||||
|
||||
WebViewDialog::WebViewDialog(wxWindow* parent, const wxString& url, const wxString& dialog_name, const wxSize& size)
|
||||
WebViewDialog::WebViewDialog(wxWindow* parent, const wxString& url, const wxString& dialog_name, const wxSize& size, const std::string& loading_html/* = "loading"*/)
|
||||
: wxDialog(parent, wxID_ANY, dialog_name, wxDefaultPosition, size, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
, m_loading_html(loading_html)
|
||||
{
|
||||
wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
|
||||
SetSizer(topsizer);
|
||||
|
||||
// Create the webview
|
||||
m_browser = WebView::CreateWebView(this, url);
|
||||
m_browser = WebView::CreateWebView(this, GUI::format_wxstr("file://%1%/web/%2%.html", boost::filesystem::path(resources_dir()).generic_string(), m_loading_html));
|
||||
if (!m_browser) {
|
||||
wxStaticText* text = new wxStaticText(this, wxID_ANY, _L("Failed to load a web browser."));
|
||||
topsizer->Add(text, 0, wxALIGN_LEFT | wxBOTTOM, 10);
|
||||
@ -669,6 +664,8 @@ WebViewDialog::WebViewDialog(wxWindow* parent, const wxString& url, const wxStri
|
||||
|
||||
Bind(wxEVT_SHOW, &WebViewDialog::on_show, this);
|
||||
Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &WebViewDialog::on_script_message, this, m_browser->GetId());
|
||||
|
||||
m_browser->LoadURL(url);
|
||||
}
|
||||
WebViewDialog::~WebViewDialog()
|
||||
{
|
||||
@ -682,7 +679,11 @@ void WebViewDialog::run_script(const wxString& javascript)
|
||||
}
|
||||
|
||||
PrinterPickWebViewDialog::PrinterPickWebViewDialog(wxWindow* parent, std::string& ret_val)
|
||||
: WebViewDialog(parent, L"https://connect.prusa3d.com/connect-slicer-app/printer-list", _L("Choose a printer"), wxSize(std::max(parent->GetClientSize().x / 2, 100 * wxGetApp().em_unit()), std::max(parent->GetClientSize().y / 2, 50 * wxGetApp().em_unit())))
|
||||
: WebViewDialog(parent
|
||||
, L"https://connect.prusa3d.com/connect-slicer-app/printer-list"
|
||||
, _L("Choose a printer")
|
||||
, wxSize(std::max(parent->GetClientSize().x / 2, 100 * wxGetApp().em_unit()), std::max(parent->GetClientSize().y / 2, 50 * wxGetApp().em_unit()))
|
||||
, "connect_loading")
|
||||
, m_ret_val(ret_val)
|
||||
{
|
||||
Centre();
|
||||
|
@ -16,7 +16,7 @@ namespace GUI {
|
||||
class WebViewPanel : public wxPanel
|
||||
{
|
||||
public:
|
||||
WebViewPanel(wxWindow *parent, const wxString& default_url);
|
||||
WebViewPanel(wxWindow *parent, const wxString& default_url, const std::string& loading_html = "loading");
|
||||
virtual ~WebViewPanel();
|
||||
|
||||
void load_url(const wxString& url);
|
||||
@ -49,8 +49,6 @@ public:
|
||||
void On_enable_dev_tools(wxCommandEvent& evt);
|
||||
void on_close(wxCloseEvent& evt);
|
||||
|
||||
wxTimer * m_LoginUpdateTimer{nullptr};
|
||||
|
||||
wxString get_default_url() const { return m_default_url; }
|
||||
void set_default_url(const wxString& url) { m_default_url = url; }
|
||||
|
||||
@ -85,6 +83,7 @@ protected:
|
||||
wxString m_response_js;
|
||||
wxString m_default_url;
|
||||
|
||||
std::string m_loading_html;
|
||||
//DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
@ -146,7 +145,7 @@ private:
|
||||
class WebViewDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
WebViewDialog(wxWindow* parent, const wxString& url, const wxString& dialog_name, const wxSize& size);
|
||||
WebViewDialog(wxWindow* parent, const wxString& url, const wxString& dialog_name, const wxSize& size, const std::string& loading_html = "loading");
|
||||
virtual ~WebViewDialog();
|
||||
|
||||
virtual void on_show(wxShowEvent& evt) = 0;
|
||||
@ -156,6 +155,7 @@ public:
|
||||
|
||||
protected:
|
||||
wxWebView* m_browser;
|
||||
std::string m_loading_html;
|
||||
};
|
||||
|
||||
class PrinterPickWebViewDialog : public WebViewDialog, public ConnectRequestHandler
|
||||
|
Loading…
x
Reference in New Issue
Block a user