Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
158 | 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 | { |
||
162 | KeyOz | 27 | read_Settings(); |
28 | |||
29 | Analog1.LogView.resize(MaxAnalog); |
||
30 | Analog1.PlotView.resize(MaxAnalog); |
||
31 | |||
32 | // Alte Settingsstruktur Löschen. |
||
33 | if (Settings_ID == 1) |
||
34 | { |
||
35 | qDebug("Konvertiere Einstellungen Version 1 -> 2"); |
||
36 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
37 | |||
38 | Setting.beginGroup("AnalogWerte"); |
||
39 | for (int a = 0; a < MaxAnalog; a++) |
||
40 | { |
||
41 | Analog1.LogView.setBit(a, Setting.value(("Analog_" + QString("%1").arg(a) + "_Log"), Def_Log[a]).toBool()); |
||
42 | Analog1.PlotView.setBit(a, Setting.value(("Analog_" + QString("%1").arg(a) + "_Plot"), Def_Plot_Show[a]).toBool()); |
||
43 | Analog1.Label[a] = Setting.value(("Analog_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString(); |
||
44 | } |
||
45 | Setting.endGroup(); |
||
46 | |||
47 | Settings_ID = 2; |
||
48 | |||
49 | Setting.remove("AnalogWerte-FC"); |
||
50 | Setting.remove("AnalogWerte"); |
||
51 | |||
52 | write_Settings_Analog(); |
||
53 | write_Settings_AnalogLabels(); |
||
54 | } |
||
55 | else |
||
56 | { |
||
57 | read_Settings_Analog(); |
||
58 | read_Settings_AnalogLabels(); |
||
59 | } |
||
158 | KeyOz | 60 | } |
61 | |||
166 | KeyOz | 62 | // Config der Analogwert-Anzeige (Plotter / CVS) |
162 | KeyOz | 63 | void cSettings::write_Settings_Analog(int ID) |
64 | { |
||
65 | QString Hardware = HardwareType[ID]; |
||
66 | |||
67 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
68 | |||
69 | Setting.beginGroup("Analog-Werte"); |
||
70 | Setting.setValue(Hardware + "-LogView", QBitArray(Analog1.LogView)); |
||
71 | Setting.setValue(Hardware + "-PlotView", QBitArray(Analog1.PlotView)); |
||
72 | Setting.endGroup(); |
||
73 | } |
||
74 | |||
75 | void cSettings::read_Settings_Analog(int ID) |
||
76 | { |
||
77 | QBitArray Def_View; |
||
78 | Def_View.fill(true,MaxAnalog); |
||
79 | |||
80 | QString Hardware = HardwareType[ID]; |
||
81 | |||
82 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
83 | |||
84 | Setting.beginGroup("Analog-Werte"); |
||
85 | Analog1.LogView = Setting.value(Hardware + "-LogView", QBitArray(Def_View)).value<QBitArray>(); |
||
86 | Analog1.PlotView = Setting.value(Hardware + "-PlotView", QBitArray(Def_View)).value<QBitArray>(); |
||
87 | Setting.endGroup(); |
||
88 | } |
||
89 | |||
166 | KeyOz | 90 | // Labels der Analogwerte. |
162 | KeyOz | 91 | void cSettings::write_Settings_AnalogLabels(int ID) |
92 | { |
||
93 | QString Hardware = HardwareType[ID]; |
||
94 | |||
95 | QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
||
96 | |||
97 | Setting.beginGroup("Analog-Labels-" + Hardware); |
||
163 | KeyOz | 98 | Setting.setValue("Version", Analog1.Version); |
162 | KeyOz | 99 | for (int a=0; a<MaxAnalog; a++) |
100 | { |
||
101 | Setting.setValue("Label_" + QString("%1").arg(a), Analog1.Label[a]); |
||
102 | } |
||
103 | Setting.endGroup(); |
||
104 | } |
||
105 | |||
106 | void cSettings::read_Settings_AnalogLabels(int ID) |
||
107 | { |
||
108 | QString Hardware = HardwareType[ID]; |
||
109 | |||
110 | QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
||
111 | |||
112 | Setting.beginGroup("Analog-Labels-" + Hardware); |
||
163 | KeyOz | 113 | Analog1.Version = Setting.value(("Version"), "0").toString(); |
162 | KeyOz | 114 | for (int a=0; a<MaxAnalog; a++) |
115 | { |
||
116 | Analog1.Label[a] = Setting.value(("Label_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString(); |
||
117 | } |
||
118 | Setting.endGroup(); |
||
119 | } |
||
120 | |||
166 | KeyOz | 121 | // Programmeinstellungen |
158 | KeyOz | 122 | void cSettings::read_Settings() |
123 | { |
||
124 | QBitArray Def_TabViews; |
||
125 | Def_TabViews.fill(true, 6); |
||
126 | |||
127 | QDir Dir; |
||
128 | |||
129 | QString HomeDir = (QString(Dir.homePath() + "/")); |
||
130 | |||
131 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
132 | |||
162 | KeyOz | 133 | Setting.beginGroup("Global"); |
134 | Settings_ID = Setting.value("Settings ID", 1).toInt(); |
||
135 | Setting.endGroup(); |
||
136 | |||
158 | KeyOz | 137 | Setting.beginGroup("Port"); |
138 | TTY.Port = Setting.value("TTY", QString("/dev/ttyUSB0")).toString(); |
||
139 | Setting.endGroup(); |
||
140 | |||
141 | Setting.beginGroup("GUI"); |
||
162 | KeyOz | 142 | GUI.isMax = Setting.value("IsMax",false).toBool(); |
143 | GUI.Size = Setting.value("Size", QSize(700, 300)).toSize(); |
||
144 | GUI.Point = Setting.value("Point",QPoint(1,1)).toPoint(); |
||
145 | GUI.TabViews = Setting.value("TabViews", QBitArray(Def_TabViews)).value<QBitArray>(); |
||
146 | GUI.Term_Info = Setting.value("Terminal_Info",false).toBool(); |
||
147 | GUI.Term_Data = Setting.value("Terminal_Data",true).toBool(); |
||
148 | GUI.Term_Always = Setting.value("Terminal_Always",false).toBool(); |
||
166 | KeyOz | 149 | GUI.Term_Send = Setting.value("Terminal_Send",true).toBool(); |
162 | KeyOz | 150 | Setting.endGroup(); |
158 | KeyOz | 151 | |
152 | Setting.beginGroup("Dirs"); |
||
153 | DIR.Logging = Setting.value("LogDir", HomeDir).toString(); |
||
154 | DIR.Parameter = Setting.value("ParDir", HomeDir).toString(); |
||
155 | Setting.endGroup(); |
||
166 | KeyOz | 156 | |
157 | Setting.beginGroup("MKData"); |
||
158 | Data.Plotter_Count = Setting.value("Plotter_Count", 100).toInt(); |
||
159 | Data.Debug_Fast = Setting.value("Debug_Fast", 100).toInt(); |
||
160 | Data.Debug_Slow = Setting.value("Debug_Slow", 500).toInt(); |
||
161 | Setting.endGroup(); |
||
162 | |||
158 | KeyOz | 163 | } |
164 | |||
165 | void cSettings::write_Settings() |
||
166 | { |
||
167 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
||
168 | |||
162 | KeyOz | 169 | Setting.beginGroup("Global"); |
170 | Setting.setValue("Settings ID", Settings_ID); |
||
171 | Setting.endGroup(); |
||
172 | |||
158 | KeyOz | 173 | Setting.beginGroup("Port"); |
163 | KeyOz | 174 | Setting.setValue("TTY", TTY.Port); |
158 | KeyOz | 175 | Setting.endGroup(); |
176 | |||
177 | Setting.beginGroup("Dirs"); |
||
178 | Setting.setValue("LogDir", DIR.Logging); |
||
179 | Setting.setValue("ParDir", DIR.Parameter); |
||
180 | Setting.endGroup(); |
||
181 | |||
182 | Setting.beginGroup("GUI"); |
||
166 | KeyOz | 183 | Setting.setValue("TabViews", QBitArray(GUI.TabViews)); |
162 | KeyOz | 184 | Setting.setValue("Terminal_Info", GUI.Term_Info); |
185 | Setting.setValue("Terminal_Data", GUI.Term_Data); |
||
186 | Setting.setValue("Terminal_Always", GUI.Term_Always); |
||
166 | KeyOz | 187 | Setting.setValue("Terminal_Send", GUI.Term_Send); |
158 | KeyOz | 188 | Setting.endGroup(); |
166 | KeyOz | 189 | |
190 | Setting.beginGroup("MKData"); |
||
191 | Setting.setValue("Plotter_Count", Data.Plotter_Count); |
||
192 | Setting.setValue("Debug_Fast", Data.Debug_Fast); |
||
193 | Setting.setValue("Debug_Slow", Data.Debug_Slow); |
||
194 | Setting.endGroup(); |
||
158 | KeyOz | 195 | } |
196 | |||
197 | cSettings::~cSettings() |
||
198 | { |
||
199 | } |
||
200 | |||
201 |