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

#include "globalsettings.h"

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

using namespace Clazy;

namespace Clazy {

class GlobalSettingsHelper
{
  public:
    GlobalSettingsHelper() noexcept : q(nullptr) {}
    ~GlobalSettingsHelper() noexcept { delete q; q = nullptr; }
    GlobalSettingsHelper(const GlobalSettingsHelper&) = delete;
    GlobalSettingsHelper& operator=(const GlobalSettingsHelper&) = delete;
    GlobalSettings *q;
};

}
Q_GLOBAL_STATIC(GlobalSettingsHelper, s_globalGlobalSettings)
GlobalSettings *GlobalSettings::self()
{
  if (!s_globalGlobalSettings()->q) {
    new GlobalSettings;
    s_globalGlobalSettings()->q->read();
  }

  return s_globalGlobalSettings()->q;
}

GlobalSettings::GlobalSettings( )
  : KConfigSkeleton()
{
  Q_ASSERT(!s_globalGlobalSettings()->q);
  s_globalGlobalSettings()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&GlobalSettings::itemChanged);

  setCurrentGroup( QStringLiteral( "Clazy" ) );

  KConfigSkeleton::ItemUrl  *itemExecutablePath;
  itemExecutablePath = new KConfigSkeleton::ItemUrl( currentGroup(), QStringLiteral( "executablePath" ), mExecutablePath, JobGlobalParameters::defaultExecutablePath() );
  addItem( itemExecutablePath, QStringLiteral( "executablePath" ) );
  KConfigCompilerSignallingItem  *itemDocsPath;
  KConfigSkeleton::ItemUrl  *innerItemDocsPath;
  innerItemDocsPath = new KConfigSkeleton::ItemUrl( currentGroup(), QStringLiteral( "docsPath" ), mDocsPath, JobGlobalParameters::defaultDocsPath() );
  itemDocsPath = new KConfigCompilerSignallingItem(innerItemDocsPath, this, notifyFunction, signalDocsPathChanged);
  addItem( itemDocsPath, QStringLiteral( "docsPath" ) );
  KConfigSkeleton::ItemBool  *itemParallelJobsEnabled;
  itemParallelJobsEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "parallelJobsEnabled" ), mParallelJobsEnabled, true );
  addItem( itemParallelJobsEnabled, QStringLiteral( "parallelJobsEnabled" ) );
  KConfigSkeleton::ItemBool  *itemParallelJobsAutoCount;
  itemParallelJobsAutoCount = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "parallelJobsAutoCount" ), mParallelJobsAutoCount, true );
  addItem( itemParallelJobsAutoCount, QStringLiteral( "parallelJobsAutoCount" ) );
  KConfigSkeleton::ItemInt  *itemParallelJobsFixedCount;
  itemParallelJobsFixedCount = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "parallelJobsFixedCount" ), mParallelJobsFixedCount, 2 );
  addItem( itemParallelJobsFixedCount, QStringLiteral( "parallelJobsFixedCount" ) );
  KConfigSkeleton::ItemBool  *itemHideOutputView;
  itemHideOutputView = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "hideOutputView" ), mHideOutputView, true );
  addItem( itemHideOutputView, QStringLiteral( "hideOutputView" ) );
  KConfigSkeleton::ItemBool  *itemVerboseOutput;
  itemVerboseOutput = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "verboseOutput" ), mVerboseOutput, false );
  addItem( itemVerboseOutput, QStringLiteral( "verboseOutput" ) );
}

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

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

  if (mSettingsChanged.contains(signalDocsPathChanged))
    Q_EMIT docsPathChanged();
  mSettingsChanged.clear();
  return true;
}

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

}
