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

#include "globalsettings_webengineurlinterceptoradblock.h"

#include <klocalizedstring.h>

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

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

  return s_globalAdBlockSettings()->q;
}

AdBlockSettings::AdBlockSettings( )
  : KConfigSkeleton( QStringLiteral( "webengineurlinterceptoradblockrc" ) )
{
  Q_ASSERT(!s_globalAdBlockSettings()->q);
  s_globalAdBlockSettings()->q = this;
  setCurrentGroup( QStringLiteral( "General" ) );

  mAdBlockEnabledItem = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "AdBlockEnabled" ), mAdBlockEnabled, false );
  mAdBlockEnabledItem->setLabel( i18n("Enabled ad block") );
  addItem( mAdBlockEnabledItem, QStringLiteral( "AdBlockEnabled" ) );

  setCurrentGroup( QStringLiteral( "Adblock" ) );

  mAdblockFilterUrlsItem = new KConfigSkeleton::ItemUrlList( currentGroup(), QStringLiteral( "adblockFilterUrls" ), mAdblockFilterUrls, 
        AdblockListsUtil::adblockFilterUrlsDefaultList()
       );
  mAdblockFilterUrlsItem->setLabel( i18n("adblockFilterUrls") );
  addItem( mAdblockFilterUrlsItem, QStringLiteral( "adblockFilterUrls" ) );
  mAdblockFilterNamesItem = new KConfigSkeleton::ItemStringList( currentGroup(), QStringLiteral( "adblockFilterNames" ), mAdblockFilterNames, 
        AdblockListsUtil::adblockFilterNamesDefaultList()
      );
  mAdblockFilterNamesItem->setLabel( i18n("adblockFilterNames") );
  addItem( mAdblockFilterNamesItem, QStringLiteral( "adblockFilterNames" ) );
  mAdblockFilterDownloadDismissedItem = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "adblockFilterDownloadDismissed" ), mAdblockFilterDownloadDismissed, false );
  mAdblockFilterDownloadDismissedItem->setLabel( i18n("adblockFilterDownloadDismissed") );
  addItem( mAdblockFilterDownloadDismissedItem, QStringLiteral( "adblockFilterDownloadDismissed" ) );
}

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

