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

#include "shakecursorconfig.h"

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

#include <QDebug>

using namespace KWin;

namespace KWin {

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

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

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

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

ShakeCursorConfig::ShakeCursorConfig( KSharedConfig::Ptr config )
  : KConfigSkeleton( std::move( config ) )
{
  Q_ASSERT(!s_globalShakeCursorConfig()->q);
  s_globalShakeCursorConfig()->q = this;
  setCurrentGroup( QStringLiteral( "Effect-shakecursor" ) );

  KConfigSkeleton::ItemUInt  *itemTimeInterval;
  itemTimeInterval = new KConfigSkeleton::ItemUInt( currentGroup(), QStringLiteral( "TimeInterval" ), mTimeInterval, 1000 );
  addItem( itemTimeInterval, QStringLiteral( "TimeInterval" ) );
  KConfigSkeleton::ItemDouble  *itemSensitivity;
  itemSensitivity = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "Sensitivity" ), mSensitivity, 4 );
  addItem( itemSensitivity, QStringLiteral( "Sensitivity" ) );
  KConfigSkeleton::ItemDouble  *itemMagnification;
  itemMagnification = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "Magnification" ), mMagnification, 3 );
  addItem( itemMagnification, QStringLiteral( "Magnification" ) );
  KConfigSkeleton::ItemDouble  *itemOverMagnification;
  itemOverMagnification = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "OverMagnification" ), mOverMagnification, 1 );
  addItem( itemOverMagnification, QStringLiteral( "OverMagnification" ) );
}

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

