diff --git a/oscar/SleepLib/common.cpp b/oscar/SleepLib/common.cpp index 1245d76b..ec91ce42 100644 --- a/oscar/SleepLib/common.cpp +++ b/oscar/SleepLib/common.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "SleepLib/common.h" @@ -214,12 +215,36 @@ QStringList getBuildInfo() { QString appResourcePath() { + static QString path; + if ( path.size() != 0 ) + return path; + #ifdef Q_OS_MAC - QString path = QDir::cleanPath(QCoreApplication::applicationDirPath() + "/../Resources"); + path = QDir::cleanPath(QCoreApplication::applicationDirPath() + "/../Resources"); #else - // not sure where it goes on Linux yet - QString path = QCoreApplication::applicationDirPath(); +// QStringList paths = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation); + // Check the Appiication Path first, so we can execute out of the build directory + QStringList paths; + // This one will be used if the Html and Translations folders + // are in the same folder as the OSCAR executable + paths.push_back( QCoreApplication::applicationDirPath() ); +#ifdef Q_OS_LINUX + paths.push_back( QString( "/usr/share/" ) + QCoreApplication::applicationName() ); + paths.push_back( QString( "/usr/local/share/" ) + QCoreApplication::applicationName() ); +#endif + for (auto p = begin(paths); p != end(paths); ++p ) { + QString fname = *p+QString("/Translations/oscar_qt_fr.qm"); + qDebug() << "Trying" << fname; + QFileInfo f = QFileInfo(fname); + if ( f.exists() ) { + path = *p; + break; + } + } + if ( path.size() == 0 ) + path = QCoreApplication::applicationDirPath(); #endif + return path; } diff --git a/oscar/main.cpp b/oscar/main.cpp index b416fcec..22503757 100644 --- a/oscar/main.cpp +++ b/oscar/main.cpp @@ -361,6 +361,9 @@ int main(int argc, char *argv[]) { // selection QDialog, which waits indefinitely for user input before MainWindow is constructed. qDebug().noquote() << "OSCAR starting" << QDateTime::currentDateTime().toString(); + qDebug() << "APP-NAME:" << QCoreApplication::applicationName(); + qDebug() << "APP-PATH:" << QCoreApplication::applicationDirPath(); + qDebug() << "APP-RESOURCES:" << appResourcePath(); #ifdef QT_DEBUG QString relinfo = " debug";