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

#include "settings.h"

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

#include <QDebug>

class SettingsHelper
{
  public:
    SettingsHelper() : q(nullptr) {}
    ~SettingsHelper() { delete q; }
    SettingsHelper(const SettingsHelper&) = delete;
    SettingsHelper& operator=(const SettingsHelper&) = delete;
    Settings *q;
};
Q_GLOBAL_STATIC(SettingsHelper, s_globalSettings)
Settings *Settings::self()
{
  if (!s_globalSettings()->q)
     qFatal("you need to call Settings::instance before using");
  return s_globalSettings()->q;
}

void Settings::instance(const QString& cfgfilename)
{
  if (s_globalSettings()->q) {
     qDebug() << "Settings::instance called after the first use - ignoring";
     return;
  }
  new Settings(KSharedConfig::openConfig(cfgfilename));
  s_globalSettings()->q->read();
}

void Settings::instance(KSharedConfig::Ptr config)
{
  if (s_globalSettings()->q) {
     qDebug() << "Settings::instance called after the first use - ignoring";
     return;
  }
  new Settings(std::move(config));
  s_globalSettings()->q->read();
}

Settings::Settings( KSharedConfig::Ptr config )
  : KConfigSkeleton( std::move( config ) )
{
  Q_ASSERT(!s_globalSettings()->q);
  s_globalSettings()->q = this;
  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigSkeleton::ItemBool  *itemShowBoundLines;
  itemShowBoundLines = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "showboundlines" ), mShowBoundLines, 
        ( s_globalSettings->q->config()->name() == QLatin1String( "ksamerc" ) )
        ? false
        : true
       );
  addItem( itemShowBoundLines, QStringLiteral( "ShowBoundLines" ) );
  KConfigSkeleton::ItemBool  *itemEnableAnimation;
  itemEnableAnimation = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "enableanimation" ), mEnableAnimation, true );
  addItem( itemEnableAnimation, QStringLiteral( "EnableAnimation" ) );
  KConfigSkeleton::ItemBool  *itemEnableHighlight;
  itemEnableHighlight = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "enablehighlight" ), mEnableHighlight, true );
  addItem( itemEnableHighlight, QStringLiteral( "EnableHighlight" ) );
  KConfigSkeleton::ItemBool  *itemEnableSounds;
  itemEnableSounds = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "enablesounds" ), mEnableSounds, true );
  addItem( itemEnableSounds, QStringLiteral( "EnableSounds" ) );

  setCurrentGroup( QStringLiteral( "Background" ) );

  KConfigSkeleton::ItemBool  *itemRadioTheme;
  itemRadioTheme = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "RadioTheme" ), mRadioTheme, true );
  addItem( itemRadioTheme, QStringLiteral( "RadioTheme" ) );
  KConfigSkeleton::ItemBool  *itemRadioColor;
  itemRadioColor = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "RadioColor" ), mRadioColor, false );
  addItem( itemRadioColor, QStringLiteral( "RadioColor" ) );
  KConfigSkeleton::ItemBool  *itemRadioImage;
  itemRadioImage = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "RadioImage" ), mRadioImage, false );
  addItem( itemRadioImage, QStringLiteral( "RadioImage" ) );
  KConfigSkeleton::ItemColor  *itemBgColor;
  itemBgColor = new KConfigSkeleton::ItemColor( currentGroup(), QStringLiteral( "Background Color" ), mBgColor, QColor( "#000000" ) );
  addItem( itemBgColor, QStringLiteral( "BgColor" ) );
  KConfigSkeleton::ItemUrl  *itemBgImage;
  itemBgImage = new KConfigSkeleton::ItemUrl( currentGroup(), QStringLiteral( "Background Image" ), mBgImage );
  addItem( itemBgImage, QStringLiteral( "BgImage" ) );

  setCurrentGroup( QStringLiteral( "CustomGame" ) );

  KConfigSkeleton::ItemInt  *itemCustomWidth;
  itemCustomWidth = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "Custom Width" ), mCustomWidth, 10 );
  itemCustomWidth->setMinValue(5);
  itemCustomWidth->setMaxValue(50);
  addItem( itemCustomWidth, QStringLiteral( "CustomWidth" ) );
  KConfigSkeleton::ItemInt  *itemCustomHeight;
  itemCustomHeight = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "Custom Height" ), mCustomHeight, 16 );
  itemCustomHeight->setMinValue(5);
  itemCustomHeight->setMaxValue(50);
  addItem( itemCustomHeight, QStringLiteral( "CustomHeight" ) );
  KConfigSkeleton::ItemInt  *itemCustomColorCount;
  itemCustomColorCount = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "Custom Color Count" ), mCustomColorCount, 5 );
  itemCustomColorCount->setMinValue(1);
  addItem( itemCustomColorCount, QStringLiteral( "CustomColorCount" ) );
}

Settings::~Settings()
{
  s_globalSettings()->q = nullptr;
}

