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

#include "settings.h"

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

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

  return s_globalHanaSettings()->q;
}

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

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

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemThumbnailsWidth;
  KConfigSkeleton::ItemInt  *innerItemThumbnailsWidth;
  innerItemThumbnailsWidth = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "ThumbnailsWidth" ), mThumbnailsWidth, 400 );
  itemThumbnailsWidth = new KConfigCompilerSignallingItem(innerItemThumbnailsWidth, this, notifyFunction, signalThumbnailsWidthChanged);
  addItem( itemThumbnailsWidth, QStringLiteral( "ThumbnailsWidth" ) );
  KConfigCompilerSignallingItem  *itemThumbnailsRows;
  KConfigSkeleton::ItemInt  *innerItemThumbnailsRows;
  innerItemThumbnailsRows = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "ThumbnailsRows" ), mThumbnailsRows, 5 );
  itemThumbnailsRows = new KConfigCompilerSignallingItem(innerItemThumbnailsRows, this, notifyFunction, signalThumbnailsRowsChanged);
  addItem( itemThumbnailsRows, QStringLiteral( "ThumbnailsRows" ) );
  KConfigCompilerSignallingItem  *itemThumbnailsColumns;
  KConfigSkeleton::ItemInt  *innerItemThumbnailsColumns;
  innerItemThumbnailsColumns = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "ThumbnailsColumns" ), mThumbnailsColumns, 4 );
  itemThumbnailsColumns = new KConfigCompilerSignallingItem(innerItemThumbnailsColumns, this, notifyFunction, signalThumbnailsColumnsChanged);
  addItem( itemThumbnailsColumns, QStringLiteral( "ThumbnailsColumns" ) );
  KConfigCompilerSignallingItem  *itemThumbnailsSpacing;
  KConfigSkeleton::ItemInt  *innerItemThumbnailsSpacing;
  innerItemThumbnailsSpacing = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "ThumbnailsSpacing" ), mThumbnailsSpacing, 20 );
  itemThumbnailsSpacing = new KConfigCompilerSignallingItem(innerItemThumbnailsSpacing, this, notifyFunction, signalThumbnailsSpacingChanged);
  addItem( itemThumbnailsSpacing, QStringLiteral( "ThumbnailsSpacing" ) );
  KConfigCompilerSignallingItem  *itemBackgroundColor;
  KConfigSkeleton::ItemString  *innerItemBackgroundColor;
  innerItemBackgroundColor = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "BackgroundColor" ), mBackgroundColor, QStringLiteral( "#374047" ) );
  itemBackgroundColor = new KConfigCompilerSignallingItem(innerItemBackgroundColor, this, notifyFunction, signalBackgroundColorChanged);
  addItem( itemBackgroundColor, QStringLiteral( "BackgroundColor" ) );
  KConfigCompilerSignallingItem  *itemAvoidDarkFrames;
  KConfigSkeleton::ItemBool  *innerItemAvoidDarkFrames;
  innerItemAvoidDarkFrames = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "AvoidDarkFrames" ), mAvoidDarkFrames, true );
  itemAvoidDarkFrames = new KConfigCompilerSignallingItem(innerItemAvoidDarkFrames, this, notifyFunction, signalAvoidDarkFramesChanged);
  addItem( itemAvoidDarkFrames, QStringLiteral( "AvoidDarkFrames" ) );
  KConfigCompilerSignallingItem  *itemShowVideoInfo;
  KConfigSkeleton::ItemBool  *innerItemShowVideoInfo;
  innerItemShowVideoInfo = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "ShowVideoInfo" ), mShowVideoInfo, true );
  itemShowVideoInfo = new KConfigCompilerSignallingItem(innerItemShowVideoInfo, this, notifyFunction, signalShowVideoInfoChanged);
  addItem( itemShowVideoInfo, QStringLiteral( "ShowVideoInfo" ) );
  KConfigCompilerSignallingItem  *itemVideoInfoAlwaysShowHours;
  KConfigSkeleton::ItemBool  *innerItemVideoInfoAlwaysShowHours;
  innerItemVideoInfoAlwaysShowHours = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "VideoInfoAlwaysShowHours" ), mVideoInfoAlwaysShowHours, true );
  itemVideoInfoAlwaysShowHours = new KConfigCompilerSignallingItem(innerItemVideoInfoAlwaysShowHours, this, notifyFunction, signalVideoInfoAlwaysShowHoursChanged);
  addItem( itemVideoInfoAlwaysShowHours, QStringLiteral( "VideoInfoAlwaysShowHours" ) );
  KConfigCompilerSignallingItem  *itemVideoInfoBackgroundColor;
  KConfigSkeleton::ItemString  *innerItemVideoInfoBackgroundColor;
  innerItemVideoInfoBackgroundColor = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "VideoInfoBackgroundColor" ), mVideoInfoBackgroundColor, QStringLiteral( "#faf0e9" ) );
  itemVideoInfoBackgroundColor = new KConfigCompilerSignallingItem(innerItemVideoInfoBackgroundColor, this, notifyFunction, signalVideoInfoBackgroundColorChanged);
  addItem( itemVideoInfoBackgroundColor, QStringLiteral( "VideoInfoBackgroundColor" ) );
  KConfigCompilerSignallingItem  *itemVideoInfoTextColor;
  KConfigSkeleton::ItemString  *innerItemVideoInfoTextColor;
  innerItemVideoInfoTextColor = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "VideoInfoTextColor" ), mVideoInfoTextColor, QStringLiteral( "#374047" ) );
  itemVideoInfoTextColor = new KConfigCompilerSignallingItem(innerItemVideoInfoTextColor, this, notifyFunction, signalVideoInfoTextColorChanged);
  addItem( itemVideoInfoTextColor, QStringLiteral( "VideoInfoTextColor" ) );

  setCurrentGroup( QStringLiteral( "Paths" ) );

  KConfigCompilerSignallingItem  *itemSaveLocation;
  KConfigSkeleton::ItemString  *innerItemSaveLocation;
  innerItemSaveLocation = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "SaveLocation" ), mSaveLocation, QStringLiteral( "NextToVideo" ) );
  itemSaveLocation = new KConfigCompilerSignallingItem(innerItemSaveLocation, this, notifyFunction, signalSaveLocationChanged);
  addItem( itemSaveLocation, QStringLiteral( "SaveLocation" ) );
  KConfigCompilerSignallingItem  *itemSaveLocationFolderName;
  KConfigSkeleton::ItemString  *innerItemSaveLocationFolderName;
  innerItemSaveLocationFolderName = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "SaveLocationFolderName" ), mSaveLocationFolderName, QStringLiteral( "thumbs" ) );
  itemSaveLocationFolderName = new KConfigCompilerSignallingItem(innerItemSaveLocationFolderName, this, notifyFunction, signalSaveLocationFolderNameChanged);
  addItem( itemSaveLocationFolderName, QStringLiteral( "SaveLocationFolderName" ) );

              QString thumbsSavePath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
              thumbsSavePath.append(QStringLiteral("/hana"));
              QUrl thumbsSaveUrl = QUrl::fromLocalFile(thumbsSavePath);
            
  KConfigCompilerSignallingItem  *itemSaveLocationFolderUrl;
  KConfigSkeleton::ItemUrl  *innerItemSaveLocationFolderUrl;
  innerItemSaveLocationFolderUrl = new KConfigSkeleton::ItemUrl( currentGroup(), QStringLiteral( "SaveLocationFolderUrl" ), mSaveLocationFolderUrl, thumbsSaveUrl );
  itemSaveLocationFolderUrl = new KConfigCompilerSignallingItem(innerItemSaveLocationFolderUrl, this, notifyFunction, signalSaveLocationFolderUrlChanged);
  addItem( itemSaveLocationFolderUrl, QStringLiteral( "SaveLocationFolderUrl" ) );

                QString videosPath = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
                QUrl videosUrl = QUrl::fromLocalFile(videosPath);
            
  KConfigCompilerSignallingItem  *itemSelectVideosUrl;
  KConfigSkeleton::ItemUrl  *innerItemSelectVideosUrl;
  innerItemSelectVideosUrl = new KConfigSkeleton::ItemUrl( currentGroup(), QStringLiteral( "SelectVideosUrl" ), mSelectVideosUrl, videosUrl );
  itemSelectVideosUrl = new KConfigCompilerSignallingItem(innerItemSelectVideosUrl, this, notifyFunction, signalSelectVideosUrlChanged);
  addItem( itemSelectVideosUrl, QStringLiteral( "SelectVideosUrl" ) );
}

