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

#include "sheetconfig.h"

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

#include <QDebug>

using namespace KWin;

namespace KWin {

class SheetConfigHelper
{
  public:
    SheetConfigHelper() noexcept : q(nullptr) {}
    ~SheetConfigHelper() noexcept { delete q; q = nullptr; }
    SheetConfigHelper(const SheetConfigHelper&) = delete;
    SheetConfigHelper& operator=(const SheetConfigHelper&) = delete;
    SheetConfig *q;
};

}
Q_GLOBAL_STATIC(SheetConfigHelper, s_globalSheetConfig)
SheetConfig *SheetConfig::self()
{
  if (!s_globalSheetConfig()->q)
     qFatal("you need to call SheetConfig::instance before using");
  return s_globalSheetConfig()->q;
}

void SheetConfig::instance(const QString& cfgfilename)
{
  if (s_globalSheetConfig()->q) {
     qDebug() << "SheetConfig::instance called after the first use - ignoring";
     return;
  }
  new SheetConfig(KSharedConfig::openConfig(cfgfilename));
  s_globalSheetConfig()->q->read();
}

void SheetConfig::instance(KSharedConfig::Ptr config)
{
  if (s_globalSheetConfig()->q) {
     qDebug() << "SheetConfig::instance called after the first use - ignoring";
     return;
  }
  new SheetConfig(std::move(config));
  s_globalSheetConfig()->q->read();
}

SheetConfig::SheetConfig( KSharedConfig::Ptr config )
  : KConfigSkeleton( std::move( config ) )
{
  Q_ASSERT(!s_globalSheetConfig()->q);
  s_globalSheetConfig()->q = this;
  setCurrentGroup( QStringLiteral( "Effect-sheet" ) );

  KConfigSkeleton::ItemInt  *itemAnimationTime;
  itemAnimationTime = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "AnimationTime" ), mAnimationTime, 0 );
  addItem( itemAnimationTime, QStringLiteral( "AnimationTime" ) );
}

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

