Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 673 → Rev 674

/QMK-Groundstation/trunk/QMK-Settings/Classes/cSettings.cpp
0,0 → 1,81
/***************************************************************************
* 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("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("SERVER");
SERVER.Password = Setting.value("Password", QString("")).toString();
SERVER.IP_MAX = Setting.value("IP_MAX", 1).toInt();
SERVER.IP_ID = Setting.value("IP_ID", 0).toInt();
 
for (int z = 0; z < SERVER.IP_MAX; z++)
{
SERVER.IP[z] = Setting.value("IP_" + QString("%1").arg(z), QString("127.0.0.1:64400")).toString();
}
Setting.endGroup();
}
 
void cSettings::write_Settings()
{
QSettings Setting("QMK", QA_NAME);
 
Setting.beginGroup("Global");
Setting.setValue("Settings ID", Settings_ID);
Setting.endGroup();
 
Setting.beginGroup("GUI");
Setting.setValue("IsMax", GUI.isMax);
Setting.setValue("Size", GUI.Size);
Setting.setValue("Point", GUI.Point);
Setting.endGroup();
 
Setting.beginGroup("SERVER");
Setting.setValue("Password", SERVER.Password);
Setting.setValue("IP_MAX", SERVER.IP_MAX);
Setting.setValue("IP_ID", SERVER.IP_ID);
 
for (int z = 0; z < SERVER.IP_MAX; z++)
{
Setting.setValue("IP_" + QString("%1").arg(z), SERVER.IP[z]);
}
Setting.endGroup();
}
/QMK-Groundstation/trunk/QMK-Settings/Classes/cSettings.h
0,0 → 1,56
/***************************************************************************
* 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. *
***************************************************************************/
#ifndef CSETTINGS_H
#define CSETTINGS_H
 
#include <QSize>
#include <QPoint>
#include <QString>
 
#include "../Defines.h"
 
struct set_GUI
{
bool isMax;
QSize Size;
QPoint Point;
};
 
struct set_SERVER
{
int IP_MAX;
int IP_ID;
QString IP[10];
QString Password;
};
 
class cSettings
{
public:
cSettings();
void read_Settings();
void write_Settings();
 
int Settings_ID;
 
set_GUI GUI;
set_SERVER SERVER;
};
 
#endif // CSETTINGS_H