int HanaSettings::defaultThumbnailsWidthValue_helper()
{

  return 400;
}

int HanaSettings::defaultThumbnailsRowsValue_helper()
{

  return 5;
}

int HanaSettings::defaultThumbnailsColumnsValue_helper()
{

  return 4;
}

int HanaSettings::defaultThumbnailsSpacingValue_helper()
{

  return 20;
}

QString HanaSettings::defaultBackgroundColorValue_helper()
{

  return QStringLiteral( "#374047" );
}

bool HanaSettings::defaultAvoidDarkFramesValue_helper()
{

  return true;
}

bool HanaSettings::defaultShowVideoInfoValue_helper()
{

  return true;
}

bool HanaSettings::defaultVideoInfoAlwaysShowHoursValue_helper()
{

  return true;
}

QString HanaSettings::defaultVideoInfoBackgroundColorValue_helper()
{

  return QStringLiteral( "#faf0e9" );
}

QString HanaSettings::defaultVideoInfoTextColorValue_helper()
{

  return QStringLiteral( "#374047" );
}

QString HanaSettings::defaultSaveLocationValue_helper()
{

  return QStringLiteral( "NextToVideo" );
}

QString HanaSettings::defaultSaveLocationFolderNameValue_helper()
{

  return QStringLiteral( "thumbs" );
}

