Exemple #1
0
static int setStringProperty(lua_State *L) {
    CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
    const char *propName = luaL_checkstring(L, 2);
    const char *value = luaL_checkstring(L, 3);
    CRPropRef props = LVCreatePropsContainer();
    props->setString(propName, value);
    doc->text_view->propsApply(props);
    return 0;
}
Exemple #2
0
void InitCREngineLog( const char * cfgfile )
{
    if ( !cfgfile ) {
        CRLog::setStdoutLogger();
        CRLog::setLogLevel( CRLog::LL_TRACE );
        return;
    }
    lString16 logfname;
    lString16 loglevelstr = 
#ifdef _DEBUG
		L"TRACE";
#else
		L"INFO";
#endif
    bool autoFlush = false;
    CRPropRef logprops = LVCreatePropsContainer();
    {
        LVStreamRef cfg = LVOpenFileStream( cfgfile, LVOM_READ );
        if ( !cfg.isNull() ) {
            logprops->loadFromStream( cfg.get() );
            logfname = logprops->getStringDef( PROP_LOG_FILENAME, "stdout" );
            loglevelstr = logprops->getStringDef( PROP_LOG_LEVEL, "TRACE" );
                        autoFlush = logprops->getBoolDef( PROP_LOG_AUTOFLUSH, false );
        }
    }
    CRLog::log_level level = CRLog::LL_INFO;
    if ( loglevelstr==L"OFF" ) {
        level = CRLog::LL_FATAL;
        logfname.clear();
    } else if ( loglevelstr==L"FATAL" ) {
        level = CRLog::LL_FATAL;
    } else if ( loglevelstr==L"ERROR" ) {
        level = CRLog::LL_ERROR;
    } else if ( loglevelstr==L"WARN" ) {
        level = CRLog::LL_WARN;
    } else if ( loglevelstr==L"INFO" ) {
        level = CRLog::LL_INFO;
    } else if ( loglevelstr==L"DEBUG" ) {
        level = CRLog::LL_DEBUG;
    } else if ( loglevelstr==L"TRACE" ) {
        level = CRLog::LL_TRACE;
    }
    if ( !logfname.empty() ) {
        if ( logfname==L"stdout" )
            CRLog::setStdoutLogger();
        else if ( logfname==L"stderr" )
            CRLog::setStderrLogger();
        else
            CRLog::setFileLogger( UnicodeToUtf8( logfname ).c_str(), autoFlush );
    }
    CRLog::setLogLevel( level );
    CRLog::trace("Log initialization done.");
}
Exemple #3
0
CRPropRef CRJNIEnv::fromJavaProperties( jobject jprops )
{
    CRPropRef props = LVCreatePropsContainer();
    CRObjectAccessor jp(env, jprops);
    CRMethodAccessor p_getProperty(jp, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
    jobject en = CRMethodAccessor( jp, "propertyNames", "()Ljava/util/Enumeration;").callObj();
    CRObjectAccessor jen(env, en);
    CRMethodAccessor jen_hasMoreElements(jen, "hasMoreElements", "()Z");
    CRMethodAccessor jen_nextElement(jen, "nextElement", "()Ljava/lang/Object;");
    while ( jen_hasMoreElements.callBool() ) {
    	jstring key = (jstring)jen_nextElement.callObj();
    	jstring value = (jstring)p_getProperty.callObj(key);
    	props->setString(LCSTR(fromJavaString(key)),LCSTR(fromJavaString(value))); 
    	env->DeleteLocalRef(key); 
    	env->DeleteLocalRef(value); 
    }
	return props;
}
int main(int argc, char *argv[])
{
    int res = 0;
    {
        Device::instance(); // initialize device
#ifndef i386
        QProcess::execute("eips -c");
        pTouch = new TouchScreen();
#endif
        lString16 exedir = LVExtractPath(LocalToUnicode(lString8(argv[0])));
        LVAppendPathDelimiter(exedir);
        lString16 datadir = exedir + "data/";
        lString16 exefontpath = exedir + "fonts";

        lString16Collection fontDirs;
        fontDirs.add(exefontpath);
#ifndef i386
        fontDirs.add("/usr/java/lib/fonts");
        fontDirs.add("/mnt/us/fonts");
#endif
        CRPropRef props = LVCreatePropsContainer();
        {
            LVStreamRef cfg = LVOpenFileStream(UnicodeToUtf8(datadir + "cr3.ini").data(), LVOM_READ);
            if(!cfg.isNull()) props->loadFromStream(cfg.get());
        }

        lString16 lang = props->getStringDef(PROP_WINDOW_LANG, "");
        InitCREngineLog(props);
        CRLog::info("main()");

        if(!InitCREngine(argv[0], fontDirs)) {
            printf("Cannot init CREngine - exiting\n");
            return 2;
        }
#ifndef i386
        PrintString(1, 1, "crengine version: " + QString(CR_ENGINE_VERSION));
        PrintString(1, 2, QString("build date: %1 %2").arg(__DATE__).arg(__TIME__));
        if (!Device::isTouch()) {
            QString message = "Please wait while application is loading...";
            int xpos = ((Device::getWidth()/12-1)-message.length())/2;
            int ypos = (Device::getHeight()/20-2)/2;
            PrintString(xpos, ypos, message);
        }
#endif
        // to catch crashes and remove current cache file on crash (SIGSEGV etc.)
        crSetSignalHandler();
        // set row count depending on device model (used in lists)
        int rc = props->getIntDef(PROP_WINDOW_ROW_COUNT, 0);
        if(!rc) {
#ifndef i386
            switch(Device::getModel()) {
            case Device::KDX:
                rc = 20;
                break;
            case Device::KT:
            case Device::KPW:
                rc = 8;
                break;
            default:
                rc = 10;
            }
            props->setInt(PROP_WINDOW_ROW_COUNT, rc);
#else
            props->setInt(PROP_WINDOW_ROW_COUNT, 10);
#endif
            LVStreamRef cfg = LVOpenFileStream(UnicodeToUtf8(datadir + "cr3.ini").data(), LVOM_WRITE);
            props->saveToStream(cfg.get());
        }

        QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
        MyApplication a(argc, argv);
        pMyApp = &a;
        // set app stylesheet
#ifndef i386
        QString style = Device::isTouch() ? "stylesheet_pw.qss" : "stylesheet_k3.qss";
        QFile qss(QDir::toNativeSeparators(cr2qt(datadir)) + style);
        // set up full update interval for the graphics driver
        Device::setFullScreenUpdateEvery(props->getIntDef(PROP_DISPLAY_FULL_UPDATE_INTERVAL, 1));
#else
        QFile qss(QDir::toNativeSeparators(cr2qt(datadir)) + "stylesheet_k3.qss");
#endif
        qss.open(QFile::ReadOnly);
        if(qss.error() == QFile::NoError) {
            a.setStyleSheet(qss.readAll());
            qss.close();
        }

        QMap<QString, QString> langToCode;
        langToCode["Russian"]   = "ru";
        langToCode["French"]    = "fr";
        langToCode["Hungarian"] = "hu";
        langToCode["Italian"]   = "it";
        langToCode["German"]    = "de";
        langToCode["Ukrainian"] = "uk";

        QString translations = cr2qt(datadir) + "i18n";
        QTranslator myappTranslator, qtr;
        if (!lang.empty() && lang.compare("English")) {
            QString lng = cr2qt(lang);
            if (myappTranslator.load(lng, translations)) {
                // default translator for Qt standard dialogs
                if (qtr.load("qt_" + langToCode[lng], translations)) {
                    QApplication::installTranslator(&qtr);
                } else {
                    qDebug() << "Failed to load Qt translation for " << lng;
                }
                // load after default to allow overriding translations
                QApplication::installTranslator(&myappTranslator);
            } else {
                qDebug() << "Can`t load translation file " << lng << " from dir " << translations;
            }
        }

        (void) signal(SIGUSR1, sigCatcher);

        MainWindow mainWin;
        a.setMainWindow(&mainWin);
        mainWin.showFullScreen();
        mainWin.doStartupActions();
        res = a.exec();
    }
    ShutdownCREngine();
    return res;
}
V3DocViewWin::V3DocViewWin( CRGUIWindowManager * wm, lString16 dataDir )
: CRViewDialog ( wm, lString16(), lString8(), lvRect(), false, false ), _dataDir(dataDir), _loadFileStart(0)
{
    CRLog::trace("V3DocViewWin()");
    LVArray<int> sizes( cr_font_sizes, sizeof(cr_font_sizes)/sizeof(int) );
	_fullscreen = true;
    _docview->setShowCover( true );
    _docview->setFontSizes( sizes, true );
    _docview->setCallback( this );
    _props = LVCreatePropsContainer();
    _newProps = _props;
    // TODO: move skin outside
    //lString16 skinfile = _dataDir;
    //LVAppendPathDelimiter( skinfile );
    //skinfile << L"skin";
    //lString8 s8 = UnicodeToLocal( skinfile );
    //CRLog::debug("Skin file is %s", s8.c_str() );
    //loadSkin( skinfile );

#define BATTERY_HEADER \
        "36 19 5 1", \
        "0 c #000000", \
        "X c #000000", \
        "o c #AAAAAA", \
        ". c #FFFFFF", \
        "  c None",


    LVRefVec<LVImageSource> icons;
    static const char * battery8[] = {
        BATTERY_HEADER
        "   .................................",
        "   .0000000000000000000000000000000.",
        "   .0.............................0.",
        "   .0.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        "....0.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0000.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0000.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        "....0.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        "   .0.XXXXXX.XXXXXX.XXXXXX.XXXXXX.0.",
        "   .0.............................0.",
        "   .0000000000000000000000000000000.",
        "   .................................",
    };
    static const char * battery7[] = {
        BATTERY_HEADER
        "   .................................",
        "   .0000000000000000000000000000000.",
        "   .0.............................0.",
        "   .0.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        "....0.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0000.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        ".0000.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        "....0.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        "   .0.oooooo.XXXXXX.XXXXXX.XXXXXX.0.",
        "   .0.............................0.",
        "   .0000000000000000000000000000000.",
        "   .................................",
    };
    static const char * battery6[] = {
        BATTERY_HEADER
        "   .................................",
        "   .0000000000000000000000000000000.",
        "   .0.............................0.",
        "   .0........XXXXXX.XXXXXX.XXXXXX.0.",
        "....0........XXXXXX.XXXXXX.XXXXXX.0.",
        ".0000........XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0........XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0........XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0........XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0........XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0........XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0........XXXXXX.XXXXXX.XXXXXX.0.",
        ".0..0........XXXXXX.XXXXXX.XXXXXX.0.",
        ".0000........XXXXXX.XXXXXX.XXXXXX.0.",
        "....0........XXXXXX.XXXXXX.XXXXXX.0.",
        "   .0........XXXXXX.XXXXXX.XXXXXX.0.",
        "   .0.............................0.",
        "   .0000000000000000000000000000000.",
        "   .................................",
    };
    static const char * battery5[] = {
        BATTERY_HEADER
        "   .................................",
        "   .0000000000000000000000000000000.",
        "   .0.............................0.",
        "   .0........oooooo.XXXXXX.XXXXXX.0.",
        "....0........oooooo.XXXXXX.XXXXXX.0.",
        ".0000........oooooo.XXXXXX.XXXXXX.0.",
        ".0..0........oooooo.XXXXXX.XXXXXX.0.",
        ".0..0........oooooo.XXXXXX.XXXXXX.0.",
        ".0..0........oooooo.XXXXXX.XXXXXX.0.",
        ".0..0........oooooo.XXXXXX.XXXXXX.0.",
        ".0..0........oooooo.XXXXXX.XXXXXX.0.",
        ".0..0........oooooo.XXXXXX.XXXXXX.0.",
        ".0..0........oooooo.XXXXXX.XXXXXX.0.",
        ".0000........oooooo.XXXXXX.XXXXXX.0.",
        "....0........oooooo.XXXXXX.XXXXXX.0.",
        "   .0........oooooo.XXXXXX.XXXXXX.0.",
        "   .0.............................0.",
        "   .0000000000000000000000000000000.",
        "   .................................",
    };
    static const char * battery4[] = {
        BATTERY_HEADER
        "   .................................",
        "   .0000000000000000000000000000000.",
        "   .0.............................0.",
        "   .0...............XXXXXX.XXXXXX.0.",
        "....0...............XXXXXX.XXXXXX.0.",
        ".0000...............XXXXXX.XXXXXX.0.",
        ".0..0...............XXXXXX.XXXXXX.0.",
        ".0..0...............XXXXXX.XXXXXX.0.",
        ".0..0...............XXXXXX.XXXXXX.0.",
        ".0..0...............XXXXXX.XXXXXX.0.",
        ".0..0...............XXXXXX.XXXXXX.0.",
        ".0..0...............XXXXXX.XXXXXX.0.",
        ".0..0...............XXXXXX.XXXXXX.0.",
        ".0000...............XXXXXX.XXXXXX.0.",
        "....0...............XXXXXX.XXXXXX.0.",
        "   .0...............XXXXXX.XXXXXX.0.",
        "   .0.............................0.",
        "   .0000000000000000000000000000000.",
        "   .................................",
    };
    static const char * battery3[] = {
        BATTERY_HEADER
        "   .................................",
        "   .0000000000000000000000000000000.",
        "   .0.............................0.",
        "   .0...............oooooo.XXXXXX.0.",
        "....0...............oooooo.XXXXXX.0.",
        ".0000...............oooooo.XXXXXX.0.",
        ".0..0...............oooooo.XXXXXX.0.",
        ".0..0...............oooooo.XXXXXX.0.",
        ".0..0...............oooooo.XXXXXX.0.",
        ".0..0...............oooooo.XXXXXX.0.",
        ".0..0...............oooooo.XXXXXX.0.",
        ".0..0...............oooooo.XXXXXX.0.",
        ".0..0...............oooooo.XXXXXX.0.",
        ".0000...............oooooo.XXXXXX.0.",
        "....0...............oooooo.XXXXXX.0.",
        "   .0...............oooooo.XXXXXX.0.",
        "   .0.............................0.",
        "   .0000000000000000000000000000000.",
        "   .................................",
    };
    static const char * battery2[] = {
        BATTERY_HEADER
        "   .................................",
        "   .0000000000000000000000000000000.",
        "   .0.............................0.",
        "   .0......................XXXXXX.0.",
        "....0......................XXXXXX.0.",
        ".0000......................XXXXXX.0.",
        ".0..0......................XXXXXX.0.",
        ".0..0......................XXXXXX.0.",
        ".0..0......................XXXXXX.0.",
        ".0..0......................XXXXXX.0.",
        ".0..0......................XXXXXX.0.",
        ".0..0......................XXXXXX.0.",
        ".0..0......................XXXXXX.0.",
        ".0000......................XXXXXX.0.",
        "....0......................XXXXXX.0.",
        "   .0......................XXXXXX.0.",
        "   .0.............................0.",
        "   .0000000000000000000000000000000.",
        "   .................................",
    };
    static const char * battery1[] = {
        BATTERY_HEADER
        "   .................................",
        "   .0000000000000000000000000000000.",
        "   .0.............................0.",
        "   .0......................oooooo.0.",
        "....0......................oooooo.0.",
        ".0000......................oooooo.0.",
        ".0..0......................oooooo.0.",
        ".0..0......................oooooo.0.",
        ".0..0......................oooooo.0.",
        ".0..0......................oooooo.0.",
        ".0..0......................oooooo.0.",
        ".0..0......................oooooo.0.",
        ".0..0......................oooooo.0.",
        ".0000......................oooooo.0.",
        "....0......................oooooo.0.",
        "   .0......................oooooo.0.",
        "   .0.............................0.",
        "   .0000000000000000000000000000000.",
        "   .................................",
    };
    static const char * battery0[] = {
        BATTERY_HEADER
        "   .................................",
        "   .0000000000000000000000000000000.",
        "   .0.............................0.",
        "   .0.............................0.",
        "....0.............................0.",
        ".0000.............................0.",
        ".0..0.............................0.",
        ".0..0.............................0.",
        ".0..0.............................0.",
        ".0..0.............................0.",
        ".0..0.............................0.",
        ".0..0.............................0.",
        ".0..0.............................0.",
        ".0000.............................0.",
        "....0.............................0.",
        "   .0.............................0.",
        "   .0.............................0.",
        "   .0000000000000000000000000000000.",
        "   .................................",
    };
    static const char * battery_charge[] = {
        BATTERY_HEADER
        "   .................................",
        "   .0000000000000000000000000000000.",
        "   .0.............................0.",
        "   .0.............................0.",
        "....0.............................0.",
        ".0000.............................0.",
        ".0..0................XX...........0.",
        ".0..0...............XXXXX.........0.",
        ".0..0..XXXX........XXXXXXXX.......0.",
        ".0..0....XXXXXX...XXXX...XXXXX....0.",
        ".0..0.......XXXXXXXXX.......XXXX..0.",
        ".0..0.........XXXXXX..............0.",
        ".0..0............XX...............0.",
        ".0000.............................0.",
        "....0.............................0.",
        "   .0.............................0.",
        "   .0.............................0.",
        "   .0000000000000000000000000000000.",
        "   .................................",
    };
    static const char * battery_frame[] = {
        BATTERY_HEADER
        "   .................................",
        "   .0000000000000000000000000000000.",
        "   .0.............................0.",
        "   .0.............................0.",
        "....0.............................0.",
        ".0000.............................0.",
        ".0..0.............................0.",
        ".0..0.............................0.",
        ".0..0.............................0.",
        ".0..0.............................0.",
        ".0..0.............................0.",
        ".0..0.............................0.",
        ".0..0.............................0.",
        ".0000.............................0.",
        "....0.............................0.",
        "   .0.............................0.",
        "   .0.............................0.",
        "   .0000000000000000000000000000000.",
        "   .................................",
    };
    icons.add( LVCreateXPMImageSource( battery_charge ) );
//#ifdef NO_BATTERY_GAUGE
//    icons.add( LVCreateXPMImageSource( battery_frame ) );
//#else
    icons.add( LVCreateXPMImageSource( battery0 ) );
    icons.add( LVCreateXPMImageSource( battery1 ) );
    icons.add( LVCreateXPMImageSource( battery2 ) );
    icons.add( LVCreateXPMImageSource( battery3 ) );
    icons.add( LVCreateXPMImageSource( battery4 ) );
    icons.add( LVCreateXPMImageSource( battery5 ) );
    icons.add( LVCreateXPMImageSource( battery6 ) );
    icons.add( LVCreateXPMImageSource( battery7 ) );
    icons.add( LVCreateXPMImageSource( battery8 ) );
//#endif
    icons.add( LVCreateXPMImageSource( battery_frame ) );
    _docview->setBatteryIcons( icons );
    _wm->setBatteryIcons(icons);
    setAccelerators( _wm->getAccTables().get("main") );
}
PropsRef Props::create()
{
    return QSharedPointer<Props>( new CRPropsImpl(LVCreatePropsContainer()) );
}
Exemple #7
0
int main(int argc, char *argv[])
{
    int res = 0;
    {
        Device::instance(); // initialize device
#ifndef i386
        QProcess::execute("eips -c");
        pTouch = new TouchScreen();
#endif
        lString16 exedir = LVExtractPath(LocalToUnicode(lString8(argv[0])));
        LVAppendPathDelimiter(exedir);
        lString16 datadir = exedir + L"data/";
        lString16 exefontpath = exedir + L"fonts";

        lString16Collection fontDirs;
        fontDirs.add(exefontpath);
#ifndef i386
        fontDirs.add(lString16(L"/usr/java/lib/fonts"));
        fontDirs.add(lString16(L"/mnt/us/fonts"));
#endif
        CRPropRef props = LVCreatePropsContainer();
        {
            LVStreamRef cfg = LVOpenFileStream(UnicodeToUtf8(datadir + L"cr3.ini").data(), LVOM_READ);
            if(!cfg.isNull()) props->loadFromStream(cfg.get());
        }

        lString16 lang = props->getStringDef(PROP_WINDOW_LANG, "");
        InitCREngineLog(props);
        CRLog::info("main()");

        if(!InitCREngine(argv[0], fontDirs)) {
            printf("Cannot init CREngine - exiting\n");
            return 2;
        }
#ifndef i386
        PrintString(1, 1, "crengine version: " + QString(CR_ENGINE_VERSION));
        PrintString(1, 2, QString("buid date: %1 %2").arg(__DATE__).arg(__TIME__));
        if (!Device::isTouch()) {
            QString message = "Please wait while application is loading...";
            int xpos = ((Device::getWidth()/12-1)-message.length())/2;
            int ypos = (Device::getHeight()/20-2)/2;
            PrintString(xpos, ypos, message);
        }
#endif

        // set row count
        int rc = props->getIntDef(PROP_WINDOW_ROW_COUNT, 0);
        if(!rc) {
#ifndef i386
            props->setInt(PROP_WINDOW_ROW_COUNT, Device::getModel() != Device::KDX ? 10 : 16);
#else
            props->setInt(PROP_WINDOW_ROW_COUNT, 10);
#endif
            LVStreamRef cfg = LVOpenFileStream(UnicodeToUtf8(datadir + L"cr3.ini").data(), LVOM_WRITE);
            props->saveToStream(cfg.get());
        }

        QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
        MyApplication a(argc, argv);
        pMyApp = &a;
        // set app stylesheet
#ifndef i386
        QString style = (Device::getModel() != Device::KDX ? "stylesheet_k3.qss" : "stylesheet_dx.qss");
        if (Device::getModel() == Device::KPW) style = "stylesheet_pw.qss";
        QFile qss(QDir::toNativeSeparators(cr2qt(datadir)) + style);
        // set up full update interval for the graphics driver
        QKindleFb *pscreen = static_cast<QKindleFb*>(QScreen::instance());
        pscreen->setFullUpdateEvery(props->getIntDef(PROP_DISPLAY_FULL_UPDATE_INTERVAL, 1));
#else
        QFile qss(QDir::toNativeSeparators(cr2qt(datadir)) + "stylesheet_k3.qss");
#endif
        qss.open(QFile::ReadOnly);
        if(qss.error() == QFile::NoError) {
            a.setStyleSheet(qss.readAll());
            qss.close();
        }
        QString translations = cr2qt(datadir) + "i18n";
        QTranslator myappTranslator;
        if(!lang.empty() && lang.compare(L"English")) {
            if(myappTranslator.load(cr2qt(lang), translations))
                QApplication::installTranslator(&myappTranslator);
            else
                qDebug("Can`t load translation file %s from dir %s", UnicodeToUtf8(lang).c_str(), UnicodeToUtf8(qt2cr(translations)).c_str());
        }

        (void) signal(SIGUSR1, sigCatcher);

        MainWindow mainWin;
        a.setMainWindow(&mainWin);
        mainWin.showFullScreen();
        mainWin.doStartupActions();
        res = a.exec();
    }
    ShutdownCREngine();
    return res;
}