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

#include "settings.h"

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

#include <QDebug>

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

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

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

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

  KConfigSkeleton::ItemPath  *itemPath;
  itemPath = new KConfigSkeleton::ItemPath( currentGroup(), QStringLiteral( "Path" ), mPath );
  addItem( itemPath, QStringLiteral( "Path" ) );
  KConfigSkeleton::ItemUInt  *itemAutosaveInterval;
  itemAutosaveInterval = new KConfigSkeleton::ItemUInt( currentGroup(), QStringLiteral( "AutosaveInterval" ), mAutosaveInterval, 5 );
  addItem( itemAutosaveInterval, QStringLiteral( "AutosaveInterval" ) );
  KConfigSkeleton::ItemBool  *itemReadOnly;
  itemReadOnly = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "ReadOnly" ), mReadOnly, false );
  addItem( itemReadOnly, QStringLiteral( "ReadOnly" ) );
}

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

