fixes linux compilation problem. add /usr/games/bin support for appPath (gentoo)
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
//
|
||||
//
|
||||
#include "qthelper.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
QtHelper::QtHelper()
|
||||
{
|
||||
@@ -31,37 +31,10 @@ std::string QtHelper::stringToUtf8(const std::string &myString) {
|
||||
|
||||
std::string QtHelper::getDefaultLanguage() { return QLocale::system().name().toStdString(); }
|
||||
|
||||
QString QtHelper::getDataPath()
|
||||
{
|
||||
QString path(QCoreApplication::instance()->applicationDirPath());
|
||||
|
||||
#ifdef _WIN32
|
||||
path += "/data/";
|
||||
#else
|
||||
#ifdef __APPLE__
|
||||
if (QRegExp("Contents/MacOS/?$").indexIn(path) != -1) {
|
||||
// pointing into an macosx application bundle
|
||||
path += "/../Resources/data/";
|
||||
} else { path += "/data/"; }
|
||||
#else //Unix
|
||||
if (QRegExp("pokerth/?$").indexIn(path) != -1) {
|
||||
// there is an own application directory
|
||||
path += "/data/";
|
||||
} else if (QRegExp("bin/?$").indexIn(path) != -1) {
|
||||
// we are in a bin directory. e.g. /usr/bin
|
||||
path += "/../share/pokerth/data/";
|
||||
} else { path += "/data/"; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
return QDir::cleanPath(path) + "/";
|
||||
}
|
||||
|
||||
std::string QtHelper::getDataPathStdString(const char * /*argv0*/)
|
||||
{
|
||||
QString path(QCoreApplication::instance()->applicationDirPath());
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
path += "/data/";
|
||||
#else
|
||||
@@ -74,13 +47,15 @@ std::string QtHelper::getDataPathStdString(const char * /*argv0*/)
|
||||
if (QRegExp("pokerth/?$").indexIn(path) != -1) {
|
||||
// there is an own application directory
|
||||
path += "/data/";
|
||||
} else if (QRegExp("usr/games/bin/?$").indexIn(path) != -1) {
|
||||
// we are in /usr/games/bin (like gentoo linux does)
|
||||
path += "/../../share/games/pokerth/data/";
|
||||
} else if (QRegExp("bin/?$").indexIn(path) != -1) {
|
||||
// we are in a bin directory. e.g. /usr/bin
|
||||
path += "/../share/pokerth/data/";
|
||||
|
||||
} else { path += "/data/"; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
return (QDir::cleanPath(path) + "/").toUtf8().constData();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ public:
|
||||
std::string stringToUtf8(const std::string &);
|
||||
std::string getDefaultLanguage();
|
||||
|
||||
QString getDataPath();
|
||||
std::string getDataPathStdString(const char *argv0);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user