diff options
author | Tor Arne Vestbø <[email protected]> | 2023-01-02 13:58:36 +0100 |
---|---|---|
committer | Tor Arne Vestbø <[email protected]> | 2023-01-02 19:01:30 +0100 |
commit | 351d3e50f993014ca6b17817c87d12153ca2f617 (patch) | |
tree | a05545600c86fca1ecc90d846c709e3db6df4ebf | |
parent | 7a37114af92fcaa6f8ed2eb17a4632b4880c8bbe (diff) |
macOS: Stop using the deprecated [NSWorkspace openFile:] API
We can use openURL instead, which also opens local files in the
associated application.
Pick-to: 6.5
Change-Id: Ieddc6fb68d6b9e64195ed261953b9fffb6b0b73e
Reviewed-by: Timur Pocheptsov <[email protected]>
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaservices.mm | 8 | ||||
-rw-r--r-- | src/printsupport/dialogs/qprintdialog_mac.mm | 2 |
2 files changed, 2 insertions, 8 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaservices.mm b/src/plugins/platforms/cocoa/qcocoaservices.mm index 29f8ed96e65..68daa660efb 100644 --- a/src/plugins/platforms/cocoa/qcocoaservices.mm +++ b/src/plugins/platforms/cocoa/qcocoaservices.mm @@ -12,18 +12,12 @@ QT_BEGIN_NAMESPACE bool QCocoaServices::openUrl(const QUrl &url) { - const QString scheme = url.scheme(); - if (scheme.isEmpty()) - return openDocument(url); return [[NSWorkspace sharedWorkspace] openURL:url.toNSURL()]; } bool QCocoaServices::openDocument(const QUrl &url) { - if (!url.isValid()) - return false; - - return [[NSWorkspace sharedWorkspace] openFile:url.toLocalFile().toNSString()]; + return openUrl(url); } QT_END_NAMESPACE diff --git a/src/printsupport/dialogs/qprintdialog_mac.mm b/src/printsupport/dialogs/qprintdialog_mac.mm index 6671afae527..b1b56dbf547 100644 --- a/src/printsupport/dialogs/qprintdialog_mac.mm +++ b/src/printsupport/dialogs/qprintdialog_mac.mm @@ -118,7 +118,7 @@ QT_USE_NAMESPACE // happen synchronously after the dialog is accepted, so we can defer // the opening of the file to the next runloop pass. dispatch_async(dispatch_get_main_queue(), ^{ - [NSWorkspace.sharedWorkspace openFile:fileName.toNSString()]; + [NSWorkspace.sharedWorkspace openURL:[NSURL fileURLWithPath:fileName.toNSString()]]; }); } else if (dest == kPMDestinationProcessPDF) { qWarning("Printing workflows are not supported"); |