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

#include "subtitlessettings.h"

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

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

  return s_globalSubtitlesSettings()->q;
}

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

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

  setCurrentGroup( QStringLiteral( "Subtitles" ) );

  QStringList defaultSubtitlesFolders;
  defaultSubtitlesFolders.append( QString::fromUtf8( "subs" ) );

  KConfigCompilerSignallingItem  *itemSubtitlesFolders;
  KConfigSkeleton::ItemStringList  *innerItemSubtitlesFolders;
  innerItemSubtitlesFolders = new KConfigSkeleton::ItemStringList( currentGroup(), QStringLiteral( "SubtitlesFolders" ), mSubtitlesFolders, defaultSubtitlesFolders );
  itemSubtitlesFolders = new KConfigCompilerSignallingItem(innerItemSubtitlesFolders, this, notifyFunction, signalSubtitlesFoldersChanged);
  addItem( itemSubtitlesFolders, QStringLiteral( "SubtitlesFolders" ) );
  KConfigCompilerSignallingItem  *itemRecursiveSubtitlesSearch;
  KConfigSkeleton::ItemBool  *innerItemRecursiveSubtitlesSearch;
  innerItemRecursiveSubtitlesSearch = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "RecursiveSubtitlesSearch" ), mRecursiveSubtitlesSearch, false );
  itemRecursiveSubtitlesSearch = new KConfigCompilerSignallingItem(innerItemRecursiveSubtitlesSearch, this, notifyFunction, signalRecursiveSubtitlesSearchChanged);
  addItem( itemRecursiveSubtitlesSearch, QStringLiteral( "RecursiveSubtitlesSearch" ) );
  KConfigCompilerSignallingItem  *itemAutoSelectSubtitles;
  KConfigSkeleton::ItemBool  *innerItemAutoSelectSubtitles;
  innerItemAutoSelectSubtitles = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "AutoSelectSubtitles" ), mAutoSelectSubtitles, true );
  itemAutoSelectSubtitles = new KConfigCompilerSignallingItem(innerItemAutoSelectSubtitles, this, notifyFunction, signalAutoSelectSubtitlesChanged);
  addItem( itemAutoSelectSubtitles, QStringLiteral( "AutoSelectSubtitles" ) );
  KConfigCompilerSignallingItem  *itemPreferredLanguage;
  KConfigSkeleton::ItemString  *innerItemPreferredLanguage;
  innerItemPreferredLanguage = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "PreferredLanguage" ), mPreferredLanguage );
  itemPreferredLanguage = new KConfigCompilerSignallingItem(innerItemPreferredLanguage, this, notifyFunction, signalPreferredLanguageChanged);
  addItem( itemPreferredLanguage, QStringLiteral( "PreferredLanguage" ) );
  KConfigCompilerSignallingItem  *itemPreferredTrack;
  KConfigSkeleton::ItemInt  *innerItemPreferredTrack;
  innerItemPreferredTrack = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "PreferredTrack" ), mPreferredTrack );
  itemPreferredTrack = new KConfigCompilerSignallingItem(innerItemPreferredTrack, this, notifyFunction, signalPreferredTrackChanged);
  addItem( itemPreferredTrack, QStringLiteral( "PreferredTrack" ) );
  KConfigCompilerSignallingItem  *itemAllowOnBlackBorders;
  KConfigSkeleton::ItemBool  *innerItemAllowOnBlackBorders;
  innerItemAllowOnBlackBorders = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "AllowOnBlackBorders" ), mAllowOnBlackBorders, false );
  itemAllowOnBlackBorders = new KConfigCompilerSignallingItem(innerItemAllowOnBlackBorders, this, notifyFunction, signalAllowOnBlackBordersChanged);
  addItem( itemAllowOnBlackBorders, QStringLiteral( "AllowOnBlackBorders" ) );
  KConfigCompilerSignallingItem  *itemFontFamily;
  KConfigSkeleton::ItemString  *innerItemFontFamily;
  innerItemFontFamily = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "FontFamily" ), mFontFamily, QStringLiteral( "Sans Serif" ) );
  itemFontFamily = new KConfigCompilerSignallingItem(innerItemFontFamily, this, notifyFunction, signalFontFamilyChanged);
  addItem( itemFontFamily, QStringLiteral( "FontFamily" ) );
  KConfigCompilerSignallingItem  *itemFontSize;
  KConfigSkeleton::ItemInt  *innerItemFontSize;
  innerItemFontSize = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "FontSize" ), mFontSize, 55 );
  itemFontSize = new KConfigCompilerSignallingItem(innerItemFontSize, this, notifyFunction, signalFontSizeChanged);
  addItem( itemFontSize, QStringLiteral( "FontSize" ) );
  KConfigCompilerSignallingItem  *itemFontColor;
  KConfigSkeleton::ItemString  *innerItemFontColor;
  innerItemFontColor = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "FontColor" ), mFontColor, QStringLiteral( "#FFFFFFFF" ) );
  itemFontColor = new KConfigCompilerSignallingItem(innerItemFontColor, this, notifyFunction, signalFontColorChanged);
  addItem( itemFontColor, QStringLiteral( "FontColor" ) );
  KConfigCompilerSignallingItem  *itemShadowColor;
  KConfigSkeleton::ItemString  *innerItemShadowColor;
  innerItemShadowColor = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "ShadowColor" ), mShadowColor, QStringLiteral( "#80F0F0F0" ) );
  itemShadowColor = new KConfigCompilerSignallingItem(innerItemShadowColor, this, notifyFunction, signalShadowColorChanged);
  addItem( itemShadowColor, QStringLiteral( "ShadowColor" ) );
  KConfigCompilerSignallingItem  *itemShadowOffset;
  KConfigSkeleton::ItemInt  *innerItemShadowOffset;
  innerItemShadowOffset = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "ShadowOffset" ), mShadowOffset, 0 );
  itemShadowOffset = new KConfigCompilerSignallingItem(innerItemShadowOffset, this, notifyFunction, signalShadowOffsetChanged);
  addItem( itemShadowOffset, QStringLiteral( "ShadowOffset" ) );
  KConfigCompilerSignallingItem  *itemBorderColor;
  KConfigSkeleton::ItemString  *innerItemBorderColor;
  innerItemBorderColor = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "BorderColor" ), mBorderColor, QStringLiteral( "#FF000000" ) );
  itemBorderColor = new KConfigCompilerSignallingItem(innerItemBorderColor, this, notifyFunction, signalBorderColorChanged);
  addItem( itemBorderColor, QStringLiteral( "BorderColor" ) );
  KConfigCompilerSignallingItem  *itemBorderSize;
  KConfigSkeleton::ItemInt  *innerItemBorderSize;
  innerItemBorderSize = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "BorderSize" ), mBorderSize, 3 );
  itemBorderSize = new KConfigCompilerSignallingItem(innerItemBorderSize, this, notifyFunction, signalBorderSizeChanged);
  addItem( itemBorderSize, QStringLiteral( "BorderSize" ) );
  KConfigCompilerSignallingItem  *itemIsBold;
  KConfigSkeleton::ItemBool  *innerItemIsBold;
  innerItemIsBold = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "IsBold" ), mIsBold, false );
  itemIsBold = new KConfigCompilerSignallingItem(innerItemIsBold, this, notifyFunction, signalIsBoldChanged);
  addItem( itemIsBold, QStringLiteral( "IsBold" ) );
  KConfigCompilerSignallingItem  *itemIsItalic;
  KConfigSkeleton::ItemBool  *innerItemIsItalic;
  innerItemIsItalic = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "IsItalic" ), mIsItalic, false );
  itemIsItalic = new KConfigCompilerSignallingItem(innerItemIsItalic, this, notifyFunction, signalIsItalicChanged);
  addItem( itemIsItalic, QStringLiteral( "IsItalic" ) );
  KConfigCompilerSignallingItem  *itemBorderStyle;
  KConfigSkeleton::ItemString  *innerItemBorderStyle;
  innerItemBorderStyle = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "BorderStyle" ), mBorderStyle, QStringLiteral( "outline-and-shadow" ) );
  itemBorderStyle = new KConfigCompilerSignallingItem(innerItemBorderStyle, this, notifyFunction, signalBorderStyleChanged);
  addItem( itemBorderStyle, QStringLiteral( "BorderStyle" ) );
}

