~verzegnassi-stefano/ubuntu-docviewer-app/reboot-uitk12

« back to all changes in this revision

Viewing changes to src/app/config.h.in

  • Committer: Stefano Verzegnassi
  • Date: 2015-10-20 18:21:17 UTC
  • mfrom: (183.1.7 lo-viewer)
  • Revision ID: stefano92.100@gmail.com-20151020182117-qza2vl31ilu2cvvj
Merged 'reboot' branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#ifndef __CONFIG_H__
 
18
#define __CONFIG_H__
 
19
 
 
20
#include <QtCore/QCoreApplication>
 
21
#include <QtCore/QDir>
 
22
#include <QtCore/QString>
 
23
 
 
24
inline bool isClick() {
 
25
    static bool click = (QCoreApplication::applicationDirPath().contains("click.ubuntu.com"));
 
26
    return click;
 
27
}
 
28
 
 
29
inline bool isRunningInstalled()
 
30
{
 
31
    static bool installed = (QCoreApplication::applicationDirPath().startsWith("/usr"));
 
32
    return installed;
 
33
}
 
34
 
 
35
inline QString docviewerDirectory()
 
36
{
 
37
    if (isClick()) {
 
38
        return QString(".");
 
39
    } else if (isRunningInstalled()) {
 
40
        return QString("@CMAKE_INSTALL_PREFIX@/@DATA_DIR@");
 
41
    } else {
 
42
        return QString("@CMAKE_CURRENT_SOURCE_DIR@");
 
43
    }
 
44
}
 
45
#endif // __CONFIG_H__