Rev 750 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
674 | 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 <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_DebugLabels(int ID) |
||
32 | { |
||
33 | QBitArray Def_View; |
||
34 | Def_View.fill(true,MAX_DebugData); |
||
35 | |||
36 | QString Hardware = HardwareType[ID]; |
||
37 | |||
38 | QSettings Setting("QMK", "Debug-Labels"); |
||
39 | |||
40 | Setting.beginGroup("Debug-Labels-" + Hardware); |
||
41 | |||
42 | DebugData.Version = Setting.value(("Version"), "0").toString(); |
||
43 | for (int a=0; a<MAX_DebugData; a++) |
||
44 | { |
||
45 | DebugData.Label[a] = Setting.value(("Label_" + QString("%1").arg(a)), "-" + DEF_DebugNames[a]).toString(); |
||
46 | } |
||
47 | DebugData.Show_Plotter = Setting.value("Show_Plotter", QBitArray(Def_View)).value<QBitArray>(); |
||
48 | |||
49 | Setting.endGroup(); |
||
50 | } |
||
51 | |||
52 | void cSettings::write_DebugLabels(int ID) |
||
53 | { |
||
54 | QString Hardware = HardwareType[ID]; |
||
55 | |||
56 | QSettings Setting("QMK", "Debug-Labels"); |
||
57 | |||
58 | Setting.beginGroup("Debug-Labels-" + Hardware); |
||
59 | |||
60 | Setting.setValue("Version", DebugData.Version); |
||
61 | for (int a=0; a<MAX_DebugData; a++) |
||
62 | { |
||
63 | Setting.setValue("Label_" + QString("%1").arg(a), DebugData.Label[a]); |
||
64 | } |
||
65 | Setting.setValue("Show_Plotter", QBitArray(DebugData.Show_Plotter)); |
||
66 | |||
67 | Setting.endGroup(); |
||
68 | } |
||
69 | |||
70 | void cSettings::read_Settings() |
||
71 | { |
||
72 | QSettings Setting("QMK", QA_NAME); |
||
73 | |||
74 | Setting.beginGroup("Global"); |
||
75 | Settings_ID = Setting.value("Settings ID", Settings_ID).toInt(); |
||
76 | Setting.endGroup(); |
||
77 | |||
78 | Setting.beginGroup("DATA"); |
||
79 | DATA.Debug_Intervall = Setting.value("Debug-Intervall", 500).toInt(); |
||
80 | DATA.Plotter_Count = Setting.value("Plotter-Count", 100).toInt(); |
||
81 | Setting.endGroup(); |
||
82 | |||
83 | Setting.beginGroup("GUI"); |
||
84 | GUI.isMax = Setting.value("IsMax",false).toBool(); |
||
85 | GUI.Size = Setting.value("Size", QSize(700, 300)).toSize(); |
||
86 | GUI.Point = Setting.value("Point",QPoint(1,1)).toPoint(); |
||
87 | Setting.endGroup(); |
||
88 | |||
89 | Setting.beginGroup("SERVER"); |
||
90 | SERVER.Password = Setting.value("Password", QString("")).toString(); |
||
91 | SERVER.IP_MAX = Setting.value("IP_MAX", 1).toInt(); |
||
92 | SERVER.IP_ID = Setting.value("IP_ID", 0).toInt(); |
||
93 | |||
94 | for (int z = 0; z < SERVER.IP_MAX; z++) |
||
95 | { |
||
96 | SERVER.IP[z] = Setting.value("IP_" + QString("%1").arg(z), QString("127.0.0.1:64400")).toString(); |
||
97 | } |
||
98 | Setting.endGroup(); |
||
99 | } |
||
100 | |||
101 | void cSettings::write_Settings() |
||
102 | { |
||
103 | QSettings Setting("QMK", QA_NAME); |
||
104 | |||
105 | Setting.beginGroup("Global"); |
||
106 | Setting.setValue("Settings ID", Settings_ID); |
||
107 | Setting.endGroup(); |
||
108 | |||
109 | Setting.beginGroup("DATA"); |
||
110 | Setting.setValue("Plotter-Count", DATA.Plotter_Count); |
||
111 | Setting.setValue("Debug-Intervall", DATA.Debug_Intervall); |
||
112 | Setting.endGroup(); |
||
113 | |||
114 | Setting.beginGroup("GUI"); |
||
115 | Setting.setValue("IsMax", GUI.isMax); |
||
116 | Setting.setValue("Size", GUI.Size); |
||
117 | Setting.setValue("Point", GUI.Point); |
||
118 | Setting.endGroup(); |
||
119 | |||
120 | Setting.beginGroup("SERVER"); |
||
121 | Setting.setValue("Password", SERVER.Password); |
||
122 | Setting.setValue("IP_MAX", SERVER.IP_MAX); |
||
123 | Setting.setValue("IP_ID", SERVER.IP_ID); |
||
124 | |||
125 | for (int z = 0; z < SERVER.IP_MAX; z++) |
||
126 | { |
||
127 | Setting.setValue("IP_" + QString("%1").arg(z), SERVER.IP[z]); |
||
128 | } |
||
129 | Setting.endGroup(); |
||
130 | } |
||
131 | |||
132 |