on 5ab40fb help sign in
unity8/paths.h.in
87 lines 2.5 kB history raw
1/*
2 * Copyright (C) 2012 Canonical, Ltd.
3 *
4 * Authors:
5 * Ugo Riboni <ugo.riboni@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
20#ifndef PATHS_H
21#define PATHS_H
23// Qt
24#include <QtCore/QCoreApplication>
25#include <QtCore/QDir>
26#include <QStandardPaths>
28inline bool isRunningInstalled() {
29 static bool installed = (QCoreApplication::applicationDirPath() ==
30 QDir(("@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@")).canonicalPath());
31 return installed;
34inline QString translationDirectory() {
35 if (isRunningInstalled()) {
36 return QString("@CMAKE_INSTALL_PREFIX@/share/locale");
37 } else {
38 return QString("@CMAKE_BINARY_DIR@/po/locale");
39 }
42inline QString shellAppDirectory() {
43 if (isRunningInstalled()) {
44 return QString("@CMAKE_INSTALL_PREFIX@/@SHELL_APP_DIR@/");
45 } else {
46 return QString("@CMAKE_SOURCE_DIR@/");
47 }
50inline QStringList overrideImportPaths() {
51 QStringList paths;
52 if (!isRunningInstalled()) {
53 paths << QString("@CMAKE_BINARY_DIR@/plugins");
54 }
55 return paths;
58inline QStringList fallbackImportPaths() {
59 QStringList paths;
60 if (isRunningInstalled()) {
61 paths << QString("@CMAKE_INSTALL_PREFIX@/@SHELL_PRIVATE_LIBDIR@/qml");
62 paths << QString("@CMAKE_INSTALL_PREFIX@/@SHELL_PRIVATE_LIBDIR@/qml/mocks");
63 } else {
64 paths << QString("@CMAKE_BINARY_DIR@/tests/mocks");
65 }
66 return paths;
69inline QStringList shellDataDirs() {
70 QStringList dirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
71 if (!isRunningInstalled()) {
72 if (getenv("UNITY_TEST_ENV")==NULL) {
73 dirs.prepend("@CMAKE_BINARY_DIR@/share");
74 }
75 }
76 else {
77 // append so by default we use xdg files.
78 dirs.append(shellAppDirectory());
79 }
80 return dirs;
83inline QString sourceDirectory() {
84 return QString("@CMAKE_SOURCE_DIR@/");
87#endif