<commit_before>//------------------------------------------------------------------------------
// File: main.cpp
//
// Desc: main - main.
//
// Copyright (c) 2014-2018. All rights reserved.
//------------------------------------------------------------------------------


#include "vscmainwindows.h"
#include <QtWidgets/QApplication>
#include <QStyleFactory>
#include "factory.hpp"
#include <QPixmap>
#include <QSplashScreen>
#include <QtWidgets/QMainWindow>
#include <QTranslator>
#include <QTextCodec>
#include "vschdddevice.h"
#include "vevent.hpp"
#include "vservicemgr.hpp"

Factory *gFactory = NULL;

int main(int argc, char *argv[])
{
	int dummy = errno;
	//QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
	QApplication a(argc, argv);
	Debug::init(0);

	//QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); 
	//QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); 
#if 0
	QFont font;
	font.setPointSize(10); 
	font.setFamily(("WenQuanYi Zen Hei"));
	font.setBold(false);

	a.setFont(font);
#endif

    QPixmap pixmap(":/logo/resources/splash.png");
    QSplashScreen *splash = new QSplashScreen(pixmap);
    //QFont splashFont;
    //splashFont.setFamily("Arial");
    //splashFont.setBold(true);

    splash->setStyleSheet(QStringLiteral("color : red;"));
    //splash->setFont(splashFont);
    
    splash->show();

    //QApplication::setStyle(QStyleFactory::create("Fusion"));
	//QApplication::setStyle(QStyleFactory::create("Plastique"));
    //QApplication::setStyle("WindowsVista"); 
#if 0
	QFile f(":qdarkstyle/style.qss");
	if (!f.exists())
	{
		printf("Unable to set stylesheet, file not found\n");
	}
	else 
	{
		f.open(QFile::ReadOnly | QFile::Text);
		QTextStream ts(&f);
		a.setStyleSheet(ts.readAll());
	}
#endif


    gFactory = new Factory;
    splash->showMessage("Starting ...");

   if (gFactory->Init() == FALSE)
   {
#ifdef WIN32
       astring strPath = "C:\\";//TODO get the hdd from hdd
       VSCHddDevice hdd;
       hdd.show();
       hdd.exec();
       s32 size = hdd.GetDiskSize();
       hdd.GetDiskPath(strPath);
#else

	astring strPath = "ve/";//TODO get the hdd from hdd
	s32 size = 2;
#endif
       gFactory->SetSystemPath(strPath);
       splash->showMessage("Create Video Database ...");
       gFactory->Init();
#ifndef WIN32
	//gFactory->AddHDD(strPath, size);
#endif
   }
	VSCLangType m_lang;
	gFactory->GetLang(m_lang);
	if (m_lang == VSC_LANG_ZH)
	{
		QTranslator *translator = new QTranslator(&a);
		bool ok = translator->load("opencvr_zh.qm",
			QCoreApplication::applicationDirPath() + "/translations");
		
		if (ok)
		{
			qDebug("Translation Files loaded.");
			a.installTranslator(translator);
		}
		QTranslator *translatorVe = new QTranslator(&a);
		ok = translatorVe->load("veuilib_zh.qm",
			QCoreApplication::applicationDirPath() + "/translations");
		
		if (ok)
		{
			qDebug("Translation Files loaded.");
			a.installTranslator(translatorVe);
		}
	}//else if add more language to here

   VEvent::Init(*gFactory);
   VServiceMgr *pServiceMgr = VServiceMgr::CreateObject(*gFactory);
<commit_msg>add auto lang<commit_after>//------------------------------------------------------------------------------
// File: main.cpp
//
// Desc: main - main.
//
// Copyright (c) 2014-2018. All rights reserved.
//------------------------------------------------------------------------------


#include "vscmainwindows.h"
#include <QtWidgets/QApplication>
#include <QStyleFactory>
#include "factory.hpp"
#include <QPixmap>
#include <QSplashScreen>
#include <QtWidgets/QMainWindow>
#include <QTranslator>
#include <QTextCodec>
#include "vschdddevice.h"
#include "vevent.hpp"
#include "vservicemgr.hpp"

Factory *gFactory = NULL;

void LoadLangZH(QApplication &a)
{
	QTranslator *translator = new QTranslator(&a);
	bool ok = translator->load("opencvr_zh.qm",
		QCoreApplication::applicationDirPath() + "/translations");

	if (ok)
	{
		qDebug("Translation Files loaded.");
		a.installTranslator(translator);
	}
	QTranslator *translatorVe = new QTranslator(&a);
	ok = translatorVe->load("veuilib_zh.qm",
		QCoreApplication::applicationDirPath() + "/translations");

	if (ok)
	{
		qDebug("Translation Files loaded.");
		a.installTranslator(translatorVe);
	}
	return ;
}

int main(int argc, char *argv[])
{
	int dummy = errno;
	//QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
	QApplication a(argc, argv);
	Debug::init(0);

#ifdef WIN32
	QFont font;
	font.setPointSize(10); 
	font.setFamily(("΢ź"));
	font.setBold(false);

	a.setFont(font);
#else
	QFont font;
	font.setPointSize(10); 
	font.setFamily(("WenQuanYi Zen Hei"));
	font.setBold(false);

	a.setFont(font);
#endif


	QPixmap pixmap(":/logo/resources/splash.png");
	QSplashScreen *splash = new QSplashScreen(pixmap);
    //QFont splashFont;
    //splashFont.setFamily("Arial");
    //splashFont.setBold(true);

    	splash->setStyleSheet(QStringLiteral("color : red;"));
    //splash->setFont(splashFont);
    
    	splash->show();

    //QApplication::setStyle(QStyleFactory::create("Fusion"));
	//QApplication::setStyle(QStyleFactory::create("Plastique"));
    //QApplication::setStyle("WindowsVista"); 
#if 0
	QFile f(":qdarkstyle/style.qss");
	if (!f.exists())
	{
		printf("Unable to set stylesheet, file not found\n");
	}
	else 
	{
		f.open(QFile::ReadOnly | QFile::Text);
		QTextStream ts(&f);
		a.setStyleSheet(ts.readAll());
	}
#endif


    gFactory = new Factory;

   if (gFactory->Init() == FALSE)
   {
#ifdef WIN32
       astring strPath = "C:\\";//TODO get the hdd from hdd
       VSCHddDevice hdd;
       hdd.show();
       hdd.exec();
       s32 size = hdd.GetDiskSize();
       hdd.GetDiskPath(strPath);
#else

	astring strPath = "ve/";//TODO get the hdd from hdd
	s32 size = 2;
#endif
       gFactory->SetSystemPath(strPath);
       //splash->showMessage(QObject::tr("Create Video Database ..."));
       gFactory->Init();
#ifndef WIN32
	//gFactory->AddHDD(strPath, size);
#endif
   }
	VSCLangType m_lang;
	gFactory->GetLang(m_lang);
	if (m_lang == VSC_LANG_AUTO)
	{
		if (QLocale::system().name() == "zh_CN")
		{
			LoadLangZH(a);
		}
	}
	else if (m_lang == VSC_LANG_ZH)
	{
		LoadLangZH(a);
	}//else if add more language to here
   splash->showMessage(QObject::tr("Starting ..."));
   VEvent::Init(*gFactory);
   VServiceMgr *pServiceMgr = VServiceMgr::CreateObject(*gFactory);

{'fraction_non_alphanumeric': 0.2085233527284164, 'fraction_numerical': 0.008020128951092938, 'mean_word_length': 3.2886041807147675, 'pattern_counts': {'":': 4, '<': 17, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7278417', 'n_tokens_mistral': 2371, 'n_tokens_neox': 2251, 'n_words': 412}