void LiteApp::load(bool bUseSession, IApplication *baseApp) { QSplashScreen *splash = 0; bool bSplash = m_settings->value(LITEAPP_SPLASHVISIBLE,true).toBool(); if (baseApp) { bSplash = false; } if (bSplash) { splash = new QSplashScreen(QPixmap::fromImage(makeSplashImage(this)),Qt::WindowStaysOnTopHint); } if (bSplash) { splash->show(); } if (bSplash) { splash->showMessage("Scanning plugins...",Qt::AlignLeft|Qt::AlignBottom); } qApp->processEvents(); loadMimeType(); loadPlugins(); if (bSplash) { splash->showMessage("Loading plugins...",Qt::AlignLeft|Qt::AlignBottom); } qApp->processEvents(); initPlugins(); if (bSplash) { splash->showMessage("Loading state...",Qt::AlignLeft|Qt::AlignBottom); } qApp->processEvents(); loadState(); if (baseApp) { if (baseApp->mainWindow()->isMaximized()) { m_mainwindow->resize(800,600); m_mainwindow->show(); } else { QRect rc = baseApp->mainWindow()->geometry(); rc.adjust(20,20,20,20); m_mainwindow->setGeometry(rc); m_mainwindow->show(); } } else { m_mainwindow->show(); } emit loaded(); m_projectManager->setCurrentProject(0); if (bSplash) { splash->showMessage("Loading session...",Qt::AlignLeft|Qt::AlignBottom); } qApp->processEvents(); bool b = m_settings->value(LITEAPP_AUTOLOADLASTSESSION,true).toBool(); if (b && bUseSession) { loadSession("default"); } if (bSplash) { m_mainwindow->raise(); splash->finish(m_mainwindow); splash->deleteLater(); } this->appendLog("HtmlWidgetFactory",m_htmlWidgetManager->classNameList().join(" ")); this->appendLog("DefaultHtmlWidgetFactory",m_htmlWidgetManager->defaultClassName()); m_goProxy->call("version"); appendLog("LiteApp","Finished loading"); }
Q_DECL_EXPORT int main(int argc, char *argv[]) { int currentExitCode = 0; QScopedPointer<QSymbianApplication> app(new QSymbianApplication(argc, argv)); // Set App Info: app->setApplicationName("Battery Status"); app->setOrganizationName("Motaz Alnuweiri"); app->setApplicationVersion(APP_Version); // QT_DEBUG or QT_NO_DEBUG // #ifdef QT_DEBUG // // Install Debug Msgs Handler: // ClearDebugFile(); // qInstallMsgHandler(DebugFileHandler); // #endif // Install EventFilter in QApplication: //app->installEventFilter(new myEventFilter); // Set App Splash Screen: QSplashScreen *splash = new QSplashScreen(QPixmap(":qml/Images/JPG/Splash_Screen.jpg"), Qt::WindowStaysOnTopHint); splash->show(); // Check System Language & Load App Translator: QString systemLang = QLocale::system().name(); QTranslator appTranslator; systemLang.truncate(2); //truncate(2) to ignore the country code if (QFile::exists("Languages/batterystatus_" + systemLang + ".qm")) { appTranslator.load("batterystatus_" + systemLang, "Languages"); } else { appTranslator.load("batterystatus_en", "Languages"); } // Install QTranslator to QApplication: app->installTranslator(&appTranslator); // Hide The App If Deactive: if (!app->foreground()) QSymbianHelper::hideInBackground(); // Register QSettings: QAppSettings appSettings; // Register QmlApplicationViewer: QmlApplicationViewer *viewer = new QmlApplicationViewer(); //viewer.setResizeMode(QmlApplicationViewer::SizeRootObjectToView); //viewer.setAutoFillBackground(false); //viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait); // Register App HSWidget: QBatteryHSWidget *batteryHSWidget = new QBatteryHSWidget(); batteryHSWidget->setBackgroundOpacity(appSettings.getWidgetOpacity()); // Register QDeviceName: QDeviceName deviceName; // Register Class to QML: qmlRegisterType<QPSMode>("PSMode", 1, 0, "PSMode"); qmlRegisterType<QGlobalNote>("GlobalNote", 1, 0, "GlobalNote"); qmlRegisterType<QCBatteryInfo>("CBatteryInfo", 1, 0, "CBatteryInfo"); qmlRegisterType<CommonType>("CommonType", 1, 0, "CommonType"); // Set Propertys to QML: viewer->rootContext()->setContextProperty("APPName", QObject::tr("Battery Status")); viewer->rootContext()->setContextProperty("APPVersion", app->applicationVersion()); viewer->rootContext()->setContextProperty("AppPath", app->applicationDirPath()); viewer->rootContext()->setContextProperty("SymbianHelper", new QSymbianHelper); viewer->rootContext()->setContextProperty("AppSettings", &appSettings); viewer->rootContext()->setContextProperty("HSWidget", batteryHSWidget); viewer->rootContext()->setContextProperty("DeviceName", &deviceName); viewer->rootContext()->setContextProperty("QApp", app->instance()); viewer->setSource(QUrl(QLatin1String("qrc:qml/main.qml"))); //viewer.setSource(QUrl::fromLocalFile("qrc:qml/main.qml")); // Lock screen orientation in portrait only //viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait); //viewer.setGeometry(app->desktop()->screenGeometry()); viewer->showFullScreen(); // Stop Splash Screen & Delete It: splash->finish(viewer); splash->deleteLater(); //viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); // Enter App Event Loop: currentExitCode = app->exec(); // Cleun Pointers: delete viewer; delete batteryHSWidget; // Check If App Is Restarting: if(app->isRestarting()) { // Workround for my app to restart it self QProcess::startDetached(qApp->applicationFilePath()); } return currentExitCode; }
Q_DECL_EXPORT int main(int argc, char *argv[]) { #ifdef Q_OS_SYMBIAN QApplication::setAttribute((Qt::ApplicationAttribute)11); //Qt::AA_CaptureMultimediaKeys #endif QApplication app(argc, argv); app.setApplicationName("QVideo"); app.setOrganizationName("QShen"); app.setApplicationVersion(VER); QString locale = QLocale::system().name(); QTranslator translator; if(!translator.load(QString("QVideo_") + locale,":/i18n")){ qDebug()<<"translator load erro"; } app.installTranslator(&translator); Utility utility; Settings settings; #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) QmlApplicationViewer viewer; //viewer.setAttribute(Qt::WA_OpaquePaintEvent); //viewer.setAttribute(Qt::WA_NoSystemBackground); //viewer.viewport()->setAttribute(Qt::WA_OpaquePaintEvent); //viewer.viewport()->setAttribute(Qt::WA_NoSystemBackground); viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait); viewer.rootContext()->setContextProperty("utility", &utility); viewer.rootContext()->setContextProperty("settings", &settings); viewer.rootContext()->setContextProperty("appVersion", app.applicationVersion()); #ifdef Q_OS_SYMBIAN QSplashScreen *splash = new QSplashScreen(QPixmap(":/qml/pic/splash_symbian.png")); splash->show(); splash->raise(); viewer.setSource(QUrl("qrc:/qml/Symbian/main.qml")); #elif defined(Q_OS_HARMATTAN) //QApplication::setGraphicsSystem("native"); viewer.setSource(QUrl("qrc:/qml/Meego/main.qml")); #elif defined(Q_WS_SIMULATOR) viewer.setSource(QUrl("qrc:/qml/Symbian/main.qml")); #endif viewer.showExpanded(); #else QQmlApplicationEngine engine; engine.rootContext()->setContextProperty("utility",&utility); #ifdef Q_OS_WIN32 engine.load(QUrl(QStringLiteral("qrc:/qml/Win32/main.qml"))); #endif #endif #ifdef Q_OS_SYMBIAN splash->finish(&viewer); splash->deleteLater(); #endif return app.exec(); }
void LiteApp::load(bool bUseSession) { QSplashScreen *splash = 0; bool bSplash = m_settings->value(LITEAPP_SPLASHVISIBLE,true).toBool(); if (bSplash) { splash = new QSplashScreen(QPixmap::fromImage(makeSplashImage(this)),Qt::WindowStaysOnTopHint); } if (bSplash) { splash->show(); } if (bSplash) { splash->showMessage("liteide scan plugins ...",Qt::AlignLeft|Qt::AlignBottom); } qApp->processEvents(); loadMimeType(); loadPlugins(); if (bSplash) { splash->showMessage("liteide load plugins ...",Qt::AlignLeft|Qt::AlignBottom); } qApp->processEvents(); initPlugins(); if (bSplash) { splash->showMessage("liteide load state ...",Qt::AlignLeft|Qt::AlignBottom); } qApp->processEvents(); loadState(); m_mainwindow->show(); emit loaded(); m_projectManager->setCurrentProject(0); if (bSplash) { splash->showMessage("liteide load session ...",Qt::AlignLeft|Qt::AlignBottom); } qApp->processEvents(); appendLog("LiteApp","loaded"); bool b = m_settings->value(LITEAPP_AUTOLOADLASTSESSION,true).toBool(); if (b && bUseSession) { loadSession("default"); } if (bSplash) { m_mainwindow->raise(); splash->finish(m_mainwindow); splash->deleteLater(); } this->appendLog("HtmlWidgetFactory",m_htmlWidgetManager->classNameList().join(" ")); this->appendLog("DefaultHtmlWidgetFactory",m_htmlWidgetManager->defaultClassName()); m_goProxy->call("version"); m_goProxy->call("cmdlist"); }
Q_DECL_EXPORT int main(int argc, char *argv[]) { QScopedPointer<QApplication> app(createApplication(argc, argv)); //qDebug()<<QString::fromUtf8("主线程地址是:")<<QThread::currentThread(); #if defined(Q_OS_SYMBIAN)||defined(Q_WS_SIMULATOR) QPixmap pixmap(":/Image/Symbian.png"); QSplashScreen *splash = new QSplashScreen(pixmap); splash->show(); splash->raise(); #endif #ifndef QT_NO_DEBUG QNetworkProxy proxy; proxy.setType(QNetworkProxy::HttpProxy); proxy.setHostName("localhost"); proxy.setPort(8888); QNetworkProxy::setApplicationProxy(proxy); #endif //int width=QApplication::desktop()->width(); //int height=QApplication::desktop()->height(); app->setApplicationName (QString::fromUtf8("IT之家")); app->setOrganizationName ("Stars"); app->setApplicationVersion ("1.2.2"); Settings *setting=new Settings; Utility *unility=new Utility; Cache *cacheContent=new Cache(setting); //qmlRegisterType<MyXmlListModel>("myXmlListModel",1,0,"MyXmlListModel"); //qmlRegisterType<MyXmlRole>("myXmlListModel", 1, 0, "MyXmlRole"); QmlApplicationViewer viewer; MyNetworkAccessManagerFactory *network = new MyNetworkAccessManagerFactory(); viewer.engine()->setNetworkAccessManagerFactory(network); viewer.rootContext ()->setContextProperty ("cacheContent",cacheContent); viewer.rootContext()->setContextProperty("settings",setting); viewer.rootContext()->setContextProperty("utility",unility); QWebSettings::globalSettings ()->setAttribute (QWebSettings::LocalContentCanAccessRemoteUrls,true); QWebSettings::globalSettings ()->setAttribute (QWebSettings::SpatialNavigationEnabled,true); QWebSettings::globalSettings ()->setAttribute (QWebSettings::SpatialNavigationEnabled, true); #if defined(Q_OS_SYMBIAN)||defined(Q_WS_SIMULATOR) #if defined(Q_OS_S60V5)//判断qt的版本 qWarning("build symbian s60v5"); viewer.setMainQmlFile(QLatin1String("qml/symbian-v5/main.qml")); if(setting->getValue("night_mode",false).toBool()) unility->setCss("./qml/symbian-v5/theme_black.css",viewer.width()-20);//设置默认的css else unility->setCss("./qml/symbian-v5/theme_white.css",viewer.width()-20); #elif defined(Q_OS_S60V3) qWarning("build symbian s60v3"); viewer.setMainQmlFile(QLatin1String("qml/symbian-v3/main.qml")); if(setting->getValue("night_mode",false).toBool()) unility->setCss("./qml/symbian-v3/theme_black.css",viewer.width()-20);//设置默认的css else unility->setCss("./qml/symbian-v3/theme_white.css",viewer.width()-20); #else qWarning("build symbian anna or simulator"); viewer.setMainQmlFile(QLatin1String("qml/symbian-anna/main.qml")); if(setting->getValue("night_mode",false).toBool()) unility->setCss("./qml/symbian-anna/theme_black.css",viewer.width()-20);//设置默认的css else unility->setCss("./qml/symbian-anna/theme_white.css",viewer.width()-20); #endif viewer.showExpanded(); splash->finish(&viewer); splash->deleteLater(); #elif defined(Q_OS_HARMATTAN) qWarning("build meego"); viewer.setMainQmlFile(QLatin1String("qml/meego/main.qml")); if(setting->getValue("night_mode",false).toBool()) unility->setCss("/opt/ithome/qml/meego/theme_black.css",460);//设置默认的css else unility->setCss("/opt/ithome/qml/meego/theme_white.css",460); viewer.showExpanded(); #endif return app->exec(); }