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

#include "settings.h"

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

#include <QDebug>

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

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

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

VcardDirResourceSettings::VcardDirResourceSettings( KSharedConfig::Ptr config )
  : KConfigSkeleton( std::move( config ) )
{
  Q_ASSERT(!s_globalVcardDirResourceSettings()->q);
  s_globalVcardDirResourceSettings()->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" ) );
}

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

