Skip to content

Commit f0043d6

Browse files
committedJul 31, 2018
Try to implement openFileExplorerAndSelectFile for OSX
1 parent 762099b commit f0043d6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed
 

‎src/native/mac/qgsmacnative.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class NATIVE_EXPORT QgsMacNative : public QgsNative
2727

2828
virtual const char *currentAppLocalizedName();
2929
void currentAppActivateIgnoringOtherApps() override;
30+
void openFileExplorerAndSelectFile( const QString &path ) override;
3031
};
3132

3233
#endif // QGSMACNATIVE_H

‎src/native/mac/qgsmacnative.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@
3434
[[NSRunningApplication currentApplication] activateWithOptions:
3535
(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];
3636
}
37+
38+
void openFileExplorerAndSelectFile( const QString &path )
39+
{
40+
NSString* pathStr = [[NSString alloc] initWithUTF8String:path.toUtf8().data()];
41+
NSArray *fileURLs = [NSArray arrayWithObjects:pathStr, /* ... */ nil];
42+
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs];
43+
}

0 commit comments

Comments
 (0)
Please sign in to comment.