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

#include "audiosettings.h"

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

class AudioSettingsHelper
{
  public:
    AudioSettingsHelper() : q(nullptr) {}
    ~AudioSettingsHelper() { delete q; q = nullptr; }
    AudioSettingsHelper(const AudioSettingsHelper&) = delete;
    AudioSettingsHelper& operator=(const AudioSettingsHelper&) = delete;
    AudioSettings *q;
};
Q_GLOBAL_STATIC(AudioSettingsHelper, s_globalAudioSettings)
AudioSettings *AudioSettings::self()
{
  if (!s_globalAudioSettings()->q) {
    new AudioSettings;
    s_globalAudioSettings()->q->read();
  }

  return s_globalAudioSettings()->q;
}

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

AudioSettings::AudioSettings( QObject *parent )
  : KConfigSkeleton( QStringLiteral( "haruna/haruna.conf" ) )
{
  setParent(parent);
  Q_ASSERT(!s_globalAudioSettings()->q);
  s_globalAudioSettings()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&AudioSettings::itemChanged);

  setCurrentGroup( QStringLiteral( "Audio" ) );

  KConfigCompilerSignallingItem  *itemPreferredLanguage;
  KConfigSkeleton::ItemString  *innerItemPreferredLanguage;
  innerItemPreferredLanguage = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "PreferredLanguage" ), mPreferredLanguage );
  itemPreferredLanguage = new KConfigCompilerSignallingItem(innerItemPreferredLanguage, this, notifyFunction, signalPreferredLanguageChanged);
  addItem( itemPreferredLanguage, QStringLiteral( "PreferredLanguage" ) );
  KConfigCompilerSignallingItem  *itemPreferredTrack;
  KConfigSkeleton::ItemInt  *innerItemPreferredTrack;
  innerItemPreferredTrack = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "PreferredTrack" ), mPreferredTrack );
  itemPreferredTrack = new KConfigCompilerSignallingItem(innerItemPreferredTrack, this, notifyFunction, signalPreferredTrackChanged);
  addItem( itemPreferredTrack, QStringLiteral( "PreferredTrack" ) );
  KConfigCompilerSignallingItem  *itemVolume;
  KConfigSkeleton::ItemInt  *innerItemVolume;
  innerItemVolume = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "Volume" ), mVolume, 80 );
  itemVolume = new KConfigCompilerSignallingItem(innerItemVolume, this, notifyFunction, signalVolumeChanged);
  addItem( itemVolume, QStringLiteral( "Volume" ) );
  KConfigCompilerSignallingItem  *itemVolumeStep;
  KConfigSkeleton::ItemInt  *innerItemVolumeStep;
  innerItemVolumeStep = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "VolumeStep" ), mVolumeStep, 5 );
  itemVolumeStep = new KConfigCompilerSignallingItem(innerItemVolumeStep, this, notifyFunction, signalVolumeStepChanged);
  addItem( itemVolumeStep, QStringLiteral( "VolumeStep" ) );
  KConfigCompilerSignallingItem  *itemReplayGain;
  KConfigSkeleton::ItemString  *innerItemReplayGain;
  innerItemReplayGain = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "ReplayGain" ), mReplayGain, QStringLiteral( "no" ) );
  itemReplayGain = new KConfigCompilerSignallingItem(innerItemReplayGain, this, notifyFunction, signalReplayGainChanged);
  addItem( itemReplayGain, QStringLiteral( "ReplayGain" ) );
  KConfigCompilerSignallingItem  *itemReplayGainPreamp;
  KConfigSkeleton::ItemInt  *innerItemReplayGainPreamp;
  innerItemReplayGainPreamp = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "ReplayGainPreamp" ), mReplayGainPreamp, 0 );
  itemReplayGainPreamp = new KConfigCompilerSignallingItem(innerItemReplayGainPreamp, this, notifyFunction, signalReplayGainPreampChanged);
  addItem( itemReplayGainPreamp, QStringLiteral( "ReplayGainPreamp" ) );
  KConfigCompilerSignallingItem  *itemReplayGainPreventClip;
  KConfigSkeleton::ItemBool  *innerItemReplayGainPreventClip;
  innerItemReplayGainPreventClip = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "ReplayGainPreventClip" ), mReplayGainPreventClip, true );
  itemReplayGainPreventClip = new KConfigCompilerSignallingItem(innerItemReplayGainPreventClip, this, notifyFunction, signalReplayGainPreventClipChanged);
  addItem( itemReplayGainPreventClip, QStringLiteral( "ReplayGainPreventClip" ) );
  KConfigCompilerSignallingItem  *itemReplayGainFallback;
  KConfigSkeleton::ItemInt  *innerItemReplayGainFallback;
  innerItemReplayGainFallback = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "ReplayGainFallback" ), mReplayGainFallback, 0 );
  itemReplayGainFallback = new KConfigCompilerSignallingItem(innerItemReplayGainFallback, this, notifyFunction, signalReplayGainFallbackChanged);
  addItem( itemReplayGainFallback, QStringLiteral( "ReplayGainFallback" ) );
}

int AudioSettings::defaultVolumeValue_helper()
{

  return 80;
}

int AudioSettings::defaultVolumeStepValue_helper()
{

  return 5;
}

QString AudioSettings::defaultReplayGainValue_helper()
{

  return QStringLiteral( "no" );
}

int AudioSettings::defaultReplayGainPreampValue_helper()
{

  return 0;
}

bool AudioSettings::defaultReplayGainPreventClipValue_helper()
{

  return true;
}

int AudioSettings::defaultReplayGainFallbackValue_helper()
{

  return 0;
}

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


void AudioSettings::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalPreferredLanguageChanged:
    Q_EMIT PreferredLanguageChanged();
    break;
  case signalPreferredTrackChanged:
    Q_EMIT PreferredTrackChanged();
    break;
  case signalVolumeChanged:
    Q_EMIT VolumeChanged();
    break;
  case signalVolumeStepChanged:
    Q_EMIT VolumeStepChanged();
    break;
  case signalReplayGainChanged:
    Q_EMIT ReplayGainChanged();
    break;
  case signalReplayGainPreampChanged:
    Q_EMIT ReplayGainPreampChanged();
    break;
  case signalReplayGainPreventClipChanged:
    Q_EMIT ReplayGainPreventClipChanged();
    break;
  case signalReplayGainFallbackChanged:
    Q_EMIT ReplayGainFallbackChanged();
    break;
  }
}
