mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 12:05:53 +08:00
SPE-2515: Improved reload functionality
Fix of script message after error with credentials /api key Reload improvements additional webview checks Reload webview on F5 for mac / linux Rename button Fix of loading error page
This commit is contained in:
parent
9f42394629
commit
85094c5c19
@ -1,28 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Connection failed</title>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 100vh;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<h1>Connection failed</h1>
|
|
||||||
<p>Something went wrong.</p>
|
|
||||||
<button style="margin-top: 20px; padding: 10px 20px; font-size: 16px;" onclick="window._prusaSlicer.postMessage(JSON.stringify({ action: 'RELOAD_HOME_PAGE' }))">Reload</button>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
106
resources/web/connect_error.html
Normal file
106
resources/web/connect_error.html
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
<!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>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
background-color: #f6f6f6;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.reload-button {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 12px 24px;
|
||||||
|
font-size: 16px;
|
||||||
|
color: black;
|
||||||
|
background-color: white;
|
||||||
|
border: 2px solid black;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: bold;
|
||||||
|
transition: background-color 0.3s ease, color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reload-button:hover {
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reload-button:focus {
|
||||||
|
outline: none;
|
||||||
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</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: #FF0033;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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>
|
||||||
|
<p style="font-size: 24px;">Something went wrong.</p>
|
||||||
|
<button class="reload-button" onclick="window._prusaSlicer.postMessage(JSON.stringify({ action: 'RELOAD_HOME_PAGE' }))">Reload</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
82
resources/web/error_no_reload.html
Normal file
82
resources/web/error_no_reload.html
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<!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>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
background-color: #f6f6f6;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</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: #FF0033;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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>
|
||||||
|
<p style="font-size: 24px;">Something went wrong.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -4,6 +4,42 @@
|
|||||||
<meta charset='UTF-8' />
|
<meta charset='UTF-8' />
|
||||||
<meta content='width=device-width, initial-scale=1.0' name='viewport' />
|
<meta content='width=device-width, initial-scale=1.0' name='viewport' />
|
||||||
<title>Connect-Slicer integration</title>
|
<title>Connect-Slicer integration</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
background-color: #f6f6f6;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.reload-button {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 12px 24px;
|
||||||
|
font-size: 16px;
|
||||||
|
color: black;
|
||||||
|
background-color: white;
|
||||||
|
border: 2px solid black;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: bold;
|
||||||
|
transition: background-color 0.3s ease, color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reload-button:hover {
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reload-button:focus {
|
||||||
|
outline: none;
|
||||||
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- This page is not served anywhere, only to be copy 'n' pasted into Slicer as a fallback loading screen. -->
|
<!-- This page is not served anywhere, only to be copy 'n' pasted into Slicer as a fallback loading screen. -->
|
||||||
@ -14,7 +50,7 @@
|
|||||||
viewBox='-250 -250 500 500' xmlns='http://www.w3.org/2000/svg'>
|
viewBox='-250 -250 500 500' xmlns='http://www.w3.org/2000/svg'>
|
||||||
<style type='text/css'>
|
<style type='text/css'>
|
||||||
.filament {
|
.filament {
|
||||||
stroke: #FA6831;
|
stroke: #FF0033;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spool {
|
.spool {
|
||||||
@ -63,7 +99,7 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</p>
|
</p>
|
||||||
<p style="font-size: 24px;">Something went wrong.</p>
|
<p style="font-size: 24px;">Something went wrong.</p>
|
||||||
<button style="margin-top: 20px; padding: 10px 20px; font-size: 16px;" onclick="window.ExternalApp.postMessage(JSON.stringify({ event: 'reloadHomePage' }))">Reload</button>
|
<button class="reload-button" onclick="window.ExternalApp.postMessage(JSON.stringify({ event: 'reloadHomePage' }))">Reload</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
@ -34,7 +34,7 @@ ConfigWizardWebViewPage::ConfigWizardWebViewPage(ConfigWizard *parent)
|
|||||||
append(fail_text);
|
append(fail_text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WebView::webview_create(m_browser, this, p_user_account->generate_login_redirect_url(), {});
|
WebView::webview_create(m_browser, this, p_user_account->generate_login_redirect_url(), {"ExternalApp"});
|
||||||
|
|
||||||
if (logged) {
|
if (logged) {
|
||||||
// TRN Config wizard page with a log in web.
|
// TRN Config wizard page with a log in web.
|
||||||
@ -49,11 +49,13 @@ ConfigWizardWebViewPage::ConfigWizardWebViewPage(ConfigWizard *parent)
|
|||||||
append(m_browser_sizer, 1, wxEXPAND);
|
append(m_browser_sizer, 1, wxEXPAND);
|
||||||
|
|
||||||
m_browser_sizer->Show(!logged);
|
m_browser_sizer->Show(!logged);
|
||||||
|
Layout();
|
||||||
|
|
||||||
// Connect the webview events
|
// Connect the webview events
|
||||||
Bind(wxEVT_WEBVIEW_ERROR, &ConfigWizardWebViewPage::on_error, this, m_browser->GetId());
|
Bind(wxEVT_WEBVIEW_ERROR, &ConfigWizardWebViewPage::on_error, this, m_browser->GetId());
|
||||||
Bind(wxEVT_WEBVIEW_NAVIGATING, &ConfigWizardWebViewPage::on_navigation_request, this, m_browser->GetId());
|
Bind(wxEVT_WEBVIEW_NAVIGATING, &ConfigWizardWebViewPage::on_navigation_request, this, m_browser->GetId());
|
||||||
Bind(wxEVT_IDLE, &ConfigWizardWebViewPage::on_idle, this);
|
Bind(wxEVT_IDLE, &ConfigWizardWebViewPage::on_idle, this);
|
||||||
|
Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &ConfigWizardWebViewPage::on_script_message, this, m_browser->GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigWizardWebViewPage::login_changed()
|
bool ConfigWizardWebViewPage::login_changed()
|
||||||
@ -115,7 +117,7 @@ void ConfigWizardWebViewPage::on_idle(wxIdleEvent &WXUNUSED(evt)) {
|
|||||||
if (!m_vetoed && m_load_error_page) {
|
if (!m_vetoed && m_load_error_page) {
|
||||||
m_load_error_page = false;
|
m_load_error_page = false;
|
||||||
m_browser->LoadURL(GUI::format_wxstr(
|
m_browser->LoadURL(GUI::format_wxstr(
|
||||||
"file://%1%/web/connection_failed.html",
|
"file://%1%/web/other_error.html",
|
||||||
boost::filesystem::path(resources_dir()).generic_string()
|
boost::filesystem::path(resources_dir()).generic_string()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -147,4 +149,11 @@ void ConfigWizardWebViewPage::on_navigation_request(wxWebViewEvent &evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigWizardWebViewPage::on_script_message(wxWebViewEvent& evt)
|
||||||
|
{
|
||||||
|
// only reaload button on erro page
|
||||||
|
m_browser->LoadURL(p_user_account->generate_login_redirect_url());
|
||||||
|
}
|
||||||
|
|
||||||
}} // namespace Slic3r::GUI
|
}} // namespace Slic3r::GUI
|
@ -53,6 +53,7 @@ public:
|
|||||||
void on_error(wxWebViewEvent &evt);
|
void on_error(wxWebViewEvent &evt);
|
||||||
void on_navigation_request(wxWebViewEvent &evt);
|
void on_navigation_request(wxWebViewEvent &evt);
|
||||||
void on_idle(wxIdleEvent &evt);
|
void on_idle(wxIdleEvent &evt);
|
||||||
|
void on_script_message(wxWebViewEvent& evt);
|
||||||
void load_error_page();
|
void load_error_page();
|
||||||
// returns true if logged in - wizard needs to update repos
|
// returns true if logged in - wizard needs to update repos
|
||||||
bool login_changed();
|
bool login_changed();
|
||||||
|
@ -919,14 +919,14 @@ void MainFrame::remove_printables_webview_tab()
|
|||||||
|
|
||||||
void MainFrame::show_printer_webview_tab(DynamicPrintConfig* dpc)
|
void MainFrame::show_printer_webview_tab(DynamicPrintConfig* dpc)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
remove_printer_webview_tab();
|
||||||
// if physical printer is selected
|
// if physical printer is selected
|
||||||
if (dpc && dpc->option<ConfigOptionEnum<PrintHostType>>("host_type")->value != htPrusaConnect) {
|
if (dpc && dpc->option<ConfigOptionEnum<PrintHostType>>("host_type")->value != htPrusaConnect) {
|
||||||
std::string url = dpc->opt_string("print_host");
|
std::string url = dpc->opt_string("print_host");
|
||||||
|
|
||||||
if (url.find("http://") != 0 && url.find("https://") != 0) {
|
if (url.find("http://") != 0 && url.find("https://") != 0) {
|
||||||
url = "http://" + url;
|
url = "http://" + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set password / api key
|
// set password / api key
|
||||||
if (dynamic_cast<const ConfigOptionEnum<AuthorizationType>*>(dpc->option("printhost_authorization_type"))->value == AuthorizationType::atKeyPassword) {
|
if (dynamic_cast<const ConfigOptionEnum<AuthorizationType>*>(dpc->option("printhost_authorization_type"))->value == AuthorizationType::atKeyPassword) {
|
||||||
set_printer_webview_api_key(dpc->opt_string("printhost_apikey"));
|
set_printer_webview_api_key(dpc->opt_string("printhost_apikey"));
|
||||||
@ -934,26 +934,14 @@ void MainFrame::show_printer_webview_tab(DynamicPrintConfig* dpc)
|
|||||||
else {
|
else {
|
||||||
set_printer_webview_credentials(dpc->opt_string("printhost_user"), dpc->opt_string("printhost_password"));
|
set_printer_webview_credentials(dpc->opt_string("printhost_user"), dpc->opt_string("printhost_password"));
|
||||||
}
|
}
|
||||||
// add printer or change url
|
|
||||||
if (get_printer_webview_tab_added()) {
|
|
||||||
set_printer_webview_tab_url(from_u8(url));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
add_printer_webview_tab(from_u8(url));
|
add_printer_webview_tab(from_u8(url));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// if physical printer isn't selected, so delete page from TopBar
|
|
||||||
else {
|
|
||||||
if (m_tabpanel->GetPageText(m_tabpanel->GetSelection()) == _L("Physical Printer"))
|
|
||||||
select_tab(size_t(0));
|
|
||||||
remove_printer_webview_tab();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::add_printer_webview_tab(const wxString& url)
|
void MainFrame::add_printer_webview_tab(const wxString& url)
|
||||||
{
|
{
|
||||||
if (m_printer_webview_added) {
|
if (m_printer_webview_added) {
|
||||||
set_printer_webview_tab_url(url);
|
//set_printer_webview_tab_url(url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_printer_webview_added = true;
|
m_printer_webview_added = true;
|
||||||
@ -967,28 +955,13 @@ void MainFrame::remove_printer_webview_tab()
|
|||||||
if (!m_printer_webview_added) {
|
if (!m_printer_webview_added) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (m_tabpanel->GetPageText(m_tabpanel->GetSelection()) == _L("Physical Printer"))
|
||||||
|
select_tab(size_t(0));
|
||||||
m_printer_webview_added = false;
|
m_printer_webview_added = false;
|
||||||
m_printer_webview->Hide();
|
m_printer_webview->Hide();
|
||||||
m_tabpanel->RemovePage(m_tabpanel->FindPage(m_printer_webview));
|
m_tabpanel->RemovePage(m_tabpanel->FindPage(m_printer_webview));
|
||||||
m_printer_webview->destroy_browser();
|
m_printer_webview->destroy_browser();
|
||||||
}
|
}
|
||||||
void MainFrame::set_printer_webview_tab_url(const wxString& url)
|
|
||||||
{
|
|
||||||
if (!m_printer_webview_added) {
|
|
||||||
add_printer_webview_tab(url);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// TODO: this will reset already filled credential when bundle loaded,
|
|
||||||
// what's the reason of clearing credentials here?
|
|
||||||
//m_printer_webview->clear();
|
|
||||||
m_printer_webview->set_default_url(url);
|
|
||||||
|
|
||||||
if (m_tabpanel->GetSelection() == m_tabpanel->FindPage(m_printer_webview)) {
|
|
||||||
m_printer_webview->load_url(url);
|
|
||||||
} else {
|
|
||||||
m_printer_webview->load_default_url_delayed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainFrame::set_printer_webview_api_key(const std::string& key)
|
void MainFrame::set_printer_webview_api_key(const std::string& key)
|
||||||
{
|
{
|
||||||
@ -1726,7 +1699,7 @@ void MainFrame::init_menubar_as_editor()
|
|||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
viewMenu->AppendSeparator();
|
viewMenu->AppendSeparator();
|
||||||
append_menu_item(viewMenu, wxID_ANY, _L("&Reload WebView"), _L("Reload WebView"),
|
append_menu_item(viewMenu, wxID_ANY, _L("&Reload Web Content") + "\tF5", _L("Reload WebView"),
|
||||||
[this](wxCommandEvent&) { reload_selected_webview(); }, "", nullptr, [this]() {return is_any_webview_selected(); }, this);
|
[this](wxCommandEvent&) { reload_selected_webview(); }, "", nullptr, [this]() {return is_any_webview_selected(); }, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,6 @@ public:
|
|||||||
|
|
||||||
void add_printer_webview_tab(const wxString& url);
|
void add_printer_webview_tab(const wxString& url);
|
||||||
void remove_printer_webview_tab();
|
void remove_printer_webview_tab();
|
||||||
void set_printer_webview_tab_url(const wxString& url);
|
|
||||||
bool get_printer_webview_tab_added() const { return m_printer_webview_added; }
|
bool get_printer_webview_tab_added() const { return m_printer_webview_added; }
|
||||||
void set_printer_webview_api_key(const std::string& key);
|
void set_printer_webview_api_key(const std::string& key);
|
||||||
void set_printer_webview_credentials(const std::string& usr, const std::string& psk);
|
void set_printer_webview_credentials(const std::string& usr, const std::string& psk);
|
||||||
|
@ -21,12 +21,13 @@ wxWebView* WebView::webview_new()
|
|||||||
wxWebView* webView = nullptr;
|
wxWebView* webView = nullptr;
|
||||||
if (backend_available)
|
if (backend_available)
|
||||||
webView = wxWebView::New();
|
webView = wxWebView::New();
|
||||||
|
if (!webView)
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "Failed to create wxWebView object.";
|
||||||
return webView;
|
return webView;
|
||||||
}
|
}
|
||||||
void WebView::webview_create(wxWebView* webView, wxWindow *parent, const wxString& url, const std::vector<std::string>& message_handlers)
|
void WebView::webview_create(wxWebView* webView, wxWindow *parent, const wxString& url, const std::vector<std::string>& message_handlers)
|
||||||
{
|
{
|
||||||
if (webView) {
|
assert(webView);
|
||||||
wxString correct_url = url.empty() ? wxString("") : wxURI(url).BuildURI();
|
wxString correct_url = url.empty() ? wxString("") : wxURI(url).BuildURI();
|
||||||
wxString user_agent = Slic3r::GUI::format_wxstr("%1%/%2% (%3%)",SLIC3R_APP_FULL_NAME, SLIC3R_VERSION, Slic3r::platform_to_string(Slic3r::platform()));
|
wxString user_agent = Slic3r::GUI::format_wxstr("%1%/%2% (%3%)",SLIC3R_APP_FULL_NAME, SLIC3R_VERSION, Slic3r::platform_to_string(Slic3r::platform()));
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
@ -48,8 +49,7 @@ void WebView::webview_create(wxWebView* webView, wxWindow *parent, const wxStrin
|
|||||||
Slic3r::GUI::wxGetApp().CallAfter([message_handlers, webView] {
|
Slic3r::GUI::wxGetApp().CallAfter([message_handlers, webView] {
|
||||||
#endif
|
#endif
|
||||||
for (const std::string& handler : message_handlers) {
|
for (const std::string& handler : message_handlers) {
|
||||||
if (!webView->AddScriptMessageHandler(Slic3r::GUI::into_u8(handler))) {
|
if (!webView->AddScriptMessageHandler(Slic3r::GUI::from_u8(handler))) {
|
||||||
//wxLogError("Could not add script message handler");
|
|
||||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Could not add script message handler " << handler;
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Could not add script message handler " << handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,8 +57,4 @@ void WebView::webview_create(wxWebView* webView, wxWindow *parent, const wxStrin
|
|||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
webView->EnableContextMenu(false);
|
webView->EnableContextMenu(false);
|
||||||
} else {
|
|
||||||
// TODO: dialog to user !!!
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "Failed to create wxWebView object.";
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -30,7 +30,7 @@ namespace pt = boost::property_tree;
|
|||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
WebViewDialog::WebViewDialog(wxWindow* parent, const wxString& url, const wxString& dialog_name, const wxSize& size, const std::vector<std::string>& message_handler_names, const std::string& loading_html/* = "loading"*/)
|
WebViewDialog::WebViewDialog(wxWindow* parent, const wxString& url, const wxString& dialog_name, const wxSize& size, const std::vector<std::string>& message_handler_names, const std::string& loading_html/* = "other_loading"*/)
|
||||||
: DPIDialog(parent, wxID_ANY, dialog_name, wxDefaultPosition, size, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
: DPIDialog(parent, wxID_ANY, dialog_name, wxDefaultPosition, size, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||||
, m_loading_html(loading_html)
|
, m_loading_html(loading_html)
|
||||||
, m_script_message_hadler_names (message_handler_names)
|
, m_script_message_hadler_names (message_handler_names)
|
||||||
@ -158,7 +158,7 @@ void WebViewDialog::on_idle(wxIdleEvent& WXUNUSED(evt))
|
|||||||
wxSetCursor(wxNullCursor);
|
wxSetCursor(wxNullCursor);
|
||||||
if (m_load_error_page) {
|
if (m_load_error_page) {
|
||||||
m_load_error_page = false;
|
m_load_error_page = false;
|
||||||
m_browser->LoadURL(GUI::format_wxstr("file://%1%/web/connection_failed.html", boost::filesystem::path(resources_dir()).generic_string()));
|
m_browser->LoadURL(GUI::format_wxstr("file://%1%/web/error_no_reload.html", boost::filesystem::path(resources_dir()).generic_string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_URL_PANEL
|
#ifdef DEBUG_URL_PANEL
|
||||||
|
@ -24,7 +24,7 @@ namespace GUI {
|
|||||||
class WebViewDialog : public DPIDialog
|
class WebViewDialog : public DPIDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WebViewDialog(wxWindow* parent, const wxString& url, const wxString& dialog_name, const wxSize& size, const std::vector<std::string>& message_handler_names, const std::string& loading_html = "loading");
|
WebViewDialog(wxWindow* parent, const wxString& url, const wxString& dialog_name, const wxSize& size, const std::vector<std::string>& message_handler_names, const std::string& loading_html = "other_loading");
|
||||||
virtual ~WebViewDialog();
|
virtual ~WebViewDialog();
|
||||||
|
|
||||||
virtual void on_show(wxShowEvent& evt) {};
|
virtual void on_show(wxShowEvent& evt) {};
|
||||||
|
@ -166,26 +166,7 @@ WebViewPanel::WebViewPanel(wxWindow *parent, const wxString& default_url, const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_do_late_webview_create = false;
|
m_do_late_webview_create = false;
|
||||||
|
late_create();
|
||||||
m_browser = WebView::webview_new();
|
|
||||||
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);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
WebView::webview_create(m_browser,this, GUI::format_wxstr("file://%1%/web/%2%.html", boost::filesystem::path(resources_dir()).generic_string(), m_loading_html), m_script_message_hadler_names);
|
|
||||||
if (Utils::ServiceConfig::instance().webdev_enabled()) {
|
|
||||||
m_browser->EnableContextMenu();
|
|
||||||
m_browser->EnableAccessToDevTools();
|
|
||||||
}
|
|
||||||
topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
|
|
||||||
|
|
||||||
|
|
||||||
// Connect the webview events
|
|
||||||
Bind(wxEVT_WEBVIEW_ERROR, &WebViewPanel::on_error, this, m_browser->GetId());
|
|
||||||
Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &WebViewPanel::on_script_message, this, m_browser->GetId());
|
|
||||||
Bind(wxEVT_WEBVIEW_NAVIGATING, &WebViewPanel::on_navigation_request, this, m_browser->GetId());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebViewPanel::late_create()
|
void WebViewPanel::late_create()
|
||||||
@ -265,6 +246,14 @@ void WebViewPanel::on_idle(wxIdleEvent& WXUNUSED(evt))
|
|||||||
load_default_url();
|
load_default_url();
|
||||||
} else {
|
} else {
|
||||||
load_url(GUI::format_wxstr("file://%1%/web/%2%.html", boost::filesystem::path(resources_dir()).generic_string(), m_error_html));
|
load_url(GUI::format_wxstr("file://%1%/web/%2%.html", boost::filesystem::path(resources_dir()).generic_string(), m_error_html));
|
||||||
|
// This is a fix of broken message handling after error.
|
||||||
|
// F.e. if there is an error but we do AddUserScript & Reload, the handling will break.
|
||||||
|
// So we just reset the handler here.
|
||||||
|
if (!m_script_message_hadler_names.empty()) {
|
||||||
|
m_browser->RemoveScriptMessageHandler(Slic3r::GUI::from_u8(m_script_message_hadler_names.front()));
|
||||||
|
bool b = m_browser->AddScriptMessageHandler(Slic3r::GUI::from_u8(m_script_message_hadler_names.front()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -433,6 +422,9 @@ void WebViewPanel::on_run_script_custom(wxCommandEvent& WXUNUSED(evt))
|
|||||||
|
|
||||||
void WebViewPanel::on_add_user_script(wxCommandEvent& WXUNUSED(evt))
|
void WebViewPanel::on_add_user_script(wxCommandEvent& WXUNUSED(evt))
|
||||||
{
|
{
|
||||||
|
if (!m_browser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
wxString userScript = "window.wx_test_var = 'wxWidgets webview sample';";
|
wxString userScript = "window.wx_test_var = 'wxWidgets webview sample';";
|
||||||
wxTextEntryDialog dialog
|
wxTextEntryDialog dialog
|
||||||
(
|
(
|
||||||
@ -572,12 +564,9 @@ void WebViewPanel::sys_color_changed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConnectWebViewPanel::ConnectWebViewPanel(wxWindow* parent)
|
ConnectWebViewPanel::ConnectWebViewPanel(wxWindow* parent)
|
||||||
: WebViewPanel(parent, GUI::from_u8(Utils::ServiceConfig::instance().connect_url()), { "_prusaSlicer" }, "connect_loading_reload", "connect_connection_failed", false)
|
: WebViewPanel(parent, GUI::from_u8(Utils::ServiceConfig::instance().connect_url()), { "_prusaSlicer" }, "connect_loading", "connect_error", false)
|
||||||
{
|
{
|
||||||
// m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new WebViewHandler("https")));
|
|
||||||
|
|
||||||
auto* plater = wxGetApp().plater();
|
auto* plater = wxGetApp().plater();
|
||||||
//plater->Bind(EVT_UA_ID_USER_SUCCESS, &ConnectWebViewPanel::on_user_token, this);
|
|
||||||
plater->Bind(EVT_UA_LOGGEDOUT, &ConnectWebViewPanel::on_user_logged_out, this);
|
plater->Bind(EVT_UA_LOGGEDOUT, &ConnectWebViewPanel::on_user_logged_out, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,7 +577,7 @@ void ConnectWebViewPanel::late_create()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// from ConnectWebViewPanel::on_user_token
|
// This code used to be inside plater->Bind(EVT_UA_ID_USER_SUCCESS, &ConnectWebViewPanel::on_user_token, this)
|
||||||
auto access_token = wxGetApp().plater()->get_user_account()->get_access_token();
|
auto access_token = wxGetApp().plater()->get_user_account()->get_access_token();
|
||||||
assert(!access_token.empty());
|
assert(!access_token.empty());
|
||||||
|
|
||||||
@ -600,7 +589,6 @@ void ConnectWebViewPanel::late_create()
|
|||||||
|
|
||||||
ConnectWebViewPanel::~ConnectWebViewPanel()
|
ConnectWebViewPanel::~ConnectWebViewPanel()
|
||||||
{
|
{
|
||||||
//m_browser->Unbind(EVT_UA_ID_USER_SUCCESS, &ConnectWebViewPanel::on_user_token, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString ConnectWebViewPanel::get_login_script(bool refresh)
|
wxString ConnectWebViewPanel::get_login_script(bool refresh)
|
||||||
@ -748,28 +736,19 @@ wxString ConnectWebViewPanel::get_logout_script()
|
|||||||
|
|
||||||
void ConnectWebViewPanel::on_page_will_load()
|
void ConnectWebViewPanel::on_page_will_load()
|
||||||
{
|
{
|
||||||
|
if (!m_browser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto javascript = get_login_script(false);
|
auto javascript = get_login_script(false);
|
||||||
BOOST_LOG_TRIVIAL(debug) << "RunScript " << javascript << "\n";
|
BOOST_LOG_TRIVIAL(debug) << "RunScript " << javascript << "\n";
|
||||||
m_browser->AddUserScript(javascript);
|
m_browser->AddUserScript(javascript);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectWebViewPanel::on_user_token(UserAccountSuccessEvent& e)
|
|
||||||
{
|
|
||||||
e.Skip();
|
|
||||||
/*
|
|
||||||
auto access_token = wxGetApp().plater()->get_user_account()->get_access_token();
|
|
||||||
assert(!access_token.empty());
|
|
||||||
|
|
||||||
wxString javascript = get_login_script(true);
|
|
||||||
BOOST_LOG_TRIVIAL(debug) << "RunScript " << javascript << "\n";
|
|
||||||
m_browser->RunScriptAsync(javascript);
|
|
||||||
resend_config();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConnectWebViewPanel::on_user_logged_out(UserAccountSuccessEvent& e)
|
void ConnectWebViewPanel::on_user_logged_out(UserAccountSuccessEvent& e)
|
||||||
{
|
{
|
||||||
e.Skip();
|
e.Skip();
|
||||||
|
if (!m_browser)
|
||||||
|
return;
|
||||||
// clear token from session storage
|
// clear token from session storage
|
||||||
m_browser->RunScriptAsync(get_logout_script());
|
m_browser->RunScriptAsync(get_logout_script());
|
||||||
}
|
}
|
||||||
@ -864,16 +843,16 @@ void ConnectWebViewPanel::on_connect_action_print(const std::string& message_dat
|
|||||||
}
|
}
|
||||||
|
|
||||||
PrinterWebViewPanel::PrinterWebViewPanel(wxWindow* parent, const wxString& default_url)
|
PrinterWebViewPanel::PrinterWebViewPanel(wxWindow* parent, const wxString& default_url)
|
||||||
: WebViewPanel(parent, default_url, {"ExternalApp"}, "other_loading_reload", "other_error", false)
|
: WebViewPanel(parent, default_url, {"ExternalApp"}, "other_loading", "other_error", false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrinterWebViewPanel::on_loaded(wxWebViewEvent& evt)
|
void PrinterWebViewPanel::on_loaded(wxWebViewEvent& evt)
|
||||||
{
|
{
|
||||||
if (evt.GetURL().IsEmpty())
|
if (evt.GetURL().IsEmpty())
|
||||||
return;
|
return;
|
||||||
m_load_default_url_on_next_error = false;
|
m_load_default_url_on_next_error = false;
|
||||||
|
|
||||||
if (!m_api_key.empty()) {
|
if (!m_api_key.empty()) {
|
||||||
send_api_key();
|
send_api_key();
|
||||||
} else if (!m_usr.empty() && !m_psk.empty()) {
|
} else if (!m_usr.empty() && !m_psk.empty()) {
|
||||||
@ -908,7 +887,6 @@ void PrinterWebViewPanel::send_api_key()
|
|||||||
sessionStorage.setItem('apiKey', '%s');
|
sessionStorage.setItem('apiKey', '%s');
|
||||||
)",
|
)",
|
||||||
key);
|
key);
|
||||||
|
|
||||||
m_browser->RemoveAllUserScripts();
|
m_browser->RemoveAllUserScripts();
|
||||||
BOOST_LOG_TRIVIAL(debug) << "RunScript " << script << "\n";
|
BOOST_LOG_TRIVIAL(debug) << "RunScript " << script << "\n";
|
||||||
m_browser->AddUserScript(script);
|
m_browser->AddUserScript(script);
|
||||||
@ -933,7 +911,7 @@ void PrinterWebViewPanel::sys_color_changed()
|
|||||||
|
|
||||||
|
|
||||||
PrintablesWebViewPanel::PrintablesWebViewPanel(wxWindow* parent)
|
PrintablesWebViewPanel::PrintablesWebViewPanel(wxWindow* parent)
|
||||||
: WebViewPanel(parent, GUI::from_u8(Utils::ServiceConfig::instance().printables_url()), { "ExternalApp" }, "other_loading_reload", "other_error", false)
|
: WebViewPanel(parent, GUI::from_u8(Utils::ServiceConfig::instance().printables_url()), { "ExternalApp" }, "other_loading", "other_error", false)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -979,7 +957,7 @@ void PrintablesWebViewPanel::on_navigation_request(wxWebViewEvent &evt)
|
|||||||
const wxString url = evt.GetURL();
|
const wxString url = evt.GetURL();
|
||||||
if (url.StartsWith(m_default_url)) {
|
if (url.StartsWith(m_default_url)) {
|
||||||
m_reached_default_url = true;
|
m_reached_default_url = true;
|
||||||
} else if (m_reached_default_url) {
|
} else if (m_reached_default_url && url.StartsWith("http")) {
|
||||||
BOOST_LOG_TRIVIAL(info) << evt.GetURL() << " does not start with default url. Vetoing.";
|
BOOST_LOG_TRIVIAL(info) << evt.GetURL() << " does not start with default url. Vetoing.";
|
||||||
evt.Veto();
|
evt.Veto();
|
||||||
}
|
}
|
||||||
@ -1068,7 +1046,7 @@ void PrintablesWebViewPanel::after_on_show(wxShowEvent& evt)
|
|||||||
|
|
||||||
void PrintablesWebViewPanel::logout(const std::string& override_url/* = std::string()*/)
|
void PrintablesWebViewPanel::logout(const std::string& override_url/* = std::string()*/)
|
||||||
{
|
{
|
||||||
if (!m_shown) {
|
if (!m_shown || !m_browser) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete_cookies(m_browser, Utils::ServiceConfig::instance().printables_url());
|
delete_cookies(m_browser, Utils::ServiceConfig::instance().printables_url());
|
||||||
@ -1113,6 +1091,9 @@ void PrintablesWebViewPanel::login(const std::string& access_token, const std::s
|
|||||||
|
|
||||||
void PrintablesWebViewPanel::load_default_url()
|
void PrintablesWebViewPanel::load_default_url()
|
||||||
{
|
{
|
||||||
|
if (!m_browser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::string actual_default_url = get_url_lang_theme(from_u8(Utils::ServiceConfig::instance().printables_url() + "/homepage"));
|
std::string actual_default_url = get_url_lang_theme(from_u8(Utils::ServiceConfig::instance().printables_url() + "/homepage"));
|
||||||
const std::string access_token = wxGetApp().plater()->get_user_account()->get_access_token();
|
const std::string access_token = wxGetApp().plater()->get_user_account()->get_access_token();
|
||||||
|
|
||||||
@ -1161,7 +1142,7 @@ void PrintablesWebViewPanel::on_script_message(wxWebViewEvent& evt)
|
|||||||
|
|
||||||
void PrintablesWebViewPanel::sys_color_changed()
|
void PrintablesWebViewPanel::sys_color_changed()
|
||||||
{
|
{
|
||||||
if (m_shown) {
|
if (m_shown && m_browser) {
|
||||||
load_url(GUI::from_u8(get_url_lang_theme(m_browser->GetCurrentURL())));
|
load_url(GUI::from_u8(get_url_lang_theme(m_browser->GetCurrentURL())));
|
||||||
}
|
}
|
||||||
WebViewPanel::sys_color_changed();
|
WebViewPanel::sys_color_changed();
|
||||||
@ -1182,8 +1163,6 @@ void PrintablesWebViewPanel::on_reload_event(const std::string& message_data)
|
|||||||
}
|
}
|
||||||
void PrintablesWebViewPanel::on_printables_event_print_gcode(const std::string& message_data)
|
void PrintablesWebViewPanel::on_printables_event_print_gcode(const std::string& message_data)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< " " << message_data;
|
|
||||||
|
|
||||||
// { "event": "downloadFile", "url": "https://media.printables.com/somesecure.stl", "modelUrl": "https://www.printables.com/model/123" }
|
// { "event": "downloadFile", "url": "https://media.printables.com/somesecure.stl", "modelUrl": "https://www.printables.com/model/123" }
|
||||||
std::string download_url;
|
std::string download_url;
|
||||||
std::string model_url;
|
std::string model_url;
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
virtual void on_script_message(wxWebViewEvent& evt);
|
virtual void on_script_message(wxWebViewEvent& evt);
|
||||||
|
|
||||||
void on_idle(wxIdleEvent& evt);
|
void on_idle(wxIdleEvent& evt);
|
||||||
void on_loaded(wxWebViewEvent& evt);
|
virtual void on_loaded(wxWebViewEvent& evt);
|
||||||
void on_url(wxCommandEvent& evt);
|
void on_url(wxCommandEvent& evt);
|
||||||
virtual void on_back_button(wxCommandEvent& evt);
|
virtual void on_back_button(wxCommandEvent& evt);
|
||||||
virtual void on_forward_button(wxCommandEvent& evt);
|
virtual void on_forward_button(wxCommandEvent& evt);
|
||||||
@ -144,7 +144,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
static wxString get_login_script(bool refresh);
|
static wxString get_login_script(bool refresh);
|
||||||
static wxString get_logout_script();
|
static wxString get_logout_script();
|
||||||
void on_user_token(UserAccountSuccessEvent& e);
|
|
||||||
void on_user_logged_out(UserAccountSuccessEvent& e);
|
void on_user_logged_out(UserAccountSuccessEvent& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -153,26 +152,21 @@ class PrinterWebViewPanel : public WebViewPanel
|
|||||||
public:
|
public:
|
||||||
PrinterWebViewPanel(wxWindow* parent, const wxString& default_url);
|
PrinterWebViewPanel(wxWindow* parent, const wxString& default_url);
|
||||||
|
|
||||||
void on_loaded(wxWebViewEvent& evt);
|
void on_loaded(wxWebViewEvent& evt) override;
|
||||||
void on_script_message(wxWebViewEvent& evt) override;
|
void on_script_message(wxWebViewEvent& evt) override;
|
||||||
|
|
||||||
void send_api_key();
|
void send_api_key();
|
||||||
void send_credentials();
|
void send_credentials();
|
||||||
void set_api_key(const std::string &key)
|
void set_api_key(const std::string &key)
|
||||||
{
|
{
|
||||||
if (m_api_key != key) {
|
|
||||||
clear();
|
clear();
|
||||||
m_api_key = key;
|
m_api_key = key;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
void set_credentials(const std::string &usr, const std::string &psk)
|
void set_credentials(const std::string &usr, const std::string &psk)
|
||||||
{
|
{
|
||||||
if (m_usr != usr || m_psk != psk) {
|
|
||||||
clear();
|
clear();
|
||||||
m_usr = usr;
|
m_usr = usr;
|
||||||
m_psk = psk;
|
m_psk = psk;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
void clear() { m_api_key.clear(); m_usr.clear(); m_psk.clear(); m_api_key_sent = false; }
|
void clear() { m_api_key.clear(); m_usr.clear(); m_psk.clear(); m_api_key_sent = false; }
|
||||||
void sys_color_changed() override;
|
void sys_color_changed() override;
|
||||||
private:
|
private:
|
||||||
@ -187,7 +181,7 @@ class PrintablesWebViewPanel : public WebViewPanel
|
|||||||
public:
|
public:
|
||||||
PrintablesWebViewPanel(wxWindow* parent);
|
PrintablesWebViewPanel(wxWindow* parent);
|
||||||
void on_navigation_request(wxWebViewEvent &evt) override;
|
void on_navigation_request(wxWebViewEvent &evt) override;
|
||||||
void on_loaded(wxWebViewEvent& evt);
|
void on_loaded(wxWebViewEvent& evt) override;
|
||||||
void after_on_show(wxShowEvent& evt) override;
|
void after_on_show(wxShowEvent& evt) override;
|
||||||
void on_script_message(wxWebViewEvent& evt) override;
|
void on_script_message(wxWebViewEvent& evt) override;
|
||||||
void sys_color_changed() override;
|
void sys_color_changed() override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user