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

#include "nightlightsettings.h"

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

#include <QDebug>

using namespace KWin;

namespace KWin {

class NightLightSettingsHelper
{
  public:
    NightLightSettingsHelper() : q(nullptr) {}
    ~NightLightSettingsHelper() { delete q; q = nullptr; }
    NightLightSettingsHelper(const NightLightSettingsHelper&) = delete;
    NightLightSettingsHelper& operator=(const NightLightSettingsHelper&) = delete;
    NightLightSettings *q;
};

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

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

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

NightLightSettings::NightLightSettings( KSharedConfig::Ptr config )
  : KConfigSkeleton( std::move( config ) )
{
  Q_ASSERT(!s_globalNightLightSettings()->q);
  s_globalNightLightSettings()->q = this;
  setCurrentGroup( QStringLiteral( "NightColor" ) );

  KConfigSkeleton::ItemBool  *itemActive;
  itemActive = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "Active" ), mActive, false );
  addItem( itemActive, QStringLiteral( "Active" ) );
  QList<KConfigSkeleton::ItemEnum::Choice> valuesMode;
  {
    KConfigSkeleton::ItemEnum::Choice choice;
    choice.name = QStringLiteral("Constant");
    valuesMode.append( choice );
  }
  {
    KConfigSkeleton::ItemEnum::Choice choice;
    choice.name = QStringLiteral("DarkLight");
    valuesMode.append( choice );
  }
  KConfigSkeleton::ItemEnum  *itemMode;
  itemMode = new KConfigSkeleton::ItemEnum( currentGroup(), QStringLiteral( "Mode" ), mMode, valuesMode, NightLightMode::DarkLight );
  addItem( itemMode, QStringLiteral( "Mode" ) );
  KConfigSkeleton::ItemInt  *itemDayTemperature;
  itemDayTemperature = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "DayTemperature" ), mDayTemperature, 6500 );
  addItem( itemDayTemperature, QStringLiteral( "DayTemperature" ) );
  KConfigSkeleton::ItemInt  *itemNightTemperature;
  itemNightTemperature = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "NightTemperature" ), mNightTemperature, 4500 );
  addItem( itemNightTemperature, QStringLiteral( "NightTemperature" ) );
}

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

