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

#include "blurconfig.h"

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

#include <QDebug>

using namespace KWin;

namespace KWin {

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

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

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

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

BlurConfig::BlurConfig( KSharedConfig::Ptr config )
  : KConfigSkeleton( std::move( config ) )
{
  Q_ASSERT(!s_globalBlurConfig()->q);
  s_globalBlurConfig()->q = this;
  setCurrentGroup( QStringLiteral( "Effect-blur" ) );

  KConfigSkeleton::ItemInt  *itemBlurStrength;
  itemBlurStrength = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "BlurStrength" ), mBlurStrength, 15 );
  addItem( itemBlurStrength, QStringLiteral( "BlurStrength" ) );
  KConfigSkeleton::ItemInt  *itemNoiseStrength;
  itemNoiseStrength = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "NoiseStrength" ), mNoiseStrength, 5 );
  addItem( itemNoiseStrength, QStringLiteral( "NoiseStrength" ) );
  KConfigSkeleton::ItemInt  *itemSaturation;
  itemSaturation = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "Saturation" ), mSaturation, 150 );
  addItem( itemSaturation, QStringLiteral( "Saturation" ) );
}

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

