~saviq/camera-app/new-icon

18 by Ugo Riboni
Add C++ application. Doesn't do anything for now but will be needed later.
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
 */
19
20
// Qt
21
#include <QtCore/QCoreApplication>
22
#include <QtCore/QDir>
23
190.1.1 by Sergio Schvezov
Fixing up
24
inline bool isClick() {
212.3.3 by Sergio Schvezov
general improvement
25
#ifdef CLICK_MODE
26
    return true;
27
#else
28
    return false;
29
#endif
190.1.1 by Sergio Schvezov
Fixing up
30
}
31
18 by Ugo Riboni
Add C++ application. Doesn't do anything for now but will be needed later.
32
inline bool isRunningInstalled() {
33
    static bool installed = (QCoreApplication::applicationDirPath() ==
34
                             QDir(("@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@")).canonicalPath());
35
    return installed;
36
}
37
38
inline QString cameraAppDirectory() {
190.1.1 by Sergio Schvezov
Fixing up
39
    if (isClick()) {
40
        return QDir::currentPath();
41
    } else if (isRunningInstalled()) {
41.1.4 by Ugo Riboni
Load the installed QML files more properly
42
        return QString("@CMAKE_INSTALL_PREFIX@/@CAMERA_APP_DIR@/");
18 by Ugo Riboni
Add C++ application. Doesn't do anything for now but will be needed later.
43
    } else {
41.1.4 by Ugo Riboni
Load the installed QML files more properly
44
        return QString("@CMAKE_SOURCE_DIR@/");
18 by Ugo Riboni
Add C++ application. Doesn't do anything for now but will be needed later.
45
    }
46
}
47
190.1.1 by Sergio Schvezov
Fixing up
48
inline QString cameraAppImportDirectory() {
49
    return QDir::currentPath() + "/@PLUGIN_BASE@";
50
}
51
52
inline QString sourceQml() {
53
    static QString qmlFile("camera-app.qml");
54
    if (isClick()) {
55
        return QDir::currentPath() + "/" + qmlFile;
56
    } else {
57
        return qmlFile;
58
    }
59
}