2 * Copyright (C) 2012 Canonical, Ltd.
5 * Ugo Riboni <ugo.riboni@canonical.com>
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.
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.
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/>.
24#include <QtCore/QCoreApplication>
27#include <QtQml/QQmlEngine>
28#include <QStandardPaths>
30inline bool isRunningInstalled() {
31 static bool installed = (QCoreApplication::applicationDirPath() ==
32 QDir(("@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@")).canonicalPath());
36inline QString translationDirectory() {
37 if (isRunningInstalled()) {
38 return QString("@CMAKE_INSTALL_PREFIX@/share/locale");
40 return QString("@CMAKE_BINARY_DIR@/po/locale");
44inline QString qmlDirectory() {
45 if (isRunningInstalled()) {
46 return QString("@CMAKE_INSTALL_PREFIX@/@SHELL_APP_DIR@/");
48 return QString("@CMAKE_SOURCE_DIR@/qml/");
52inline QStringList overrideImportPaths() {
54 if (!isRunningInstalled()) {
55 paths << QString("@CMAKE_BINARY_DIR@/plugins");
60inline QStringList nonMirImportPaths() {
62 if (isRunningInstalled()) {
63 paths << QString("@CMAKE_INSTALL_PREFIX@/@SHELL_INSTALL_QML@/nonmirplugins");
65 paths << QString("@CMAKE_BINARY_DIR@/nonmirplugins");
70inline QStringList fallbackImportPaths() {
72 if (isRunningInstalled()) {
73 paths << QString("@CMAKE_INSTALL_PREFIX@/@SHELL_INSTALL_QML@");
74 paths << QString("@USS_PRIVATE_PLUGINDIR@");
75 paths << QString("@SHELL_PLUGINDIR@");
76 paths << QString("@CMAKE_INSTALL_PREFIX@/@SHELL_INSTALL_QML@/mocks");
78 paths << QString("@USS_PRIVATE_PLUGINDIR@");
79 paths << QString("@SHELL_PLUGINDIR@");
80 paths << QString("@CMAKE_BINARY_DIR@/tests/mocks");
85inline QString mockPluginsDir() {
86 if (isRunningInstalled()) {
87 return QString("@CMAKE_INSTALL_PREFIX@/@SHELL_INSTALL_QML@/mocks");
89 return QString("@CMAKE_BINARY_DIR@/tests/mocks");
93inline QStringList shellDataDirs() {
94 QStringList dirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
95 if (isRunningInstalled()) {
96 // append so by default we use xdg files.
97 dirs.append(qmlDirectory());
102inline QString sourceDirectory() {
103 return QString("@CMAKE_SOURCE_DIR@/");
106inline void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
108 QStringList importPathList = engine->importPathList();
109 for (int i = paths.count() -1; i >= 0; i--) {
111 const QString& path = paths[i];
112 QStringList::iterator iter = qFind(importPathList.begin(), importPathList.end(), path);
113 if (iter == importPathList.end()) {
114 engine->addImportPath(path);
119/* When you append and import path to the list of import paths it will be the *last*
120 place where Qt will search for QML modules.
121 The usual QQmlEngine::addImportPath() actually prepends the given path.*/
122inline void appendImportPaths(QQmlEngine *engine, const QStringList &paths)
124 QStringList importPathList = engine->importPathList();
125 Q_FOREACH(const QString& path, paths) {
127 QStringList::iterator iter = qFind(importPathList.begin(), importPathList.end(), path);
128 if (iter == importPathList.end()) {
129 importPathList.append(path);
132 engine->setImportPathList(importPathList);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list