mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-28 04:18:41 +00:00
fix: macOS
This commit is contained in:
@@ -39,6 +39,7 @@ using Slic3r::GUI::unique_plugin_download_path;
|
|||||||
- (void)removeDownloadDelegate:(id)delegate;
|
- (void)removeDownloadDelegate:(id)delegate;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
API_AVAILABLE(macos(11.3))
|
||||||
@interface OrcaWKDownloadDelegate : NSObject <WKDownloadDelegate>
|
@interface OrcaWKDownloadDelegate : NSObject <WKDownloadDelegate>
|
||||||
{
|
{
|
||||||
OrcaWKDownloadContext* m_context;
|
OrcaWKDownloadContext* m_context;
|
||||||
@@ -169,10 +170,14 @@ static void wk_decide_navigation_response(WKWebView* webView,
|
|||||||
should_download = should_download ||
|
should_download = should_download ||
|
||||||
[disposition rangeOfString:@"attachment" options:NSCaseInsensitiveSearch].location != NSNotFound;
|
[disposition rangeOfString:@"attachment" options:NSCaseInsensitiveSearch].location != NSNotFound;
|
||||||
}
|
}
|
||||||
decisionHandler(should_download ? WKNavigationResponsePolicyDownload : WKNavigationResponsePolicyAllow);
|
if (@available(macOS 11.3, *)) {
|
||||||
|
decisionHandler(should_download ? WKNavigationResponsePolicyDownload : WKNavigationResponsePolicyAllow);
|
||||||
|
} else {
|
||||||
|
decisionHandler(WKNavigationResponsePolicyAllow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wk_did_become_download(WKWebView* webView, WKNavigationResponse*, WKDownload* download)
|
static void wk_did_become_download(WKWebView* webView, WKNavigationResponse*, WKDownload* download) API_AVAILABLE(macos(11.3))
|
||||||
{
|
{
|
||||||
OrcaWKDownloadContext* context = wk_download_context(webView);
|
OrcaWKDownloadContext* context = wk_download_context(webView);
|
||||||
if (!context)
|
if (!context)
|
||||||
@@ -197,7 +202,7 @@ static void wk_did_become_download_imp(id,
|
|||||||
SEL,
|
SEL,
|
||||||
WKWebView* webView,
|
WKWebView* webView,
|
||||||
WKNavigationResponse* response,
|
WKNavigationResponse* response,
|
||||||
WKDownload* download)
|
WKDownload* download) API_AVAILABLE(macos(11.3))
|
||||||
{
|
{
|
||||||
wk_did_become_download(webView, response, download);
|
wk_did_become_download(webView, response, download);
|
||||||
}
|
}
|
||||||
@@ -206,7 +211,7 @@ static void wk_did_become_action_download_imp(id,
|
|||||||
SEL,
|
SEL,
|
||||||
WKWebView* webView,
|
WKWebView* webView,
|
||||||
WKNavigationAction* action,
|
WKNavigationAction* action,
|
||||||
WKDownload* download)
|
WKDownload* download) API_AVAILABLE(macos(11.3))
|
||||||
{
|
{
|
||||||
(void)action;
|
(void)action;
|
||||||
OrcaWKDownloadContext* context = wk_download_context(webView);
|
OrcaWKDownloadContext* context = wk_download_context(webView);
|
||||||
@@ -229,14 +234,16 @@ static void install_wk_download_delegate_methods(WKWebView* webView)
|
|||||||
@selector(webView:decidePolicyForNavigationResponse:decisionHandler:),
|
@selector(webView:decidePolicyForNavigationResponse:decisionHandler:),
|
||||||
(IMP)wk_decide_navigation_response_imp,
|
(IMP)wk_decide_navigation_response_imp,
|
||||||
"v@:@@@");
|
"v@:@@@");
|
||||||
class_addMethod(delegateClass,
|
if (@available(macOS 11.3, *)) {
|
||||||
@selector(webView:navigationResponse:didBecomeDownload:),
|
class_addMethod(delegateClass,
|
||||||
(IMP)wk_did_become_download_imp,
|
@selector(webView:navigationResponse:didBecomeDownload:),
|
||||||
"v@:@@@");
|
(IMP)wk_did_become_download_imp,
|
||||||
class_addMethod(delegateClass,
|
"v@:@@@");
|
||||||
@selector(webView:navigationAction:didBecomeDownload:),
|
class_addMethod(delegateClass,
|
||||||
(IMP)wk_did_become_action_download_imp,
|
@selector(webView:navigationAction:didBecomeDownload:),
|
||||||
"v@:@@@");
|
(IMP)wk_did_become_action_download_imp,
|
||||||
|
"v@:@@@");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation MacDarkMode
|
@implementation MacDarkMode
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <slic3r/plugin/PluginManager.hpp>
|
#include <slic3r/plugin/PluginManager.hpp>
|
||||||
#include <slic3r/plugin/PythonInterpreter.hpp>
|
#include <slic3r/plugin/PythonInterpreter.hpp>
|
||||||
#include <slic3r/plugin/PythonPluginInterface.hpp>
|
#include <slic3r/plugin/PythonPluginInterface.hpp>
|
||||||
|
#include <slic3r/Utils/OrcaCloudServiceAgent.hpp>
|
||||||
|
|
||||||
#include "plugin_test_utils.hpp"
|
#include "plugin_test_utils.hpp"
|
||||||
|
|
||||||
@@ -180,7 +181,18 @@ TEST_CASE("cloud metadata refresh preserves a plugin's stored config", "[PluginC
|
|||||||
CHECK_FALSE(orphaned.has_error());
|
CHECK_FALSE(orphaned.has_error());
|
||||||
CHECK(orphaned.get_update_status() == PluginUpdateStatus::Normal);
|
CHECK(orphaned.get_update_status() == PluginUpdateStatus::Normal);
|
||||||
|
|
||||||
// Orphaned is informational only: the local package must remain loadable and usable.
|
// Orphaned is informational only: the local package must remain loadable and usable. Loading
|
||||||
|
// it exercises get_storage_dir(), which for a cloud plugin needs a real logged-in session
|
||||||
|
// (PluginManager::get_storage_dir() throws otherwise) -- the same session a real user would
|
||||||
|
// already hold for a plugin they'd previously subscribed to and downloaded. Give the manager
|
||||||
|
// one via the real agent: OrcaCloudServiceAgent's constructor does no networking, and
|
||||||
|
// set_user_session(..., persist=false) only sets in-memory session state, so this stays a
|
||||||
|
// fast, offline unit test.
|
||||||
|
auto cloud_agent = std::make_shared<OrcaCloudServiceAgent>(get_orca_plugins_dir());
|
||||||
|
cloud_agent->set_user_session(/*token=*/"test-token", /*user_id=*/"test-user", /*username=*/"test-user",
|
||||||
|
/*nickname=*/"", /*avatar=*/"", /*refresh_token=*/"", /*persist=*/false);
|
||||||
|
manager.set_cloud_agent(cloud_agent);
|
||||||
|
|
||||||
std::string load_error;
|
std::string load_error;
|
||||||
manager.load_plugin(uuid, /*skip_deps=*/true);
|
manager.load_plugin(uuid, /*skip_deps=*/true);
|
||||||
REQUIRE(manager.wait_for_plugin_load(uuid, std::chrono::seconds(120), load_error));
|
REQUIRE(manager.wait_for_plugin_load(uuid, std::chrono::seconds(120), load_error));
|
||||||
|
|||||||
Reference in New Issue
Block a user