Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
801 - 1
/***************************************************************************
2
 *   Copyright (C) 2008 by Manuel Schrape                                  *
3
 *   manuel.schrape@gmx.de                                                 *
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation; either version 2 of the License.        *
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, write to the                         *
16
 *   Free Software Foundation, Inc.,                                       *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18
 ***************************************************************************/
19
#include <QSettings>
20
#include <QDir>
21
 
22
#include "cSettings.h"
23
 
24
cSettings::cSettings()
25
{
26
    Settings_ID = 1;
27
 
28
    read_Settings();
29
}
30
 
31
void cSettings::read_Settings()
32
{
33
    QSettings Setting("QMK", QA_NAME);
34
 
35
    Setting.beginGroup("Global");
36
        Settings_ID  = Setting.value("Settings ID", Settings_ID).toInt();
37
    Setting.endGroup();
38
 
39
    Setting.beginGroup("GUI");
40
        GUI.isMax       = Setting.value("IsMax",false).toBool();
41
        GUI.Size        = Setting.value("Size", QSize(500, 350)).toSize();
42
        GUI.Point       = Setting.value("Point",QPoint(1,1)).toPoint();
43
    Setting.endGroup();
44
 
45
    Setting.beginGroup("SERVER");
46
        SERVER.Password = Setting.value("Password", QString("")).toString();
47
        SERVER.IP_MAX = Setting.value("IP_MAX", 1).toInt();
48
        SERVER.IP_ID  = Setting.value("IP_ID",  0).toInt();
49
 
50
        for (int z = 0; z < SERVER.IP_MAX; z++)
51
        {
52
            SERVER.IP[z] = Setting.value("IP_" + QString("%1").arg(z), QString("127.0.0.1:64400")).toString();
53
        }
54
    Setting.endGroup();
55
}
56
 
57
void cSettings::write_Settings()
58
{
59
    QSettings Setting("QMK", QA_NAME);
60
 
61
    Setting.beginGroup("Global");
62
        Setting.setValue("Settings ID", Settings_ID);
63
    Setting.endGroup();
64
 
65
    Setting.beginGroup("GUI");
66
        Setting.setValue("IsMax", GUI.isMax);
67
        Setting.setValue("Size", GUI.Size);
68
        Setting.setValue("Point", GUI.Point);
69
    Setting.endGroup();
70
 
71
    Setting.beginGroup("SERVER");
72
        Setting.setValue("Password", SERVER.Password);
73
        Setting.setValue("IP_MAX", SERVER.IP_MAX);
74
        Setting.setValue("IP_ID",  SERVER.IP_ID);
75
 
76
        for (int z = 0; z < SERVER.IP_MAX; z++)
77
        {
78
            Setting.setValue("IP_" + QString("%1").arg(z), SERVER.IP[z]);
79
        }
80
    Setting.endGroup();
81
}