Rev 674 | Rev 750 | Go to most recent revision | 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 | |||
45 | Setting.beginGroup("CLIENT"); |
||
46 | CLIENT.TTY_MAX = Setting.value("TTY_MAX", 1).toInt(); |
||
47 | CLIENT.TTY_ID = Setting.value("TTY_ID", 0).toInt(); |
||
48 | |||
49 | for (int z = 0; z < CLIENT.TTY_MAX; z++) |
||
50 | { |
||
51 | CLIENT.TTY_DEVICES[z] = Setting.value("TTY_DEVICE_" + QString("%1").arg(z), QString("/dev/ttyS3")).toString(); |
||
52 | } |
||
711 | KeyOz | 53 | CLIENT.TCP_MAX = Setting.value("TCP_MAX", 1).toInt(); |
54 | CLIENT.TCP_ID = Setting.value("TCP_ID", 0).toInt(); |
||
55 | CLIENT.TCP_Password = Setting.value("Password", QString("")).toString(); |
||
56 | |||
57 | for (int z = 0; z < CLIENT.TCP_MAX; z++) |
||
58 | { |
||
59 | CLIENT.TCP_SERVER[z] = Setting.value("TCP_SERVER_" + QString("%1").arg(z), QString("127.0.0.1:64400")).toString(); |
||
60 | } |
||
674 | KeyOz | 61 | Setting.endGroup(); |
62 | |||
63 | Setting.beginGroup("GUI"); |
||
64 | GUI.isMax = Setting.value("IsMax",false).toBool(); |
||
65 | GUI.Size = Setting.value("Size", QSize(500, 350)).toSize(); |
||
66 | GUI.Point = Setting.value("Point",QPoint(1,1)).toPoint(); |
||
67 | Setting.endGroup(); |
||
68 | } |
||
69 | |||
70 | void cSettings::write_Settings() |
||
71 | { |
||
72 | QSettings Setting("QMK", QA_NAME); |
||
73 | |||
74 | Setting.beginGroup("Global"); |
||
75 | Setting.setValue("Settings ID", Settings_ID); |
||
76 | Setting.endGroup(); |
||
77 | |||
78 | Setting.beginGroup("SERVER"); |
||
79 | Setting.setValue("TCP-PORT", SERVER.TCP_PORT); |
||
80 | Setting.setValue("UDP-PORT", SERVER.UDP_PORT); |
||
81 | Setting.setValue("Password", SERVER.Password); |
||
82 | Setting.endGroup(); |
||
83 | |||
84 | Setting.beginGroup("CLIENT"); |
||
85 | Setting.setValue("TTY_MAX", CLIENT.TTY_MAX); |
||
86 | Setting.setValue("TTY_ID", CLIENT.TTY_ID); |
||
711 | KeyOz | 87 | Setting.setValue("Password", CLIENT.TCP_Password); |
674 | KeyOz | 88 | |
89 | for (int z = 0; z < CLIENT.TTY_MAX; z++) |
||
90 | { |
||
91 | Setting.setValue("TTY_DEVICE_" + QString("%1").arg(z), CLIENT.TTY_DEVICES[z]); |
||
92 | } |
||
711 | KeyOz | 93 | |
94 | Setting.setValue("TCP_MAX", CLIENT.TCP_MAX); |
||
95 | Setting.setValue("TCP_ID", CLIENT.TCP_ID); |
||
96 | |||
97 | for (int z = 0; z < CLIENT.TCP_MAX; z++) |
||
98 | { |
||
99 | Setting.setValue("TCP_SERVER_" + QString("%1").arg(z), CLIENT.TCP_SERVER[z]); |
||
100 | } |
||
674 | KeyOz | 101 | Setting.endGroup(); |
102 | |||
103 | Setting.beginGroup("GUI"); |
||
104 | Setting.setValue("IsMax", GUI.isMax); |
||
105 | Setting.setValue("Size", GUI.Size); |
||
106 | Setting.setValue("Point", GUI.Point); |
||
107 | Setting.endGroup(); |
||
108 | |||
109 | } |