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

#include "ktripsettings.h"

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

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

  return s_globalKTripSettings()->q;
}

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

KTripSettings::KTripSettings( QObject *parent )
  : KConfigSkeleton( QStringLiteral( "ktriprc" ) )
{
  setParent(parent);
  Q_ASSERT(!s_globalKTripSettings()->q);
  s_globalKTripSettings()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&KTripSettings::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemFirstRun;
  KConfigSkeleton::ItemBool  *innerItemFirstRun;
  innerItemFirstRun = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "firstRun" ), mFirstRun, true );
  itemFirstRun = new KConfigCompilerSignallingItem(innerItemFirstRun, this, notifyFunction, signalFirstRunChanged);
  addItem( itemFirstRun, QStringLiteral( "firstRun" ) );

  setCurrentGroup( QStringLiteral( "StopPicker" ) );

  KConfigCompilerSignallingItem  *itemHistorySortMode;
  KConfigSkeleton::ItemString  *innerItemHistorySortMode;
  innerItemHistorySortMode = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "historySortMode" ), mHistorySortMode, QStringLiteral( "lastUsed" ) );
  itemHistorySortMode = new KConfigCompilerSignallingItem(innerItemHistorySortMode, this, notifyFunction, signalHistorySortModeChanged);
  addItem( itemHistorySortMode, QStringLiteral( "historySortMode" ) );

  setCurrentGroup( QStringLiteral( "Backends" ) );

  KConfigCompilerSignallingItem  *itemEnabledBackends;
  KConfigSkeleton::ItemStringList  *innerItemEnabledBackends;
  innerItemEnabledBackends = new KConfigSkeleton::ItemStringList( currentGroup(), QStringLiteral( "EnabledBackends" ), mEnabledBackends );
  itemEnabledBackends = new KConfigCompilerSignallingItem(innerItemEnabledBackends, this, notifyFunction, signalEnabledBackendsChanged);
  addItem( itemEnabledBackends, QStringLiteral( "EnabledBackends" ) );
}

bool KTripSettings::defaultFirstRunValue_helper()
{

  return true;
}

QString KTripSettings::defaultHistorySortModeValue_helper()
{

  return QStringLiteral( "lastUsed" );
}

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


void KTripSettings::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalFirstRunChanged:
    Q_EMIT firstRunChanged();
    break;
  case signalHistorySortModeChanged:
    Q_EMIT historySortModeChanged();
    break;
  case signalEnabledBackendsChanged:
    Q_EMIT EnabledBackendsChanged();
    break;
  }
}
