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

#include "settings.h"

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

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

  return s_globalBlinkenSettings()->q;
}

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

BlinkenSettings::BlinkenSettings( )
  : KConfigSkeleton( QStringLiteral( "blinkenrc" ) )
{
  Q_ASSERT(!s_globalBlinkenSettings()->q);
  s_globalBlinkenSettings()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&BlinkenSettings::itemChanged);

  setCurrentGroup( QStringLiteral( "general" ) );

  KConfigCompilerSignallingItem  *itemPlaySounds;
  KConfigSkeleton::ItemBool  *innerItemPlaySounds;
  innerItemPlaySounds = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "playSounds" ), mPlaySounds, true );
  itemPlaySounds = new KConfigCompilerSignallingItem(innerItemPlaySounds, this, notifyFunction, signalPlaySoundsChanged);
  addItem( itemPlaySounds, QStringLiteral( "playSounds" ) );
  KConfigCompilerSignallingItem  *itemCustomFont;
  KConfigSkeleton::ItemBool  *innerItemCustomFont;
  innerItemCustomFont = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "customFont" ), mCustomFont, true );
  itemCustomFont = new KConfigCompilerSignallingItem(innerItemCustomFont, this, notifyFunction, signalCustomFontChanged);
  addItem( itemCustomFont, QStringLiteral( "customFont" ) );
}

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


void BlinkenSettings::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalPlaySoundsChanged:
    Q_EMIT playSoundsChanged();
    break;
  case signalCustomFontChanged:
    Q_EMIT customFontChanged();
    break;
  }
}
