mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
启动时进行 WebView2 运行时检查 (#1944)
* 启动时进行 WebView2 运行时检查 * 启动时进行 WebView2 运行时检查 * skip code sign for PR build * Russian translation for OrcaSlicer V1.6.4 (#1900) * Russian translation for OrcaSlicer V1.6.4 Please replace the existing translation with my translation. Advantages of this translation: -A normal translation based on the Prusa slicer translation (the translation of which I have been supporting for a long time). The translation that is used now is crude, there are a lot of errors and typos. -Added missing lines I also made a pull request for this translation for Bambu Studio (with small edits and add lines) * file name and location updates * update rename Russian.po in OrcaSlicer_ru.po * update * move OrcaSlicer_ru.po to correct location --------- Co-authored-by: SoftFever <softfeverever@gmail.com> * Fixed viewer resize malfunction when cjk language is use (#1909) * Update Korean translation * 1. Fix blank button text after translation 2. Fix some mistranslated korean * -fix bottom surface in gcode viewer -update korean translation * - Fixed UI being broken 'cause "display" text size could not be calculated when cjk language is use * Port overhang extra perimeters from PrusaSlicer (#1939) * Port overhang extra perimeters from PrusaSlicer * Reduce duplicated code * Add credits --------- Co-authored-by: SoftFever <softfeverever@gmail.com> Co-authored-by: PavelMikus <pavel.mikus.mail@seznam.cz> * Create OrcaSlicer_zh_TW.po for traditional Chinese translate (#1952) Create OrcaSlicer_zh_TW.po * update czech translate (#1949) * QoL: make slider thinner * QoL: show transparent shell in gcode preview and truncate long gcode line caused by native Klipper commands * PlaceholderParser: new interpolate_table() "function" interpolate_table(x, (x0, y0), (x1, y1), (x2, y2), ...) interpolates a table at position x. * GCodeGenerator / custom G-codes: Added new read/only options providing the amount of total extruded material and per extruder extruded material up to the point the value is evaluated: "extruded_volume", "extruded_weight", "extruded_volume_total", "extruded_weight_total" * support profile notes * Add support for PrusaLink webview * update Prusa profiles * Support Marlin 2 * tweak MK4IS * Fix Linux build errors * Add Tranditional Chinese * Fix *nix build error and some other fixes --------- Co-authored-by: ZdDroid <601865048@qq.com> Co-authored-by: SoftFever <softfeverever@gmail.com> Co-authored-by: Andy <andylg@yandex.ru> Co-authored-by: Hotsolidinfill <138652683+Hotsolidinfill@users.noreply.github.com> Co-authored-by: Noisyfox <timemanager.rick@gmail.com> Co-authored-by: PavelMikus <pavel.mikus.mail@seznam.cz> Co-authored-by: ablegods <85563455+ablegods@users.noreply.github.com> Co-authored-by: renemosner <99507763+renemosner@users.noreply.github.com> Co-authored-by: Vojtech Bubnik <bubnikv@gmail.com>
This commit is contained in:
parent
0b7b606881
commit
51eae690bd
4 changed files with 93 additions and 1 deletions
|
@ -1295,6 +1295,9 @@ GUI_App::GUI_App()
|
||||||
//app config initializes early becasuse it is used in instance checking in OrcaSlicer.cpp
|
//app config initializes early becasuse it is used in instance checking in OrcaSlicer.cpp
|
||||||
this->init_app_config();
|
this->init_app_config();
|
||||||
this->init_download_path();
|
this->init_download_path();
|
||||||
|
#if wxUSE_WEBVIEW_EDGE
|
||||||
|
this->init_webview_runtime();
|
||||||
|
#endif
|
||||||
|
|
||||||
reset_to_active();
|
reset_to_active();
|
||||||
}
|
}
|
||||||
|
@ -2045,6 +2048,20 @@ void GUI_App::init_download_path()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_WEBVIEW_EDGE
|
||||||
|
void GUI_App::init_webview_runtime()
|
||||||
|
{
|
||||||
|
// Check WebView Runtime
|
||||||
|
if (!WebView::CheckWebViewRuntime()) {
|
||||||
|
int nRet = wxMessageBox(_L("Orca Slicer requires the Microsoft WebView2 Runtime to operate certain features.\nClick Yes to install it now."),
|
||||||
|
_L("WebView2 Runtime"), wxYES_NO);
|
||||||
|
if (nRet == wxYES) {
|
||||||
|
WebView::DownloadAndInstallWebViewRuntime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void GUI_App::init_app_config()
|
void GUI_App::init_app_config()
|
||||||
{
|
{
|
||||||
// Profiles for the alpha are stored into the PrusaSlicer-alpha directory to not mix with the current release.
|
// Profiles for the alpha are stored into the PrusaSlicer-alpha directory to not mix with the current release.
|
||||||
|
|
|
@ -340,6 +340,9 @@ private:
|
||||||
bool init_opengl();
|
bool init_opengl();
|
||||||
|
|
||||||
void init_download_path();
|
void init_download_path();
|
||||||
|
#if wxUSE_WEBVIEW_EDGE
|
||||||
|
void init_webview_runtime();
|
||||||
|
#endif
|
||||||
static unsigned get_colour_approx_luma(const wxColour& colour);
|
static unsigned get_colour_approx_luma(const wxColour& colour);
|
||||||
static bool dark_mode();
|
static bool dark_mode();
|
||||||
const wxColour get_label_default_clr_system();
|
const wxColour get_label_default_clr_system();
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#include <WebView2.h>
|
#include <WebView2.h>
|
||||||
|
#include <Shellapi.h>
|
||||||
|
#include <slic3r/Utils/Http.hpp>
|
||||||
#elif defined __linux__
|
#elif defined __linux__
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#define WEBKIT_API
|
#define WEBKIT_API
|
||||||
|
@ -38,6 +40,61 @@ webkit_javascript_result_unref (WebKitJavascriptResult *js_result);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
|
// Run Download and Install in another thread so we don't block the UI thread
|
||||||
|
DWORD DownloadAndInstallWV2RT() {
|
||||||
|
|
||||||
|
int returnCode = 2; // Download failed
|
||||||
|
// Use fwlink to download WebView2 Bootstrapper at runtime and invoke installation
|
||||||
|
// Broken/Invalid Https Certificate will fail to download
|
||||||
|
// Use of the download link below is governed by the below terms. You may acquire the link
|
||||||
|
// for your use at https://developer.microsoft.com/microsoft-edge/webview2/. Microsoft owns
|
||||||
|
// all legal right, title, and interest in and to the WebView2 Runtime Bootstrapper
|
||||||
|
// ("Software") and related documentation, including any intellectual property in the
|
||||||
|
// Software. You must acquire all code, including any code obtained from a Microsoft URL,
|
||||||
|
// under a separate license directly from Microsoft, including a Microsoft download site
|
||||||
|
// (e.g., https://developer.microsoft.com/microsoft-edge/webview2/).
|
||||||
|
// HRESULT hr = URLDownloadToFileW(NULL, L"https://go.microsoft.com/fwlink/p/?LinkId=2124703",
|
||||||
|
// L".\\plugin\\MicrosoftEdgeWebview2Setup.exe", 0, 0);
|
||||||
|
fs::path target_file_path = (fs::temp_directory_path() / "MicrosoftEdgeWebview2Setup.exe");
|
||||||
|
bool downloaded = false;
|
||||||
|
Slic3r::Http::get("https://go.microsoft.com/fwlink/p/?LinkId=2124703")
|
||||||
|
.on_error([](std::string body, std::string error, unsigned http_status) {
|
||||||
|
|
||||||
|
})
|
||||||
|
.on_complete([&downloaded, target_file_path](std::string body, unsigned http_status) {
|
||||||
|
fs::fstream file(target_file_path, std::ios::out | std::ios::binary | std::ios::trunc);
|
||||||
|
file.write(body.c_str(), body.size());
|
||||||
|
file.flush();
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
downloaded = true;
|
||||||
|
})
|
||||||
|
.perform_sync();
|
||||||
|
// Sleep for 1 second to wait for the buffer writen into disk
|
||||||
|
std::this_thread::sleep_for(1000ms);
|
||||||
|
if (downloaded) {
|
||||||
|
// Either Package the WebView2 Bootstrapper with your app or download it using fwlink
|
||||||
|
// Then invoke install at Runtime.
|
||||||
|
SHELLEXECUTEINFOW shExInfo = {0};
|
||||||
|
shExInfo.cbSize = sizeof(shExInfo);
|
||||||
|
shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||||
|
shExInfo.hwnd = 0;
|
||||||
|
shExInfo.lpVerb = L"runas";
|
||||||
|
shExInfo.lpFile = target_file_path.generic_wstring().c_str();
|
||||||
|
shExInfo.lpParameters = L" /install";
|
||||||
|
shExInfo.lpDirectory = 0;
|
||||||
|
shExInfo.nShow = 0;
|
||||||
|
shExInfo.hInstApp = 0;
|
||||||
|
|
||||||
|
if (ShellExecuteExW(&shExInfo)) {
|
||||||
|
WaitForSingleObject(shExInfo.hProcess, INFINITE);
|
||||||
|
returnCode = 0; // Install successfull
|
||||||
|
} else {
|
||||||
|
returnCode = 1; // Install failed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnCode;
|
||||||
|
}
|
||||||
|
|
||||||
class WebViewEdge : public wxWebViewEdge
|
class WebViewEdge : public wxWebViewEdge
|
||||||
{
|
{
|
||||||
|
@ -260,7 +317,19 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
|
||||||
g_webviews.push_back(webView);
|
g_webviews.push_back(webView);
|
||||||
return webView;
|
return webView;
|
||||||
}
|
}
|
||||||
|
#if wxUSE_WEBVIEW_EDGE
|
||||||
|
bool WebView::CheckWebViewRuntime()
|
||||||
|
{
|
||||||
|
wxWebViewFactoryEdge factory;
|
||||||
|
auto wxVersion = factory.GetVersionInfo();
|
||||||
|
return wxVersion.GetMajor() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WebView::DownloadAndInstallWebViewRuntime()
|
||||||
|
{
|
||||||
|
return DownloadAndInstallWV2RT() == 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
void WebView::LoadUrl(wxWebView * webView, wxString const &url)
|
void WebView::LoadUrl(wxWebView * webView, wxString const &url)
|
||||||
{
|
{
|
||||||
auto url2 = url;
|
auto url2 = url;
|
||||||
|
|
|
@ -7,7 +7,10 @@ class WebView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static wxWebView *CreateWebView(wxWindow *parent, wxString const &url);
|
static wxWebView *CreateWebView(wxWindow *parent, wxString const &url);
|
||||||
|
#if wxUSE_WEBVIEW_EDGE
|
||||||
|
static bool CheckWebViewRuntime();
|
||||||
|
static bool DownloadAndInstallWebViewRuntime();
|
||||||
|
#endif
|
||||||
static void LoadUrl(wxWebView * webView, wxString const &url);
|
static void LoadUrl(wxWebView * webView, wxString const &url);
|
||||||
|
|
||||||
static bool RunScript(wxWebView * webView, wxString const & msg);
|
static bool RunScript(wxWebView * webView, wxString const & msg);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue