/***************************************************************************
 *                                                                         *
 *   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, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/


#include <kapplication.h>
#include <kconfig.h>
#include <klocale.h>

#include "kfconfiguration.h"

const int KFConfiguration::m_defaultLevel = 10;
const int KFConfiguration::m_defaultGameLevel = 0;
const QString KFConfiguration::m_defaultImage = "root_reminder.png";
const QString KFConfiguration::m_defaultPlayer = "Your Name";

KFConfiguration::KFConfiguration() {
	read(); // read the settings or set them to the default values
}

void KFConfiguration::read() {
	KConfig * conf = kapp->config();
	conf->sync();
	conf->setGroup( "GENERAL" );
	m_Level = conf->readNumEntry( "Level", m_defaultLevel );
	m_GameLevel = conf->readNumEntry( "GameLevel", m_defaultGameLevel );
	m_Image = conf->readEntry( "Image", m_defaultImage );
	m_player = conf->readEntry( "Player", m_defaultPlayer );
}

void KFConfiguration::write() const {
	KConfig * conf = kapp->config();
	conf->setGroup( "GENERAL" );
	conf->writeEntry( "Level", m_Level );
	conf->writeEntry( "GameLevel", m_GameLevel );
	conf->writeEntry( "Image", m_Image );
	conf->writeEntry( "Player", m_player );
	conf->sync();
}

KFConfiguration& Config() {
	static KFConfiguration conf;
	return conf;
}
