mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	ENH: create new page on click of privacy policy
Change-Id: I20026514c1e880986f24716c9f473507f608cd67
This commit is contained in:
		
							parent
							
								
									1b3ac0a0b6
								
							
						
					
					
						commit
						e422797292
					
				
					 4 changed files with 38 additions and 32 deletions
				
			
		|  | @ -2401,7 +2401,7 @@ bool CLI::setup(int argc, char **argv) | |||
| #ifdef __APPLE__ | ||||
|     // The application is packed in the .dmg archive as 'Slic3r.app/Contents/MacOS/Slic3r'
 | ||||
|     // The resources are packed to 'Slic3r.app/Contents/Resources'
 | ||||
|     boost::filesystem::path path_resources = boost::filesystem::canonical(path_to_binary).parent_path() / "../Resources"; | ||||
|     boost::filesystem::path path_resources = boost::filesystem::canonical(path_to_binary).parent_path().parent_path() / "Resources"; | ||||
| #elif defined _WIN32 | ||||
|     // The application is packed in the .zip archive in the root,
 | ||||
|     // The resources are packed to 'resources'
 | ||||
|  | @ -2415,7 +2415,7 @@ bool CLI::setup(int argc, char **argv) | |||
|     // The application is packed in the .tar.bz archive (or in AppImage) as 'bin/slic3r',
 | ||||
|     // The resources are packed to 'resources'
 | ||||
|     // Path from Slic3r binary to resources:
 | ||||
|     boost::filesystem::path path_resources = boost::filesystem::canonical(path_to_binary).parent_path() / "../resources"; | ||||
|     boost::filesystem::path path_resources = boost::filesystem::canonical(path_to_binary).parent_path().parent_path() / "resources"; | ||||
| #endif | ||||
| 
 | ||||
|     set_resources_dir(path_resources.string()); | ||||
|  |  | |||
|  | @ -57,16 +57,16 @@ PrivacyUpdateDialog::PrivacyUpdateDialog(wxWindow* parent, wxWindowID id, const | |||
|     m_vebview_release_note->SetSize(wxSize(FromDIP(540), FromDIP(340))); | ||||
|     m_vebview_release_note->SetMinSize(wxSize(FromDIP(540), FromDIP(340))); | ||||
| 
 | ||||
| 	fs::path ph(data_dir()); | ||||
| 	ph /= "resources/tooltip/privacyupdate.html"; | ||||
| 	if (!fs::exists(ph)) { | ||||
| 		ph = resources_dir(); | ||||
| 		ph /= "tooltip/privacyupdate.html"; | ||||
| 	} | ||||
| 	auto url = ph.string(); | ||||
| 	std::replace(url.begin(), url.end(), '\\', '/'); | ||||
| 	url = "file:///" + url; | ||||
|     m_vebview_release_note->LoadURL(from_u8(url)); | ||||
|     fs::path ph(data_dir()); | ||||
|     ph /= "resources/tooltip/privacyupdate.html"; | ||||
|     if (!fs::exists(ph)) { | ||||
|         ph = resources_dir(); | ||||
|         ph /= "tooltip/privacyupdate.html"; | ||||
|     } | ||||
|     m_host_url = ph.string(); | ||||
|     std::replace(m_host_url.begin(), m_host_url.end(), '\\', '/'); | ||||
|     m_host_url = "file:///" + m_host_url; | ||||
|     m_vebview_release_note->LoadURL(from_u8(m_host_url)); | ||||
|     m_sizer_right->Add(m_vebview_release_note, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(15)); | ||||
| 
 | ||||
|     auto sizer_button = new wxBoxSizer(wxHORIZONTAL); | ||||
|  | @ -84,8 +84,11 @@ PrivacyUpdateDialog::PrivacyUpdateDialog(wxWindow* parent, wxWindowID id, const | |||
|          if (!m_mkdown_text.empty()) { | ||||
|              ShowReleaseNote(m_mkdown_text); | ||||
|          } | ||||
|          e.Skip(); | ||||
|     }); | ||||
| 
 | ||||
|     m_vebview_release_note->Bind(wxEVT_WEBVIEW_NAVIGATING , &PrivacyUpdateDialog::OnNavigating, this); | ||||
| 
 | ||||
