#include <QtGui>
#include "helpfrm.h"

helpfrm::helpfrm(QWidget *parent) : QDialog(parent)
{
	setupUi(this);
	QWidget::setWindowFlags(Qt::WindowMinMaxButtonsHint);
	QString wlpack = QLocale::system().name();
	QDir currentDir = QDir::homePath();
	QString wg_tmp_002;
	QByteArray newData;
	QFile configfile( currentDir.path() + "/.smile.cnf" );
	if (configfile.open(QFile::ReadOnly)) 
	{
		newData = configfile.readLine(0);
		wg_tmp_002 = QString::fromLocal8Bit(newData);
		qDebug() << "SMILE CONF VERSION : " << wg_tmp_002.left(8);
		if (wg_tmp_002.left(8) != "SMILE_V3")
		{
			qDebug() << "ERROR OLD CONFIG FILE REMOVE .smile.cnf FROM YOUR HOME DIRECTORY";
		}
		else
		{
			newData = configfile.readLine(0);
			wg_tmp_002 = QString::fromLocal8Bit(newData);
			qDebug() << "LOADING HELP LANGUAGE ... " + wlpack.left(2);
			if ( wlpack.left(2) == "fr" )
			{
				webhelp->load(QUrl(wg_tmp_002 + "/BIB_ManSlide/Help/doc_fr.html"));
			}
			else
			{
				webhelp->load(QUrl(wg_tmp_002 + "/BIB_ManSlide/Help/doc_en.html"));
			}
		}
		configfile.close();
	}
	else
	{
		qDebug() << "ERROR FINDING CONFIG FILE";
	}
}

