/* * Copyright (C) 2012 Canonical, Ltd. * * Authors: * Ugo Riboni * MichaƂ Sawicz * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ // Qt #include #include #include static QString SNAP = qgetenv("SNAP"); static QString APP_DIR = qgetenv("APP_DIR"); static QString LOCALE_DIR = QStringLiteral("@CMAKE_INSTALL_FULL_LOCALEDIR@"); static QString MEDIAPLAYER_DIR = QStringLiteral("@MEDIAPLAYER_DIR@"); inline bool isRunningInstalled() { static bool installed = (QCoreApplication::applicationDirPath() == QDir(("@CMAKE_INSTALL_FULL_BINDIR@")).canonicalPath()); return installed; } inline QString i18nDir() { if (!SNAP.isEmpty()) { return QDir::cleanPath(SNAP + QStringLiteral("/") + LOCALE_DIR); } else if (!APP_DIR.isEmpty()) { return QDir::cleanPath(APP_DIR + QStringLiteral("/") + LOCALE_DIR); } else if (isRunningInstalled()) { return QDir::cleanPath(LOCALE_DIR); } else { return QDir::currentPath(); } } inline QString mediaPlayerDirectory() { if (!SNAP.isEmpty()) { return QDir::cleanPath(SNAP + QStringLiteral("/") + MEDIAPLAYER_DIR); } else if (!APP_DIR.isEmpty()) { return QDir::cleanPath(APP_DIR + QStringLiteral("/") + MEDIAPLAYER_DIR); } else if (isRunningInstalled()) { return QDir::cleanPath(MEDIAPLAYER_DIR); } else { return QDir::currentPath(); } }