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 <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-01-02 13:58:36 +01:00
parent 7a37114af9
commit 351d3e50f9
2 changed files with 2 additions and 8 deletions

View File

@ -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

View File

@ -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");