Skip to content

Commit

Permalink
Try to implement openFileExplorerAndSelectFile for OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 31, 2018
1 parent 762099b commit f0043d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/native/mac/qgsmacnative.h
Expand Up @@ -27,6 +27,7 @@ class NATIVE_EXPORT QgsMacNative : public QgsNative

virtual const char *currentAppLocalizedName();
void currentAppActivateIgnoringOtherApps() override;
void openFileExplorerAndSelectFile( const QString &path ) override;
};

#endif // QGSMACNATIVE_H
7 changes: 7 additions & 0 deletions src/native/mac/qgsmacnative.mm
Expand Up @@ -34,3 +34,10 @@
[[NSRunningApplication currentApplication] activateWithOptions:
(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];
}

void openFileExplorerAndSelectFile( const QString &path )
{
NSString* pathStr = [[NSString alloc] initWithUTF8String:path.toUtf8().data()];
NSArray *fileURLs = [NSArray arrayWithObjects:pathStr, /* ... */ nil];
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs];
}

0 comments on commit f0043d6

Please sign in to comment.