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

#include "pdfsettings.h"

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

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

  return s_globalPDFSettings()->q;
}

PDFSettings::PDFSettings( )
  : KConfigSkeleton( QStringLiteral( "okular-generator-popplerrc" ) )
{
  Q_ASSERT(!s_globalPDFSettings()->q);
  s_globalPDFSettings()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&PDFSettings::itemChanged);

  setCurrentGroup( QStringLiteral( "General" ) );

  QList<KConfigSkeleton::ItemEnum::Choice> valuesEnhanceThinLines;
  {
    KConfigSkeleton::ItemEnum::Choice choice;
    choice.name = QStringLiteral("No");
    valuesEnhanceThinLines.append( choice );
  }
  {
    KConfigSkeleton::ItemEnum::Choice choice;
    choice.name = QStringLiteral("Solid");
    valuesEnhanceThinLines.append( choice );
  }
  {
    KConfigSkeleton::ItemEnum::Choice choice;
    choice.name = QStringLiteral("Shape");
    valuesEnhanceThinLines.append( choice );
  }
  KConfigSkeleton::ItemEnum  *itemEnhanceThinLines;
  itemEnhanceThinLines = new KConfigSkeleton::ItemEnum( currentGroup(), QStringLiteral( "EnhanceThinLines" ), mEnhanceThinLines, valuesEnhanceThinLines, EnumEnhanceThinLines::No );
  addItem( itemEnhanceThinLines, QStringLiteral( "EnhanceThinLines" ) );
  QList<KConfigSkeleton::ItemEnum::Choice> valuesOverprintPreviewEnabled;
  {
    KConfigSkeleton::ItemEnum::Choice choice;
    choice.name = QStringLiteral("Never");
    valuesOverprintPreviewEnabled.append( choice );
  }
  {
    KConfigSkeleton::ItemEnum::Choice choice;
    choice.name = QStringLiteral("Always");
    valuesOverprintPreviewEnabled.append( choice );
  }
  {
    KConfigSkeleton::ItemEnum::Choice choice;
    choice.name = QStringLiteral("Automatic");
    valuesOverprintPreviewEnabled.append( choice );
  }
  KConfigSkeleton::ItemEnum  *itemOverprintPreviewEnabled;
  itemOverprintPreviewEnabled = new KConfigSkeleton::ItemEnum( currentGroup(), QStringLiteral( "OverprintPreviewEnabled" ), mOverprintPreviewEnabled, valuesOverprintPreviewEnabled, EnumOverprintPreviewEnabled::Automatic );
  addItem( itemOverprintPreviewEnabled, QStringLiteral( "OverprintPreviewEnabled" ) );

  setCurrentGroup( QStringLiteral( "PDF Printing" ) );

  KConfigSkeleton::ItemUInt  *itemPrintScaleMode;
  itemPrintScaleMode = new KConfigSkeleton::ItemUInt( currentGroup(), QStringLiteral( "PrintScaleMode" ), mPrintScaleMode, 0 );
  itemPrintScaleMode->setMaxValue(2);
  addItem( itemPrintScaleMode, QStringLiteral( "PrintScaleMode" ) );

  setCurrentGroup( QStringLiteral( "Signatures" ) );

  KConfigCompilerSignallingItem  *itemSignatureBackend;
  KConfigSkeleton::ItemString  *innerItemSignatureBackend;
  innerItemSignatureBackend = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "SignatureBackend" ), mSignatureBackend );
  itemSignatureBackend = new KConfigCompilerSignallingItem(innerItemSignatureBackend, this, notifyFunction, signalSignatureBackendChanged);
  addItem( itemSignatureBackend, QStringLiteral( "SignatureBackend" ) );
  KConfigCompilerSignallingItem  *itemEnablePgp;
  KConfigSkeleton::ItemBool  *innerItemEnablePgp;
  innerItemEnablePgp = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "EnablePgp" ), mEnablePgp, false );
  itemEnablePgp = new KConfigCompilerSignallingItem(innerItemEnablePgp, this, notifyFunction, signalEnablePgpChanged);
  addItem( itemEnablePgp, QStringLiteral( "EnablePgp" ) );
  KConfigCompilerSignallingItem  *itemUseDefaultCertDB;
  KConfigSkeleton::ItemBool  *innerItemUseDefaultCertDB;
  innerItemUseDefaultCertDB = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "UseDefaultCertDB" ), mUseDefaultCertDB, true );
  itemUseDefaultCertDB = new KConfigCompilerSignallingItem(innerItemUseDefaultCertDB, this, notifyFunction, signalUseDefaultDBChanged);
  addItem( itemUseDefaultCertDB, QStringLiteral( "UseDefaultCertDB" ) );
  KConfigCompilerSignallingItem  *itemDBCertificatePath;
  KConfigSkeleton::ItemString  *innerItemDBCertificatePath;
  innerItemDBCertificatePath = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "DBCertificatePath" ), mDBCertificatePath );
  itemDBCertificatePath = new KConfigCompilerSignallingItem(innerItemDBCertificatePath, this, notifyFunction, signalDBCertificatePathChanged);
  addItem( itemDBCertificatePath, QStringLiteral( "DBCertificatePath" ) );
  KConfigSkeleton::ItemBool  *itemCheckOCSPServers;
  itemCheckOCSPServers = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "CheckOCSPServers" ), mCheckOCSPServers, true );
  addItem( itemCheckOCSPServers, QStringLiteral( "CheckOCSPServers" ) );
}

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

bool PDFSettings::usrSave()
{
  const bool res = KConfigSkeleton::usrSave();
  if (!res) return false;

  if (mSettingsChanged.contains(signalUseDefaultDBChanged))
    Q_EMIT useDefaultDBChanged();
  if (mSettingsChanged.contains(signalSignatureBackendChanged))
    Q_EMIT signatureBackendChanged();
  if (mSettingsChanged.contains(signalDBCertificatePathChanged))
    Q_EMIT dBCertificatePathChanged();
  if (mSettingsChanged.contains(signalEnablePgpChanged))
    Q_EMIT enablePgpChanged();
  mSettingsChanged.clear();
  return true;
}

void PDFSettings::itemChanged(quint64 signalFlag) {
  mSettingsChanged.insert(signalFlag);

}