QStringList SubtitlesSettings::defaultSubtitlesFoldersValue_helper()
{
  QStringList defaultSubtitlesFolders;
  defaultSubtitlesFolders.append( QString::fromUtf8( "subs" ) );

  return defaultSubtitlesFolders;
}

bool SubtitlesSettings::defaultRecursiveSubtitlesSearchValue_helper()
{

  return false;
}

bool SubtitlesSettings::defaultAutoSelectSubtitlesValue_helper()
{

  return true;
}

bool SubtitlesSettings::defaultAllowOnBlackBordersValue_helper()
{

  return false;
}

QString SubtitlesSettings::defaultFontFamilyValue_helper()
{

  return QStringLiteral( "Sans Serif" );
}

int SubtitlesSettings::defaultFontSizeValue_helper()
{

  return 55;
}

QString SubtitlesSettings::defaultFontColorValue_helper()
{

  return QStringLiteral( "#FFFFFFFF" );
}

QString SubtitlesSettings::defaultShadowColorValue_helper()
{

  return QStringLiteral( "#80F0F0F0" );
}

int SubtitlesSettings::defaultShadowOffsetValue_helper()
{

  return 0;
}

QString SubtitlesSettings::defaultBorderColorValue_helper()
{

  return QStringLiteral( "#FF000000" );
}

