mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 15:12:00 +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 "slic3r/GUI/I18N.hpp"
|
||||
#include "format.hpp"
|
||||
|
||||
#include "Event.hpp"
|
||||
#include <wx/webview.h>
|
||||
|
||||
wxDEFINE_EVENT(EVT_OPEN_EXTERNAL_LOGIN_WIZARD, wxCommandEvent);
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
wxDEFINE_EVENT(EVT_LOGIN_VIA_WIZARD, Event<std::string>);
|
||||
@ -124,7 +126,17 @@ void ConfigWizardWebViewPage::on_navigation_request(wxWebViewEvent &evt)
|
||||
evt.Veto();
|
||||
m_vetoed = true;
|
||||
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
|
@ -2,15 +2,18 @@
|
||||
#define slic3r_ConfigWizardWebViewPage_hpp_
|
||||
|
||||
#include "ConfigWizard_private.hpp"
|
||||
#include "Event.hpp"
|
||||
#include <wx/event.h>
|
||||
|
||||
class wxWebView;
|
||||
class wxWebViewEvent;
|
||||
|
||||
wxDECLARE_EVENT(EVT_OPEN_EXTERNAL_LOGIN_WIZARD, wxCommandEvent);
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
wxDECLARE_EVENT(EVT_LOGIN_VIA_WIZARD, Event<std::string>);
|
||||
|
||||
/*
|
||||
struct ConfigWizardPage: wxPanel
|
||||
{
|
||||
@ -61,6 +64,7 @@ private:
|
||||
wxStaticText *m_text{nullptr};
|
||||
bool m_load_error_page{false};
|
||||
bool m_vetoed{false};
|
||||
bool m_evt_sent{false};
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
@ -126,6 +126,7 @@
|
||||
#include "UserAccountUtils.hpp"
|
||||
#include "DesktopIntegrationDialog.hpp"
|
||||
#include "WebViewDialog.hpp"
|
||||
#include "ConfigWizardWebViewPage.hpp"
|
||||
#include "PresetArchiveDatabase.hpp"
|
||||
|
||||
#ifdef __APPLE__
|
||||
@ -890,8 +891,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||
login_dialog = nullptr;
|
||||
}
|
||||
});
|
||||
this->q->Bind(EVT_OPEN_EXTERNAL_LOGIN, [this](wxCommandEvent& evt) {
|
||||
DownloaderUtils::Worker::perform_url_register();
|
||||
|
||||
auto open_external_login = [this](wxCommandEvent& evt){
|
||||
DownloaderUtils::Worker::perform_url_register();
|
||||
#if defined(__linux__)
|
||||
// Remove all desktop files registering prusaslicer:// url done by previous versions.
|
||||
DesktopIntegrationDialog::undo_downloader_registration_rigid();
|
||||
@ -909,8 +911,11 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||
service = "facebook";
|
||||
}
|
||||
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) {
|
||||
user_account->clear();
|
||||
|
@ -1385,7 +1385,10 @@ void LoginWebViewDialog::on_navigation_request(wxWebViewEvent &evt)
|
||||
evt.Veto();
|
||||
m_ret_val = into_u8(url);
|
||||
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();
|
||||
if (!m_evt_sent && !url.starts_with(GUI::from_u8(sc.account_url()))) {
|
||||
wxCommandEvent* evt = new wxCommandEvent(EVT_OPEN_EXTERNAL_LOGIN);
|
||||
|
Loading…
x
Reference in New Issue
Block a user