fit-webview-bridge 0.2.1a5__tar.gz → 0.2.2a2__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.
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/PKG-INFO +1 -1
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/bindings/pyside6/macos/typesystem_wkwebview.xml +3 -0
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/pyproject.toml +1 -1
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/src/macos/CMakeLists.txt +1 -0
- fit_webview_bridge-0.2.2a2/src/macos/DownloadInfo.h +26 -0
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/src/macos/WKWebViewWidget.h +3 -1
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/src/macos/WKWebViewWidget.mm +51 -5
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/.github/workflows/wheels-macos.yml +0 -0
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/.gitignore +0 -0
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/.vscode/settings.json +0 -0
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/CMakeLists.txt +0 -0
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/README.md +0 -0
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/bindings/pyside6/macos/CMakeLists.txt +0 -0
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/examples/macos/wkwebview_demo.py +0 -0
- {fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/fit_webview_bridge/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "fit-webview-bridge"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.2a2"
|
|
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"]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <QObject>
|
|
3
|
+
#include <QString>
|
|
4
|
+
#include <QUrl>
|
|
5
|
+
|
|
6
|
+
class DownloadInfo : public QObject {
|
|
7
|
+
Q_OBJECT
|
|
8
|
+
Q_PROPERTY(QString downloadFileName READ downloadFileName CONSTANT)
|
|
9
|
+
Q_PROPERTY(QString downloadDirectory READ downloadDirectory CONSTANT)
|
|
10
|
+
Q_PROPERTY(QUrl downloadUrl READ downloadUrl CONSTANT)
|
|
11
|
+
public:
|
|
12
|
+
explicit DownloadInfo(const QString& fileName,
|
|
13
|
+
const QString& directory,
|
|
14
|
+
const QUrl& url,
|
|
15
|
+
QObject* parent=nullptr)
|
|
16
|
+
: QObject(parent), m_fileName(fileName), m_directory(directory), m_url(url) {}
|
|
17
|
+
|
|
18
|
+
QString downloadFileName() const { return m_fileName; }
|
|
19
|
+
QString downloadDirectory() const { return m_directory; }
|
|
20
|
+
QUrl downloadUrl() const { return m_url; }
|
|
21
|
+
|
|
22
|
+
private:
|
|
23
|
+
QString m_fileName;
|
|
24
|
+
QString m_directory;
|
|
25
|
+
QUrl m_url;
|
|
26
|
+
};
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
#include <QObject>
|
|
4
4
|
#include <QUrl>
|
|
5
5
|
|
|
6
|
+
#include "DownloadInfo.h"
|
|
7
|
+
|
|
6
8
|
class QString; class QShowEvent; class QResizeEvent;
|
|
7
9
|
|
|
8
10
|
class WKWebViewWidget : public QWidget {
|
|
@@ -36,7 +38,7 @@ signals:
|
|
|
36
38
|
|
|
37
39
|
void downloadStarted(const QString& suggestedFilename, const QString& destinationPath);
|
|
38
40
|
void downloadProgress(qint64 bytesReceived, qint64 totalBytes);
|
|
39
|
-
void downloadFinished(
|
|
41
|
+
void downloadFinished(DownloadInfo* info);
|
|
40
42
|
void downloadFailed(const QString& filePath, const QString& error);
|
|
41
43
|
|
|
42
44
|
protected:
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#import <WebKit/WebKit.h>
|
|
3
3
|
|
|
4
4
|
#include "WKWebViewWidget.h"
|
|
5
|
+
#include "DownloadInfo.h"
|
|
5
6
|
|
|
6
7
|
#include <QtWidgets>
|
|
7
8
|
#include <QString>
|
|
@@ -53,6 +54,8 @@ static NSURL* toNSURL(QUrl u);
|
|
|
53
54
|
@property(nonatomic, strong) NSMapTable<NSProgress*, WKDownload*>* progressToDownload; // weak->weak
|
|
54
55
|
@property(nonatomic, strong) NSHashTable<NSProgress*>* completedProgresses; // weak set
|
|
55
56
|
@property(nonatomic, strong) NSMapTable<WKDownload*, NSNumber*>* expectedTotals; // weak->strong
|
|
57
|
+
@property(nonatomic, strong) NSMapTable<WKDownload*, NSURL*>* sourceURLs; // weak->strong
|
|
58
|
+
@property(nonatomic, strong) NSMapTable<WKDownload*, NSString*>* suggestedNames; // weak->strong
|
|
56
59
|
@end
|
|
57
60
|
|
|
58
61
|
@implementation WKNavDelegate
|
|
@@ -63,6 +66,8 @@ static NSURL* toNSURL(QUrl u);
|
|
|
63
66
|
_progressToDownload = [NSMapTable weakToWeakObjectsMapTable];
|
|
64
67
|
_completedProgresses = [NSHashTable weakObjectsHashTable];
|
|
65
68
|
_expectedTotals = [NSMapTable weakToStrongObjectsMapTable];
|
|
69
|
+
_sourceURLs = [NSMapTable weakToStrongObjectsMapTable];
|
|
70
|
+
_suggestedNames = [NSMapTable weakToStrongObjectsMapTable];
|
|
66
71
|
}
|
|
67
72
|
return self;
|
|
68
73
|
}
|
|
@@ -133,6 +138,12 @@ navigationAction:(WKNavigationAction *)navigationAction
|
|
|
133
138
|
didBecomeDownload:(WKDownload *)download
|
|
134
139
|
{
|
|
135
140
|
download.delegate = self;
|
|
141
|
+
|
|
142
|
+
// URL sorgente (request dell’azione)
|
|
143
|
+
if (navigationAction.request.URL) {
|
|
144
|
+
[self.sourceURLs setObject:navigationAction.request.URL forKey:download];
|
|
145
|
+
}
|
|
146
|
+
|
|
136
147
|
if (self.owner) emit self.owner->downloadStarted(QString(), QString());
|
|
137
148
|
|
|
138
149
|
// KVO su NSProgress (3 keyPath, con INITIAL)
|
|
@@ -155,6 +166,10 @@ didBecomeDownload:(WKDownload *)download
|
|
|
155
166
|
{
|
|
156
167
|
download.delegate = self;
|
|
157
168
|
|
|
169
|
+
if (navigationResponse.response.URL) {
|
|
170
|
+
[self.sourceURLs setObject:navigationResponse.response.URL forKey:download];
|
|
171
|
+
}
|
|
172
|
+
|
|
158
173
|
NSString* suggested = navigationResponse.response.suggestedFilename ?: @"download";
|
|
159
174
|
if (self.owner) {
|
|
160
175
|
QString dir = self.owner->downloadDirectory();
|
|
@@ -228,6 +243,12 @@ completionHandler:(void (^)(NSURL * _Nullable destination))completionHandler
|
|
|
228
243
|
}
|
|
229
244
|
}
|
|
230
245
|
|
|
246
|
+
if (suggestedFilename) {
|
|
247
|
+
[self.suggestedNames setObject:suggestedFilename forKey:download];
|
|
248
|
+
} else if (![self.suggestedNames objectForKey:download]) {
|
|
249
|
+
[self.suggestedNames setObject:@"download" forKey:download];
|
|
250
|
+
}
|
|
251
|
+
|
|
231
252
|
completionHandler([NSURL fileURLWithPath:finalPath]);
|
|
232
253
|
}
|
|
233
254
|
|
|
@@ -269,43 +290,68 @@ completionHandler:(void (^)(NSURL * _Nullable destination))completionHandler
|
|
|
269
290
|
- (void)downloadDidFinish:(WKDownload *)download {
|
|
270
291
|
if (!self.owner) return;
|
|
271
292
|
|
|
293
|
+
// 1) stop KVO
|
|
272
294
|
@try {
|
|
273
295
|
[download.progress removeObserver:self forKeyPath:@"fractionCompleted"];
|
|
274
296
|
[download.progress removeObserver:self forKeyPath:@"completedUnitCount"];
|
|
275
297
|
[download.progress removeObserver:self forKeyPath:@"totalUnitCount"];
|
|
276
298
|
} @catch (...) {}
|
|
277
299
|
|
|
300
|
+
// 2) marca come completato per filtrare update tardivi
|
|
278
301
|
[self.completedProgresses addObject:download.progress];
|
|
279
302
|
|
|
280
|
-
|
|
303
|
+
// 3) raccogli dati
|
|
281
304
|
NSString* finalPath = [self.downloadPaths objectForKey:download];
|
|
282
|
-
|
|
305
|
+
NSString* fname = [self.suggestedNames objectForKey:download];
|
|
306
|
+
if (!fname && finalPath) fname = [finalPath lastPathComponent];
|
|
307
|
+
NSString* dir = finalPath ? [finalPath stringByDeletingLastPathComponent] : nil;
|
|
308
|
+
NSURL* src = [self.sourceURLs objectForKey:download];
|
|
309
|
+
|
|
310
|
+
// 4) crea DownloadInfo* e emetti
|
|
311
|
+
QString qFileName = fname ? QString::fromUtf8(fname.UTF8String) : QString();
|
|
312
|
+
QString qDir = dir ? QString::fromUtf8(dir.UTF8String) : QString();
|
|
313
|
+
QUrl qUrl = src ? QUrl::fromEncoded(QByteArray(src.absoluteString.UTF8String))
|
|
314
|
+
: QUrl();
|
|
315
|
+
|
|
316
|
+
DownloadInfo* info = new DownloadInfo(qFileName, qDir, qUrl, self.owner);
|
|
317
|
+
emit self.owner->downloadFinished(info);
|
|
318
|
+
|
|
319
|
+
// 5) cleanup mappe
|
|
283
320
|
if (finalPath) [self.downloadPaths removeObjectForKey:download];
|
|
284
321
|
[self.progressToDownload removeObjectForKey:download.progress];
|
|
285
|
-
[self.expectedTotals removeObjectForKey:download];
|
|
322
|
+
[self.expectedTotals removeObjectForKey:download];
|
|
323
|
+
[self.sourceURLs removeObjectForKey:download];
|
|
324
|
+
[self.suggestedNames removeObjectForKey:download];
|
|
286
325
|
}
|
|
287
326
|
|
|
327
|
+
|
|
288
328
|
- (void)download:(WKDownload *)download didFailWithError:(NSError *)error resumeData:(NSData *)resumeData {
|
|
289
329
|
if (!self.owner) return;
|
|
290
330
|
|
|
331
|
+
// stop KVO
|
|
291
332
|
@try {
|
|
292
333
|
[download.progress removeObserver:self forKeyPath:@"fractionCompleted"];
|
|
293
334
|
[download.progress removeObserver:self forKeyPath:@"completedUnitCount"];
|
|
294
335
|
[download.progress removeObserver:self forKeyPath:@"totalUnitCount"];
|
|
295
336
|
} @catch (...) {}
|
|
296
|
-
|
|
297
337
|
[self.completedProgresses addObject:download.progress];
|
|
298
338
|
|
|
339
|
+
// path (se già deciso)
|
|
299
340
|
NSString* finalPath = [self.downloadPaths objectForKey:download];
|
|
300
341
|
emit self.owner->downloadFailed(
|
|
301
342
|
finalPath ? QString::fromUtf8(finalPath.UTF8String) : QString(),
|
|
302
343
|
QString::fromUtf8(error.localizedDescription.UTF8String)
|
|
303
344
|
);
|
|
345
|
+
|
|
346
|
+
// cleanup mappe
|
|
304
347
|
if (finalPath) [self.downloadPaths removeObjectForKey:download];
|
|
305
348
|
[self.progressToDownload removeObjectForKey:download.progress];
|
|
306
|
-
[self.expectedTotals removeObjectForKey:download];
|
|
349
|
+
[self.expectedTotals removeObjectForKey:download];
|
|
350
|
+
[self.sourceURLs removeObjectForKey:download];
|
|
351
|
+
[self.suggestedNames removeObjectForKey:download];
|
|
307
352
|
}
|
|
308
353
|
|
|
354
|
+
|
|
309
355
|
@end
|
|
310
356
|
|
|
311
357
|
// =======================
|
{fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/.github/workflows/wheels-macos.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fit_webview_bridge-0.2.1a5 → fit_webview_bridge-0.2.2a2}/bindings/pyside6/macos/CMakeLists.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|