Blame |
Last modification |
View Log
| RSS feed
/***************************************************************************
* Copyright (C) 2008 by Manuel Schrape *
* manuel.schrape@gmx.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QSettings>
#include <QDir>
#include "cSettings.h"
cSettings::cSettings()
{
Settings_ID = 1;
read_Settings();
}
void cSettings::read_Settings()
{
QSettings Setting("QMK", QA_NAME);
Setting.beginGroup("Global");
Settings_ID = Setting.value("Settings ID", Settings_ID).toInt();
Setting.endGroup();
Setting.beginGroup("SERVER");
SERVER.TCP_PORT = Setting.value("TCP-PORT", DEV_IP_PORT).toInt();
SERVER.UDP_PORT = Setting.value("UDP-PORT", DEV_IP_PORT).toInt();
SERVER.Password = Setting.value("Password", QString("")).toString();
Setting.endGroup();
Setting.beginGroup("LIVEDATA");
LIVEDATA.Server = Setting.value("Server", QString("")).toString();
LIVEDATA.Port = Setting.value("Port", QString("64410")).toString();
LIVEDATA.User = Setting.value("User", QString("")).toString();
LIVEDATA.Password = Setting.value("Password", QString("")).toString();
Setting.endGroup();
Setting.beginGroup("CLIENT");
CLIENT.TTY_MAX = Setting.value("TTY_MAX", 1).toInt();
CLIENT.TTY_ID = Setting.value("TTY_ID", 0).toInt();
for (int z = 0; z < CLIENT.TTY_MAX; z++)
{
CLIENT.TTY_DEVICES[z] = Setting.value("TTY_DEVICE_" + QString("%1").arg(z), QString("/dev/ttyS3")).toString();
}
CLIENT.TCP_MAX = Setting.value("TCP_MAX", 1).toInt();
CLIENT.TCP_ID = Setting.value("TCP_ID", 0).toInt();
CLIENT.TCP_Password = Setting.value("Password", QString("")).toString();
for (int z = 0; z < CLIENT.TCP_MAX; z++)
{
CLIENT.TCP_SERVER[z] = Setting.value("TCP_SERVER_" + QString("%1").arg(z), QString("127.0.0.1:64400")).toString();
}
Setting.endGroup();
Setting.beginGroup("GUI");
GUI.isMax = Setting.value("IsMax",false).toBool();
GUI.Size = Setting.value("Size", QSize(500, 350)).toSize();
GUI.Point = Setting.value("Point",QPoint(1,1)).toPoint();
Setting.endGroup();
Setting.beginGroup("TERMINAL");
TERMINAL.isMax = Setting.value("IsMax",false).toBool();
TERMINAL.Size = Setting.value("Size", QSize(500, 350)).toSize();
TERMINAL.Point = Setting.value("Point",QPoint(1,1)).toPoint();
DATA.Data = Setting.value("Data",false).toBool();
DATA.Info = Setting.value("Info",false).toBool();
DATA.Send = Setting.value("Send",false).toBool();
DATA.TCP = Setting.value("TCP",false).toBool();
Setting.endGroup();
}
void cSettings::write_Settings()
{
QSettings Setting("QMK", QA_NAME);
Setting.beginGroup("Global");
Setting.setValue("Settings ID", Settings_ID);
Setting.endGroup();
Setting.beginGroup("SERVER");
Setting.setValue("TCP-PORT", SERVER.TCP_PORT);
Setting.setValue("UDP-PORT", SERVER.UDP_PORT);
Setting.setValue("Password", SERVER.Password);
Setting.endGroup();
Setting.beginGroup("LIVEDATA");
Setting.setValue("Server", LIVEDATA.Server);
Setting.setValue("Port", LIVEDATA.Port);
Setting.setValue("User", LIVEDATA.User);
Setting.setValue("Password", LIVEDATA.Password);
Setting.endGroup();
Setting.beginGroup("CLIENT");
Setting.setValue("TTY_MAX", CLIENT.TTY_MAX);
Setting.setValue("TTY_ID", CLIENT.TTY_ID);
Setting.setValue("Password", CLIENT.TCP_Password);
for (int z = 0; z < CLIENT.TTY_MAX; z++)
{
Setting.setValue("TTY_DEVICE_" + QString("%1").arg(z), CLIENT.TTY_DEVICES[z]);
}
Setting.setValue("TCP_MAX", CLIENT.TCP_MAX);
Setting.setValue("TCP_ID", CLIENT.TCP_ID);
for (int z = 0; z < CLIENT.TCP_MAX; z++)
{
Setting.setValue("TCP_SERVER_" + QString("%1").arg(z), CLIENT.TCP_SERVER[z]);
}
Setting.endGroup();
Setting.beginGroup("GUI");
Setting.setValue("IsMax", GUI.isMax);
Setting.setValue("Size", GUI.Size);
Setting.setValue("Point", GUI.Point);
Setting.endGroup();
Setting.beginGroup("TERMINAL");
Setting.setValue("IsMax", TERMINAL.isMax);
Setting.setValue("Size", TERMINAL.Size);
Setting.setValue("Point", TERMINAL.Point);
Setting.setValue("Data", DATA.Data);
Setting.setValue("Send", DATA.Send);
Setting.setValue("Info", DATA.Info);
Setting.setValue("TCP", DATA.TCP);
Setting.endGroup();
}