fit-webview-bridge 0.2.2a2__tar.gz → 0.2.2a5__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.2a5
4
4
  Summary: Qt native WebView bridge with PySide6 bindings
5
5
  Author: FIT Project
6
6
  License: LGPL-3.0-or-later
@@ -33,7 +33,7 @@ class Main(QMainWindow):
33
33
  self.view.titleChanged.connect(self.setWindowTitle)
34
34
  self.view.loadProgress.connect(lambda p: print("progress:", p))
35
35
 
36
- self.view.setUrl(QUrl("http://fit-project.org/"))
36
+ self.view.setUrl(QUrl("https://web.whatsapp.com/"))
37
37
 
38
38
 
39
39
  app = QApplication([])
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fit-webview-bridge"
3
- version = "0.2.2a2"
3
+ version = "0.2.2a5"
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,29 @@ 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
+ // Se è un _blank, no-op qui: ci pensa createWebView... (sopra)
86
+ decisionHandler(WKNavigationActionPolicyAllow);
87
+ }
88
+
89
+ // 1b) UI: invocato quando la pagina chiede esplicitamente una nuova webview
90
+ - (WKWebView *)webView:(WKWebView *)webView
91
+ createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration
92
+ forNavigationAction:(WKNavigationAction *)navigationAction
93
+ windowFeatures:(WKWindowFeatures *)windowFeatures
94
+ {
95
+ if (navigationAction.targetFrame == nil || !navigationAction.targetFrame.isMainFrame) {
96
+ [webView loadRequest:navigationAction.request]; // apri nella stessa webview
97
+ }
98
+ return nil; // restituisci nil per NON creare una nuova finestra
99
+ }
100
+
101
+
77
102
  - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation {
78
103
  if (!self.owner) return;
79
104
  if (webView.URL)
@@ -390,6 +415,21 @@ WKWebViewWidget::WKWebViewWidget(QWidget* parent)
390
415
  cfg.defaultWebpagePreferences.allowsContentJavaScript = YES;
391
416
  }
392
417
 
418
+ // --- Fullscreen HTML5 (via KVC tollerante) ---
419
+ @try {
420
+ [cfg.preferences setValue:@YES forKey:@"fullScreenEnabled"];
421
+ } @catch (NSException *e) {
422
+ // ignore if not available
423
+ }
424
+
425
+ // --- AirPlay & PiP via selector per compatibilità SDK ---
426
+ if ([cfg respondsToSelector:@selector(setAllowsAirPlayForMediaPlayback:)]) {
427
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(cfg, @selector(setAllowsAirPlayForMediaPlayback:), YES);
428
+ }
429
+ if ([cfg respondsToSelector:@selector(setAllowsPictureInPictureMediaPlayback:)]) {
430
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(cfg, @selector(setAllowsPictureInPictureMediaPlayback:), YES);
431
+ }
432
+
393
433
  // SPA: intercetta pushState/replaceState/popstate/click
394
434
  d->ucc = [WKUserContentController new];
395
435
  d->msg = [FitUrlMsgHandler new];
@@ -423,6 +463,8 @@ WKWebViewWidget::WKWebViewWidget(QWidget* parent)
423
463
  d->delegate = [WKNavDelegate new];
424
464
  d->delegate.owner = this;
425
465
  [d->wk setNavigationDelegate:d->delegate];
466
+
467
+ [d->wk setUIDelegate:d->delegate];
426
468
  }
427
469
 
428
470
  WKWebViewWidget::~WKWebViewWidget() {