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

#include "marknotesettings.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( "marknoterc" ) )
{
  setParent(parent);
  Q_ASSERT(!s_globalConfig()->q);
  s_globalConfig()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&Config::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemSortBehaviour;
  KConfigSkeleton::ItemString  *innerItemSortBehaviour;
  innerItemSortBehaviour = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "sortBehaviour" ), mSortBehaviour, QStringLiteral("sort-name") );
  itemSortBehaviour = new KConfigCompilerSignallingItem(innerItemSortBehaviour, this, notifyFunction, signalSortBehaviourChanged);
  addItem( itemSortBehaviour, QStringLiteral( "sortBehaviour" ) );
  KConfigCompilerSignallingItem  *itemExpandedSidebar;
  KConfigSkeleton::ItemBool  *innerItemExpandedSidebar;
  innerItemExpandedSidebar = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "expandedSidebar" ), mExpandedSidebar, true );
  itemExpandedSidebar = new KConfigCompilerSignallingItem(innerItemExpandedSidebar, this, notifyFunction, signalExpandedSidebarChanged);
  addItem( itemExpandedSidebar, QStringLiteral( "expandedSidebar" ) );
  KConfigCompilerSignallingItem  *itemFillWindow;
  KConfigSkeleton::ItemBool  *innerItemFillWindow;
  innerItemFillWindow = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "fillWindow" ), mFillWindow, false );
  itemFillWindow = new KConfigCompilerSignallingItem(innerItemFillWindow, this, notifyFunction, signalFillWindowChanged);
  addItem( itemFillWindow, QStringLiteral( "fillWindow" ) );
  KConfigCompilerSignallingItem  *itemColumnWidth;
  KConfigSkeleton::ItemInt  *innerItemColumnWidth;
  innerItemColumnWidth = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "columnWidth" ), mColumnWidth, 370 );
  itemColumnWidth = new KConfigCompilerSignallingItem(innerItemColumnWidth, this, notifyFunction, signalColumnWidthChanged);
  addItem( itemColumnWidth, QStringLiteral( "columnWidth" ) );
  KConfigCompilerSignallingItem  *itemStorage;
  KConfigSkeleton::ItemPath  *innerItemStorage;
  innerItemStorage = new KConfigSkeleton::ItemPath( currentGroup(), QStringLiteral( "storage" ), mStorage, QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + u'/' + QStringLiteral("Notes") );
  itemStorage = new KConfigCompilerSignallingItem(innerItemStorage, this, notifyFunction, signalStorageChanged);
  addItem( itemStorage, QStringLiteral( "storage" ) );
  KConfigCompilerSignallingItem  *itemColorScheme;
  KConfigSkeleton::ItemString  *innerItemColorScheme;
  innerItemColorScheme = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "colorScheme" ), mColorScheme );
  itemColorScheme = new KConfigCompilerSignallingItem(innerItemColorScheme, this, notifyFunction, signalColorSchemeChanged);
  addItem( itemColorScheme, QStringLiteral( "colorScheme" ) );

  setCurrentGroup( QStringLiteral( "Fonts" ) );

  KConfigCompilerSignallingItem  *itemEditorFont;
  KConfigSkeleton::ItemFont  *innerItemEditorFont;
  innerItemEditorFont = new KConfigSkeleton::ItemFont( currentGroup(), QStringLiteral( "editor-font" ), mEditorFont, QFontDatabase::systemFont(QFontDatabase::GeneralFont) );
  itemEditorFont = new KConfigCompilerSignallingItem(innerItemEditorFont, this, notifyFunction, signalEditorFontChanged);
  addItem( itemEditorFont, QStringLiteral( "EditorFont" ) );
}

QString Config::defaultSortBehaviourValue_helper()
{

  return QStringLiteral("sort-name");
}

bool Config::defaultExpandedSidebarValue_helper()
{

  return true;
}

bool Config::defaultFillWindowValue_helper()
{

  return false;
}

int Config::defaultColumnWidthValue_helper()
{

  return 370;
}

QString Config::defaultStorageValue_helper()
{

  return QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + u'/' + QStringLiteral("Notes");
}

QFont Config::defaultEditorFontValue_helper()
{

  return QFontDatabase::systemFont(QFontDatabase::GeneralFont);
}

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


void Config::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalSortBehaviourChanged:
    Q_EMIT sortBehaviourChanged();
    break;
  case signalExpandedSidebarChanged:
    Q_EMIT expandedSidebarChanged();
    break;
  case signalFillWindowChanged:
    Q_EMIT fillWindowChanged();
    break;
  case signalColumnWidthChanged:
    Q_EMIT columnWidthChanged();
    break;
  case signalStorageChanged:
    Q_EMIT storageChanged();
    break;
  case signalColorSchemeChanged:
    Q_EMIT colorSchemeChanged();
    break;
  case signalEditorFontChanged:
    Q_EMIT EditorFontChanged();
    break;
  }
}
