1 /**********************************************************************************************
2    Copyright (C) 2015 Ivo Kronenberg <>
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, either version 3 of the License, or
7    (at your option) any later version.
8 
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 
17 **********************************************************************************************/
18 
19 #include "config.h"
20 #include "CAppSetupLinux.h"
21 #include "version.h"
22 
23 #ifndef _MKSTR_1
24 #define _MKSTR_1(x)    #x
25 #define _MKSTR(x)      _MKSTR_1(x)
26 #endif
27 
initQMapShack()28 void CAppSetupLinux::initQMapShack()
29 {
30     prepareGdal("", "");
31 
32     // setup translators
33     QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
34     QString translationPath = QCoreApplication::applicationDirPath();
35     translationPath.replace(QRegExp("bin$"), "share/qmapshack/translations");
36     prepareTranslator(resourceDir, "qt_");
37     prepareTranslator(translationPath, "qmapshack_");
38 
39     // create directories
40     IAppSetup::path(defaultCachePath(), 0, true, "CACHE");
41     IAppSetup::path(userDataPath("WaypointIcons"), 0, true, "USER DATA");
42     IAppSetup::path(logDir(), 0, true, "LOG");
43 }
44 
45 
routinoPath(QString xmlFile)46 QString CAppSetupLinux::routinoPath(QString xmlFile)
47 {
48     QDir dirXml(_MKSTR(ROUTINO_XML_PATH));
49     return IAppSetup::path(dirXml.absolutePath(), xmlFile, false, "ROUTINO");
50 }
51 
52 
defaultCachePath()53 QString CAppSetupLinux::defaultCachePath()
54 {
55     return IAppSetup::path(QDir::home().absolutePath(), ".QMapShack/", false, 0);
56 }
57 
58 
userDataPath(QString subdir)59 QString CAppSetupLinux::userDataPath(QString subdir)
60 {
61     QString path = QDir::home().absoluteFilePath(CONFIGDIR);
62     return IAppSetup::path(path, subdir, false, 0);
63 }
64 
65 
logDir()66 QString CAppSetupLinux::logDir()
67 {
68     return QDir::temp().absolutePath();
69 }
70 
helpFile()71 QString CAppSetupLinux::helpFile()
72 {
73     QDir dir(_MKSTR(HELPPATH));
74     return dir.absoluteFilePath("QMSHelp.qhc");
75 }
76