|     m_button_ok = new Button(this, _L("Accept")); | ||||
|     m_button_ok->SetBackgroundColor(btn_bg_green); | ||||
|     m_button_ok->SetBorderColor(*wxWHITE); | ||||
|  | @ -140,29 +143,24 @@ PrivacyUpdateDialog::PrivacyUpdateDialog(wxWindow* parent, wxWindowID id, const | |||
|     wxGetApp().UpdateDlgDarkUI(this); | ||||
| } | ||||
| 
 | ||||
| void PrivacyUpdateDialog::OnLoaded(wxWebViewEvent& event) | ||||
| { | ||||
|     event.Skip(); | ||||
| } | ||||
| 
 | ||||
| void PrivacyUpdateDialog::OnTitleChanged(wxWebViewEvent& event) | ||||
| { | ||||
|     event.Skip(); | ||||
| } | ||||
| void PrivacyUpdateDialog::OnError(wxWebViewEvent& event) | ||||
| { | ||||
|     event.Skip(); | ||||
| } | ||||
| 
 | ||||
| wxWebView* PrivacyUpdateDialog::CreateTipView(wxWindow* parent) | ||||
| { | ||||
| 	wxWebView* tipView = WebView::CreateWebView(parent, ""); | ||||
| 	tipView->Bind(wxEVT_WEBVIEW_LOADED, &PrivacyUpdateDialog::OnLoaded, this); | ||||
| 	tipView->Bind(wxEVT_WEBVIEW_NAVIGATED, &PrivacyUpdateDialog::OnTitleChanged, this); | ||||
| 	tipView->Bind(wxEVT_WEBVIEW_ERROR, &PrivacyUpdateDialog::OnError, this); | ||||
| 	return tipView; | ||||
| } | ||||
| 
 | ||||
| void PrivacyUpdateDialog::OnNavigating(wxWebViewEvent& event) | ||||
| { | ||||
|     wxString jump_url = event.GetURL(); | ||||
|     if (jump_url != m_host_url) { | ||||
|         event.Veto(); | ||||
|         wxLaunchDefaultBrowser(jump_url); | ||||
|     } | ||||
|     else { | ||||
|         event.Skip(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| bool PrivacyUpdateDialog::ShowReleaseNote(std::string content) | ||||
| { | ||||
| 	auto script = "window.showMarkdown('" + url_encode(content) + "', true);"; | ||||
|  |  | |||
|  | @ -31,9 +31,7 @@ public: | |||
|         long style = wxPD_APP_MODAL| wxCAPTION | ||||
|     ); | ||||
|     wxWebView* CreateTipView(wxWindow* parent); | ||||
|     void OnLoaded(wxWebViewEvent& event); | ||||
|     void OnTitleChanged(wxWebViewEvent& event); | ||||
|     void OnError(wxWebViewEvent& event); | ||||
|     void OnNavigating(wxWebViewEvent& event); | ||||
|     bool ShowReleaseNote(std::string content); | ||||
|     void RunScript(std::string script); | ||||
|     void set_text(std::string str) { m_mkdown_text = str; }; | ||||
|  | @ -50,6 +48,7 @@ public: | |||
|     Button* m_button_ok; | ||||
|     Button* m_button_cancel; | ||||
|     std::string m_mkdown_text; | ||||
|     std::string m_host_url; | ||||
| }; | ||||
| 
 | ||||
| }} // namespace Slic3r::GUI
 | ||||
|  |  | |||
|  | @ -287,6 +287,15 @@ void ZUserLogin::OnScriptMessage(wxWebViewEvent &evt) | |||
|                     wxLaunchDefaultBrowser(url); | ||||
|                     }); | ||||
|             } | ||||
|         } | ||||
|         else if (strCmd == "new_webpage") { | ||||
|             if (j["data"].contains("url")) { | ||||
|                 std::string jump_url = j["data"]["url"].get<std::string>(); | ||||
|                 CallAfter([this, jump_url] { | ||||
|                     wxString url = wxString::FromUTF8(jump_url); | ||||
|                     wxLaunchDefaultBrowser(url); | ||||
|                     }); | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|     } catch (std::exception &e) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 tao.jin
						tao.jin