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

#include "PowerDevilGlobalSettings.h"

using namespace PowerDevil;

GlobalSettings::GlobalSettings( bool CanSuspend, bool CanHibernate, QObject *parent )
  : KConfigSkeleton( QStringLiteral( "powerdevilrc" ) )
  , mParamCanSuspend(CanSuspend)
  , mParamCanHibernate(CanHibernate)
{
  setParent(parent);
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&GlobalSettings::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemPausePlayersOnSuspend;
  KConfigSkeleton::ItemBool  *innerItemPausePlayersOnSuspend;
  innerItemPausePlayersOnSuspend = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "pausePlayersOnSuspend" ), mPausePlayersOnSuspend, true );
  itemPausePlayersOnSuspend = new KConfigCompilerSignallingItem(innerItemPausePlayersOnSuspend, this, notifyFunction, signalPausePlayersOnSuspendChanged);
  addItem( itemPausePlayersOnSuspend, QStringLiteral( "pausePlayersOnSuspend" ) );

  setCurrentGroup( QStringLiteral( "BatteryManagement" ) );

  KConfigCompilerSignallingItem  *itemBatteryLowLevel;
  KConfigSkeleton::ItemInt  *innerItemBatteryLowLevel;
  innerItemBatteryLowLevel = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "BatteryLowLevel" ), mBatteryLowLevel, 10 );
  itemBatteryLowLevel = new KConfigCompilerSignallingItem(innerItemBatteryLowLevel, this, notifyFunction, signalBatteryLowLevelChanged);
  addItem( itemBatteryLowLevel, QStringLiteral( "BatteryLowLevel" ) );
  KConfigCompilerSignallingItem  *itemBatteryCriticalLevel;
  KConfigSkeleton::ItemInt  *innerItemBatteryCriticalLevel;
  innerItemBatteryCriticalLevel = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "BatteryCriticalLevel" ), mBatteryCriticalLevel, 5 );
  itemBatteryCriticalLevel = new KConfigCompilerSignallingItem(innerItemBatteryCriticalLevel, this, notifyFunction, signalBatteryCriticalLevelChanged);
  addItem( itemBatteryCriticalLevel, QStringLiteral( "BatteryCriticalLevel" ) );
  KConfigCompilerSignallingItem  *itemBatteryCriticalAction;
  KConfigSkeleton::ItemUInt  *innerItemBatteryCriticalAction;
  innerItemBatteryCriticalAction = new KConfigSkeleton::ItemUInt( currentGroup(), QStringLiteral( "BatteryCriticalAction" ), mBatteryCriticalAction, 
        PowerDevil::GlobalDefaults::defaultBatteryCriticalAction(mParamCanSuspend, mParamCanHibernate)
       );
  itemBatteryCriticalAction = new KConfigCompilerSignallingItem(innerItemBatteryCriticalAction, this, notifyFunction, signalBatteryCriticalActionChanged);
  addItem( itemBatteryCriticalAction, QStringLiteral( "BatteryCriticalAction" ) );
  KConfigCompilerSignallingItem  *itemPeripheralBatteryLowLevel;
  KConfigSkeleton::ItemInt  *innerItemPeripheralBatteryLowLevel;
  innerItemPeripheralBatteryLowLevel = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "PeripheralBatteryLowLevel" ), mPeripheralBatteryLowLevel, 10 );
  itemPeripheralBatteryLowLevel = new KConfigCompilerSignallingItem(innerItemPeripheralBatteryLowLevel, this, notifyFunction, signalPeripheralBatteryLowLevelChanged);
  addItem( itemPeripheralBatteryLowLevel, QStringLiteral( "PeripheralBatteryLowLevel" ) );

  setCurrentGroup( QStringLiteral( "Inhibitions" ) );

  KConfigCompilerSignallingItem  *itemBlockedInhibitions;
  KConfigSkeleton::ItemStringList  *innerItemBlockedInhibitions;
  innerItemBlockedInhibitions = new KConfigSkeleton::ItemStringList( currentGroup(), QStringLiteral( "BlockedInhibitions" ), mBlockedInhibitions );
  itemBlockedInhibitions = new KConfigCompilerSignallingItem(innerItemBlockedInhibitions, this, notifyFunction, signalBlockedInhibitionsChanged);
  addItem( itemBlockedInhibitions, QStringLiteral( "BlockedInhibitions" ) );
}

bool GlobalSettings::defaultPausePlayersOnSuspendValue_helper() const
{

  return true;
}

int GlobalSettings::defaultBatteryLowLevelValue_helper() const
{

  return 10;
}

int GlobalSettings::defaultBatteryCriticalLevelValue_helper() const
{

  return 5;
}

uint GlobalSettings::defaultBatteryCriticalActionValue_helper() const
{

  return 
        PowerDevil::GlobalDefaults::defaultBatteryCriticalAction(mParamCanSuspend, mParamCanHibernate)
      ;
}

int GlobalSettings::defaultPeripheralBatteryLowLevelValue_helper() const
{

  return 10;
}

GlobalSettings::~GlobalSettings()
{
}


void GlobalSettings::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalPausePlayersOnSuspendChanged:
    Q_EMIT pausePlayersOnSuspendChanged();
    break;
  case signalBatteryLowLevelChanged:
    Q_EMIT BatteryLowLevelChanged();
    break;
  case signalBatteryCriticalLevelChanged:
    Q_EMIT BatteryCriticalLevelChanged();
    break;
  case signalBatteryCriticalActionChanged:
    Q_EMIT BatteryCriticalActionChanged();
    break;
  case signalPeripheralBatteryLowLevelChanged:
    Q_EMIT PeripheralBatteryLowLevelChanged();
    break;
  case signalBlockedInhibitionsChanged:
    Q_EMIT BlockedInhibitionsChanged();
    break;
  }
}
