2017-02-21 11:01:06 +00:00
|
|
|
#include "LaunchConfig.hxx"
|
|
|
|
|
|
|
|
#include <Main/options.hxx>
|
|
|
|
#include <simgear/misc/sg_path.hxx>
|
|
|
|
|
2017-07-19 18:24:33 +00:00
|
|
|
static bool static_enableDownloadDirUI = true;
|
|
|
|
|
2017-02-21 11:01:06 +00:00
|
|
|
LaunchConfig::LaunchConfig(QObject* parent) :
|
|
|
|
QObject(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchConfig::reset()
|
|
|
|
{
|
|
|
|
m_values.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchConfig::applyToOptions() const
|
|
|
|
{
|
|
|
|
flightgear::Options* options = flightgear::Options::sharedInstance();
|
|
|
|
std::for_each(m_values.begin(), m_values.end(), [options](const Arg& arg)
|
|
|
|
{
|
|
|
|
options->addOption(arg.arg.toStdString(), arg.value.toStdString());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchConfig::setArg(QString name, QString value)
|
|
|
|
{
|
|
|
|
m_values.push_back(Arg(name, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchConfig::setArg(const std::string &name, const std::string &value)
|
|
|
|
{
|
|
|
|
setArg(QString::fromStdString(name), QString::fromStdString(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchConfig::setProperty(QString path, QVariant value)
|
|
|
|
{
|
|
|
|
m_values.push_back(Arg("prop", path + "=" + value.toString()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchConfig::setEnableDisableOption(QString name, bool value)
|
|
|
|
{
|
|
|
|
m_values.push_back(Arg((value ? "enable-" : "disable-") + name));
|
|
|
|
}
|
|
|
|
|
|
|
|
QString LaunchConfig::defaultDownloadDir() const
|
|
|
|
{
|
|
|
|
return QString::fromStdString(flightgear::defaultDownloadDir().utf8Str());
|
|
|
|
}
|
|
|
|
|
2017-07-19 18:24:33 +00:00
|
|
|
bool LaunchConfig::enableDownloadDirUI() const
|
|
|
|
{
|
|
|
|
return static_enableDownloadDirUI;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchConfig::setEnableDownloadDirUI(bool enableDownloadDirUI)
|
|
|
|
{
|
|
|
|
static_enableDownloadDirUI = enableDownloadDirUI;
|
|
|
|
}
|
|
|
|
|
2017-02-21 11:01:06 +00:00
|
|
|
auto LaunchConfig::values() const -> std::vector<Arg>
|
|
|
|
{
|
|
|
|
return m_values;
|
|
|
|
}
|