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

#include "prefs.h"

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

class PrefsHelper
{
  public:
    PrefsHelper() noexcept : q(nullptr) {}
    ~PrefsHelper() noexcept { delete q; q = nullptr; }
    PrefsHelper(const PrefsHelper&) = delete;
    PrefsHelper& operator=(const PrefsHelper&) = delete;
    Prefs *q;
};
Q_GLOBAL_STATIC(PrefsHelper, s_globalPrefs)
Prefs *Prefs::self()
{
  if (!s_globalPrefs()->q) {
    new Prefs;
    s_globalPrefs()->q->read();
  }

  return s_globalPrefs()->q;
}

Prefs::Prefs( )
  : KConfigSkeleton( QStringLiteral( "kapptemplaterc" ) )
{
  Q_ASSERT(!s_globalPrefs()->q);
  s_globalPrefs()->q = this;
  setCurrentGroup( QStringLiteral( "Project" ) );

  KConfigSkeleton::ItemString  *itemAppName;
  itemAppName = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "appName" ), mAppName, QStringLiteral( "KApp4" ) );
  addItem( itemAppName, QStringLiteral( "appName" ) );
  KConfigSkeleton::ItemString  *itemAppVersion;
  itemAppVersion = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "appVersion" ), mAppVersion, QStringLiteral( "0.1" ) );
  addItem( itemAppVersion, QStringLiteral( "appVersion" ) );
QString defaultDir = KUser().homeDir() + "/src";
      
  KConfigSkeleton::ItemString  *itemUrl;
  itemUrl = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "url" ), mUrl, defaultDir );
  addItem( itemUrl, QStringLiteral( "url" ) );

  setCurrentGroup( QStringLiteral( "User" ) );

QString name;
      {
        KEMailSettings emailConfig;
        emailConfig.setProfile(emailConfig.defaultProfileName());
        name = emailConfig.getSetting(KEMailSettings::RealName);
      }
      
  KConfigSkeleton::ItemString  *itemName;
  itemName = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "name" ), mName, name );
  addItem( itemName, QStringLiteral( "name" ) );
QString address;
      {
        KEMailSettings emailConfig;
        emailConfig.setProfile(emailConfig.defaultProfileName());
        address = emailConfig.getSetting(KEMailSettings::EmailAddress);
      }
      
  KConfigSkeleton::ItemString  *itemEmail;
  itemEmail = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "email" ), mEmail, address );
  addItem( itemEmail, QStringLiteral( "email" ) );
}

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

