fit-webview-bridge 0.2.2a2__tar.gz → 0.2.2a4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fit-webview-bridge might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: fit-webview-bridge
3
- Version: 0.2.2a2
3
+ Version: 0.2.2a4
4
4
  Summary: Qt native WebView bridge with PySide6 bindings
5
5
  Author: FIT Project
6
6
  License: LGPL-3.0-or-later
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fit-webview-bridge"
3
- version = "0.2.2a2"
3
+ version = "0.2.2a4"
4
4
  description = "Qt native WebView bridge with PySide6 bindings"
5
5
  requires-python = ">=3.11,<3.14"
6
6
  dependencies = ["PySide6==6.9.0", "shiboken6==6.9.0", "shiboken6-generator==6.9.0"]
@@ -1,9 +1,11 @@
1
1
  #import <Cocoa/Cocoa.h>
2
2
  #import <WebKit/WebKit.h>
3
+ #import <objc/message.h>
3
4
 
4
5
  #include "WKWebViewWidget.h"
5
6
  #include "DownloadInfo.h"
6
7
 
8
+
7
9
  #include <QtWidgets>
8
10
  #include <QString>
9
11
  #include <QUrl>
@@ -47,7 +49,7 @@ static NSURL* toNSURL(QUrl u);
47
49
  @end
48
50
 
49
51
  // ===== WKNavDelegate =====
50
- @interface WKNavDelegate : NSObject <WKNavigationDelegate, WKDownloadDelegate>
52
+ @interface WKNavDelegate : NSObject <WKNavigationDelegate, WKDownloadDelegate, WKUIDelegate>
51
53
  @property(nonatomic, assign) WKWebViewWidget* owner;
52
54
  // mappe per download
53
55
  @property(nonatomic, strong) NSMapTable<WKDownload*, NSString*>* downloadPaths; // weak key -> strong value
@@ -74,6 +76,34 @@ static NSURL* toNSURL(QUrl u);
74
76
 
75
77
  #pragma mark - Navigazione
76
78
 
79
+
80
+ // 1a) Navigation: intercetta click con targetFrame == nil (tipico di _blank)
81
+ - (void)webView:(WKWebView *)webView
82
+ decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
83
+ decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
84
+ {
85
+ // targetFrame == nil => richiesta per nuova finestra (target="_blank" o window.open)
86
+ if (navigationAction.targetFrame == nil || !navigationAction.targetFrame.isMainFrame) {
87
+ [webView loadRequest:navigationAction.request]; // carica QUI
88
+ decisionHandler(WKNavigationActionPolicyCancel); // cancella la creazione nuova finestra
89
+ return;
90
+ }
91
+ decisionHandler(WKNavigationActionPolicyAllow);
92
+ }
93
+
94
+ // 1b) UI: invocato quando la pagina chiede esplicitamente una nuova webview
95
+ - (WKWebView *)webView:(WKWebView *)webView
96
+ createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration
97
+ forNavigationAction:(WKNavigationAction *)navigationAction
98
+ windowFeatures:(WKWindowFeatures *)windowFeatures
99
+ {
100
+ if (navigationAction.targetFrame == nil || !navigationAction.targetFrame.isMainFrame) {
101
+ [webView loadRequest:navigationAction.request]; // apri nella stessa webview
102
+ }
103
+ return nil; // restituisci nil per NON creare una nuova finestra
104
+ }
105
+
106
+
77
107
  - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation {
78
108
  if (!self.owner) return;
79
109
  if (webView.URL)
@@ -390,6 +420,21 @@ WKWebViewWidget::WKWebViewWidget(QWidget* parent)
390
420
  cfg.defaultWebpagePreferences.allowsContentJavaScript = YES;
391
421
  }
392
422
 
423
+ // --- Fullscreen HTML5 (via KVC tollerante) ---
424
+ @try {
425
+ [cfg.preferences setValue:@YES forKey:@"fullScreenEnabled"];
426
+ } @catch (NSException *e) {
427
+ // ignore if not available
428
+ }
429
+
430
+ // --- AirPlay & PiP via selector per compatibilità SDK ---
431
+ if ([cfg respondsToSelector:@selector(setAllowsAirPlayForMediaPlayback:)]) {
432
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(cfg, @selector(setAllowsAirPlayForMediaPlayback:), YES);
433
+ }
434
+ if ([cfg respondsToSelector:@selector(setAllowsPictureInPictureMediaPlayback:)]) {
435
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(cfg, @selector(setAllowsPictureInPictureMediaPlayback:), YES);
436
+ }
437
+
393
438
  // SPA: intercetta pushState/replaceState/popstate/click
394
439
  d->ucc = [WKUserContentController new];
395
440
  d->msg = [FitUrlMsgHandler new];
@@ -423,6 +468,8 @@ WKWebViewWidget::WKWebViewWidget(QWidget* parent)
423
468
  d->delegate = [WKNavDelegate new];
424
469
  d->delegate.owner = this;
425
470
  [d->wk setNavigationDelegate:d->delegate];
471
+
472
+ [d->wk setUIDelegate:d->delegate];
426
473
  }
427
474
 
428
475
  WKWebViewWidget::~WKWebViewWidget() {