void Device::setFullScreenUpdateEvery(int n) { #ifndef i386 QKindleFb *pscreen = static_cast<QKindleFb*>(QScreen::instance()); if (pscreen) pscreen->setFullUpdateEvery(n); #endif }
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; }