Ejemplo n.º 1
0
void Settings::loadSettings(const QString & fileName, QByteArray * windowGeometry)
{

    QString path = fileName;
    if(fileName.isEmpty())
    {
        path = iniDefaultPath();
    }
    cerr << " Settings path is " << fileName.toStdString() << endl;
    QSettings ini(path, QSettings::IniFormat);
    for(ParametersMap::const_iterator iter = defaultParameters_.begin(); iter!=defaultParameters_.end(); ++iter)
    {
        const QString & key = iter.key();
        QVariant value = ini.value(key, QVariant());
        if(value.isValid())
        {
            setParameter(key, value);
        }
    }

    if(windowGeometry)
    {
        QVariant value = ini.value("windowGeometry", QVariant());
        if(value.isValid())
        {
            *windowGeometry = value.toByteArray();
        }
    }

    printf("Settings loaded from %s\n", path.toStdString().c_str());
}
void Settings::loadSettings(const QString & fileName, QByteArray * windowGeometry, QByteArray * windowState)
{
	QString path = fileName;
	if(fileName.isEmpty())
	{
		path = iniDefaultPath();
	}
	QSettings ini(path, QSettings::IniFormat);
	for(ParametersMap::const_iterator iter = defaultParameters_.begin(); iter!=defaultParameters_.end(); ++iter)
	{
		const QString & key = iter.key();
		QVariant value = ini.value(key, QVariant());
		if(value.isValid())
		{
			QString str = value.toString();
			if(str.contains(";") && str.size() != getParameter(key).toString().size())
			{
				// If a string list is modified, update the value
				// (assuming that index < 10... one character for index)
				QChar index = str.at(0);
				str = getParameter(key).toString();
				str[0] = index.toAscii();
				value = QVariant(str);
				printf("Updated list of parameter \"%s\"\n", key.toStdString().c_str());
			}
			setParameter(key, value);
		}
	}

	if(windowGeometry)
	{
		QVariant value = ini.value("windowGeometry", QVariant());
		if(value.isValid())
		{
			*windowGeometry = value.toByteArray();
		}
	}
	if(windowState)
	{
		QVariant value = ini.value("windowState", QVariant());
		if(value.isValid())
		{
			*windowState = value.toByteArray();
		}
	}

	printf("Settings loaded from %s\n", path.toStdString().c_str());
}
Ejemplo n.º 3
0
void Settings::loadSettings(const QString & fileName)
{
	QString path = fileName;
	if(fileName.isEmpty())
	{
		path = iniPath();
	}
	if(!path.isEmpty())
	{
		QSettings ini(path, QSettings::IniFormat);
		for(ParametersMap::const_iterator iter = defaultParameters_.begin(); iter!=defaultParameters_.end(); ++iter)
		{
			const QString & key = iter.key();
			QVariant value = ini.value(key, QVariant());
			if(value.isValid())
			{
				QString str = value.toString();
				if(str.contains(";") && str.size() != getParameter(key).toString().size())
				{
					// If a string list is modified, update the value
					// (assuming that index < 10... one character for index)
					QChar index = str.at(0);
					str = getParameter(key).toString();
					str[0] = index.toAscii();
					value = QVariant(str);
					UINFO("Updated list of parameter \"%s\"", key.toStdString().c_str());
				}
				setParameter(key, value);
			}
		}
		UINFO("Settings loaded from %s.", path.toStdString().c_str());
	}
	else
	{
		parameters_ = defaultParameters_;
		UINFO("Settings set to defaults.");
	}

	if(cv::gpu::getCudaEnabledDeviceCount() == 0)
	{
		Settings::setFeature2D_SURF_gpu(false);
		Settings::setFeature2D_Fast_gpu(false);
		Settings::setFeature2D_ORB_gpu(false);
	}
}
void Settings::saveSettings(const QString & fileName, const QByteArray & windowGeometry, const QByteArray & windowState)
{
	QString path = fileName;
	if(fileName.isEmpty())
	{
		path = iniDefaultPath();
	}
	QSettings ini(path, QSettings::IniFormat);
	for(ParametersMap::const_iterator iter = parameters_.begin(); iter!=parameters_.end(); ++iter)
	{
		QString type = Settings::getParametersType().value(iter.key());
		if(type.compare("float") == 0)
		{
			ini.setValue(iter.key(), QString::number(iter.value().toFloat(),'g',6));
		}
		else
		{
			ini.setValue(iter.key(), iter.value());
		}
	}
	if(!windowGeometry.isEmpty())
	{
		ini.setValue("windowGeometry", windowGeometry);
	}
	if(!windowState.isEmpty())
	{
		ini.setValue("windowState", windowState);
	}
	printf("Settings saved to %s\n", path.toStdString().c_str());
}
Ejemplo n.º 5
0
void Settings::saveSettings(const QString & fileName)
{
	QString path = fileName;
	if(fileName.isEmpty())
	{
		path = iniPath();
	}
	if(!path.isEmpty())
	{
		QSettings ini(path, QSettings::IniFormat);
		for(ParametersMap::const_iterator iter = parameters_.begin(); iter!=parameters_.end(); ++iter)
		{
			QString type = Settings::getParametersType().value(iter.key());
			if(type.compare("float") == 0)
			{
				ini.setValue(iter.key(), QString::number(iter.value().toFloat(),'g',6));
			}
			else
			{
				ini.setValue(iter.key(), iter.value());
			}
		}
		UINFO("Settings saved to %s", path.toStdString().c_str());
	}
}