Skip to content

Commit

Permalink
fix mac build and fix native file selector
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Aug 3, 2018
1 parent 970fc4f commit a893f52
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/native/CMakeLists.txt
Expand Up @@ -116,7 +116,7 @@ ELSE(NOT APPLE)
FRAMEWORK_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}"
MACOSX_FRAMEWORK_INFO_PLIST "${CMAKE_SOURCE_DIR}/mac/framework.info.plist.in"
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${COMPLETE_VERSION}
MACOSX_FRAMEWORK_IDENTIFIER org.qgis.qgis2_native
MACOSX_FRAMEWORK_IDENTIFIER org.qgis.qgis3_native
BUILD_WITH_INSTALL_RPATH TRUE
PUBLIC_HEADER "${QGIS_NATIVE_HDRS}"
LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
Expand Down
3 changes: 3 additions & 0 deletions src/native/mac/qgsmacnative.h
Expand Up @@ -20,6 +20,9 @@

#include "qgsnative.h"

class QString;


class NATIVE_EXPORT QgsMacNative : public QgsNative
{
public:
Expand Down
12 changes: 6 additions & 6 deletions src/native/mac/qgsmacnative.mm
Expand Up @@ -18,26 +18,26 @@
#include "qgsmacnative.h"

#include <Cocoa/Cocoa.h>
#include <QString>

QgsMacNative::~QgsMacNative()
{
}

const char* QgsMacNative::currentAppLocalizedName()
const char *QgsMacNative::currentAppLocalizedName()
{
return [[[NSRunningApplication currentApplication] localizedName] UTF8String];
}

void QgsMacNative::currentAppActivateIgnoringOtherApps()
{
// valid for Mac OS X >= 10.6
[[NSRunningApplication currentApplication] activateWithOptions:
(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];
( NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps )];
}

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

2 comments on commit a893f52

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@3nids
Thanks! Who'd have thought coding without testing was a bad idea?

@3nids
Copy link
Member Author

@3nids 3nids commented on a893f52 Aug 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not that bad for a blind test!

Please sign in to comment.