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

#include "prefs.h"

#include <qglobal.h>
#include <QFile>

class PrefsHelper
{
  public:
    PrefsHelper() : q(nullptr) {}
    ~PrefsHelper() { delete q; q = nullptr; }
    PrefsHelper(const PrefsHelper&) = delete;
    PrefsHelper& operator=(const PrefsHelper&) = delete;
    Prefs *q;
};
Q_GLOBAL_STATIC(PrefsHelper, s_globalPrefs)
Prefs *Prefs::self()
{
  if (!s_globalPrefs()->q) {
    new Prefs;
    s_globalPrefs()->q->read();
  }

  return s_globalPrefs()->q;
}

Prefs::Prefs( )
  : KCoreConfigSkeleton( QStringLiteral( "khangmanrc" ) )
{
  Q_ASSERT(!s_globalPrefs()->q);
  s_globalPrefs()->q = this;
  setCurrentGroup( QStringLiteral( "Language" ) );

  KCoreConfigSkeleton::ItemInt  *itemCurrentLevel;
  itemCurrentLevel = new KCoreConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "CurrentLevel" ), mCurrentLevel, 0 );
  addItem( itemCurrentLevel, QStringLiteral( "CurrentLevel" ) );
  KCoreConfigSkeleton::ItemString  *itemLevelFile;
  itemLevelFile = new KCoreConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "LevelFile" ), mLevelFile, QStringLiteral( "\"animals.kvtml\"" ) );
  addItem( itemLevelFile, QStringLiteral( "LevelFile" ) );

                KSharedConfigPtr globalConf = KSharedConfig::openConfig();
                QString userLanguage=globalConf->group(QStringLiteral("Locale")).readEntry("Language", QStringLiteral("en"));
                if (userLanguage.isEmpty())
                    userLanguage = QStringLiteral("en");
                else
                    //keep only the first 2 characters
                    userLanguage = userLanguage.left(2);
            
  KCoreConfigSkeleton::ItemString  *itemSelectedLanguage;
  itemSelectedLanguage = new KCoreConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "SelectedLanguage" ), mSelectedLanguage, QStringLiteral( "en" ) );
  addItem( itemSelectedLanguage, QStringLiteral( "SelectedLanguage" ) );

  setCurrentGroup( QStringLiteral( "Look" ) );

  KCoreConfigSkeleton::ItemString  *itemTheme;
  itemTheme = new KCoreConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "Theme" ), mTheme, QStringLiteral( "notes" ) );
  addItem( itemTheme, QStringLiteral( "Theme" ) );

  setCurrentGroup( QStringLiteral( "General" ) );

  KCoreConfigSkeleton::ItemBool  *itemOneLetter;
  itemOneLetter = new KCoreConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "OneLetter" ), mOneLetter, false );
  addItem( itemOneLetter, QStringLiteral( "OneLetter" ) );
  KCoreConfigSkeleton::ItemBool  *itemEnableAnimations;
  itemEnableAnimations = new KCoreConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "EnableAnimations" ), mEnableAnimations, false );
  addItem( itemEnableAnimations, QStringLiteral( "EnableAnimations" ) );
  KCoreConfigSkeleton::ItemBool  *itemSound;
  itemSound = new KCoreConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "Sound" ), mSound, false );
  addItem( itemSound, QStringLiteral( "Sound" ) );
  KCoreConfigSkeleton::ItemBool  *itemHint;
  itemHint = new KCoreConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "Hint" ), mHint, false );
  addItem( itemHint, QStringLiteral( "Hint" ) );
  KCoreConfigSkeleton::ItemInt  *itemResolveTime;
  itemResolveTime = new KCoreConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "resolveTime" ), mResolveTime, 120 );
  addItem( itemResolveTime, QStringLiteral( "resolveTime" ) );

  setCurrentGroup( QStringLiteral( "Advanced" ) );

  KCoreConfigSkeleton::ItemBool  *itemAccentedLetters;
  itemAccentedLetters = new KCoreConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "AccentedLetters" ), mAccentedLetters, false );
  addItem( itemAccentedLetters, QStringLiteral( "AccentedLetters" ) );

  setCurrentGroup( QStringLiteral( "KNewStuff" ) );

  KCoreConfigSkeleton::ItemPath  *itemProvidersUrl;
  itemProvidersUrl = new KCoreConfigSkeleton::ItemPath( currentGroup(), QStringLiteral( "ProvidersUrl" ), mProvidersUrl, QStringLiteral( "\"https://edu.kde.org/khangman/downloads/providers.xml\"" ) );
  addItem( itemProvidersUrl, QStringLiteral( "ProvidersUrl" ) );
}

Prefs::~Prefs()
{
  if (s_globalPrefs.exists() && !s_globalPrefs.isDestroyed()) {
    s_globalPrefs()->q = nullptr;
  }
}

