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

#include "settings.h"

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

#include <QDebug>

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

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

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

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

  KConfigSkeleton::ItemPath  *itemPath;
  itemPath = new KConfigSkeleton::ItemPath( currentGroup(), QStringLiteral( "Path" ), mPath, QStringLiteral( "$HOME/.local/share/contacts/" ) );
  addItem( itemPath, QStringLiteral( "Path" ) );
  KConfigSkeleton::ItemBool  *itemReadOnly;
  itemReadOnly = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "ReadOnly" ), mReadOnly, false );
  addItem( itemReadOnly, QStringLiteral( "ReadOnly" ) );
  KConfigSkeleton::ItemBool  *itemIsConfigured;
  itemIsConfigured = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "IsConfigured" ), mIsConfigured, false );
  addItem( itemIsConfigured, QStringLiteral( "IsConfigured" ) );
}

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

