// This file is generated by tdeconfig_compiler from klatin.kcfg.
// All changes you do to this file will be lost.

#include "settings.h"

#include <kstaticdeleter.h>

Settings *Settings::mSelf = 0;
static KStaticDeleter<Settings> staticSettingsDeleter;

Settings *Settings::self()
{
  if ( !mSelf ) {
    staticSettingsDeleter.setObject( mSelf, new Settings() );
    mSelf->readConfig();
  }

  return mSelf;
}

Settings::Settings(  )
  : TDEConfigSkeleton( TQString::fromLatin1( "klatinrc" ) )
{
  mSelf = this;
  setCurrentGroup( TQString::fromLatin1( "Language" ) );


						TDEConfigBase *globalConf = TDEGlobal::config();
						globalConf->setGroup("Locale");
						TQString m_language = globalConf->readEntry("Language", "en");
						//keep only the first 2 characters
						m_language = m_language.left(2);
						TQString filename = locate("data", "klatin/data/vocabs/");
						filename += m_language;
						TQDir check(filename);

						if (!check.exists()) {
							m_language = "en";
						}
						kdDebug()<< m_language <<endl;
					
  TDEConfigSkeleton::ItemString  *itemUserLanguage;
  itemUserLanguage = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "UserLanguage" ), mUserLanguage, m_language );
  addItem( itemUserLanguage, TQString::fromLatin1( "UserLanguage" ) );

  setCurrentGroup( TQString::fromLatin1( "Vocabulary" ) );

  TDEConfigSkeleton::ItemInt  *itemNumOfQuestions;
  itemNumOfQuestions = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "NumOfQuestions" ), mNumOfQuestions, 10 );
  addItem( itemNumOfQuestions, TQString::fromLatin1( "NumOfQuestions" ) );
  TDEConfigSkeleton::ItemInt  *itemUnlimitedQuestions;
  itemUnlimitedQuestions = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "UnlimitedQuestions" ), mUnlimitedQuestions, 0 );
  addItem( itemUnlimitedQuestions, TQString::fromLatin1( "UnlimitedQuestions" ) );

				TQString fileDir = locate("data", "klatin/data/vocabs/");
				fileDir += m_language;
				TQDir vocabDirectory(fileDir, "*.kvtml");
				kdDebug()<< m_language <<endl;
				
				TQString defaultFile = (fileDir + "/" + vocabDirectory[0]);
				kdDebug()<< defaultFile <<endl;
			
  TDEConfigSkeleton::ItemString  *itemDefaultFile;
  itemDefaultFile = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "DefaultFile" ), mDefaultFile, defaultFile );
  addItem( itemDefaultFile, TQString::fromLatin1( "DefaultFile" ) );
  TDEConfigSkeleton::ItemBool  *itemLatinToLang;
  itemLatinToLang = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "LatinToLang" ), mLatinToLang, true );
  addItem( itemLatinToLang, TQString::fromLatin1( "LatinToLang" ) );
  TDEConfigSkeleton::ItemBool  *itemLangToLatin;
  itemLangToLatin = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "LangToLatin" ), mLangToLatin, false );
  addItem( itemLangToLatin, TQString::fromLatin1( "LangToLatin" ) );
}

Settings::~Settings()
{
  if ( mSelf == this )
    staticSettingsDeleter.setObject( mSelf, 0, false );
}

