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

#include "config.h"

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

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

  return s_globalConfig()->q;
}

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

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

  setCurrentGroup( QStringLiteral( "General" ) );


      QStringList defaultLocations;
      defaultLocations = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
      defaultLocations << QStandardPaths::standardLocations(QStandardPaths::DownloadLocation);
      defaultLocations << QStringLiteral("%1/books").arg(QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).constFirst());
      
  KConfigCompilerSignallingItem  *itemBookLocations;
  KConfigSkeleton::ItemStringList  *innerItemBookLocations;
  innerItemBookLocations = new KConfigSkeleton::ItemStringList( currentGroup(), QStringLiteral( "bookLocations" ), mBookLocations, defaultLocations );
  itemBookLocations = new KConfigCompilerSignallingItem(innerItemBookLocations, this, notifyFunction, signalBookLocationsChanged);
  addItem( itemBookLocations, QStringLiteral( "bookLocations" ) );

  setCurrentGroup( QStringLiteral( "Appearance" ) );


      QFont generalFont = QFont(QStringLiteral("serif"), 12);
      generalFont.setStyleName(QStringLiteral("Regular"));
      
  KConfigCompilerSignallingItem  *itemDefaultFont;
  KConfigSkeleton::ItemFont  *innerItemDefaultFont;
  innerItemDefaultFont = new KConfigSkeleton::ItemFont( currentGroup(), QStringLiteral( "defaultFont" ), mDefaultFont, generalFont );
  itemDefaultFont = new KConfigCompilerSignallingItem(innerItemDefaultFont, this, notifyFunction, signalDefaultFontChanged);
  addItem( itemDefaultFont, QStringLiteral( "defaultFont" ) );
  KConfigCompilerSignallingItem  *itemUsePublisherFont;
  KConfigSkeleton::ItemBool  *innerItemUsePublisherFont;
  innerItemUsePublisherFont = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "usePublisherFont" ), mUsePublisherFont, false );
  itemUsePublisherFont = new KConfigCompilerSignallingItem(innerItemUsePublisherFont, this, notifyFunction, signalUsePublisherFontChanged);
  addItem( itemUsePublisherFont, QStringLiteral( "usePublisherFont" ) );
  KConfigCompilerSignallingItem  *itemInvert;
  KConfigSkeleton::ItemBool  *innerItemInvert;
  innerItemInvert = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "invert" ), mInvert, false );
  itemInvert = new KConfigCompilerSignallingItem(innerItemInvert, this, notifyFunction, signalInvertChanged);
  addItem( itemInvert, QStringLiteral( "invert" ) );
  KConfigCompilerSignallingItem  *itemJustify;
  KConfigSkeleton::ItemBool  *innerItemJustify;
  innerItemJustify = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "justify" ), mJustify, true );
  itemJustify = new KConfigCompilerSignallingItem(innerItemJustify, this, notifyFunction, signalJustifyChanged);
  addItem( itemJustify, QStringLiteral( "justify" ) );
  KConfigCompilerSignallingItem  *itemHyphenate;
  KConfigSkeleton::ItemBool  *innerItemHyphenate;
  innerItemHyphenate = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "hyphenate" ), mHyphenate, false );
  itemHyphenate = new KConfigCompilerSignallingItem(innerItemHyphenate, this, notifyFunction, signalHyphenateChanged);
  addItem( itemHyphenate, QStringLiteral( "hyphenate" ) );
  KConfigCompilerSignallingItem  *itemSpacing;
  KConfigSkeleton::ItemDouble  *innerItemSpacing;
  innerItemSpacing = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "spacing" ), mSpacing, 1.5 );
  itemSpacing = new KConfigCompilerSignallingItem(innerItemSpacing, this, notifyFunction, signalSpacingChanged);
  addItem( itemSpacing, QStringLiteral( "spacing" ) );
  KConfigCompilerSignallingItem  *itemBrightness;
  KConfigSkeleton::ItemDouble  *innerItemBrightness;
  innerItemBrightness = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "brightness" ), mBrightness, 1 );
  itemBrightness = new KConfigCompilerSignallingItem(innerItemBrightness, this, notifyFunction, signalBrightnessChanged);
  addItem( itemBrightness, QStringLiteral( "brightness" ) );
  KConfigCompilerSignallingItem  *itemMaxWidth;
  KConfigSkeleton::ItemInt  *innerItemMaxWidth;
  innerItemMaxWidth = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "maxWidth" ), mMaxWidth, 1400 );
  itemMaxWidth = new KConfigCompilerSignallingItem(innerItemMaxWidth, this, notifyFunction, signalMaxWidthChanged);
  addItem( itemMaxWidth, QStringLiteral( "maxWidth" ) );
  KConfigCompilerSignallingItem  *itemMargin;
  KConfigSkeleton::ItemInt  *innerItemMargin;
  innerItemMargin = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "margin" ), mMargin, 40 );
  itemMargin = new KConfigCompilerSignallingItem(innerItemMargin, this, notifyFunction, signalMarginChanged);
  addItem( itemMargin, QStringLiteral( "margin" ) );
  KConfigCompilerSignallingItem  *itemShowProgress;
  KConfigSkeleton::ItemBool  *innerItemShowProgress;
  innerItemShowProgress = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "showProgress" ), mShowProgress, true );
  itemShowProgress = new KConfigCompilerSignallingItem(innerItemShowProgress, this, notifyFunction, signalShowProgressChanged);
  addItem( itemShowProgress, QStringLiteral( "showProgress" ) );
}

