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

#include "playbacksettings.h"

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

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

  return s_globalPlaybackSettings()->q;
}

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

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

  setCurrentGroup( QStringLiteral( "Playback" ) );

  KConfigCompilerSignallingItem  *itemRestoreFilePosition;
  KConfigSkeleton::ItemBool  *innerItemRestoreFilePosition;
  innerItemRestoreFilePosition = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "RestoreFilePosition" ), mRestoreFilePosition, false );
  itemRestoreFilePosition = new KConfigCompilerSignallingItem(innerItemRestoreFilePosition, this, notifyFunction, signalRestoreFilePositionChanged);
  addItem( itemRestoreFilePosition, QStringLiteral( "RestoreFilePosition" ) );
  KConfigCompilerSignallingItem  *itemMinDurationToSavePosition;
  KConfigSkeleton::ItemInt  *innerItemMinDurationToSavePosition;
  innerItemMinDurationToSavePosition = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "MinDurationToSavePosition" ), mMinDurationToSavePosition, 1 );
  itemMinDurationToSavePosition = new KConfigCompilerSignallingItem(innerItemMinDurationToSavePosition, this, notifyFunction, signalMinDurationToSavePositionChanged);
  addItem( itemMinDurationToSavePosition, QStringLiteral( "MinDurationToSavePosition" ) );
  KConfigCompilerSignallingItem  *itemSavePositionInterval;
  KConfigSkeleton::ItemInt  *innerItemSavePositionInterval;
  innerItemSavePositionInterval = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "SavePositionInterval" ), mSavePositionInterval, 1 );
  itemSavePositionInterval = new KConfigCompilerSignallingItem(innerItemSavePositionInterval, this, notifyFunction, signalSavePositionIntervalChanged);
  addItem( itemSavePositionInterval, QStringLiteral( "SavePositionInterval" ) );
  KConfigCompilerSignallingItem  *itemSkipChapters;
  KConfigSkeleton::ItemBool  *innerItemSkipChapters;
  innerItemSkipChapters = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "SkipChapters" ), mSkipChapters, false );
  itemSkipChapters = new KConfigCompilerSignallingItem(innerItemSkipChapters, this, notifyFunction, signalSkipChaptersChanged);
  addItem( itemSkipChapters, QStringLiteral( "SkipChapters" ) );
  KConfigCompilerSignallingItem  *itemChaptersToSkip;
  KConfigSkeleton::ItemString  *innerItemChaptersToSkip;
  innerItemChaptersToSkip = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "ChaptersToSkip" ), mChaptersToSkip );
  itemChaptersToSkip = new KConfigCompilerSignallingItem(innerItemChaptersToSkip, this, notifyFunction, signalChaptersToSkipChanged);
  addItem( itemChaptersToSkip, QStringLiteral( "ChaptersToSkip" ) );
  KConfigCompilerSignallingItem  *itemShowOsdOnSkipChapters;
  KConfigSkeleton::ItemBool  *innerItemShowOsdOnSkipChapters;
  innerItemShowOsdOnSkipChapters = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "ShowOsdOnSkipChapters" ), mShowOsdOnSkipChapters, true );
  itemShowOsdOnSkipChapters = new KConfigCompilerSignallingItem(innerItemShowOsdOnSkipChapters, this, notifyFunction, signalShowOsdOnSkipChaptersChanged);
  addItem( itemShowOsdOnSkipChapters, QStringLiteral( "ShowOsdOnSkipChapters" ) );
  KConfigCompilerSignallingItem  *itemYtdlFormat;
  KConfigSkeleton::ItemString  *innerItemYtdlFormat;
  innerItemYtdlFormat = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "YtdlFormat" ), mYtdlFormat );
  itemYtdlFormat = new KConfigCompilerSignallingItem(innerItemYtdlFormat, this, notifyFunction, signalYtdlFormatChanged);
  addItem( itemYtdlFormat, QStringLiteral( "YtdlFormat" ) );
  KConfigCompilerSignallingItem  *itemYtdlFormatCustom;
  KConfigSkeleton::ItemString  *innerItemYtdlFormatCustom;
  innerItemYtdlFormatCustom = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "YtdlFormatCustom" ), mYtdlFormatCustom );
  itemYtdlFormatCustom = new KConfigCompilerSignallingItem(innerItemYtdlFormatCustom, this, notifyFunction, signalYtdlFormatCustomChanged);
  addItem( itemYtdlFormatCustom, QStringLiteral( "YtdlFormatCustom" ) );
  KConfigCompilerSignallingItem  *itemHWDecoding;
  KConfigSkeleton::ItemString  *innerItemHWDecoding;
  innerItemHWDecoding = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "HWDecoding" ), mHWDecoding, QStringLiteral( "auto" ) );
  itemHWDecoding = new KConfigCompilerSignallingItem(innerItemHWDecoding, this, notifyFunction, signalHWDecodingChanged);
  addItem( itemHWDecoding, QStringLiteral( "HWDecoding" ) );
  KConfigCompilerSignallingItem  *itemSeekSmallStep;
  KConfigSkeleton::ItemInt  *innerItemSeekSmallStep;
  innerItemSeekSmallStep = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "SeekSmallStep" ), mSeekSmallStep, 5 );
  itemSeekSmallStep = new KConfigCompilerSignallingItem(innerItemSeekSmallStep, this, notifyFunction, signalSeekSmallStepChanged);
  addItem( itemSeekSmallStep, QStringLiteral( "SeekSmallStep" ) );
  KConfigCompilerSignallingItem  *itemSeekMediumStep;
  KConfigSkeleton::ItemInt  *innerItemSeekMediumStep;
  innerItemSeekMediumStep = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "SeekMediumStep" ), mSeekMediumStep, 15 );
  itemSeekMediumStep = new KConfigCompilerSignallingItem(innerItemSeekMediumStep, this, notifyFunction, signalSeekMediumStepChanged);
  addItem( itemSeekMediumStep, QStringLiteral( "SeekMediumStep" ) );
  KConfigCompilerSignallingItem  *itemSeekBigStep;
  KConfigSkeleton::ItemInt  *innerItemSeekBigStep;
  innerItemSeekBigStep = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "SeekBigStep" ), mSeekBigStep, 30 );
  itemSeekBigStep = new KConfigCompilerSignallingItem(innerItemSeekBigStep, this, notifyFunction, signalSeekBigStepChanged);
  addItem( itemSeekBigStep, QStringLiteral( "SeekBigStep" ) );
  KConfigCompilerSignallingItem  *itemOpenLastPlayedFile;
  KConfigSkeleton::ItemBool  *innerItemOpenLastPlayedFile;
  innerItemOpenLastPlayedFile = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "OpenLastPlayedFile" ), mOpenLastPlayedFile, false );
  itemOpenLastPlayedFile = new KConfigCompilerSignallingItem(innerItemOpenLastPlayedFile, this, notifyFunction, signalOpenLastPlayedFileChanged);
  addItem( itemOpenLastPlayedFile, QStringLiteral( "OpenLastPlayedFile" ) );
  KConfigCompilerSignallingItem  *itemPauseWhileMinimized;
  KConfigSkeleton::ItemBool  *innerItemPauseWhileMinimized;
  innerItemPauseWhileMinimized = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "PauseWhileMinimized" ), mPauseWhileMinimized, false );
  itemPauseWhileMinimized = new KConfigCompilerSignallingItem(innerItemPauseWhileMinimized, this, notifyFunction, signalPauseWhileMinimizedChanged);
  addItem( itemPauseWhileMinimized, QStringLiteral( "PauseWhileMinimized" ) );
  KConfigCompilerSignallingItem  *itemPlayOnResume;
  KConfigSkeleton::ItemBool  *innerItemPlayOnResume;
  innerItemPlayOnResume = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "PlayOnResume" ), mPlayOnResume, true );
  itemPlayOnResume = new KConfigCompilerSignallingItem(innerItemPlayOnResume, this, notifyFunction, signalPlayOnResumeChanged);
  addItem( itemPlayOnResume, QStringLiteral( "PlayOnResume" ) );
}

