From 96714fc2c136da990d9da1b4d6416f5a23e0e98a Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 10 Nov 2013 22:19:32 +0400 Subject: [PATCH] OpenCS: proper working dir & library path on OS X --- apps/opencs/main.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/apps/opencs/main.cpp b/apps/opencs/main.cpp index 76869d0af..1a3f63c4b 100644 --- a/apps/opencs/main.cpp +++ b/apps/opencs/main.cpp @@ -8,8 +8,8 @@ #include // for Ogre::macBundlePath -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE -#include +#ifdef Q_OS_MAC +#include #endif class Application : public QApplication @@ -37,15 +37,28 @@ class Application : public QApplication int main(int argc, char *argv[]) { -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE - // set current dir to bundle path - boost::filesystem::path bundlePath = boost::filesystem::path(Ogre::macBundlePath()).parent_path(); - boost::filesystem::current_path(bundlePath); -#endif - Q_INIT_RESOURCE (resources); Application mApplication (argc, argv); +#ifdef Q_OS_MAC + QDir dir(QCoreApplication::applicationDirPath()); + if (dir.dirName() == "MacOS") { + dir.cdUp(); + dir.cdUp(); + dir.cdUp(); + } + QDir::setCurrent(dir.absolutePath()); + + // force Qt to load only LOCAL plugins, don't touch system Qt installation + QDir pluginsPath(QCoreApplication::applicationDirPath()); + pluginsPath.cdUp(); + pluginsPath.cd("Plugins"); + + QStringList libraryPaths; + libraryPaths << pluginsPath.path() << QCoreApplication::applicationDirPath(); + mApplication.setLibraryPaths(libraryPaths); +#endif + mApplication.setWindowIcon (QIcon (":./opencs.png")); CS::Editor editor;