Rev 162 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 162 | Rev 163 | ||
---|---|---|---|
1 | /*************************************************************************** |
1 | /*************************************************************************** |
2 | * Copyright (C) 2008 by Manuel Schrape * |
2 | * Copyright (C) 2008 by Manuel Schrape * |
3 | * manuel.schrape@gmx.de * |
3 | * manuel.schrape@gmx.de * |
4 | * * |
4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * |
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 * |
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. * |
7 | * the Free Software Foundation; either version 2 of the License. * |
8 | * * |
8 | * * |
9 | * This program is distributed in the hope that it will be useful, * |
9 | * This program is distributed in the hope that it will be useful, * |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
12 | * GNU General Public License for more details. * |
12 | * GNU General Public License for more details. * |
13 | * * |
13 | * * |
14 | * You should have received a copy of the GNU General Public License * |
14 | * You should have received a copy of the GNU General Public License * |
15 | * along with this program; if not, write to the * |
15 | * along with this program; if not, write to the * |
16 | * Free Software Foundation, Inc., * |
16 | * Free Software Foundation, Inc., * |
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
18 | ***************************************************************************/ |
18 | ***************************************************************************/ |
19 | #include <QCoreApplication> |
19 | #include <QCoreApplication> |
20 | #include <QSettings> |
20 | #include <QSettings> |
21 | #include <QDir> |
21 | #include <QDir> |
22 | 22 | ||
23 | #include "cSettings.h" |
23 | #include "cSettings.h" |
24 | 24 | ||
25 | cSettings::cSettings() |
25 | cSettings::cSettings() |
26 | { |
26 | { |
27 | read_Settings(); |
27 | read_Settings(); |
28 | 28 | ||
29 | Analog1.LogView.resize(MaxAnalog); |
29 | Analog1.LogView.resize(MaxAnalog); |
30 | Analog1.PlotView.resize(MaxAnalog); |
30 | Analog1.PlotView.resize(MaxAnalog); |
31 | 31 | ||
32 | // Alte Settingsstruktur Löschen. |
32 | // Alte Settingsstruktur Löschen. |
33 | if (Settings_ID == 1) |
33 | if (Settings_ID == 1) |
34 | { |
34 | { |
35 | qDebug("Konvertiere Einstellungen Version 1 -> 2"); |
35 | qDebug("Konvertiere Einstellungen Version 1 -> 2"); |
36 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
36 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
37 | 37 | ||
38 | Setting.beginGroup("AnalogWerte"); |
38 | Setting.beginGroup("AnalogWerte"); |
39 | for (int a = 0; a < MaxAnalog; a++) |
39 | for (int a = 0; a < MaxAnalog; a++) |
40 | { |
40 | { |
41 | Analog1.LogView.setBit(a, Setting.value(("Analog_" + QString("%1").arg(a) + "_Log"), Def_Log[a]).toBool()); |
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()); |
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(); |
43 | Analog1.Label[a] = Setting.value(("Analog_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString(); |
44 | } |
44 | } |
45 | Setting.endGroup(); |
45 | Setting.endGroup(); |
46 | 46 | ||
47 | Settings_ID = 2; |
47 | Settings_ID = 2; |
48 | 48 | ||
49 | Setting.remove("AnalogWerte-FC"); |
49 | Setting.remove("AnalogWerte-FC"); |
50 | Setting.remove("AnalogWerte"); |
50 | Setting.remove("AnalogWerte"); |
51 | 51 | ||
52 | write_Settings_Analog(); |
52 | write_Settings_Analog(); |
53 | write_Settings_AnalogLabels(); |
53 | write_Settings_AnalogLabels(); |
54 | } |
54 | } |
55 | else |
55 | else |
56 | { |
56 | { |
57 | read_Settings_Analog(); |
57 | read_Settings_Analog(); |
58 | read_Settings_AnalogLabels(); |
58 | read_Settings_AnalogLabels(); |
59 | } |
59 | } |
60 | } |
60 | } |
61 | 61 | ||
62 | void cSettings::write_Settings_Analog(int ID) |
62 | void cSettings::write_Settings_Analog(int ID) |
63 | { |
63 | { |
64 | QString Hardware = HardwareType[ID]; |
64 | QString Hardware = HardwareType[ID]; |
65 | 65 | ||
66 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
66 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
67 | 67 | ||
68 | Setting.beginGroup("Analog-Werte"); |
68 | Setting.beginGroup("Analog-Werte"); |
69 | Setting.setValue(Hardware + "-LogView", QBitArray(Analog1.LogView)); |
69 | Setting.setValue(Hardware + "-LogView", QBitArray(Analog1.LogView)); |
70 | Setting.setValue(Hardware + "-PlotView", QBitArray(Analog1.PlotView)); |
70 | Setting.setValue(Hardware + "-PlotView", QBitArray(Analog1.PlotView)); |
71 | Setting.endGroup(); |
71 | Setting.endGroup(); |
72 | } |
72 | } |
73 | 73 | ||
74 | void cSettings::read_Settings_Analog(int ID) |
74 | void cSettings::read_Settings_Analog(int ID) |
75 | { |
75 | { |
76 | QBitArray Def_View; |
76 | QBitArray Def_View; |
77 | Def_View.fill(true,MaxAnalog); |
77 | Def_View.fill(true,MaxAnalog); |
78 | 78 | ||
79 | QString Hardware = HardwareType[ID]; |
79 | QString Hardware = HardwareType[ID]; |
80 | 80 | ||
81 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
81 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
82 | 82 | ||
83 | Setting.beginGroup("Analog-Werte"); |
83 | Setting.beginGroup("Analog-Werte"); |
84 | Analog1.LogView = Setting.value(Hardware + "-LogView", QBitArray(Def_View)).value<QBitArray>(); |
84 | Analog1.LogView = Setting.value(Hardware + "-LogView", QBitArray(Def_View)).value<QBitArray>(); |
85 | Analog1.PlotView = Setting.value(Hardware + "-PlotView", QBitArray(Def_View)).value<QBitArray>(); |
85 | Analog1.PlotView = Setting.value(Hardware + "-PlotView", QBitArray(Def_View)).value<QBitArray>(); |
86 | Setting.endGroup(); |
86 | Setting.endGroup(); |
87 | } |
87 | } |
88 | 88 | ||
89 | void cSettings::write_Settings_AnalogLabels(int ID) |
89 | void cSettings::write_Settings_AnalogLabels(int ID) |
90 | { |
90 | { |
91 | QString Hardware = HardwareType[ID]; |
91 | QString Hardware = HardwareType[ID]; |
92 | 92 | ||
93 | QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
93 | QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
94 | 94 | ||
95 | Setting.beginGroup("Analog-Labels-" + Hardware); |
95 | Setting.beginGroup("Analog-Labels-" + Hardware); |
- | 96 | Setting.setValue("Version", Analog1.Version); |
|
96 | for (int a=0; a<MaxAnalog; a++) |
97 | for (int a=0; a<MaxAnalog; a++) |
97 | { |
98 | { |
98 | Setting.setValue("Label_" + QString("%1").arg(a), Analog1.Label[a]); |
99 | Setting.setValue("Label_" + QString("%1").arg(a), Analog1.Label[a]); |
99 | } |
100 | } |
100 | Setting.endGroup(); |
101 | Setting.endGroup(); |
101 | } |
102 | } |
102 | 103 | ||
103 | void cSettings::read_Settings_AnalogLabels(int ID) |
104 | void cSettings::read_Settings_AnalogLabels(int ID) |
104 | { |
105 | { |
105 | QString Hardware = HardwareType[ID]; |
106 | QString Hardware = HardwareType[ID]; |
106 | 107 | ||
107 | QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
108 | QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
108 | 109 | ||
109 | Setting.beginGroup("Analog-Labels-" + Hardware); |
110 | Setting.beginGroup("Analog-Labels-" + Hardware); |
- | 111 | Analog1.Version = Setting.value(("Version"), "0").toString(); |
|
110 | for (int a=0; a<MaxAnalog; a++) |
112 | for (int a=0; a<MaxAnalog; a++) |
111 | { |
113 | { |
112 | Analog1.Label[a] = Setting.value(("Label_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString(); |
114 | Analog1.Label[a] = Setting.value(("Label_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString(); |
113 | } |
115 | } |
114 | Setting.endGroup(); |
116 | Setting.endGroup(); |
115 | } |
117 | } |
116 | 118 | ||
117 | void cSettings::read_Settings() |
119 | void cSettings::read_Settings() |
118 | { |
120 | { |
119 | QBitArray Def_TabViews; |
121 | QBitArray Def_TabViews; |
120 | Def_TabViews.fill(true, 6); |
122 | Def_TabViews.fill(true, 6); |
121 | 123 | ||
122 | QDir Dir; |
124 | QDir Dir; |
123 | 125 | ||
124 | QString HomeDir = (QString(Dir.homePath() + "/")); |
126 | QString HomeDir = (QString(Dir.homePath() + "/")); |
125 | 127 | ||
126 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
128 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
127 | 129 | ||
128 | Setting.beginGroup("Global"); |
130 | Setting.beginGroup("Global"); |
129 | Settings_ID = Setting.value("Settings ID", 1).toInt(); |
131 | Settings_ID = Setting.value("Settings ID", 1).toInt(); |
130 | Setting.endGroup(); |
132 | Setting.endGroup(); |
131 | 133 | ||
132 | Setting.beginGroup("Port"); |
134 | Setting.beginGroup("Port"); |
133 | TTY.Port = Setting.value("TTY", QString("/dev/ttyUSB0")).toString(); |
135 | TTY.Port = Setting.value("TTY", QString("/dev/ttyUSB0")).toString(); |
134 | Setting.endGroup(); |
136 | Setting.endGroup(); |
135 | 137 | ||
136 | Setting.beginGroup("GUI"); |
138 | Setting.beginGroup("GUI"); |
137 | GUI.isMax = Setting.value("IsMax",false).toBool(); |
139 | GUI.isMax = Setting.value("IsMax",false).toBool(); |
138 | GUI.Size = Setting.value("Size", QSize(700, 300)).toSize(); |
140 | GUI.Size = Setting.value("Size", QSize(700, 300)).toSize(); |
139 | GUI.Point = Setting.value("Point",QPoint(1,1)).toPoint(); |
141 | GUI.Point = Setting.value("Point",QPoint(1,1)).toPoint(); |
140 | GUI.TabViews = Setting.value("TabViews", QBitArray(Def_TabViews)).value<QBitArray>(); |
142 | GUI.TabViews = Setting.value("TabViews", QBitArray(Def_TabViews)).value<QBitArray>(); |
141 | GUI.Term_Info = Setting.value("Terminal_Info",false).toBool(); |
143 | GUI.Term_Info = Setting.value("Terminal_Info",false).toBool(); |
142 | GUI.Term_Data = Setting.value("Terminal_Data",true).toBool(); |
144 | GUI.Term_Data = Setting.value("Terminal_Data",true).toBool(); |
143 | GUI.Term_Always = Setting.value("Terminal_Always",false).toBool(); |
145 | GUI.Term_Always = Setting.value("Terminal_Always",false).toBool(); |
144 | Setting.endGroup(); |
146 | Setting.endGroup(); |
145 | 147 | ||
146 | Setting.beginGroup("Dirs"); |
148 | Setting.beginGroup("Dirs"); |
147 | DIR.Logging = Setting.value("LogDir", HomeDir).toString(); |
149 | DIR.Logging = Setting.value("LogDir", HomeDir).toString(); |
148 | DIR.Parameter = Setting.value("ParDir", HomeDir).toString(); |
150 | DIR.Parameter = Setting.value("ParDir", HomeDir).toString(); |
149 | Setting.endGroup(); |
151 | Setting.endGroup(); |
150 | } |
152 | } |
151 | 153 | ||
152 | void cSettings::write_Settings() |
154 | void cSettings::write_Settings() |
153 | { |
155 | { |
154 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
156 | QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
155 | 157 | ||
156 | Setting.beginGroup("Global"); |
158 | Setting.beginGroup("Global"); |
157 | Setting.setValue("Settings ID", Settings_ID); |
159 | Setting.setValue("Settings ID", Settings_ID); |
158 | Setting.endGroup(); |
160 | Setting.endGroup(); |
159 | 161 | ||
160 | Setting.beginGroup("Port"); |
162 | Setting.beginGroup("Port"); |
161 | // Setting.setValue("TTY", le_Port->text()); |
163 | Setting.setValue("TTY", TTY.Port); |
162 | Setting.endGroup(); |
164 | Setting.endGroup(); |
163 | 165 | ||
164 | Setting.beginGroup("Dirs"); |
166 | Setting.beginGroup("Dirs"); |
165 | Setting.setValue("LogDir", DIR.Logging); |
167 | Setting.setValue("LogDir", DIR.Logging); |
166 | Setting.setValue("ParDir", DIR.Parameter); |
168 | Setting.setValue("ParDir", DIR.Parameter); |
167 | Setting.endGroup(); |
169 | Setting.endGroup(); |
168 | 170 | ||
169 | Setting.beginGroup("GUI"); |
171 | Setting.beginGroup("GUI"); |
170 | Setting.setValue("Terminal_Info", GUI.Term_Info); |
172 | Setting.setValue("Terminal_Info", GUI.Term_Info); |
171 | Setting.setValue("Terminal_Data", GUI.Term_Data); |
173 | Setting.setValue("Terminal_Data", GUI.Term_Data); |
172 | Setting.setValue("Terminal_Always", GUI.Term_Always); |
174 | Setting.setValue("Terminal_Always", GUI.Term_Always); |
- | 175 | Setting.setValue("TabViews", QBitArray(GUI.TabViews)); |
|
173 | Setting.endGroup(); |
176 | Setting.endGroup(); |
174 | } |
177 | } |
175 | 178 | ||
176 | cSettings::~cSettings() |
179 | cSettings::~cSettings() |
177 | { |
180 | { |
178 | } |
181 | } |
179 | 182 | ||
180 | 183 | ||
181 | 184 |