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

#include "magnifierconfig.h"

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

#include <QDebug>

using namespace KWin;

namespace KWin {

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

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

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

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

MagnifierConfig::MagnifierConfig( KSharedConfig::Ptr config )
  : KConfigSkeleton( std::move( config ) )
{
  Q_ASSERT(!s_globalMagnifierConfig()->q);
  s_globalMagnifierConfig()->q = this;
  setCurrentGroup( QStringLiteral( "Effect-magnifier" ) );

  KConfigSkeleton::ItemUInt  *itemWidth;
  itemWidth = new KConfigSkeleton::ItemUInt( currentGroup(), QStringLiteral( "Width" ), mWidth, 200 );
  addItem( itemWidth, QStringLiteral( "Width" ) );
  KConfigSkeleton::ItemUInt  *itemHeight;
  itemHeight = new KConfigSkeleton::ItemUInt( currentGroup(), QStringLiteral( "Height" ), mHeight, 200 );
  addItem( itemHeight, QStringLiteral( "Height" ) );

  setCurrentGroup( QStringLiteral( "Effect-zoom" ) );

  KConfigSkeleton::ItemDouble  *itemZoomFactor;
  itemZoomFactor = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "ZoomFactor" ), mZoomFactor, 1.2 );
  addItem( itemZoomFactor, QStringLiteral( "ZoomFactor" ) );
  KConfigSkeleton::ItemDouble  *itemInitialZoom;
  itemInitialZoom = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "InitialZoom" ), mInitialZoom, 1.0 );
  addItem( itemInitialZoom, QStringLiteral( "InitialZoom" ) );
}

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

