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

#include "stateprefs.h"

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

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

  return s_globalStatePrefs()->q;
}

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

StatePrefs::StatePrefs( QObject *parent )
  : KConfigSkeleton( KSharedConfig::openStateConfig(QStringLiteral( "kwordquizstaterc") ) )
{
  setParent(parent);
  Q_ASSERT(!s_globalStatePrefs()->q);
  s_globalStatePrefs()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&StatePrefs::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemDocuments;
  KConfigSkeleton::ItemPathList  *innerItemDocuments;
  innerItemDocuments = new KConfigSkeleton::ItemPathList( currentGroup(), QStringLiteral( "Documents" ), mDocuments );
  itemDocuments = new KConfigCompilerSignallingItem(innerItemDocuments, this, notifyFunction, signalDocumentsChanged);
  addItem( itemDocuments, QStringLiteral( "Documents" ) );
}

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


void StatePrefs::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalDocumentsChanged:
    Q_EMIT DocumentsChanged();
    break;
  }
}