QUrl HanaSettings::defaultSaveLocationFolderUrlValue_helper()
{

              QString thumbsSavePath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
              thumbsSavePath.append(QStringLiteral("/hana"));
              QUrl thumbsSaveUrl = QUrl::fromLocalFile(thumbsSavePath);
            
  return thumbsSaveUrl;
}

QUrl HanaSettings::defaultSelectVideosUrlValue_helper()
{

                QString videosPath = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
                QUrl videosUrl = QUrl::fromLocalFile(videosPath);
            
  return videosUrl;
}

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


void HanaSettings::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalThumbnailsWidthChanged:
    Q_EMIT ThumbnailsWidthChanged();
    break;
  case signalThumbnailsRowsChanged:
    Q_EMIT ThumbnailsRowsChanged();
    break;
  case signalThumbnailsColumnsChanged:
    Q_EMIT ThumbnailsColumnsChanged();
    break;
  case signalThumbnailsSpacingChanged:
    Q_EMIT ThumbnailsSpacingChanged();
    break;
  case signalBackgroundColorChanged:
    Q_EMIT BackgroundColorChanged();
    break;
  case signalAvoidDarkFramesChanged:
    Q_EMIT AvoidDarkFramesChanged();
    break;
  case signalShowVideoInfoChanged:
    Q_EMIT ShowVideoInfoChanged();
    break;
  case signalVideoInfoAlwaysShowHoursChanged:
    Q_EMIT VideoInfoAlwaysShowHoursChanged();
    break;
  case signalVideoInfoBackgroundColorChanged:
    Q_EMIT VideoInfoBackgroundColorChanged();
    break;
  case signalVideoInfoTextColorChanged:
    Q_EMIT VideoInfoTextColorChanged();
    break;
  case signalSaveLocationChanged:
    Q_EMIT SaveLocationChanged();
    break;
  case signalSaveLocationFolderNameChanged:
    Q_EMIT SaveLocationFolderNameChanged();
    break;
  case signalSaveLocationFolderUrlChanged:
    Q_EMIT SaveLocationFolderUrlChanged();
    break;
  case signalSelectVideosUrlChanged:
    Q_EMIT SelectVideosUrlChanged();
    break;
  }
}
