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

#include "kamosoSettings.h"

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

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

  return s_globalSettings()->q;
}

Settings::Settings( )
  : KConfigSkeleton( QStringLiteral( "kamosorc" ) )
{
  Q_ASSERT(!s_globalSettings()->q);
  s_globalSettings()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&Settings::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemSaveUrl;
  KConfigSkeleton::ItemUrl  *innerItemSaveUrl;
  innerItemSaveUrl = new KConfigSkeleton::ItemUrl( currentGroup(), QStringLiteral( "saveUrl" ), mSaveUrl, QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) );
  itemSaveUrl = new KConfigCompilerSignallingItem(innerItemSaveUrl, this, notifyFunction, signalSaveUrlChanged);
  addItem( itemSaveUrl, QStringLiteral( "saveUrl" ) );
  KConfigCompilerSignallingItem  *itemSaveVideos;
  KConfigSkeleton::ItemUrl  *innerItemSaveVideos;
  innerItemSaveVideos = new KConfigSkeleton::ItemUrl( currentGroup(), QStringLiteral( "saveVideos" ), mSaveVideos, QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation)) );
  itemSaveVideos = new KConfigCompilerSignallingItem(innerItemSaveVideos, this, notifyFunction, signalSaveVideosChanged);
  addItem( itemSaveVideos, QStringLiteral( "saveVideos" ) );

  setCurrentGroup( QStringLiteral( "WebcamSettings" ) );

  KConfigCompilerSignallingItem  *itemMirrored;
  KConfigSkeleton::ItemBool  *innerItemMirrored;
  innerItemMirrored = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "mirrored" ), mMirrored, true );
  itemMirrored = new KConfigCompilerSignallingItem(innerItemMirrored, this, notifyFunction, signalMirroredChanged);
  addItem( itemMirrored, QStringLiteral( "mirrored" ) );
  KConfigCompilerSignallingItem  *itemDeviceObjectId;
  KConfigSkeleton::ItemString  *innerItemDeviceObjectId;
  innerItemDeviceObjectId = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "deviceObjectId" ), mDeviceObjectId );
  itemDeviceObjectId = new KConfigCompilerSignallingItem(innerItemDeviceObjectId, this, notifyFunction, signalDeviceObjectIdChanged);
  addItem( itemDeviceObjectId, QStringLiteral( "DeviceObjectId" ) );
}

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


void Settings::itemChanged(quint64 flags) {

  if ( flags & signalSaveUrlChanged ) {
    Q_EMIT saveUrlChanged();
  }
  if ( flags & signalSaveVideosChanged ) {
    Q_EMIT saveVideosChanged();
  }
  if ( flags & signalMirroredChanged ) {
    Q_EMIT mirroredChanged();
  }
  if ( flags & signalDeviceObjectIdChanged ) {
    Q_EMIT DeviceObjectIdChanged();
  }
}

#include "kamosoSettings.moc"

