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

#include "easyeffects_db_test_signals.h"

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

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

  return s_globalDbTestSignals()->q;
}

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

DbTestSignals::DbTestSignals( )
  : KConfigBaseEE( QStringLiteral( "easyeffects/db/easyeffectsrc" ) )
{
  Q_ASSERT(!s_globalDbTestSignals()->q);
  s_globalDbTestSignals()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&DbTestSignals::itemChanged);

  setCurrentGroup( QStringLiteral( "TestSignals" ) );

  KConfigCompilerSignallingItem  *itemEnable;
  KConfigBaseEE::ItemBool  *innerItemEnable;
  innerItemEnable = new KConfigBaseEE::ItemBool( currentGroup(), QStringLiteral( "enable" ), mEnable, false );
  itemEnable = new KConfigCompilerSignallingItem(innerItemEnable, this, notifyFunction, signalEnableChanged);
  itemEnable->setWriteFlags(KConfigBase::Notify);
  addItem( itemEnable, QStringLiteral( "enable" ) );
  KConfigCompilerSignallingItem  *itemFrequency;
  KConfigBaseEE::ItemDouble  *innerItemFrequency;
  innerItemFrequency = new KConfigBaseEE::ItemDouble( currentGroup(), QStringLiteral( "frequency" ), mFrequency, 1000 );
  itemFrequency = new KConfigCompilerSignallingItem(innerItemFrequency, this, notifyFunction, signalFrequencyChanged);
  innerItemFrequency->setMinValue(10);
  innerItemFrequency->setMaxValue(22000);
  itemFrequency->setWriteFlags(KConfigBase::Notify);
  addItem( itemFrequency, QStringLiteral( "frequency" ) );
  QList<KConfigBaseEE::ItemEnum::Choice> valueschannels;
  {
    KConfigBaseEE::ItemEnum::Choice choice;
    choice.name = QStringLiteral("left");
    valueschannels.append( choice );
  }
  {
    KConfigBaseEE::ItemEnum::Choice choice;
    choice.name = QStringLiteral("right");
    valueschannels.append( choice );
  }
  {
    KConfigBaseEE::ItemEnum::Choice choice;
    choice.name = QStringLiteral("both");
    valueschannels.append( choice );
  }
  KConfigCompilerSignallingItem  *itemChannels;
  KConfigBaseEE::ItemEnum  *innerItemChannels;
  innerItemChannels = new KConfigBaseEE::ItemEnum( currentGroup(), QStringLiteral( "channels" ), mChannels, valueschannels, 2 );
  itemChannels = new KConfigCompilerSignallingItem(innerItemChannels, this, notifyFunction, signalChannelsChanged);
  itemChannels->setWriteFlags(KConfigBase::Notify);
  addItem( itemChannels, QStringLiteral( "channels" ) );
  QList<KConfigBaseEE::ItemEnum::Choice> valuessignalType;
  {
    KConfigBaseEE::ItemEnum::Choice choice;
    choice.name = QStringLiteral("sineWave");
    valuessignalType.append( choice );
  }
  {
    KConfigBaseEE::ItemEnum::Choice choice;
    choice.name = QStringLiteral("whiteNoise");
    valuessignalType.append( choice );
  }
  {
    KConfigBaseEE::ItemEnum::Choice choice;
    choice.name = QStringLiteral("pinkNoise");
    valuessignalType.append( choice );
  }
  KConfigCompilerSignallingItem  *itemSignalType;
  KConfigBaseEE::ItemEnum  *innerItemSignalType;
  innerItemSignalType = new KConfigBaseEE::ItemEnum( currentGroup(), QStringLiteral( "signalType" ), mSignalType, valuessignalType, 0 );
  itemSignalType = new KConfigCompilerSignallingItem(innerItemSignalType, this, notifyFunction, signalSignalTypeChanged);
  itemSignalType->setWriteFlags(KConfigBase::Notify);
  addItem( itemSignalType, QStringLiteral( "signalType" ) );
}

bool DbTestSignals::defaultEnableValue_helper()
{

  return false;
}

double DbTestSignals::defaultFrequencyValue_helper()
{

  return 1000;
}

int DbTestSignals::defaultChannelsValue_helper()
{

  return 2;
}

int DbTestSignals::defaultSignalTypeValue_helper()
{

  return 0;
}

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


void DbTestSignals::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalEnableChanged:
    Q_EMIT enableChanged();
    break;
  case signalFrequencyChanged:
    Q_EMIT frequencyChanged();
    break;
  case signalChannelsChanged:
    Q_EMIT channelsChanged();
    break;
  case signalSignalTypeChanged:
    Q_EMIT signalTypeChanged();
    break;
  }
}