int SubtitlesSettings::defaultBorderSizeValue_helper()
{

  return 3;
}

bool SubtitlesSettings::defaultIsBoldValue_helper()
{

  return false;
}

bool SubtitlesSettings::defaultIsItalicValue_helper()
{

  return false;
}

QString SubtitlesSettings::defaultBorderStyleValue_helper()
{

  return QStringLiteral( "outline-and-shadow" );
}

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


void SubtitlesSettings::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalSubtitlesFoldersChanged:
    Q_EMIT SubtitlesFoldersChanged();
    break;
  case signalRecursiveSubtitlesSearchChanged:
    Q_EMIT RecursiveSubtitlesSearchChanged();
    break;
  case signalAutoSelectSubtitlesChanged:
    Q_EMIT AutoSelectSubtitlesChanged();
    break;
  case signalPreferredLanguageChanged:
    Q_EMIT PreferredLanguageChanged();
    break;
  case signalPreferredTrackChanged:
    Q_EMIT PreferredTrackChanged();
    break;
  case signalAllowOnBlackBordersChanged:
    Q_EMIT AllowOnBlackBordersChanged();
    break;
  case signalFontFamilyChanged:
    Q_EMIT FontFamilyChanged();
    break;
  case signalFontSizeChanged:
    Q_EMIT FontSizeChanged();
    break;
  case signalFontColorChanged:
    Q_EMIT FontColorChanged();
    break;
  case signalShadowColorChanged:
    Q_EMIT ShadowColorChanged();
    break;
  case signalShadowOffsetChanged:
    Q_EMIT ShadowOffsetChanged();
    break;
  case signalBorderColorChanged:
    Q_EMIT BorderColorChanged();
    break;
  case signalBorderSizeChanged:
    Q_EMIT BorderSizeChanged();
    break;
  case signalIsBoldChanged:
    Q_EMIT IsBoldChanged();
    break;
  case signalIsItalicChanged:
    Q_EMIT IsItalicChanged();
    break;
  case signalBorderStyleChanged:
    Q_EMIT BorderStyleChanged();
    break;
  }
}
