Mercurial > hg > forks > UniversalIndentGUI
annotate src/SettingsPaths.cpp @ 801:71b89219671c default tip
Fix Debian package rules for Qt5 build.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 13 Apr 2018 02:02:51 +0300 |
parents | 4950731d52c1 |
children |
rev | line source |
---|---|
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
1 /*************************************************************************** |
794
fa7aa6f543f1
Changed the copyright date within the code files to 2012.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
768
diff
changeset
|
2 * Copyright (C) 2006-2012 by Thomas Schweitzer * |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
3 * thomas-schweitzer(at)arcor.de * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
4 * * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
6 * it under the terms of the GNU General Public License version 2.0 as * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
7 * published by the Free Software Foundation. * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
8 * * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
12 * GNU General Public License for more details. * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
13 * * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
14 * You should have received a copy of the GNU General Public License * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
15 * along with this program in the file LICENSE.GPL; if not, write to the * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
16 * Free Software Foundation, Inc., * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
18 ***************************************************************************/ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
19 |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
20 #include "SettingsPaths.h" |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
21 |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
22 #include <QCoreApplication> |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
23 #include <QFile> |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
24 #include <QDir> |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
25 #include <QDirIterator> |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
26 #include <QStack> |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
27 #include <QtDebug> |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
28 |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
29 #include <stdlib.h> |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
30 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
31 //! \defgroup grp_Settings All concerning applications settings. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
32 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
33 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
34 \class SettingsPaths |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
35 \ingroup grp_Settings |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
36 \brief SettingsPaths is a pure static functions class from which info about the |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
37 paths needed for settings can be retrieved. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
38 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
39 |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
40 bool SettingsPaths::_alreadyInitialized = false; |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
41 QString SettingsPaths::_applicationBinaryPath = ""; |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
42 QString SettingsPaths::_settingsPath = ""; |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
43 QString SettingsPaths::_globalFilesPath = ""; |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
44 QString SettingsPaths::_indenterPath = ""; |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
45 QString SettingsPaths::_tempPath = ""; |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
46 bool SettingsPaths::_portableMode = false; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
47 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
48 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
49 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
50 \brief Initializes all available information about the paths. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
51 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
52 Mainly during this init it is detected whether to start in portable mode or not. This is |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
53 done by testing whether the directory "config" is in the same directory as this |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
54 applications executable file. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
55 In portable mode all data is ONLY written to subdirectories of the applications executable file. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
56 Means also that the directory "indenters" has to be there. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
57 In not portable mode (multiuser mode) only users home directory is used for writing config data. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
58 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
59 void SettingsPaths::init() { |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
60 _alreadyInitialized = true; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
61 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
62 qDebug() << __LINE__ << " " << __FUNCTION__ << ": Initializing application paths."; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
63 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
64 // Get the applications binary path, with respect to MacOSXs use of the .app folder. |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
65 _applicationBinaryPath = QCoreApplication::applicationDirPath(); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
66 // Remove any trailing slashes |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
67 while ( _applicationBinaryPath.right(1) == "/" ) { |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
68 _applicationBinaryPath.chop(1); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
69 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
70 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
71 #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
72 _applicationBinaryPath += "/plugins/uigui"; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
73 #endif |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
74 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
75 #ifdef Q_OS_MAC |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
76 // Because on Mac universal binaries are used, the binary path is not equal |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
77 // to the applications (.app) path. So get the .apps path here. |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
78 int indexOfDotApp = _applicationBinaryPath.indexOf(".app"); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
79 if ( indexOfDotApp != -1 ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
80 // Cut off after the dot of ".app". |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
81 _applicationBinaryPath = _applicationBinaryPath.left( indexOfDotApp-1 ); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
82 // Cut off after the first slash that was in front of ".app" (normally this is the word "UniversalIndentGUI") |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
83 _applicationBinaryPath = _applicationBinaryPath.left( _applicationBinaryPath.lastIndexOf("/") ); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
84 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
85 #endif |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
86 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
87 // If the "config" directory is a subdir of the applications binary path, use this one (portable mode) |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
88 _settingsPath = _applicationBinaryPath + "/config"; |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
89 if ( QFile::exists( _settingsPath ) ) { |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
90 _portableMode = true; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
91 QDir dirCreator; |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
92 _globalFilesPath = _applicationBinaryPath; |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
93 _indenterPath = _applicationBinaryPath + "/indenters"; |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
94 dirCreator.mkpath( _settingsPath ); |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
95 _tempPath = _applicationBinaryPath + "/temp"; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
96 //TODO: If the portable drive has write protection, use local temp path and clean it up on exit. |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
97 dirCreator.mkpath( _tempPath ); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
98 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
99 // ... otherwise use the system specific global application data path. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
100 else { |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
101 _portableMode = false; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
102 QDir dirCreator; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
103 #ifdef Q_OS_WIN |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
104 // Get the local users application settings directory. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
105 // Remove any trailing slashes. |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
106 _settingsPath = QDir::fromNativeSeparators( qgetenv("APPDATA") ); |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
107 while ( _settingsPath.right(1) == "/" ) { |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
108 _settingsPath.chop(1); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
109 } |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
110 _settingsPath = _settingsPath + "/UniversalIndentGUI"; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
111 |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
112 // On windows systems the directories "indenters", "translations" are subdirs of the _applicationBinaryPath. |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
113 _globalFilesPath = _applicationBinaryPath; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
114 #else |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
115 // Remove any trailing slashes. |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
116 _settingsPath = QDir::homePath(); |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
117 while ( _settingsPath.right(1) == "/" ) { |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
118 _settingsPath.chop(1); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
119 } |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
120 _settingsPath = _settingsPath + "/.universalindentgui"; |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
121 _globalFilesPath = "/usr/share/universalindentgui"; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
122 #endif |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
123 dirCreator.mkpath( _settingsPath ); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
124 // If a highlighter config file does not exist in the users home config dir |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
125 // copy the default config file over there. |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
126 if ( !QFile::exists(_settingsPath+"/UiGuiSyntaxHighlightConfig.ini") ) { |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
127 QFile::copy( _globalFilesPath+"/config/UiGuiSyntaxHighlightConfig.ini", _settingsPath+"/UiGuiSyntaxHighlightConfig.ini" ); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
128 } |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
129 _indenterPath = _globalFilesPath + "/indenters"; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
130 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
131 // On different systems it may be that "QDir::tempPath()" ends with a "/" or not. So check this. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
132 // Remove any trailing slashes. |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
133 _tempPath = QDir::tempPath(); |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
134 while ( _tempPath.right(1) == "/" ) { |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
135 _tempPath.chop(1); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
136 } |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
137 _tempPath = _tempPath + "/UniversalIndentGUI"; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
138 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
139 #if defined(Q_OS_WIN32) |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
140 dirCreator.mkpath( _tempPath ); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
141 #else |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
142 // On Unix based systems create a random temporary directory for security |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
143 // reasons. Otherwise an evil human being could create a symbolic link |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
144 // to an important existing file which gets overwritten when UiGUI writes |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
145 // into this normally temporary but linked file. |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
146 char *pathTemplate = new char[_tempPath.length()+8]; |
798
4950731d52c1
Port to Qt5. Seems to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
147 QByteArray pathTemplateQBA = QString(_tempPath + "-XXXXXX").toUtf8(); |
716
b9123ff53106
Run cppcheck over the code and removed some possible problems.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
714
diff
changeset
|
148 delete [] pathTemplate; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
149 pathTemplate = pathTemplateQBA.data(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
150 pathTemplate = mkdtemp( pathTemplate ); |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
151 _tempPath = pathTemplate; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
152 #endif |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
153 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
154 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
155 qDebug() << __LINE__ << " " << __FUNCTION__ << ": Paths are:" \ |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
156 "<ul><li>_applicationBinaryPath=" << _applicationBinaryPath \ |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
157 << "</li><li>_settingsPath=" << _settingsPath \ |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
158 << "</li><li>_globalFilesPath=" << _globalFilesPath \ |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
159 << "</li><li>_indenterPath=" << _indenterPath \ |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
160 << "</li><li>_tempPath=" << _tempPath \ |
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
161 << "</li><li>Running in portable mode=" << _portableMode << "</li></ul>"; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
162 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
163 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
164 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
165 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
166 \brief Returns the path of the applications executable. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
167 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
168 const QString SettingsPaths::getApplicationBinaryPath() { |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
169 if ( !_alreadyInitialized ) { |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
170 SettingsPaths::init(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
171 } |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
172 return _applicationBinaryPath; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
173 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
174 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
175 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
176 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
177 \brief Returns the path where all settings are being/should be written to. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
178 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
179 const QString SettingsPaths::getSettingsPath() { |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
180 if ( !_alreadyInitialized ) { |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
181 SettingsPaths::init(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
182 } |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
183 return _settingsPath; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
184 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
185 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
186 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
187 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
188 \brief Returns the path where the files concerning all users reside. For example translations. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
189 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
190 const QString SettingsPaths::getGlobalFilesPath() { |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
191 if ( !_alreadyInitialized ) { |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
192 SettingsPaths::init(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
193 } |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
194 return _globalFilesPath; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
195 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
196 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
197 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
198 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
199 \brief Returns the path where the indenter executables reside. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
200 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
201 const QString SettingsPaths::getIndenterPath() { |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
202 if ( !_alreadyInitialized ) { |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
203 SettingsPaths::init(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
204 } |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
205 return _indenterPath; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
206 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
207 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
208 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
209 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
210 \brief Returns the path where the where all temporary data should be written to. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
211 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
212 const QString SettingsPaths::getTempPath() { |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
213 if ( !_alreadyInitialized ) { |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
214 SettingsPaths::init(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
215 } |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
216 return _tempPath; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
217 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
218 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
219 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
220 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
221 \brief Returns true if portable mode shall be used. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
222 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
223 bool SettingsPaths::getPortableMode() { |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
224 if ( !_alreadyInitialized ) { |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
225 SettingsPaths::init(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
226 } |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
227 return _portableMode; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
228 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
229 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
230 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
231 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
232 \brief Completely deletes the created temporary directory with all of its content. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
233 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
234 void SettingsPaths::cleanAndRemoveTempDir() { |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
235 QDirIterator dirIterator(_tempPath, QDirIterator::Subdirectories); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
236 QStack<QString> directoryStack; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
237 bool noErrorsOccurred = true; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
238 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
239 while ( dirIterator.hasNext() ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
240 QString currentDirOrFile = dirIterator.next(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
241 // If this dummy call isn't done here, calling "dirIterator.fileInfo().isDir()" later somehow fails. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
242 dirIterator.fileInfo(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
243 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
244 if ( !currentDirOrFile.isEmpty() && dirIterator.fileName() != "." && dirIterator.fileName() != ".." ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
245 // There is a path on the stack but the current path doesn't start with that path. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
246 // So we changed into another parent directory and the one on the stack can be deleted |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
247 // since it must be empty. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
248 if ( !directoryStack.isEmpty() && !currentDirOrFile.startsWith(directoryStack.top()) ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
249 QString dirToBeRemoved = directoryStack.pop(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
250 bool couldRemoveDir = QDir(dirToBeRemoved).rmdir(dirToBeRemoved); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
251 noErrorsOccurred &= couldRemoveDir; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
252 if ( couldRemoveDir == false ) |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
253 qWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the directory: " << dirToBeRemoved; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
254 //qDebug() << "Removing Dir " << directoryStack.pop(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
255 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
256 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
257 // If the iterator currently points to a directory push it onto the stack. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
258 if ( dirIterator.fileInfo().isDir() ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
259 directoryStack.push( currentDirOrFile ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
260 //qDebug() << "Pushing onto Stack " << currentDirOrFile; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
261 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
262 // otherwise it must be a file, so delete it. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
263 else { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
264 bool couldRemoveFile = QFile::remove( currentDirOrFile ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
265 noErrorsOccurred &= couldRemoveFile; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
266 if ( couldRemoveFile == false ) |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
267 qWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the file: " << currentDirOrFile; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
268 //qDebug() << "Removing File " << currentDirOrFile; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
269 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
270 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
271 } |
751
ac165b6ae67e
Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
727
diff
changeset
|
272 noErrorsOccurred &= QDir(_tempPath).rmdir(_tempPath); |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
273 if ( noErrorsOccurred == false ) |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
274 qWarning() << __LINE__ << " " << __FUNCTION__ << "While cleaning up the temp dir an error occurred."; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
275 } |