#include "contentpresenttest.h"
#include "mainwindow.h"
#include "srcedit_defaulttext.h"
#include "srcedit_storyboard.h"
#include "srcedit_storychain.h"
#include "srcedit_storyconcept.h"
#include "srcedit_storyunit.h"
#include "srcedit_storyvolume.h"
#include "xapp.h"

#include <QApplication>
#include <QLocale>
#include <QStyleFactory>
#include <QTranslator>
#include <QDebug>
#include <QtTest/QTest>

int main(int argc, char *argv[])
{
    XApp a(argc, argv);

#ifdef UNIT_TEST

    MakeTools::ContentPresent *array[] = {
        new Components::DefaultTextPresent(),
        new Components::StorychainSourceEdit(),
        new Components::StoryunitSourceEdit(),
        new Components::StoryboardSourceEdit(),
        new Components::StoryvolumeSourceEdit(),
        new Components::StoryconceptSourceEdit()
    };

    for(auto &it : array){
        TestCase::ContentPresentTest tx0(it);
        QTest::qExec(&tx0, argc, argv);
    }

#else
    QTranslator translator;
    const QStringList uiLanguages = QLocale::system().uiLanguages();
    for (const QString &locale : uiLanguages) {
        const QString baseName = "WordsIDE_" + QLocale(locale).name();
        if (translator.load(":/i18n/" + baseName)) {
            a.installTranslator(&translator);
            break;
        }
    }

    MainWindow w;
    w.show();
#endif

    return a.exec();
}
