Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
157 KeyOz 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 <QCoreApplication>
20
#include <QSettings>
21
#include <QDir>
22
 
23
#include "cSettings.h"
24
 
25
cSettings::cSettings()
26
{
27
}
28
 
29
void cSettings::read_Settings()
30
{
31
    QDir Dir;
32
 
33
    QString HomeDir = (QString(Dir.homePath() + "/"));
34
 
35
    QSettings Setting("KeyOz-Net", "QMK-Groundstation");
36
 
37
    Setting.beginGroup("Port");
38
        TTY.Port     = Setting.value("TTY", QString("/dev/ttyUSB0")).toString();
39
    Setting.endGroup();
40
 
41
    Setting.beginGroup("GUI");
42
        GUI.isMax    = Setting.value("IsMax",false).toBool();
43
        GUI.Size     = Setting.value("Size", QSize(700, 300)).toSize();
44
        GUI.Point    = Setting.value("Point",QPoint(1,1)).toPoint();
45
    Setting.endGroup();
46
 
47
    Setting.beginGroup("Dirs");
48
        DIR.Logging   = Setting.value("LogDir", HomeDir).toString();
49
        DIR.Parameter = Setting.value("ParDir", HomeDir).toString();
50
    Setting.endGroup();
51
 
52
    Setting.beginGroup("AnalogWerte");
53
        for (int a = 0; a < MaxAnalog; a++)
54
        {
55
            Analog[a].Name  = Setting.value(("Analog_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString();
56
            Analog[a].Plot  = Setting.value(("Analog_" + QString("%1").arg(a) + "_Plot"),  Def_Plot_Show[a]).toBool();
57
            Analog[a].Color = Setting.value(("Analog_" + QString("%1").arg(a) + "_Color"), QColor(Def_Colors[a])).value<QColor>();
58
            Analog[a].Log   = Setting.value(("Analog_" + QString("%1").arg(a) + "_Log"),   Def_Log[a]).toBool();
59
        }
60
    Setting.endGroup();
61
}
62
 
63
void cSettings::write_Settings()
64
{
65
    QSettings Setting("KeyOz-Net", "QMK-Groundstation");
66
 
67
    Setting.beginGroup("Port");
68
//        Setting.setValue("TTY", le_Port->text());
69
    Setting.endGroup();
70
 
71
    Setting.beginGroup("Dirs");
72
        Setting.setValue("LogDir", DIR.Logging);
73
        Setting.setValue("ParDir", DIR.Parameter);
74
    Setting.endGroup();
75
 
76
    Setting.beginGroup("GUI");
77
//        Setting.setValue("IsMax", isMaximized());
78
//        Setting.setValue("Size",  size());
79
//        Setting.setValue("Point", pos());
80
    Setting.endGroup();
81
 
82
    Setting.beginGroup("AnalogWerte");
83
        for (int a=0; a<MaxAnalog; a++)
84
        {
85
            Setting.setValue("Analog_" + QString("%1").arg(a), Analog[a].Name);
86
            Setting.setValue("Analog_" + QString("%1").arg(a) + "_Plot", Analog[a].Plot);
87
            Setting.setValue("Analog_" + QString("%1").arg(a) + "_Log", Analog[a].Log);
88
            Setting.setValue("Analog_" + QString("%1").arg(a) + "_Color", QColor(Analog[a].Color));
89
        }
90
    Setting.endGroup();
91
}
92
 
93
cSettings::~cSettings()
94
{
95
}
96
 
97