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

#include "nightcolorsettings.h"

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

#include <QDebug>

using namespace KWin;

namespace KWin {

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

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

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

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

NightColorSettings::NightColorSettings( KSharedConfig::Ptr config )
  : KConfigSkeleton( std::move( config ) )
{
  Q_ASSERT(!s_globalNightColorSettings()->q);
  s_globalNightColorSettings()->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("Automatic");
    valuesMode.append( choice );
  }
  {
    KConfigSkeleton::ItemEnum::Choice choice;
    choice.name = QStringLiteral("Location");
    valuesMode.append( choice );
  }
  {
    KConfigSkeleton::ItemEnum::Choice choice;
    choice.name = QStringLiteral("Times");
    valuesMode.append( choice );
  }
  {
    KConfigSkeleton::ItemEnum::Choice choice;
    choice.name = QStringLiteral("Constant");
    valuesMode.append( choice );
  }
  KConfigSkeleton::ItemEnum  *itemMode;
  itemMode = new KConfigSkeleton::ItemEnum( currentGroup(), QStringLiteral( "Mode" ), mMode, valuesMode, NightColorMode::Automatic );
  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" ) );
  KConfigSkeleton::ItemDouble  *itemLatitudeAuto;
  itemLatitudeAuto = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "LatitudeAuto" ), mLatitudeAuto, 0. );
  addItem( itemLatitudeAuto, QStringLiteral( "LatitudeAuto" ) );
  KConfigSkeleton::ItemDouble  *itemLongitudeAuto;
  itemLongitudeAuto = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "LongitudeAuto" ), mLongitudeAuto, 0. );
  addItem( itemLongitudeAuto, QStringLiteral( "LongitudeAuto" ) );
  KConfigSkeleton::ItemDouble  *itemLatitudeFixed;
  itemLatitudeFixed = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "LatitudeFixed" ), mLatitudeFixed, 0. );
  addItem( itemLatitudeFixed, QStringLiteral( "LatitudeFixed" ) );
  KConfigSkeleton::ItemDouble  *itemLongitudeFixed;
  itemLongitudeFixed = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "LongitudeFixed" ), mLongitudeFixed, 0. );
  addItem( itemLongitudeFixed, QStringLiteral( "LongitudeFixed" ) );
  KConfigSkeleton::ItemString  *itemMorningBeginFixed;
  itemMorningBeginFixed = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "MorningBeginFixed" ), mMorningBeginFixed, QStringLiteral( "0600" ) );
  addItem( itemMorningBeginFixed, QStringLiteral( "MorningBeginFixed" ) );
  KConfigSkeleton::ItemString  *itemEveningBeginFixed;
  itemEveningBeginFixed = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "EveningBeginFixed" ), mEveningBeginFixed, QStringLiteral( "1800" ) );
  addItem( itemEveningBeginFixed, QStringLiteral( "EveningBeginFixed" ) );
  KConfigSkeleton::ItemInt  *itemTransitionTime;
  itemTransitionTime = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "TransitionTime" ), mTransitionTime, 30 );
  addItem( itemTransitionTime, QStringLiteral( "TransitionTime" ) );
}

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

