// This file is generated by kconfig_compiler_kf5 from birthdaysresource.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; q = nullptr; }
    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( "Filter" ) );

  KConfigSkeleton::ItemBool  *itemFilterOnCategories;
  itemFilterOnCategories = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "FilterOnCategories" ), mFilterOnCategories, false );
  addItem( itemFilterOnCategories, QStringLiteral( "FilterOnCategories" ) );
  KConfigSkeleton::ItemStringList  *itemFilterCategories;
  itemFilterCategories = new KConfigSkeleton::ItemStringList( currentGroup(), QStringLiteral( "FilterCategories" ), mFilterCategories );
  addItem( itemFilterCategories, QStringLiteral( "FilterCategories" ) );

  setCurrentGroup( QStringLiteral( "Alarm" ) );

  KConfigSkeleton::ItemBool  *itemEnableAlarm;
  itemEnableAlarm = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "EnableAlarm" ), mEnableAlarm, true );
  addItem( itemEnableAlarm, QStringLiteral( "EnableAlarm" ) );
  KConfigSkeleton::ItemInt  *itemAlarmDays;
  itemAlarmDays = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "AlarmDays" ), mAlarmDays, 1 );
  addItem( itemAlarmDays, QStringLiteral( "AlarmDays" ) );
}

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

