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

#include "KalmSettings.h"

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

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

  return s_globalKalmSettings()->q;
}

KalmSettings *KalmSettings::create(QQmlEngine *, QJSEngine *)
{
  QQmlEngine::setObjectOwnership(self(), QQmlEngine::CppOwnership);
  return self();
}

KalmSettings::KalmSettings( )
  : KConfigSkeleton( QStringLiteral( "kalmrc" ) )
{
  Q_ASSERT(!s_globalKalmSettings()->q);
  s_globalKalmSettings()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&KalmSettings::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemShowInfoButton;
  KConfigSkeleton::ItemBool  *innerItemShowInfoButton;
  innerItemShowInfoButton = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "showInfoButton" ), mShowInfoButton, true );
  itemShowInfoButton = new KConfigCompilerSignallingItem(innerItemShowInfoButton, this, notifyFunction, signalShowInfoButtonChanged);
  addItem( itemShowInfoButton, QStringLiteral( "showInfoButton" ) );

  setCurrentGroup( QStringLiteral( "Coordinated Breathing" ) );

  KConfigCompilerSignallingItem  *itemBreatheOutDuration;
  KConfigSkeleton::ItemUInt  *innerItemBreatheOutDuration;
  innerItemBreatheOutDuration = new KConfigSkeleton::ItemUInt( currentGroup(), QStringLiteral( "breatheOutDuration" ), mBreatheOutDuration, 20 );
  itemBreatheOutDuration = new KConfigCompilerSignallingItem(innerItemBreatheOutDuration, this, notifyFunction, signalBreatheOutDurationChanged);
  addItem( itemBreatheOutDuration, QStringLiteral( "breatheOutDuration" ) );
}

bool KalmSettings::defaultShowInfoButtonValue_helper()
{

  return true;
}

uint KalmSettings::defaultBreatheOutDurationValue_helper()
{

  return 20;
}

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


void KalmSettings::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalShowInfoButtonChanged:
    Q_EMIT showInfoButtonChanged();
    break;
  case signalBreatheOutDurationChanged:
    Q_EMIT breatheOutDurationChanged();
    break;
  }
}
