#include "settings.h"

QSettings appSettings(QSettings::IniFormat, QSettings::UserScope, SETTINGS_NAME, SETTINGS_NAME);


QSettings &AppSettings::settings()
{
	return appSettings;
}


bool AppSettings::openLastNetwork()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(OPEN_LAST_NETWORK, true).toBool();
}

void AppSettings::setOpenLastNetwork(bool val)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(OPEN_LAST_NETWORK, val);
	settings.sync();
}

double AppSettings::defaultCPUPower()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(DEFAULT_CPU_POWER, 10000000).toDouble();
}

void AppSettings::setDefaultCPUPower(double val)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(DEFAULT_CPU_POWER, val);
	settings.sync();
}

double AppSettings::defaultBandwidth()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(DEFAULT_BANDWIDTH, 10000000).toDouble();
}

void AppSettings::setDefaultBandwidth(double val)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(DEFAULT_BANDWIDTH, val);
	settings.sync();
}

double AppSettings::defaultLatency()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(DEFAULT_LATENCY, 0.0005).toDouble();
}

void AppSettings::setDefaultLatency(double val)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(DEFAULT_LATENCY, val);
	settings.sync();
}

QString AppSettings::lastDocument()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(LAST_DOCUMENT).toString();
}

void AppSettings::setLastDocument(const QString &docName)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(LAST_DOCUMENT, docName);
	settings.sync();
}

bool AppSettings::openOutputWindow()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(OPEN_OUTPUT_WINDOW, true).toBool();
}

void AppSettings::setOpenOutputWindow(bool open)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(OPEN_OUTPUT_WINDOW, open);
	settings.sync();
}

bool AppSettings::showSimulationProgressOutputWindow()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(SHOW_SIMULATION_PROGRESS_OUTPUT_WINDOW, true).toBool();
}

void AppSettings::setShowSimulationProgressOutputWindow(bool show)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(SHOW_SIMULATION_PROGRESS_OUTPUT_WINDOW, show);
	settings.sync();
}

bool AppSettings::showSimulationProgressNetwork()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(SHOW_SIMULATION_PROGRESS_NETWORK, true).toBool();
}

void AppSettings::setShowSimulationProgressNetwork(bool show)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(SHOW_SIMULATION_PROGRESS_NETWORK, show);
	settings.sync();
}

bool AppSettings::changeNodeColor()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(SIMULATION_CHANGE_NODES_COLOR, true).toBool();
}

void AppSettings::setChangeNodeColor(bool change)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(SIMULATION_CHANGE_NODES_COLOR, change);
	settings.sync();
}

bool AppSettings::showCustomSimulationProgress()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(SIMULATION_CUSTOM_PROGRESS, false).toBool();
}

void AppSettings::setShowCustomSimulationProgress(bool change)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(SIMULATION_CUSTOM_PROGRESS, change);
	settings.sync();
}

bool AppSettings::showSimulationOutput()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(SHOW_SIMULATION_OUTPUT, true).toBool();
}

void AppSettings::setShowSimulationOutput(bool show)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(SHOW_SIMULATION_OUTPUT, show);
	settings.sync();
}

bool AppSettings::showSimulationErrors()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(SHOW_SIMULATION_ERRORS, true).toBool();
}

void AppSettings::setShowSimulationErrors(bool show)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(SHOW_SIMULATION_ERRORS, show);
	settings.sync();
}

bool AppSettings::debugMode()
{
	QSettings &settings = AppSettings::settings();
	return settings.value(SIMULATION_DEBUG_MODE, false).toBool();
}

void AppSettings::setDebugMode(bool mode)
{
	QSettings &settings = AppSettings::settings();

	settings.setValue(SIMULATION_DEBUG_MODE, mode);
	settings.sync();
}
