~unity-2d-team/unity-2d/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
#define INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@"
#define INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@"
#define UNITY_2D_DIR "@UNITY_2D_DIR@"
#define UNITY_DIR "@UNITY_DIR@"
#define UNITY_2D_SCHEMA_FILE "@UNITY_2D_SCHEMA_FILE@"

#include <QCoreApplication>
#include "qconf.h"

static const char* UNITY2D_DCONF_SCHEMA = "com.canonical.Unity2d";
static const char* LAUNCHER2D_DCONF_SCHEMA = "com.canonical.Unity2d.Launcher";
static const char* PANEL2D_DCONF_SCHEMA = "com.canonical.Unity2d.Panel";

static const char* UNITY_DCONF_SCHEMA = "com.canonical.Unity";
static const char* LAUNCHER_DCONF_SCHEMA = "com.canonical.Unity.Launcher";
static const char* PANEL_DCONF_SCHEMA = "com.canonical.Unity.Panel";

inline QConf& unity2dConfiguration() {
    static QConf configuration(UNITY2D_DCONF_SCHEMA);
    return configuration;
}

inline QConf& launcher2dConfiguration() {
    static QConf configuration(LAUNCHER2D_DCONF_SCHEMA);
    return configuration;
}

inline QConf& panel2dConfiguration() {
    static QConf configuration(PANEL2D_DCONF_SCHEMA);
    return configuration;
}

inline QConf& unityConfiguration() {
    static QConf configuration(UNITY_DCONF_SCHEMA);
    return configuration;
}

inline QConf& launcherConfiguration() {
    static QConf configuration(LAUNCHER_DCONF_SCHEMA);
    return configuration;
}

inline QConf& panelConfiguration() {
    static QConf configuration(PANEL_DCONF_SCHEMA);
    return configuration;
}


inline bool isRunningInstalled() {
    return (QCoreApplication::applicationDirPath() == (INSTALL_PREFIX "/" INSTALL_BINDIR));
}

inline QString unity2dDirectory() {
    if (isRunningInstalled()) {
        return QString(INSTALL_PREFIX "/" UNITY_2D_DIR);
    } else {
        return QString("@CMAKE_SOURCE_DIR@/");
    }
}

inline QString unity2dImportPath() {
    if (isRunningInstalled()) {
        return QString(INSTALL_PREFIX "/" INSTALL_LIBDIR "/qt4/imports");
    } else {
        return QString("@CMAKE_BINARY_DIR@/libunity-2d-private/");
    }
}

inline QString unity2dPluginsPath() {
    if (isRunningInstalled()) {
        return QString(INSTALL_PREFIX "/" INSTALL_LIBDIR "/unity-2d/plugins");
    } else {
        return QString("@CMAKE_BINARY_DIR@");
    }
}