#include <QApplication>
#include <iostream>
#include <QLocale>
#include <QTranslator>
#include <QTextCodec>
#include <QDebug>
#include <time.h>

#include "../widget/logger.h"
#include "../geometry/label_store.h"
#include "main_window.h"


class MyApplication : public QApplication
{
public:
	MyApplication(int& argc, char ** argv) : QApplication(argc, argv) { }
	virtual ~MyApplication() { }

	// reimplemented from QApplication so we can throw exceptions in slots
	virtual bool notify(QObject * receiver, QEvent * event) {
		try {
			return QApplication::notify(receiver, event);
		} catch(std::exception& e) {
			qCritical() << "Exception thrown:" << e.what();
		}
		return false;
	}
};



int main(int argc, char **argv)
{
	srand(time(0));
	MyApplication app(argc, argv);


	// commented to get "1000", else "1,000", 
	// if commented, it seems not recognize paths containing Chinese characters
	//std::locale::global(std::locale("")); 
	//QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
	//QTextCodec::setCodecForLocale(QTextCodec::codecForLocale());
	//QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());

	MainWindow win;		
	Logger::output("[PcdViewer]: Welcome using PcdViewer, have fun :)") << Logger::endl(); 
	
	//////////////////////////////////////////////////////////////////////////

	LabelStore::initialize();

	//////////////////////////////////////////////////////////////////////////

	win.show();

	return app.exec();
};
