void PhotoKitView::setRenderingSystem() { QWidget *viewport = 0; #ifndef QT_NO_OPENGL if (Config::openGlRendering) { setViewportUpdateMode(QGraphicsView::FullViewportUpdate); QGLWidget *glw = new QGLWidget(QGLFormat(QGL::SampleBuffers)); if (Config::noScreenSync) glw->format().setSwapInterval(0); glw->setAutoFillBackground(false); viewport = glw; setCacheMode(QGraphicsView::CacheNone); if (Config::verbose) ezlog_debug("- using OpenGL"); } else // software rendering #endif { // software rendering setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate); viewport = new QWidget; setCacheMode(QGraphicsView::CacheBackground); if (Config::verbose) ezlog_debug("- using software rendering"); } setViewport(viewport); }
QTM_USE_NAMESPACE #endif #endif MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { m_view = new QDeclarativeView(this); m_view->setAttribute(Qt::WA_NoSystemBackground); #ifndef QT_NO_OPENGL // Use QGLWidget to get the opengl support if available QGLFormat format = QGLFormat::defaultFormat(); format.setSampleBuffers(false); QGLWidget *glWidget = new QGLWidget(format); glWidget->setAutoFillBackground(false); m_view->setViewport(glWidget); // ownership of glWidget is taken #endif m_view->setSource(QUrl("qrc:/qml/SplashScreen.qml")); m_view->setResizeMode(QDeclarativeView::SizeRootObjectToView); setCentralWidget(m_view); // To delay the loading of main QML file so that the splash screen // would show, we use single shot timer. QTimer::singleShot(0, this, SLOT(initializeQMLComponent())); }
int main(int argc, char *argv[]) { // Depending on which is the recommended way for the platform, either use // opengl graphics system or paint into QGLWidget. #ifdef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM QApplication::setGraphicsSystem("opengl"); #endif QApplication app(argc, argv); QmlApplicationViewer viewer; #ifndef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM QGLFormat format = QGLFormat::defaultFormat(); format.setSampleBuffers(false); format.setSwapInterval(1); QGLWidget* glWidget = new QGLWidget(format); glWidget->setAutoFillBackground(false); viewer.setViewport(glWidget); #endif viewer.setViewportUpdateMode(QGraphicsView::FullViewportUpdate); viewer.setAttribute(Qt::WA_OpaquePaintEvent); viewer.setAttribute(Qt::WA_NoSystemBackground); viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer.setMainQmlFile(QLatin1String("qml/shadereffects/main.qml")); QObject::connect(viewer.engine(), SIGNAL(quit()), &viewer, SLOT(close())); viewer.showExpanded(); return app.exec(); }
void MainWindow::setRenderingSystem() { QWidget *viewport = 0; #ifndef QT_NO_OPENGL if (Colors::openGlRendering) { QGLWidget *glw = new QGLWidget(QGLFormat(QGL::SampleBuffers)); if (Colors::noScreenSync) glw->format().setSwapInterval(0); glw->setAutoFillBackground(false); viewport = glw; setCacheMode(QGraphicsView::CacheNone); if (Colors::verbose) qDebug() << "- using OpenGL"; } else // software rendering #endif { // software rendering viewport = new QWidget; setCacheMode(QGraphicsView::CacheBackground); if (Colors::verbose) qDebug() << "- using software rendering"; } setViewport(viewport); }
MuseBox::MuseBox(QWidget *parent) : QMainWindow(parent) { //TODO add a splash screen here? would be totally fun! qmlRegisterType<TrackArrangementBackground>("TrackArrangement",1,0,"TrackArrangementBackground"); qmlRegisterType<CursorRuler>("TrackArrangement",1,0,"CursorRuler"); qmlRegisterType<PatternModel>("DataModel",1,0,"PatternModel"); qmlRegisterType<NoteModel>("DataModel",1,0,"NoteModel"); qmlRegisterType<PatternDisplay>("TrackArrangement",1,0,"PatternDisplay"); qmlRegisterType<PatternNoteDisplay>("TrackArrangement",1,0,"PatternNoteDisplay"); QmlApplicationViewer *view = new QmlApplicationViewer(); view->rootContext()->setContextProperty("musebox", this); view->rootContext()->setContextProperty("trackModel", &this->trackModel); view->setSource(QUrl::fromLocalFile("qml/MuseBox/main.qml")); view->setResizeMode(QDeclarativeView::SizeRootObjectToView); QGLFormat format = QGLFormat::defaultFormat(); format.setSampleBuffers(false); QGLWidget *glWidget = new QGLWidget(format); glWidget->setAutoFillBackground(false); view->setViewport(glWidget); setCentralWidget(view); Hardware::Init(); view->rootContext()->setContextProperty("transposeMachine", Hardware::TransposeMachine); Hardware::StartAudio(); }
void VideoPlayer::setOpenGL(bool o) { videoItem->setOpenGL(o); if (!o) { view->setViewport(0); return; } #ifndef QT_NO_OPENGL QGLWidget *glw = new QGLWidget();//QGLFormat(QGL::SampleBuffers)); glw->setAutoFillBackground(false); view->setViewport(glw); view->setCacheMode(QGraphicsView::CacheNone); #endif }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QApplication::setGraphicsSystem("opengl"); QDeclarativeView* view = new QDeclarativeView(); QDeclarativeTouchArea::registerQML(); QGLFormat format = QGLFormat::defaultFormat(); format.setSampleBuffers(false); QGLWidget* glWidget = new QGLWidget(format, view); glWidget->setAutoFillBackground(false); QDeclarativeContext* context = view->rootContext(); AudioControl audioControl(context); audioControl.start(); QMutex& waitAudio = audioControl.getStartLock(); qDebug("main::waiting for Audio thread to initialize"); waitAudio.lock(); qDebug("main::Audio thread initialized, setting up qml window"); waitAudio.unlock(); QRect screenSize = app.desktop()->screenGeometry(); context->setContextProperty("ScreenWidth", screenSize.width()); context->setContextProperty("ScreenHeight", screenSize.height()); context->setContextProperty("PlayControl", &audioControl); view->setViewport(glWidget); view->setSource(QUrl("qrc:/qml/funkeysynth/main.qml")); view->setResizeMode(QDeclarativeView::SizeRootObjectToView); //qDebug("main::showing qml window"); //view->showFullScreen(); view->showNormal(); app.exec(); delete view; return 0; }
VideoPlayer::VideoPlayer(QWidget *parent) : QWidget(parent) , videoItem(0) { videoItem = new GraphicsItemRenderer; videoItem->resizeRenderer(640, 360); videoItem->setOutAspectRatioMode(VideoRenderer::RendererAspectRatio); QGraphicsScene *scene = new QGraphicsScene(this); scene->addItem(videoItem); QGraphicsView *graphicsView = new QGraphicsView(scene); #if 0 #ifndef QT_NO_OPENGL QGLWidget *glw = new QGLWidget(QGLFormat(QGL::SampleBuffers)); glw->setAutoFillBackground(false); graphicsView->setCacheMode(QGraphicsView::CacheNone); graphicsView->setViewport(glw); #endif #endif //0 QSlider *rotateSlider = new QSlider(Qt::Horizontal); rotateSlider->setRange(-180, 180); rotateSlider->setValue(0); connect(rotateSlider, SIGNAL(valueChanged(int)), this, SLOT(rotateVideo(int))); QPushButton *openBtn = new QPushButton; openBtn->setText("Open"); connect(openBtn, SIGNAL(clicked()), SLOT(open())); QBoxLayout *layout = new QVBoxLayout; layout->addWidget(graphicsView); layout->addWidget(rotateSlider); layout->addWidget(openBtn); setLayout(layout); mediaPlayer.setRenderer(videoItem); }
int main(int argc, char *argv[]) { // We don't need meego graphics system setenv("QT_GRAPHICSSYSTEM", "raster", 1); #ifdef WINDOW_DEBUG // React to context-commander's fake events; required by test20.py // to be able to fake a phone call. setenv("CONTEXT_COMMANDING", "1", 1); #endif // Don't load any Qt plugins QCoreApplication::setLibraryPaths(QStringList()); MCompositeManager app(argc, argv); QGraphicsScene *scene = app.scene(); QGraphicsView view(scene); view.setProperty("NoMStyle", true); view.setUpdatesEnabled(false); view.setAutoFillBackground(false); view.setBackgroundBrush(Qt::NoBrush); view.setForegroundBrush(Qt::NoBrush); view.setFrameShadow(QFrame::Plain); view.setWindowFlags(Qt::X11BypassWindowManagerHint); view.setAttribute(Qt::WA_NoSystemBackground); #if QT_VERSION >= 0x040600 view.move(-2, -2); view.setViewportUpdateMode(QGraphicsView::NoViewportUpdate); view.setOptimizationFlags(QGraphicsView::IndirectPainting); #endif app.setSurfaceWindow(view.winId()); view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); view.setMinimumSize(QApplication::desktop()->width() + 2, QApplication::desktop()->height() + 2); view.setMaximumSize(QApplication::desktop()->width() + 2, QApplication::desktop()->height() + 2); QGLFormat fmt; fmt.setSamples(0); fmt.setSampleBuffers(false); QGLWidget *w = new QGLWidget(fmt); w->setAttribute(Qt::WA_PaintOutsidePaintEvent); #ifndef GLES2_VERSION QPalette p = w->palette(); p.setColor(QPalette::Background, QColor(Qt::black)); w->setPalette(p); w->update(); #endif w->setAutoFillBackground(false); w->setMinimumSize(QApplication::desktop()->width(), QApplication::desktop()->height()); w->setMaximumSize(QApplication::desktop()->width(), QApplication::desktop()->height()); app.setGLWidget(w); view.setViewport(w); w->makeCurrent(); view.show(); // The directory is hard-coded for now. could be moved this // to $plugindir later. int testPlugin; const QStringList &args = app.arguments(); app.prepareEvents(); app.redirectWindows(); for (testPlugin = 1; testPlugin < args.length(); testPlugin++) if (!args[testPlugin].isEmpty() && args[testPlugin][0] != '-') break; app.loadPlugins(testPlugin < args.length() ? args[testPlugin] : QString(), "/usr/lib/mcompositor"); return app.exec(); }
hosted_button_id=RZ2A2ZB93827Y"; int main(int argc, char **argv) { QApplication app (argc, argv); app.setOrganizationName("SfietKonstantin"); app.setApplicationName("qfb-mobile"); // QFB::QueryManager queryManager; QFB::LoginManager loginManager; TokenManager tokenManager; Me me; // PostUpdateRelay postUpdateRelay; qmlRegisterType<UserInfoHelper>("org.SfietKonstantin.qfb.mobile", 4, 0, "QFBUserInfoHelper"); // qmlRegisterType<BackPixmapItem>("org.SfietKonstantin.qfb.mobile", 4, 0, // "QFBBackPixmapItem"); qmlRegisterType<PostHelper>("org.SfietKonstantin.qfb.mobile", 4, 0, "QFBPostHelper"); // qmlRegisterType<MobilePostValidator>("org.SfietKonstantin.qfb.mobile", 4, 0, // "QFBMobilePostValidator"); QDeclarativeView view; #ifdef MEEGO_EDITION_HARMATTAN QGLFormat format = QGLFormat::defaultFormat(); format.setSampleBuffers(false); format.setSwapInterval(1); QGLWidget* glWidget = new QGLWidget(format); glWidget->setAutoFillBackground(false); view.setViewport(glWidget); PagePixmapProvider *pagePixmapProvider = new PagePixmapProvider(glWidget); #else PagePixmapProvider *pagePixmapProvider = new PagePixmapProvider(&view); #endif #ifndef MEEGO_EDITION_HARMATTAN view.engine()->addImportPath(IMPORT_PATH); #endif view.engine()->addImageProvider("pagepixmapprovider", pagePixmapProvider); view.engine()->setNetworkAccessManagerFactory(new NetworkAccessManagerFactory()); // view.rootContext()->setContextProperty("QUERY_MANAGER", &queryManager); view.rootContext()->setContextProperty("LOGIN_MANAGER", &loginManager); view.rootContext()->setContextProperty("TOKEN_MANAGER", &tokenManager); // view.rootContext()->setContextProperty("POST_UPDATE_RELAY", &postUpdateRelay); view.rootContext()->setContextProperty("ME", &me); view.rootContext()->setContextProperty("DATA_PATH", DATA_PATH); view.rootContext()->setContextProperty("FACEBOOK_PAGE", FACEBOOK_PAGE); view.rootContext()->setContextProperty("PAYPAL_DONATE", PAYPAL_DONATE); view.rootContext()->setContextProperty("VERSION_MAJOR", QString::number(VERSION_MAJOR)); view.rootContext()->setContextProperty("VERSION_MINOR", QString::number(VERSION_MINOR)); view.rootContext()->setContextProperty("VERSION_PATCH", QString::number(VERSION_PATCH)); // Friends specific QString clientId; QPluginLoader pluginLoader (CLIENT_ID_PLUGIN); if (pluginLoader.load()) { QObject *plugin = pluginLoader.instance(); Interface *castedPlugin = qobject_cast<Interface *>(plugin); if (castedPlugin) { clientId = castedPlugin->clientId(); qDebug() << "Client id loaded"; } } if (clientId.isEmpty()) { if (app.arguments().count() == 2) { clientId = app.arguments().at(1); } else { qDebug() << "Failed to find the client id"; return -1; } } view.rootContext()->setContextProperty("CLIENT_ID", clientId); // End Friends specific view.setSource(QUrl(MAIN_QML_FILE)); view.showFullScreen(); QObject::connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit())); return app.exec(); }
int main(int argc, char *argv[]) { #ifdef USE_OPENGL_GRAPHICS_SYSTEM QApplication::setGraphicsSystem("opengl"); #endif QApplication app(argc, argv); #ifdef PERFORMANCEMONITOR_SUPPORT PerformanceMonitor::qmlRegisterTypes(); #endif QUrl fileName; qreal volume = 0.5; QStringList args = app.arguments(); #ifdef PERFORMANCEMONITOR_SUPPORT PerformanceMonitor::State performanceMonitorState; #endif for (int i=1; i<args.count(); ++i) { const QString &arg = args.at(i); if (arg.startsWith('-')) { if ("-volume" == arg) { if (i+1 < args.count()) volume = 0.01 * args.at(++i).toInt(); else qtTrace() << "Option \"-volume\" takes a value"; } #ifdef PERFORMANCEMONITOR_SUPPORT else if (PerformanceMonitor::parseArgument(arg, performanceMonitorState)) { // Do nothing } #endif else { qtTrace() << "Option" << arg << "ignored"; } } else { if (fileName.isEmpty()) fileName = QUrl::fromLocalFile(arg); else qtTrace() << "Argument" << arg << "ignored"; } } QmlApplicationViewer viewer; #ifndef USE_OPENGL_GRAPHICS_SYSTEM QGLFormat format = QGLFormat::defaultFormat(); format.setSampleBuffers(false); format.setSwapInterval(1); QGLWidget* glWidget = new QGLWidget(format); glWidget->setAutoFillBackground(false); viewer.setViewport(glWidget); #endif viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer.setMainQmlFile(QLatin1String("qml/qmlvideofx/") + MainQmlFile); viewer.setViewportUpdateMode(QGraphicsView::FullViewportUpdate); QGraphicsObject *rootObject = viewer.rootObject(); rootObject->setProperty("fileName", fileName); viewer.rootObject()->setProperty("volume", volume); #ifdef PERFORMANCEMONITOR_SUPPORT if (performanceMonitorState.valid) { rootObject->setProperty("perfMonitorsLogging", performanceMonitorState.logging); rootObject->setProperty("perfMonitorsVisible", performanceMonitorState.visible); } PaintEventMonitor paintEventMonitor; paintEventMonitor.setTarget(viewer.viewport()); QObject::connect(&paintEventMonitor, SIGNAL(targetPainted()), rootObject, SLOT(qmlFramePainted())); #endif FileReader fileReader; viewer.rootContext()->setContextProperty("fileReader", &fileReader); QString imagePath = "../../images"; const QString picturesLocation = QDesktopServices::storageLocation(QDesktopServices::PicturesLocation); if (!picturesLocation.isEmpty()) imagePath = picturesLocation; viewer.rootContext()->setContextProperty("imagePath", imagePath); QString videoPath; const QString moviesLocation = QDesktopServices::storageLocation(QDesktopServices::MoviesLocation); if (!moviesLocation.isEmpty()) videoPath = moviesLocation; viewer.rootContext()->setContextProperty("videoPath", videoPath); #ifdef SMALL_SCREEN_PHYSICAL viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape); viewer.showFullScreen(); #else viewer.showExpanded(); #endif // Delay invocation of init until the event loop has started, to work around // a GL context issue on Harmattan: without this, we get the following error // when the first ShaderEffectItem is created: // "QGLShaderProgram::addShader: Program and shader are not associated with same context" QMetaObject::invokeMethod(viewer.rootObject(), "init", Qt::QueuedConnection); return app.exec(); }