1 /**********************************************************************************************
2     Copyright (C) 2012 Oliver Eichler <oliver.eichler@gmx.de>
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 #ifndef CSETTINGS_H
19 #define CSETTINGS_H
20 
21 #include "setup/CAppOpts.h"
22 #include <QtCore>
23 
24 class CSettings : public QObject
25 {
26 public:
CSettings()27     CSettings()
28     {
29         if(!qlOpts->configfile.isEmpty())
30         {
31             cfg = new QSettings(qlOpts->configfile, QSettings::IniFormat, this);
32         }
33         else
34         {
35             cfg = new QSettings(this);
36         }
37     }
~CSettings()38     ~CSettings()
39     {
40     }
41 
get()42     QSettings& get()
43     {
44         return *cfg;
45     }
46 
47 private:
48     QSettings* cfg;
49 };
50 
51 #define SETTINGS \
52     CSettings ccfg; \
53     QSettings& cfg = ccfg.get()
54 #endif                           //CSETTINGS_H
55