| 1 |
/* |
| 2 |
* Copyright (C) 2012 Canonical, Ltd. |
| 3 |
* |
| 4 |
* Authors: |
| 5 |
* Ugo Riboni <[email protected]> |
| 6 |
* MichaĆ Sawicz <[email protected]> |
| 7 |
* |
| 8 |
* This program is free software; you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation; version 3. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
// Qt |
| 22 |
#include <QtCore/QCoreApplication> |
| 23 |
#include <QtCore/QDir> |
| 24 |
#include <QtCore/QString> |
| 25 |
|
| 26 |
static QString SNAP = qgetenv("SNAP"); |
| 27 |
static QString APP_DIR = qgetenv("APP_DIR"); |
| 28 |
static QString LOCALE_DIR = QStringLiteral("@CMAKE_INSTALL_FULL_LOCALEDIR@"); |
| 29 |
static QString MEDIAPLAYER_DIR = QStringLiteral("@MEDIAPLAYER_DIR@"); |
| 30 |
|
| 31 |
inline bool isRunningInstalled() { |
| 32 |
static bool installed = (QCoreApplication::applicationDirPath() == |
| 33 |
QDir(("@CMAKE_INSTALL_FULL_BINDIR@")).canonicalPath()); |
| 34 |
return installed; |
| 35 |
} |
| 36 |
|
| 37 |
inline QString i18nDir() |
| 38 |
{ |
| 39 |
if (!SNAP.isEmpty()) { |
| 40 |
return QDir::cleanPath(SNAP + QStringLiteral("/") + LOCALE_DIR); |
| 41 |
} else if (!APP_DIR.isEmpty()) { |
| 42 |
return QDir::cleanPath(APP_DIR + QStringLiteral("/") + LOCALE_DIR); |
| 43 |
} else if (isRunningInstalled()) { |
| 44 |
return QDir::cleanPath(LOCALE_DIR); |
| 45 |
} else { |
| 46 |
return QDir::currentPath(); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
inline QString mediaPlayerDirectory() { |
| 51 |
if (!SNAP.isEmpty()) { |
| 52 |
return QDir::cleanPath(SNAP + QStringLiteral("/") + MEDIAPLAYER_DIR); |
| 53 |
} else if (!APP_DIR.isEmpty()) { |
| 54 |
return QDir::cleanPath(APP_DIR + QStringLiteral("/") + MEDIAPLAYER_DIR); |
| 55 |
} else if (isRunningInstalled()) { |
| 56 |
return QDir::cleanPath(MEDIAPLAYER_DIR); |
| 57 |
} else { |
| 58 |
return QDir::currentPath(); |
| 59 |
} |
| 60 |
} |
| 61 |
|