15 * You should have received a copy of the GNU General Public License |
15 * You should have received a copy of the GNU General Public License |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 * ===================================================================== |
17 * ===================================================================== |
18 * |
18 * |
19 * config.cpp: Configuration management. I don't like how unsafe QSettings |
19 * config.cpp: Configuration management. I don't like how unsafe QSettings |
20 * is so this implements a type-safer and idenitifer-safer wrapping system of |
20 * is so this implements a type-safer and identifer-safer wrapping system of |
21 * configuration variables. QSettings is used underlyingly, this is a matter |
21 * configuration variables. QSettings is used underlyingly, this is a matter |
22 * of interface. |
22 * of interface. |
23 */ |
23 */ |
24 |
24 |
25 #include <errno.h> |
25 #include <errno.h> |
30 #include "config.h" |
30 #include "config.h" |
31 #include "misc.h" |
31 #include "misc.h" |
32 #include "gui.h" |
32 #include "gui.h" |
33 #include "file.h" |
33 #include "file.h" |
34 |
34 |
|
35 #ifdef _WIN32 |
|
36 # define EXTENSION ".ini" |
|
37 #else |
|
38 # define EXTENSION ".cfg" |
|
39 #endif // _WIN32 |
|
40 |
35 Config* g_configPointers[MAX_CONFIG]; |
41 Config* g_configPointers[MAX_CONFIG]; |
36 static int g_cfgPointerCursor = 0; |
42 static int g_cfgPointerCursor = 0; |
37 |
43 |
38 // ============================================================================= |
44 // ============================================================================= |
39 // Get the QSettings object. A portable build refers to a file in the current |
45 // Get the QSettings object. A portable build refers to a file in the current |
40 // directory, a non-portable build to ~/.config/LDForge or to registry. |
46 // directory, a non-portable build to ~/.config/LDForge or to registry. |
41 // ----------------------------------------------------------------------------- |
47 // ----------------------------------------------------------------------------- |
42 static QSettings* getSettingsObject() |
48 static QSettings* getSettingsObject() |
43 { |
49 { |
44 #ifdef PORTABLE |
50 #ifdef PORTABLE |
45 # ifdef _WIN32 |
|
46 # define EXTENSION ".ini" |
|
47 # else |
|
48 # define EXTENSION ".cfg" |
|
49 # endif // _WIN32 |
|
50 return new QSettings (str (APPNAME).toLower() + EXTENSION, QSettings::IniFormat); |
51 return new QSettings (str (APPNAME).toLower() + EXTENSION, QSettings::IniFormat); |
51 #else |
52 #else |
52 return new QSettings; |
53 return new QSettings; |
53 #endif // PORTABLE |
54 #endif // PORTABLE |
54 } |
55 } |