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

#include "plasmakeyboardsettings.h"

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

class PlasmaKeyboardSettingsHelper
{
  public:
    PlasmaKeyboardSettingsHelper() noexcept : q(nullptr) {}
    ~PlasmaKeyboardSettingsHelper() noexcept { delete q; q = nullptr; }
    PlasmaKeyboardSettingsHelper(const PlasmaKeyboardSettingsHelper&) = delete;
    PlasmaKeyboardSettingsHelper& operator=(const PlasmaKeyboardSettingsHelper&) = delete;
    PlasmaKeyboardSettings *q;
};
Q_GLOBAL_STATIC(PlasmaKeyboardSettingsHelper, s_globalPlasmaKeyboardSettings)
PlasmaKeyboardSettings *PlasmaKeyboardSettings::self()
{
  if (!s_globalPlasmaKeyboardSettings()->q) {
    new PlasmaKeyboardSettings;
    s_globalPlasmaKeyboardSettings()->q->read();
  }

  return s_globalPlasmaKeyboardSettings()->q;
}

PlasmaKeyboardSettings *PlasmaKeyboardSettings::create(QQmlEngine *, QJSEngine *)
{
  QQmlEngine::setObjectOwnership(self(), QQmlEngine::CppOwnership);
  return self();
}

PlasmaKeyboardSettings::PlasmaKeyboardSettings( )
  : KConfigSkeleton( QStringLiteral( "plasmakeyboardrc" ) )
{
  Q_ASSERT(!s_globalPlasmaKeyboardSettings()->q);
  s_globalPlasmaKeyboardSettings()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&PlasmaKeyboardSettings::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemSoundEnabled;
  KConfigSkeleton::ItemBool  *innerItemSoundEnabled;
  innerItemSoundEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "soundEnabled" ), mSoundEnabled, false );
  itemSoundEnabled = new KConfigCompilerSignallingItem(innerItemSoundEnabled, this, notifyFunction, signalSoundEnabledChanged);
  itemSoundEnabled->setWriteFlags(KConfigBase::Notify);
  addItem( itemSoundEnabled, QStringLiteral( "soundEnabled" ) );
  KConfigCompilerSignallingItem  *itemVibrationEnabled;
  KConfigSkeleton::ItemBool  *innerItemVibrationEnabled;
  innerItemVibrationEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "vibrationEnabled" ), mVibrationEnabled, true );
  itemVibrationEnabled = new KConfigCompilerSignallingItem(innerItemVibrationEnabled, this, notifyFunction, signalVibrationEnabledChanged);
  itemVibrationEnabled->setWriteFlags(KConfigBase::Notify);
  addItem( itemVibrationEnabled, QStringLiteral( "vibrationEnabled" ) );
  KConfigCompilerSignallingItem  *itemVibrationMs;
  KConfigSkeleton::ItemInt  *innerItemVibrationMs;
  innerItemVibrationMs = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "vibrationMs" ), mVibrationMs, 10 );
  itemVibrationMs = new KConfigCompilerSignallingItem(innerItemVibrationMs, this, notifyFunction, signalVibrationMsChanged);
  itemVibrationMs->setWriteFlags(KConfigBase::Notify);
  addItem( itemVibrationMs, QStringLiteral( "vibrationMs" ) );
  KConfigCompilerSignallingItem  *itemEnabledLocales;
  KConfigSkeleton::ItemStringList  *innerItemEnabledLocales;
  innerItemEnabledLocales = new KConfigSkeleton::ItemStringList( currentGroup(), QStringLiteral( "enabledLocales" ), mEnabledLocales );
  itemEnabledLocales = new KConfigCompilerSignallingItem(innerItemEnabledLocales, this, notifyFunction, signalEnabledLocalesChanged);
  itemEnabledLocales->setWriteFlags(KConfigBase::Notify);
  addItem( itemEnabledLocales, QStringLiteral( "enabledLocales" ) );
  KConfigCompilerSignallingItem  *itemKeyboardNavigationEnabled;
  KConfigSkeleton::ItemBool  *innerItemKeyboardNavigationEnabled;
  innerItemKeyboardNavigationEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "keyboardNavigationEnabled" ), mKeyboardNavigationEnabled, false );
  itemKeyboardNavigationEnabled = new KConfigCompilerSignallingItem(innerItemKeyboardNavigationEnabled, this, notifyFunction, signalKeyboardNavigationEnabledChanged);
  itemKeyboardNavigationEnabled->setWriteFlags(KConfigBase::Notify);
  addItem( itemKeyboardNavigationEnabled, QStringLiteral( "keyboardNavigationEnabled" ) );
  KConfigCompilerSignallingItem  *itemAutoCapitalizationEnabled;
  KConfigSkeleton::ItemBool  *innerItemAutoCapitalizationEnabled;
  innerItemAutoCapitalizationEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "autoCapitalizationEnabled" ), mAutoCapitalizationEnabled, true );
  itemAutoCapitalizationEnabled = new KConfigCompilerSignallingItem(innerItemAutoCapitalizationEnabled, this, notifyFunction, signalAutoCapitalizationEnabledChanged);
  itemAutoCapitalizationEnabled->setWriteFlags(KConfigBase::Notify);
  addItem( itemAutoCapitalizationEnabled, QStringLiteral( "autoCapitalizationEnabled" ) );
  KConfigCompilerSignallingItem  *itemPanelFillScreenWidth;
  KConfigSkeleton::ItemBool  *innerItemPanelFillScreenWidth;
  innerItemPanelFillScreenWidth = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "panelFillScreenWidth" ), mPanelFillScreenWidth, true );
  itemPanelFillScreenWidth = new KConfigCompilerSignallingItem(innerItemPanelFillScreenWidth, this, notifyFunction, signalPanelFillScreenWidthChanged);
  itemPanelFillScreenWidth->setWriteFlags(KConfigBase::Notify);
  addItem( itemPanelFillScreenWidth, QStringLiteral( "panelFillScreenWidth" ) );
  KConfigCompilerSignallingItem  *itemDiacriticsPopupEnabled;
  KConfigSkeleton::ItemBool  *innerItemDiacriticsPopupEnabled;
  innerItemDiacriticsPopupEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "diacriticsPopupEnabled" ), mDiacriticsPopupEnabled, true );
  itemDiacriticsPopupEnabled = new KConfigCompilerSignallingItem(innerItemDiacriticsPopupEnabled, this, notifyFunction, signalDiacriticsPopupEnabledChanged);
  itemDiacriticsPopupEnabled->setWriteFlags(KConfigBase::Notify);
  addItem( itemDiacriticsPopupEnabled, QStringLiteral( "diacriticsPopupEnabled" ) );
  KConfigCompilerSignallingItem  *itemDiacriticsHoldThresholdMs;
  KConfigSkeleton::ItemInt  *innerItemDiacriticsHoldThresholdMs;
  innerItemDiacriticsHoldThresholdMs = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "diacriticsHoldThresholdMs" ), mDiacriticsHoldThresholdMs, 200 );
  itemDiacriticsHoldThresholdMs = new KConfigCompilerSignallingItem(innerItemDiacriticsHoldThresholdMs, this, notifyFunction, signalDiacriticsHoldThresholdMsChanged);
  innerItemDiacriticsHoldThresholdMs->setMinValue(100);
  innerItemDiacriticsHoldThresholdMs->setMaxValue(1500);
  itemDiacriticsHoldThresholdMs->setWriteFlags(KConfigBase::Notify);
  addItem( itemDiacriticsHoldThresholdMs, QStringLiteral( "diacriticsHoldThresholdMs" ) );
}

