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

#include "kalkconfig.h"

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

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

  return s_globalKalkConfig()->q;
}

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

KalkConfig::KalkConfig( QObject *parent )
  : KConfigSkeleton( QStringLiteral( "kalk/kalkrc" ) )
{
  setParent(parent);
  Q_ASSERT(!s_globalKalkConfig()->q);
  s_globalKalkConfig()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&KalkConfig::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemPrecision;
  KConfigSkeleton::ItemInt  *innerItemPrecision;
  innerItemPrecision = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "Precision" ), mPrecision, 12 );
  itemPrecision = new KConfigCompilerSignallingItem(innerItemPrecision, this, notifyFunction, signalPrecisionChanged);
  addItem( itemPrecision, QStringLiteral( "Precision" ) );
  KConfigCompilerSignallingItem  *itemAngleUnit;
  KConfigSkeleton::ItemInt  *innerItemAngleUnit;
  innerItemAngleUnit = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "AngleUnit" ), mAngleUnit, 1 );
  itemAngleUnit = new KConfigCompilerSignallingItem(innerItemAngleUnit, this, notifyFunction, signalAngleUnitChanged);
  addItem( itemAngleUnit, QStringLiteral( "AngleUnit" ) );
  KConfigCompilerSignallingItem  *itemParsingMode;
  KConfigSkeleton::ItemInt  *innerItemParsingMode;
  innerItemParsingMode = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "ParsingMode" ), mParsingMode, 1 );
  itemParsingMode = new KConfigCompilerSignallingItem(innerItemParsingMode, this, notifyFunction, signalParsingModeChanged);
  addItem( itemParsingMode, QStringLiteral( "ParsingMode" ) );
  KConfigCompilerSignallingItem  *itemCopyWithSeparators;
  KConfigSkeleton::ItemBool  *innerItemCopyWithSeparators;
  innerItemCopyWithSeparators = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "copyWithSeparators" ), mCopyWithSeparators, true );
  itemCopyWithSeparators = new KConfigCompilerSignallingItem(innerItemCopyWithSeparators, this, notifyFunction, signalCopyWithSeparatorsChanged);
  addItem( itemCopyWithSeparators, QStringLiteral( "copyWithSeparators" ) );
}

int KalkConfig::defaultPrecisionValue_helper()
{

  return 12;
}

int KalkConfig::defaultAngleUnitValue_helper()
{

  return 1;
}

int KalkConfig::defaultParsingModeValue_helper()
{

  return 1;
}

bool KalkConfig::defaultCopyWithSeparatorsValue_helper()
{

  return true;
}

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


void KalkConfig::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalPrecisionChanged:
    Q_EMIT PrecisionChanged();
    break;
  case signalAngleUnitChanged:
    Q_EMIT AngleUnitChanged();
    break;
  case signalParsingModeChanged:
    Q_EMIT ParsingModeChanged();
    break;
  case signalCopyWithSeparatorsChanged:
    Q_EMIT copyWithSeparatorsChanged();
    break;
  }
}
