mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-29 17:22:06 +08:00
Merge branch 'dk_login'
This commit is contained in:
commit
b037da1126
@ -47,7 +47,7 @@ ConfigWizardWebViewPage::ConfigWizardWebViewPage(ConfigWizard *parent)
|
||||
// Connect the webview events
|
||||
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_IDLE, &ConfigWizardWebViewPage::on_idle, this);
|
||||
}
|
||||
|
||||
bool ConfigWizardWebViewPage::login_changed()
|
||||
@ -85,14 +85,44 @@ case type: \
|
||||
WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_OTHER);
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(error) << "WebViewPanel error: " << category;
|
||||
BOOST_LOG_TRIVIAL(error) << "ConfigWizardWebViewPage error: " << category;
|
||||
load_error_page();
|
||||
}
|
||||
|
||||
void ConfigWizardWebViewPage::load_error_page() {
|
||||
if (!m_browser)
|
||||
return;
|
||||
if (m_vetoed)
|
||||
return;
|
||||
m_browser->Stop();
|
||||
m_load_error_page = true;
|
||||
}
|
||||
|
||||
void ConfigWizardWebViewPage::on_idle(wxIdleEvent &WXUNUSED(evt)) {
|
||||
if (!m_browser)
|
||||
return;
|
||||
if (m_browser->IsBusy()) {
|
||||
wxSetCursor(wxCURSOR_ARROWWAIT);
|
||||
} else {
|
||||
wxSetCursor(wxNullCursor);
|
||||
|
||||
if (!m_vetoed && m_load_error_page) {
|
||||
m_load_error_page = false;
|
||||
m_browser->LoadURL(GUI::format_wxstr(
|
||||
"file://%1%/web/connection_failed.html",
|
||||
boost::filesystem::path(resources_dir()).generic_string()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ConfigWizardWebViewPage::on_navigation_request(wxWebViewEvent &evt)
|
||||
{
|
||||
wxString url = evt.GetURL();
|
||||
if (url.starts_with(L"prusaslicer")) {
|
||||
evt.Veto();
|
||||
m_vetoed = true;
|
||||
wxPostEvent(wxGetApp().plater(), Event<std::string>(EVT_LOGIN_VIA_WIZARD, into_u8(url)));
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,8 @@ public:
|
||||
|
||||
void on_error(wxWebViewEvent &evt);
|
||||
void on_navigation_request(wxWebViewEvent &evt);
|
||||
void on_idle(wxIdleEvent &evt);
|
||||
void load_error_page();
|
||||
// returns true if logged in - wizard needs to update repos
|
||||
bool login_changed();
|
||||
|
||||
@ -57,6 +59,8 @@ private:
|
||||
UserAccount *p_user_account{nullptr};
|
||||
wxBoxSizer *m_browser_sizer{nullptr};
|
||||
wxStaticText *m_text{nullptr};
|
||||
bool m_load_error_page{false};
|
||||
bool m_vetoed{false};
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
@ -307,7 +307,7 @@ wxString UserAccountCommunication::get_login_redirect_url() {
|
||||
BOOST_LOG_TRIVIAL(info) << "code verifier: " << m_code_verifier;
|
||||
BOOST_LOG_TRIVIAL(info) << "code challenge: " << code_challenge;
|
||||
|
||||
wxString url = GUI::format_wxstr(L"%1%/o/authorize/?embed=1&client_id=%2%&response_type=code&code_challenge=%3%&code_challenge_method=S256&scope=basic_info&redirect_uri=%4%&choose_account=1&language=%5%", AUTH_HOST, CLIENT_ID, code_challenge, REDIRECT_URI, language);
|
||||
wxString url = GUI::format_wxstr(L"%1%/o/authorize/?embed=1&client_id=%2%&response_type=code&code_challenge=%3%&code_challenge_method=S256&scope=basic_info&redirect_uri=%4%&language=%5%", AUTH_HOST, CLIENT_ID, code_challenge, REDIRECT_URI, language);
|
||||
|
||||
return url;
|
||||
}
|
||||
|
@ -820,7 +820,7 @@ void PrinterWebViewPanel::sys_color_changed()
|
||||
}
|
||||
|
||||
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"*/)
|
||||
: wxDialog(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_script_message_hadler_names (message_handler_names)
|
||||
{
|
||||
@ -1313,11 +1313,23 @@ void PrinterPickWebViewDialog::request_compatible_printers_SLA()
|
||||
wxString script = GUI::format_wxstr("window._prusaConnect_v1.requestCompatiblePrinter(%1%)", request);
|
||||
run_script(script);
|
||||
}
|
||||
void PrinterPickWebViewDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
{
|
||||
wxWindow *parent = GetParent();
|
||||
const wxSize &size = wxSize(
|
||||
std::max(parent->GetClientSize().x / 2, 100 * wxGetApp().em_unit()),
|
||||
std::max(parent->GetClientSize().y / 2, 50 * wxGetApp().em_unit())
|
||||
);
|
||||
SetMinSize(size);
|
||||
Fit();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
LoginWebViewDialog::LoginWebViewDialog(wxWindow *parent, std::string &ret_val, const wxString& url)
|
||||
: WebViewDialog(parent
|
||||
, url
|
||||
, _L("Log in dialog")
|
||||
, wxSize(parent->GetClientSize().x / 3, parent->GetClientSize().y / 4 * 3)
|
||||
, _L("Log in dialog"),
|
||||
wxSize(50 * wxGetApp().em_unit(), 80 * wxGetApp().em_unit())
|
||||
, {})
|
||||
, m_ret_val(ret_val)
|
||||
{
|
||||
@ -1332,6 +1344,13 @@ void LoginWebViewDialog::on_navigation_request(wxWebViewEvent &evt)
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
}
|
||||
void LoginWebViewDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
{
|
||||
const wxSize &size = wxSize(50 * wxGetApp().em_unit(), 80 * wxGetApp().em_unit());
|
||||
SetMinSize(size);
|
||||
Fit();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
LogoutWebViewDialog::LogoutWebViewDialog(wxWindow *parent)
|
||||
: WebViewDialog(parent
|
||||
@ -1342,6 +1361,7 @@ LogoutWebViewDialog::LogoutWebViewDialog(wxWindow *parent)
|
||||
{
|
||||
Centre();
|
||||
}
|
||||
|
||||
void LogoutWebViewDialog::on_loaded(wxWebViewEvent &evt)
|
||||
{
|
||||
EndModal(wxID_OK);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <wx/wx.h>
|
||||
#include <wx/event.h>
|
||||
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "UserAccountSession.hpp"
|
||||
|
||||
#ifdef DEBUG_URL_PANEL
|
||||
@ -102,7 +103,7 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
class WebViewDialog : public wxDialog
|
||||
class WebViewDialog : public DPIDialog
|
||||
{
|
||||
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");
|
||||
@ -247,6 +248,7 @@ protected:
|
||||
void request_compatible_printers_FFF();
|
||||
void request_compatible_printers_SLA();
|
||||
void run_script_bridge(const wxString& script) override { run_script(script); }
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||
|
||||
private:
|
||||
std::string& m_ret_val;
|
||||
@ -263,6 +265,7 @@ class LoginWebViewDialog : public WebViewDialog
|
||||
public:
|
||||
LoginWebViewDialog(wxWindow *parent, std::string &ret_val, const wxString& url);
|
||||
void on_navigation_request(wxWebViewEvent &evt) override;
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||
|
||||
private:
|
||||
std::string &m_ret_val;
|
||||
@ -273,6 +276,7 @@ class LogoutWebViewDialog : public WebViewDialog
|
||||
public:
|
||||
LogoutWebViewDialog(wxWindow* parent);
|
||||
void on_loaded(wxWebViewEvent &evt) override;
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override {}
|
||||
};
|
||||
|
||||
} // GUI
|
||||
|
Loading…
x
Reference in New Issue
Block a user