bool PlasmaKeyboardSettings::defaultSoundEnabledValue_helper()
{

  return false;
}

bool PlasmaKeyboardSettings::defaultVibrationEnabledValue_helper()
{

  return true;
}

int PlasmaKeyboardSettings::defaultVibrationMsValue_helper()
{

  return 10;
}

bool PlasmaKeyboardSettings::defaultKeyboardNavigationEnabledValue_helper()
{

  return false;
}

bool PlasmaKeyboardSettings::defaultAutoCapitalizationEnabledValue_helper()
{

  return true;
}

bool PlasmaKeyboardSettings::defaultPanelFillScreenWidthValue_helper()
{

  return true;
}

bool PlasmaKeyboardSettings::defaultDiacriticsPopupEnabledValue_helper()
{

  return true;
}

int PlasmaKeyboardSettings::defaultDiacriticsHoldThresholdMsValue_helper()
{

  return 200;
}

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


void PlasmaKeyboardSettings::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalSoundEnabledChanged:
    Q_EMIT soundEnabledChanged();
    break;
  case signalVibrationEnabledChanged:
    Q_EMIT vibrationEnabledChanged();
    break;
  case signalVibrationMsChanged:
    Q_EMIT vibrationMsChanged();
    break;
  case signalEnabledLocalesChanged:
    Q_EMIT enabledLocalesChanged();
    break;
  case signalKeyboardNavigationEnabledChanged:
    Q_EMIT keyboardNavigationEnabledChanged();
    break;
  case signalAutoCapitalizationEnabledChanged:
    Q_EMIT autoCapitalizationEnabledChanged();
    break;
  case signalPanelFillScreenWidthChanged:
    Q_EMIT panelFillScreenWidthChanged();
    break;
  case signalDiacriticsPopupEnabledChanged:
    Q_EMIT diacriticsPopupEnabledChanged();
    break;
  case signalDiacriticsHoldThresholdMsChanged:
    Q_EMIT diacriticsHoldThresholdMsChanged();
    break;
  }
}
