Commit 9f9cbf2a authored by Mario Hlawitschka's avatar Mario Hlawitschka
Browse files

[CHANGE] changed path handling for OSX if the software is started from within a OSX bundle.

Next step is to fix my scripts and upload them into the tools directory to create OSX disk images that we can distribute easily.
parent a0dc0ffd
......@@ -65,6 +65,18 @@ void WPathHelper::setBasePaths( boost::filesystem::path appPath, boost::filesyst
m_modulePath = m_libPath / "openwalnut";
}
void WPathHelper::setBasePathsOSXBundle( boost::filesystem::path appPath, boost::filesystem::path homePath )
{
//W_ASSERT( appPath.substr( size()-sizeof( "MacOS" ), sizeof( "MacOS" ) ) == "MacOS" );
m_appPath = appPath;
m_homePath = homePath;
m_sharePath = m_appPath / "../Resources/openwalnut";
m_docPath = m_appPath / "../Resources/doc";
m_configPath = m_appPath / "../Resources/openwalnut";
m_libPath = m_appPath / "../lib"; // TODO(mario): what is this for?
m_modulePath = m_appPath / "../Resources/modules";
}
boost::filesystem::path WPathHelper::getAppPath()
{
return getPathHelper()->m_appPath;
......
......@@ -56,7 +56,7 @@ public:
static boost::shared_ptr< WPathHelper > getPathHelper();
/**
* Set the current application path. This should be called only once. The home path hereby is NOT the users home. It is an directory, where
* Set the current application path. This should be called only once. The home path hereby is NOT the users home. It is a directory, where
* OW can write user specific data. A good default here is to specify USERHOME/.OpenWalnut for example.
*
* \param appPath the application path
......@@ -64,6 +64,15 @@ public:
*/
void setBasePaths( boost::filesystem::path appPath, boost::filesystem::path homePath );
/**
* Set the current application path. This should be called only once. The home path hereby is NOT the users home. It is a directory, where
* OW can write user specific data. A good default here is to specify USERHOME/.OpenWalnut for example.
*
* \param appPath the application path
* \param homePath the OW home path
*/
void setBasePathsOSXBundle( boost::filesystem::path appPath, boost::filesystem::path homePath );
/**
* The path where the binary file resides in. This is for example /usr/bin.
*
......
......@@ -153,8 +153,27 @@ int WQt4Gui::run()
// the call path of the application, this uses QApplication which needs to be instantiated.
boost::filesystem::path walnutBin = boost::filesystem::path( QApplication::applicationDirPath().toStdString() );
// setup path helper which provides several paths to others^
// setup path helper which provides several paths to others
#ifdef Q_WS_MAC
// apple has a special file hierarchy in so-called bundles
// this code determines whether we are started from a bundle context
// and sets the paths according to Apple's guidelines inside the bundle
if ( QApplication::applicationDirPath().endsWith( "/MacOS" ) )
{
std::cout << "OSX bundle" << std::endl;
// we are in a bundle
// TODO(mario): apply default OSX behavior of using $HOME/Library/OpenWalnut ?
WPathHelper::getPathHelper()->setBasePathsOSXBundle( walnutBin, boost::filesystem::path( QDir::homePath().toStdString() ) / ".OpenWalnut" );
}
else
{
// assume standard behavior
WPathHelper::getPathHelper()->setBasePaths( walnutBin, boost::filesystem::path( QDir::homePath().toStdString() ) / ".OpenWalnut" );
}
#else
// on all other platforms, get the home directory form Qt and the path from the application binary location
WPathHelper::getPathHelper()->setBasePaths( walnutBin, boost::filesystem::path( QDir::homePath().toStdString() ) / ".OpenWalnut" );
#endif
// with the correct paths, we can load the settings
m_settings = new QSettings( QString::fromStdString( ( WPathHelper::getHomePath() / "config.qt4gui" ).string() ), QSettings::IniFormat );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment