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

#include "systemmonitor.h"

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

class ConfigurationHelper
{
  public:
    ConfigurationHelper() noexcept : q(nullptr) {}
    ~ConfigurationHelper() noexcept { delete q; q = nullptr; }
    ConfigurationHelper(const ConfigurationHelper&) = delete;
    ConfigurationHelper& operator=(const ConfigurationHelper&) = delete;
    Configuration *q;
};
Q_GLOBAL_STATIC(ConfigurationHelper, s_globalConfiguration)
Configuration *Configuration::self()
{
  if (!s_globalConfiguration()->q) {
    new Configuration;
    s_globalConfiguration()->q->read();
  }

  return s_globalConfiguration()->q;
}

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

Configuration::Configuration( )
  : KConfigSkeleton( QStringLiteral( "systemmonitorrc" ) )
{
  Q_ASSERT(!s_globalConfiguration()->q);
  s_globalConfiguration()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&Configuration::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemSidebarCollapsed;
  KConfigSkeleton::ItemBool  *innerItemSidebarCollapsed;
  innerItemSidebarCollapsed = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "sidebarCollapsed" ), mSidebarCollapsed, false );
  itemSidebarCollapsed = new KConfigCompilerSignallingItem(innerItemSidebarCollapsed, this, notifyFunction, signalSidebarCollapsedChanged);
  addItem( itemSidebarCollapsed, QStringLiteral( "sidebarCollapsed" ) );
  KConfigCompilerSignallingItem  *itemSidebarWidth;
  KConfigSkeleton::ItemInt  *innerItemSidebarWidth;
  innerItemSidebarWidth = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "sidebarWidth" ), mSidebarWidth, -1 );
  itemSidebarWidth = new KConfigCompilerSignallingItem(innerItemSidebarWidth, this, notifyFunction, signalSidebarWidthChanged);
  addItem( itemSidebarWidth, QStringLiteral( "sidebarWidth" ) );
  QStringList defaultpageOrder;
  defaultpageOrder.append( QString::fromUtf8( "overview.page" ) );
  defaultpageOrder.append( QString::fromUtf8( "applications.page" ) );
  defaultpageOrder.append( QString::fromUtf8( "history.page" ) );
  defaultpageOrder.append( QString::fromUtf8( "processes.page" ) );

  KConfigCompilerSignallingItem  *itemPageOrder;
  KConfigSkeleton::ItemStringList  *innerItemPageOrder;
  innerItemPageOrder = new KConfigSkeleton::ItemStringList( currentGroup(), QStringLiteral( "pageOrder" ), mPageOrder, defaultpageOrder );
  itemPageOrder = new KConfigCompilerSignallingItem(innerItemPageOrder, this, notifyFunction, signalPageOrderChanged);
  addItem( itemPageOrder, QStringLiteral( "pageOrder" ) );
  KConfigCompilerSignallingItem  *itemHiddenPages;
  KConfigSkeleton::ItemStringList  *innerItemHiddenPages;
  innerItemHiddenPages = new KConfigSkeleton::ItemStringList( currentGroup(), QStringLiteral( "hiddenPages" ), mHiddenPages );
  itemHiddenPages = new KConfigCompilerSignallingItem(innerItemHiddenPages, this, notifyFunction, signalHiddenPagesChanged);
  addItem( itemHiddenPages, QStringLiteral( "hiddenPages" ) );
  KConfigCompilerSignallingItem  *itemStartPage;
  KConfigSkeleton::ItemString  *innerItemStartPage;
  innerItemStartPage = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "startPage" ), mStartPage, QStringLiteral( "overview.page" ) );
  itemStartPage = new KConfigCompilerSignallingItem(innerItemStartPage, this, notifyFunction, signalStartPageChanged);
  addItem( itemStartPage, QStringLiteral( "startPage" ) );
  KConfigCompilerSignallingItem  *itemLastVisitedPage;
  KConfigSkeleton::ItemString  *innerItemLastVisitedPage;
  innerItemLastVisitedPage = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "lastVisitedPage" ), mLastVisitedPage );
  itemLastVisitedPage = new KConfigCompilerSignallingItem(innerItemLastVisitedPage, this, notifyFunction, signalLastVisitedPageChanged);
  addItem( itemLastVisitedPage, QStringLiteral( "lastVisitedPage" ) );
}

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


void Configuration::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalSidebarCollapsedChanged:
    Q_EMIT sidebarCollapsedChanged();
    break;
  case signalSidebarWidthChanged:
    Q_EMIT sidebarWidthChanged();
    break;
  case signalPageOrderChanged:
    Q_EMIT pageOrderChanged();
    break;
  case signalHiddenPagesChanged:
    Q_EMIT hiddenPagesChanged();
    break;
  case signalStartPageChanged:
    Q_EMIT startPageChanged();
    break;
  case signalLastVisitedPageChanged:
    Q_EMIT lastVisitedPageChanged();
    break;
  }
}
