Rev 750 | Details | Compare with Previous | 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_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("SERVER"); |
||
40 | SERVER.TCP_PORT = Setting.value("TCP-PORT", DEV_IP_PORT).toInt(); |
||
41 | SERVER.UDP_PORT = Setting.value("UDP-PORT", DEV_IP_PORT).toInt(); |
||
42 | SERVER.Password = Setting.value("Password", QString("")).toString(); |
||
43 | Setting.endGroup(); |
||
44 | |||
750 | KeyOz | 45 | Setting.beginGroup("LIVEDATA"); |
46 | LIVEDATA.Server = Setting.value("Server", QString("")).toString(); |
||
47 | LIVEDATA.Port = Setting.value("Port", QString("64410")).toString(); |
||
48 | LIVEDATA.User = Setting.value("User", QString("")).toString(); |
||
49 | LIVEDATA.Password = Setting.value("Password", QString("")).toString(); |
||
50 | Setting.endGroup(); |
||
51 | |||
674 | KeyOz | 52 | Setting.beginGroup("CLIENT"); |
53 | CLIENT.TTY_MAX = Setting.value("TTY_MAX", 1).toInt(); |
||
54 | CLIENT.TTY_ID = Setting.value("TTY_ID", 0).toInt(); |
||
55 | |||
56 | for (int z = 0; z < CLIENT.TTY_MAX; z++) |
||
57 | { |
||
801 | - | 58 | #ifdef WIN32 |
59 | CLIENT.TTY_DEVICES[z] = Setting.value("TTY_DEVICE_" + QString("%1").arg(z), QString("COM1")).toString(); |
||
60 | #else |
||
674 | KeyOz | 61 | CLIENT.TTY_DEVICES[z] = Setting.value("TTY_DEVICE_" + QString("%1").arg(z), QString("/dev/ttyS3")).toString(); |
801 | - | 62 | #endif |
674 | KeyOz | 63 | } |
711 | KeyOz | 64 | CLIENT.TCP_MAX = Setting.value("TCP_MAX", 1).toInt(); |
65 | CLIENT.TCP_ID = Setting.value("TCP_ID", 0).toInt(); |
||
66 | CLIENT.TCP_Password = Setting.value("Password", QString("")).toString(); |
||
67 | |||
68 | for (int z = 0; z < CLIENT.TCP_MAX; z++) |
||
69 | { |
||
70 | CLIENT.TCP_SERVER[z] = Setting.value("TCP_SERVER_" + QString("%1").arg(z), QString("127.0.0.1:64400")).toString(); |
||
71 | } |
||
674 | KeyOz | 72 | Setting.endGroup(); |
73 | |||
74 | Setting.beginGroup("GUI"); |
||
75 | GUI.isMax = Setting.value("IsMax",false).toBool(); |
||
76 | GUI.Size = Setting.value("Size", QSize(500, 350)).toSize(); |
||
77 | GUI.Point = Setting.value("Point",QPoint(1,1)).toPoint(); |
||
78 | Setting.endGroup(); |
||
750 | KeyOz | 79 | |
80 | Setting.beginGroup("TERMINAL"); |
||
81 | TERMINAL.isMax = Setting.value("IsMax",false).toBool(); |
||
82 | TERMINAL.Size = Setting.value("Size", QSize(500, 350)).toSize(); |
||
83 | TERMINAL.Point = Setting.value("Point",QPoint(1,1)).toPoint(); |
||
84 | DATA.Data = Setting.value("Data",false).toBool(); |
||
85 | DATA.Info = Setting.value("Info",false).toBool(); |
||
86 | DATA.Send = Setting.value("Send",false).toBool(); |
||
87 | DATA.TCP = Setting.value("TCP",false).toBool(); |
||
88 | Setting.endGroup(); |
||
674 | KeyOz | 89 | } |
90 | |||
91 | void cSettings::write_Settings() |
||
92 | { |
||
93 | QSettings Setting("QMK", QA_NAME); |
||
94 | |||
95 | Setting.beginGroup("Global"); |
||
96 | Setting.setValue("Settings ID", Settings_ID); |
||
97 | Setting.endGroup(); |
||
98 | |||
99 | Setting.beginGroup("SERVER"); |
||
100 | Setting.setValue("TCP-PORT", SERVER.TCP_PORT); |
||
101 | Setting.setValue("UDP-PORT", SERVER.UDP_PORT); |
||
102 | Setting.setValue("Password", SERVER.Password); |
||
103 | Setting.endGroup(); |
||
104 | |||
750 | KeyOz | 105 | Setting.beginGroup("LIVEDATA"); |
106 | Setting.setValue("Server", LIVEDATA.Server); |
||
107 | Setting.setValue("Port", LIVEDATA.Port); |
||
108 | Setting.setValue("User", LIVEDATA.User); |
||
109 | Setting.setValue("Password", LIVEDATA.Password); |
||
110 | Setting.endGroup(); |
||
111 | |||
674 | KeyOz | 112 | Setting.beginGroup("CLIENT"); |
750 | KeyOz | 113 | Setting.setValue("TTY_MAX", CLIENT.TTY_MAX); |
114 | Setting.setValue("TTY_ID", CLIENT.TTY_ID); |
||
711 | KeyOz | 115 | Setting.setValue("Password", CLIENT.TCP_Password); |
674 | KeyOz | 116 | |
117 | for (int z = 0; z < CLIENT.TTY_MAX; z++) |
||
118 | { |
||
119 | Setting.setValue("TTY_DEVICE_" + QString("%1").arg(z), CLIENT.TTY_DEVICES[z]); |
||
120 | } |
||
711 | KeyOz | 121 | |
122 | Setting.setValue("TCP_MAX", CLIENT.TCP_MAX); |
||
123 | Setting.setValue("TCP_ID", CLIENT.TCP_ID); |
||
124 | |||
125 | for (int z = 0; z < CLIENT.TCP_MAX; z++) |
||
126 | { |
||
127 | Setting.setValue("TCP_SERVER_" + QString("%1").arg(z), CLIENT.TCP_SERVER[z]); |
||
128 | } |
||
674 | KeyOz | 129 | Setting.endGroup(); |
130 | |||
131 | Setting.beginGroup("GUI"); |
||
132 | Setting.setValue("IsMax", GUI.isMax); |
||
750 | KeyOz | 133 | Setting.setValue("Size", GUI.Size); |
674 | KeyOz | 134 | Setting.setValue("Point", GUI.Point); |
135 | Setting.endGroup(); |
||
136 | |||
750 | KeyOz | 137 | Setting.beginGroup("TERMINAL"); |
138 | Setting.setValue("IsMax", TERMINAL.isMax); |
||
139 | Setting.setValue("Size", TERMINAL.Size); |
||
140 | Setting.setValue("Point", TERMINAL.Point); |
||
141 | Setting.setValue("Data", DATA.Data); |
||
142 | Setting.setValue("Send", DATA.Send); |
||
143 | Setting.setValue("Info", DATA.Info); |
||
144 | Setting.setValue("TCP", DATA.TCP); |
||
145 | Setting.endGroup(); |
||
674 | KeyOz | 146 | } |