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

#include "hidecursorconfig.h"

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

#include <QDebug>

using namespace KWin;

namespace KWin {

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

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

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

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

HideCursorConfig::HideCursorConfig( KSharedConfig::Ptr config )
  : KConfigSkeleton( std::move( config ) )
{
  Q_ASSERT(!s_globalHideCursorConfig()->q);
  s_globalHideCursorConfig()->q = this;
  setCurrentGroup( QStringLiteral( "Effect-hidecursor" ) );

  KConfigSkeleton::ItemUInt  *itemInactivityDuration;
  itemInactivityDuration = new KConfigSkeleton::ItemUInt( currentGroup(), QStringLiteral( "InactivityDuration" ), mInactivityDuration, 0 );
  addItem( itemInactivityDuration, QStringLiteral( "InactivityDuration" ) );
  KConfigSkeleton::ItemBool  *itemHideOnTyping;
  itemHideOnTyping = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "HideOnTyping" ), mHideOnTyping, true );
  addItem( itemHideOnTyping, QStringLiteral( "HideOnTyping" ) );
}

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

