Add some useful mac functions.
This commit is contained in:
parent
2986b27fd7
commit
a4386de578
@ -11,6 +11,9 @@ void SetShortcutHandler(GlobalShortcuts* handler);
|
||||
void SetApplicationHandler(QObject* handler);
|
||||
void CheckForUpdates();
|
||||
|
||||
QString GetBundlePath();
|
||||
QString GetResourcesPath();
|
||||
|
||||
} // namespace mac
|
||||
|
||||
#endif
|
||||
|
@ -152,4 +152,19 @@ void CheckForUpdates() {
|
||||
[[SUUpdater sharedUpdater] checkForUpdates: NSApp];
|
||||
}
|
||||
|
||||
QString GetBundlePath() {
|
||||
CFURLRef app_url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||
CFStringRef mac_path = CFURLCopyFileSystemPath(app_url, kCFURLPOSIXPathStyle);
|
||||
const char* path = CFStringGetCStringPtr(mac_path, kCFStringEncodingUTF8);
|
||||
QString bundle_path = QString::fromUtf8(path);
|
||||
CFRelease(app_url);
|
||||
CFRelease(mac_path);
|
||||
return bundle_path;
|
||||
}
|
||||
|
||||
QString GetResourcesPath() {
|
||||
QString bundle_path = GetBundlePath();
|
||||
return bundle_path + "/Contents/Resources";
|
||||
}
|
||||
|
||||
} // namespace mac
|
||||
|
Loading…
x
Reference in New Issue
Block a user