bool PlaybackSettings::defaultRestoreFilePositionValue_helper()
{

  return false;
}

int PlaybackSettings::defaultMinDurationToSavePositionValue_helper()
{

  return 1;
}

int PlaybackSettings::defaultSavePositionIntervalValue_helper()
{

  return 1;
}

bool PlaybackSettings::defaultSkipChaptersValue_helper()
{

  return false;
}

bool PlaybackSettings::defaultShowOsdOnSkipChaptersValue_helper()
{

  return true;
}

QString PlaybackSettings::defaultHWDecodingValue_helper()
{

  return QStringLiteral( "auto" );
}

int PlaybackSettings::defaultSeekSmallStepValue_helper()
{

  return 5;
}

int PlaybackSettings::defaultSeekMediumStepValue_helper()
{

  return 15;
}

int PlaybackSettings::defaultSeekBigStepValue_helper()
{

  return 30;
}

bool PlaybackSettings::defaultOpenLastPlayedFileValue_helper()
{

  return false;
}

bool PlaybackSettings::defaultPauseWhileMinimizedValue_helper()
{

  return false;
}

bool PlaybackSettings::defaultPlayOnResumeValue_helper()
{

  return true;
}

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


void PlaybackSettings::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalRestoreFilePositionChanged:
    Q_EMIT RestoreFilePositionChanged();
    break;
  case signalMinDurationToSavePositionChanged:
    Q_EMIT MinDurationToSavePositionChanged();
    break;
  case signalSavePositionIntervalChanged:
    Q_EMIT SavePositionIntervalChanged();
    break;
  case signalSkipChaptersChanged:
    Q_EMIT SkipChaptersChanged();
    break;
  case signalChaptersToSkipChanged:
    Q_EMIT ChaptersToSkipChanged();
    break;
  case signalShowOsdOnSkipChaptersChanged:
    Q_EMIT ShowOsdOnSkipChaptersChanged();
    break;
  case signalYtdlFormatChanged:
    Q_EMIT YtdlFormatChanged();
    break;
  case signalYtdlFormatCustomChanged:
    Q_EMIT YtdlFormatCustomChanged();
    break;
  case signalHWDecodingChanged:
    Q_EMIT HWDecodingChanged();
    break;
  case signalSeekSmallStepChanged:
    Q_EMIT SeekSmallStepChanged();
    break;
  case signalSeekMediumStepChanged:
    Q_EMIT SeekMediumStepChanged();
    break;
  case signalSeekBigStepChanged:
    Q_EMIT SeekBigStepChanged();
    break;
  case signalOpenLastPlayedFileChanged:
    Q_EMIT OpenLastPlayedFileChanged();
    break;
  case signalPauseWhileMinimizedChanged:
    Q_EMIT PauseWhileMinimizedChanged();
    break;
  case signalPlayOnResumeChanged:
    Q_EMIT PlayOnResumeChanged();
    break;
  }
}
