mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-02 06:30:38 +08:00
Open external browser in config wizard.
This commit is contained in:
parent
fa94b9fb54
commit
5871ad2e51
@ -6,9 +6,11 @@
|
|||||||
#include "Plater.hpp"
|
#include "Plater.hpp"
|
||||||
#include "slic3r/GUI/I18N.hpp"
|
#include "slic3r/GUI/I18N.hpp"
|
||||||
#include "format.hpp"
|
#include "format.hpp"
|
||||||
|
#include "Event.hpp"
|
||||||
#include <wx/webview.h>
|
#include <wx/webview.h>
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(EVT_OPEN_EXTERNAL_LOGIN_WIZARD, wxCommandEvent);
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
wxDEFINE_EVENT(EVT_LOGIN_VIA_WIZARD, Event<std::string>);
|
wxDEFINE_EVENT(EVT_LOGIN_VIA_WIZARD, Event<std::string>);
|
||||||
@ -124,7 +126,17 @@ void ConfigWizardWebViewPage::on_navigation_request(wxWebViewEvent &evt)
|
|||||||
evt.Veto();
|
evt.Veto();
|
||||||
m_vetoed = true;
|
m_vetoed = true;
|
||||||
wxPostEvent(wxGetApp().plater(), Event<std::string>(EVT_LOGIN_VIA_WIZARD, into_u8(url)));
|
wxPostEvent(wxGetApp().plater(), Event<std::string>(EVT_LOGIN_VIA_WIZARD, into_u8(url)));
|
||||||
|
} else if (url.Find("accounts.google.com") != wxString::npos
|
||||||
|
|| url.Find("appleid.apple.com") != wxString::npos
|
||||||
|
|| url.Find("facebook.com") != wxString::npos)
|
||||||
|
{
|
||||||
|
auto& sc = Utils::ServiceConfig::instance();
|
||||||
|
if (!m_evt_sent && !url.starts_with(GUI::from_u8(sc.account_url()))) {
|
||||||
|
wxCommandEvent evt(EVT_OPEN_EXTERNAL_LOGIN_WIZARD);
|
||||||
|
evt.SetString(url);
|
||||||
|
wxPostEvent(wxGetApp().plater(), evt);
|
||||||
|
m_evt_sent = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}} // namespace Slic3r::GUI
|
}} // namespace Slic3r::GUI
|
@ -2,15 +2,18 @@
|
|||||||
#define slic3r_ConfigWizardWebViewPage_hpp_
|
#define slic3r_ConfigWizardWebViewPage_hpp_
|
||||||
|
|
||||||
#include "ConfigWizard_private.hpp"
|
#include "ConfigWizard_private.hpp"
|
||||||
#include "Event.hpp"
|
#include <wx/event.h>
|
||||||
|
|
||||||
class wxWebView;
|
class wxWebView;
|
||||||
class wxWebViewEvent;
|
class wxWebViewEvent;
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(EVT_OPEN_EXTERNAL_LOGIN_WIZARD, wxCommandEvent);
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
wxDECLARE_EVENT(EVT_LOGIN_VIA_WIZARD, Event<std::string>);
|
wxDECLARE_EVENT(EVT_LOGIN_VIA_WIZARD, Event<std::string>);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
struct ConfigWizardPage: wxPanel
|
struct ConfigWizardPage: wxPanel
|
||||||
{
|
{
|
||||||
@ -61,6 +64,7 @@ private:
|
|||||||
wxStaticText *m_text{nullptr};
|
wxStaticText *m_text{nullptr};
|
||||||
bool m_load_error_page{false};
|
bool m_load_error_page{false};
|
||||||
bool m_vetoed{false};
|
bool m_vetoed{false};
|
||||||
|
bool m_evt_sent{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace Slic3r::GUI
|
}} // namespace Slic3r::GUI
|
||||||
|
@ -126,6 +126,7 @@
|
|||||||
#include "UserAccountUtils.hpp"
|
#include "UserAccountUtils.hpp"
|
||||||
#include "DesktopIntegrationDialog.hpp"
|
#include "DesktopIntegrationDialog.hpp"
|
||||||
#include "WebViewDialog.hpp"
|
#include "WebViewDialog.hpp"
|
||||||
|
#include "ConfigWizardWebViewPage.hpp"
|
||||||
#include "PresetArchiveDatabase.hpp"
|
#include "PresetArchiveDatabase.hpp"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@ -890,7 +891,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||||||
login_dialog = nullptr;
|
login_dialog = nullptr;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this->q->Bind(EVT_OPEN_EXTERNAL_LOGIN, [this](wxCommandEvent& evt) {
|
|
||||||
|
auto open_external_login = [this](wxCommandEvent& evt){
|
||||||
DownloaderUtils::Worker::perform_url_register();
|
DownloaderUtils::Worker::perform_url_register();
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
// Remove all desktop files registering prusaslicer:// url done by previous versions.
|
// Remove all desktop files registering prusaslicer:// url done by previous versions.
|
||||||
@ -909,8 +911,11 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||||||
service = "facebook";
|
service = "facebook";
|
||||||
}
|
}
|
||||||
wxString url = user_account->get_login_redirect_url(service);
|
wxString url = user_account->get_login_redirect_url(service);
|
||||||
wxGetApp().open_login_browser_with_dialog(into_u8(url));
|
wxGetApp().open_login_browser_with_dialog(into_u8(url), nullptr, false);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
this->q->Bind(EVT_OPEN_EXTERNAL_LOGIN_WIZARD, open_external_login);
|
||||||
|
this->q->Bind(EVT_OPEN_EXTERNAL_LOGIN, open_external_login);
|
||||||
|
|
||||||
this->q->Bind(EVT_UA_LOGGEDOUT, [this](UserAccountSuccessEvent& evt) {
|
this->q->Bind(EVT_UA_LOGGEDOUT, [this](UserAccountSuccessEvent& evt) {
|
||||||
user_account->clear();
|
user_account->clear();
|
||||||
|
@ -1385,7 +1385,10 @@ void LoginWebViewDialog::on_navigation_request(wxWebViewEvent &evt)
|
|||||||
evt.Veto();
|
evt.Veto();
|
||||||
m_ret_val = into_u8(url);
|
m_ret_val = into_u8(url);
|
||||||
EndModal(wxID_OK);
|
EndModal(wxID_OK);
|
||||||
} else if (url.starts_with(L"http")) {
|
} else if (url.Find("accounts.google.com") != wxString::npos
|
||||||
|
|| url.Find("appleid.apple.com") != wxString::npos
|
||||||
|
|| url.Find("facebook.com") != wxString::npos)
|
||||||
|
{
|
||||||
auto& sc = Utils::ServiceConfig::instance();
|
auto& sc = Utils::ServiceConfig::instance();
|
||||||
if (!m_evt_sent && !url.starts_with(GUI::from_u8(sc.account_url()))) {
|
if (!m_evt_sent && !url.starts_with(GUI::from_u8(sc.account_url()))) {
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_OPEN_EXTERNAL_LOGIN);
|
wxCommandEvent* evt = new wxCommandEvent(EVT_OPEN_EXTERNAL_LOGIN);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user