QStringList Config::defaultBookLocationsValue_helper()
{

      QStringList defaultLocations;
      defaultLocations = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
      defaultLocations << QStandardPaths::standardLocations(QStandardPaths::DownloadLocation);
      defaultLocations << QStringLiteral("%1/books").arg(QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).constFirst());
      
  return defaultLocations;
}

QFont Config::defaultDefaultFontValue_helper()
{

      QFont generalFont = QFont(QStringLiteral("serif"), 12);
      generalFont.setStyleName(QStringLiteral("Regular"));
      
  return generalFont;
}

bool Config::defaultUsePublisherFontValue_helper()
{

  return false;
}

bool Config::defaultInvertValue_helper()
{

  return false;
}

bool Config::defaultJustifyValue_helper()
{

  return true;
}

bool Config::defaultHyphenateValue_helper()
{

  return false;
}

double Config::defaultSpacingValue_helper()
{

  return 1.5;
}

double Config::defaultBrightnessValue_helper()
{

  return 1;
}

int Config::defaultMaxWidthValue_helper()
{

  return 1400;
}

int Config::defaultMarginValue_helper()
{

  return 40;
}

bool Config::defaultShowProgressValue_helper()
{

  return true;
}

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


void Config::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalBookLocationsChanged:
    Q_EMIT bookLocationsChanged();
    break;
  case signalDefaultFontChanged:
    Q_EMIT defaultFontChanged();
    break;
  case signalUsePublisherFontChanged:
    Q_EMIT usePublisherFontChanged();
    break;
  case signalInvertChanged:
    Q_EMIT invertChanged();
    break;
  case signalJustifyChanged:
    Q_EMIT justifyChanged();
    break;
  case signalHyphenateChanged:
    Q_EMIT hyphenateChanged();
    break;
  case signalSpacingChanged:
    Q_EMIT spacingChanged();
    break;
  case signalBrightnessChanged:
    Q_EMIT brightnessChanged();
    break;
  case signalMaxWidthChanged:
    Q_EMIT maxWidthChanged();
    break;
  case signalMarginChanged:
    Q_EMIT marginChanged();
    break;
  case signalShowProgressChanged:
    Q_EMIT showProgressChanged();
    break;
  }
}
