/***************************************************************************
                           cubetest.cpp
                           -------------------
    copyright            : (C) 2004 by Jos van den Oever
    email                : jos@vandenoever.info
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#include "testdialog.h"
#include "question.h"
//Added by qt3to4:
#include <QTranslator>
#include <QLocale>
#include <QIcon>
#include "block.xpm"
#include <qapplication.h>
#include <qtextcodec.h>
#include <qpixmap.h>
#include <cstdlib>
#include <ctime>
#include <iostream>
using std::cout;
using std::endl;

#ifdef Q_WS_X11
#include <fenv.h>
#endif
#ifdef Q_WS_WIN
#include <float.h>
#endif

int main( int argc, char **argv ) {
	QApplication a( argc, argv );

#ifdef Q_WS_X11
	// enable floating point exceptions: they help with debugging
//	feenableexcept(FE_DIVBYZERO|FE_INVALID);
#endif
#ifdef Q_WS_WIN
	// disable floating point exceptions on windows
	_control87(MCW_EM, MCW_EM);
#endif

	if (argc > 1 && argc != 13) {
		srand(atoi(argv[1]));
	} else {
		srand(time(NULL));
	}

	QString appDir = qApp->applicationDirPath();
	QString i18nDir = appDir+"/../share/cubetest/translations";
	QTranslator translator( 0 );
	QString locale = QLocale::system().name();
	QString langfile = i18nDir + QString("/cubetest_") + locale;
	translator.load(langfile, "." );
	a.installTranslator( &translator );

	TestDialog td;
        td.setWindowIcon(QIcon(QPixmap(block_xpm)));
	a.setMainWidget( &td );
	td.resize(600,400);
	td.show();

	if (argc == 13) {
		Question q;
		for (short i=0; i<6; ++i) {
			q.shownTypes[i] = atoi(argv[1+2*i]);
			q.shownSyms[i] = Symmetry(atoi(argv[2+2*i]));
		}
		for (short i=0; i<6; ++i) {
			cout << q.shownTypes[i] << ' ';
			cout << q.shownSyms[i] << ' ';
		}
		cout << endl;
		td.setQuestion(q);
	}

	return a.exec();
}
