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

#include "filereceiversettings.h"

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

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

  return s_globalFileReceiverSettings()->q;
}

FileReceiverSettings::FileReceiverSettings( )
  : KConfigSkeleton( QStringLiteral( "bluedevilreceiverrc" ) )
{
  Q_ASSERT(!s_globalFileReceiverSettings()->q);
  s_globalFileReceiverSettings()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&FileReceiverSettings::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  KConfigCompilerSignallingItem  *itemSaveUrl;
  KConfigSkeleton::ItemUrl  *innerItemSaveUrl;
  innerItemSaveUrl = new KConfigSkeleton::ItemUrl( currentGroup(), QStringLiteral( "saveUrl" ), mSaveUrl, QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)) );
  itemSaveUrl = new KConfigCompilerSignallingItem(innerItemSaveUrl, this, notifyFunction, signalSaveUrlChanged);
  addItem( itemSaveUrl, QStringLiteral( "saveUrl" ) );
  KConfigCompilerSignallingItem  *itemAutoAccept;
  KConfigSkeleton::ItemInt  *innerItemAutoAccept;
  innerItemAutoAccept = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "autoAccept" ), mAutoAccept, 0 );
  itemAutoAccept = new KConfigCompilerSignallingItem(innerItemAutoAccept, this, notifyFunction, signalAutoAcceptChanged);
  addItem( itemAutoAccept, QStringLiteral( "autoAccept" ) );
}

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


void FileReceiverSettings::itemChanged(quint64 signalFlag) {

  switch (signalFlag) {
  case signalSaveUrlChanged:
    Q_EMIT saveUrlChanged();
    break;
  case signalAutoAcceptChanged:
    Q_EMIT autoAcceptChanged();
    break;
  }
}
