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

#include "settings.h"

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

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

  return s_globalScilabSettings()->q;
}

ScilabSettings::ScilabSettings( )
  : KConfigSkeleton( QStringLiteral( "cantorrc" ) )
{
  Q_ASSERT(!s_globalScilabSettings()->q);
  s_globalScilabSettings()->q = this;
  setCurrentGroup( QStringLiteral( "ScilabBackend" ) );

  KConfigSkeleton::ItemUrl  *itemPath;
  itemPath = new KConfigSkeleton::ItemUrl( currentGroup(), QStringLiteral( "Path" ), mPath, 
          [this] {
                #ifdef Q_OS_WIN
                return QUrl::fromLocalFile(QStandardPaths::findExecutable( QLatin1String("WScilex-cli.exe") ));
                #else
                return QUrl::fromLocalFile(QStandardPaths::findExecutable( QLatin1String("scilab-adv-cli") ));
                #endif
            } ()
         );
  addItem( itemPath, QStringLiteral( "Path" ) );
  KConfigSkeleton::ItemBool  *itemIntegratePlots;
  itemIntegratePlots = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "integratePlots" ), mIntegratePlots, true );
  addItem( itemIntegratePlots, QStringLiteral( "integratePlots" ) );
  KConfigSkeleton::ItemStringList  *itemAutorunScripts;
  itemAutorunScripts = new KConfigSkeleton::ItemStringList( currentGroup(), QStringLiteral( "autorunScripts" ), mAutorunScripts );
  addItem( itemAutorunScripts, QStringLiteral( "autorunScripts" ) );
}

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

