コード例 #1
0
ファイル: main.cpp プロジェクト: darcyg/pi
/*----------------------------------------------------------------------
|    main
+---------------------------------------------------------------------*/
int main(int argc, char* argv[])
{
	QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
	QGuiApplication app(argc, argv);

	// Utility.
	QStringList args = app.arguments();
	POC_Mode currentMode;
	if (args.contains("--animations"))
		currentMode = MODE_ANIMATIONS;
	else if (args.contains("--loop"))
		currentMode = MODE_LOOP;
	else if (args.contains("--seektest"))
		currentMode = MODE_SEEK;
	else if (args.contains("--multipletest"))
		currentMode = MODE_MULTIPLE;
	else if (args.contains("--multipleanimtest"))
		currentMode = MODE_MULTIPLEANIM;
	else if (args.contains("--overlaystest"))
		currentMode = MODE_OVERLAYS;
	else
		currentMode = MODE_PLAYER;

	POC_QMLUtils qmlUtils;
	POC_Uptime uptime;

	QQuickView view;

	// Set EGL to 24bit color depth.
	QSurfaceFormat curSurface = view.format();
	curSurface.setRedBufferSize(8);
	curSurface.setGreenBufferSize(8);
	curSurface.setBlueBufferSize(8);
	curSurface.setAlphaBufferSize(0);
	view.setFormat(curSurface);

	view.engine()->rootContext()->setContextProperty("utils", &qmlUtils);
	view.engine()->rootContext()->setContextProperty("uptime", &uptime);

	switch (currentMode) {
	case MODE_ANIMATIONS:
		view.setSource(QUrl(QStringLiteral("qrc:///qml/main_animations.qml")));
		break;
	case MODE_LOOP:
		view.setSource(QUrl(QStringLiteral("qrc:///qml/main_loop.qml")));
		break;
	case MODE_SEEK:
		view.setSource(QUrl(QStringLiteral("qrc:///qml/main_seektest.qml")));
		break;
	case MODE_MULTIPLE:
		view.setSource(QUrl(QStringLiteral("qrc:///qml/main_multiple.qml")));
		break;
	case MODE_OVERLAYS:
		view.setSource(QUrl(QStringLiteral("qrc:///qml/main_overlays.qml")));
		break;
	case MODE_MULTIPLEANIM:
		view.setSource(QUrl(QStringLiteral("qrc:///qml/main_multipleanim.qml")));
		break;
	default:
		view.setSource(QUrl(QStringLiteral("qrc:///qml/main.qml")));
		break;
	}

	qInstallMessageHandler(&log_handler);
	LC_QMLLogger::registerObject(view.rootContext());

	view.setResizeMode(QQuickView::SizeRootObjectToView);
#ifdef RASPBERRY
	view.showFullScreen();
#else
	view.resize(800, 400);
	view.show();
#endif // RASPBERRY
	qApp->connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));

	// If file path is provided from the command line, I start the player
	// immediately.
	switch (currentMode) {
	case MODE_MULTIPLEANIM:
	case MODE_LOOP: {
		QStringList list;
		for (int i = 2; i < args.size(); i++)
			list << args.at(i);
		if (list.size() < 1)
			return log_warn("No items to play.");
      if (!show_media(&view, list))
			return 1;
		break;
	}
	case MODE_PLAYER:
		if (args.size() > 1)
			if (!show_media(&view, args.at(1)))
				return 1;
		break;
	case MODE_MULTIPLE:
		break;
	default:
		if (args.size() > 2)
			if (!show_media(&view, args.at(2)))
				return 1;
		break;
	}

	return app.exec();
}
コード例 #2
0
ファイル: main.cpp プロジェクト: GPUWorks/calliper
int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);

    QSurfaceFormat format;
    format.setMajorVersion(4);
    format.setMinorVersion(1);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    format.setSamples(2);

    // Today I learned: the surface itself doesn't need an alpha channel.
    // When we blend colours in OpenGL, the alpha value passed in with the colour
    // is only used internally by OpenGL in order to calculate the physical RGB
    // to write back into the colour buffer. We don't need to set any alpha on the
    // surface itself, since the RGB values will already have been blended by the
    // time they're written back to the colour buffer. If we do set the alpha, that
    // means we'll actually be able to see through the surface and whatever is behind
    // will be visible. This isn't what we want for the application main window!
    // If we want to create a frame buffer later on where the actual colour buffer
    // output should be translucent, override the default alpha buffer size to 8 bits.

    format.setDepthBufferSize(24);
    format.setRedBufferSize(8);
    format.setGreenBufferSize(8);
    format.setBlueBufferSize(8);
    format.setAlphaBufferSize(0);
    format.setStencilBufferSize(8);

    QSurfaceFormat::setDefaultFormat(format);
    qDebug() << "Set default OpenGL format:" << format;

    QApplication a(argc, argv);
    a.setApplicationName("Calliper");
    a.setApplicationDisplayName("Calliper");
    a.setOrganizationName("Infra");
    a.setOrganizationName("Infra");

    // Initialise the resource manager.
    ResourceManager::initialise();

    // Initialise the renderer.
    OpenGLRenderer::initialise();

    // Initialise the over-arching application.
    Application::initialise(new MainWindow());

    // Set up resources.
    resourceManager()->makeCurrent();
    resourceManager()->setUpOpenGLResources();
    renderer()->setUpOpenGLResources();
    resourceManager()->doneCurrent();

    application()->mainWindow()->show();
    
    int ret = a.exec();

    // Shut down the application.
    Application::shutdown();

    // Shut down the renderer.
    OpenGLRenderer::shutdown();

    // Shut down the resource manager.
    ResourceManager::shutdown();

    return ret;

    return a.exec();
}
コード例 #3
0
ファイル: qwidget_qpa.cpp プロジェクト: cedrus/qt
void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
{
    Q_Q(QWidget);

    Q_UNUSED(window);
    Q_UNUSED(initializeWindow);
    Q_UNUSED(destroyOldWindow);

    Qt::WindowFlags flags = data.window_flags;

    if (!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow())
        return; // we only care about real toplevels

    QWindow *win = topData()->window;
    // topData() ensures the extra is created but does not ensure 'window' is non-null
    // in case the extra was already valid.
    if (!win) {
        createTLSysExtra();
        win = topData()->window;
    }

    win->setFlags(data.window_flags);
    fixPosIncludesFrame();
    if (q->testAttribute(Qt::WA_Moved))
        win->setGeometry(q->geometry());
    else
        win->resize(q->size());
    win->setScreen(QGuiApplication::screens().value(topData()->screenIndex, 0));

    if (q->testAttribute(Qt::WA_TranslucentBackground)) {
        QSurfaceFormat format;
        format.setAlphaBufferSize(8);
        win->setFormat(format);
    }

    if (QWidget *nativeParent = q->nativeParentWidget()) {
        if (nativeParent->windowHandle()) {
            if (flags & Qt::Window) {
                win->setTransientParent(nativeParent->windowHandle());
                win->setParent(0);
            } else {
                win->setTransientParent(0);
                win->setParent(nativeParent->windowHandle());
            }
        }
    }

    qt_window_private(win)->positionPolicy = topData()->posIncludesFrame ?
        QWindowPrivate::WindowFrameInclusive : QWindowPrivate::WindowFrameExclusive;
    win->create();
    // Enable nonclient-area events for QDockWidget and other NonClientArea-mouse event processing.
    if ((flags & Qt::Desktop) == Qt::Window)
        win->handle()->setFrameStrutEventsEnabled(true);

    data.window_flags = win->flags();

    QBackingStore *store = q->backingStore();

    if (!store) {
        if (win && q->windowType() != Qt::Desktop)
            q->setBackingStore(new QBackingStore(win));
        else
            q->setAttribute(Qt::WA_PaintOnScreen, true);
    }

    setWindowModified_helper();
    setWinId(win->winId());

    // Check children and create windows for them if necessary
    q_createNativeChildrenAndSetParent(q);

    if (extra && !extra->mask.isEmpty())
        setMask_sys(extra->mask);

    // If widget is already shown, set window visible, too
    if (q->isVisible())
        win->setVisible(true);
}
コード例 #4
0
void WebApplicationWindow::createAndSetup()
{
    if (mTrustScope == TrustScopeSystem) {
        mUserScripts.append(QUrl("qrc:///qml/webos-api.js"));
        createDefaultExtensions();
    }

    if (mWindowType == "dashboard")
        mLoadingAnimationDisabled = true;

    if (mHeadless) {
        qDebug() << __PRETTY_FUNCTION__ << "Creating application container for headless ...";

        mEngine = new QQmlEngine;
        configureQmlEngine();

        QQmlComponent component(mEngine, QUrl(QString("qrc:///qml/ApplicationContainer.qml")));
        mRootItem = qobject_cast<QQuickItem*>(component.create());
    }
    else {
        QQuickWebViewExperimental::setFlickableViewportEnabled(mApplication->desc().flickable());

        mWindow = new QQuickView;
        mWindow->installEventFilter(this);


        mEngine = mWindow->engine();
        configureQmlEngine();

        connect(mWindow, &QObject::destroyed,  [=](QObject *obj) {
            qDebug() << "Window destroyed";
        });

        mWindow->setColor(Qt::transparent);

        mWindow->reportContentOrientationChange(QGuiApplication::primaryScreen()->primaryOrientation());

        mWindow->setSurfaceType(QSurface::OpenGLSurface);
        QSurfaceFormat surfaceFormat = mWindow->format();
        surfaceFormat.setAlphaBufferSize(8);
        surfaceFormat.setRenderableType(QSurfaceFormat::OpenGLES);
        mWindow->setFormat(surfaceFormat);

        // make sure the platform window gets created to be able to set it's
        // window properties
        mWindow->create();

        // set different information bits for our window
        setWindowProperty(QString("_LUNE_WINDOW_TYPE"), QVariant(mWindowType));
        setWindowProperty(QString("_LUNE_WINDOW_PARENT_ID"), QVariant(mParentWindowId));
        setWindowProperty(QString("_LUNE_WINDOW_LOADING_ANIMATION_DISABLED"), QVariant(mApplication->loadingAnimationDisabled()));
        setWindowProperty(QString("_LUNE_APP_ICON"), QVariant(mApplication->icon()));
        setWindowProperty(QString("_LUNE_APP_ID"), QVariant(mApplication->id()));

        connect(mWindow, SIGNAL(visibleChanged(bool)), this, SLOT(onVisibleChanged(bool)));

        QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
        connect(nativeInterface, SIGNAL(windowPropertyChanged(QPlatformWindow*, const QString&)),
                this, SLOT(onWindowPropertyChanged(QPlatformWindow*, const QString&)));

        mWindow->setSource(QUrl(QString("qrc:///qml/ApplicationContainer.qml")));

        mRootItem = mWindow->rootObject();

        mWindow->resize(mSize);
    }
}
コード例 #5
0
QSurfaceFormat QEglFSKmsEglDeviceIntegration::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
{
    QSurfaceFormat format = QEglFSKmsIntegration::surfaceFormatFor(inputFormat);
    format.setAlphaBufferSize(8);
    return format;
}
コード例 #6
0
QQnxGLContext::QQnxGLContext(QOpenGLContext *glContext)
    : QPlatformOpenGLContext(),
      m_glContext(glContext),
      m_currentEglSurface(EGL_NO_SURFACE)
{
    qGLContextDebug() << Q_FUNC_INFO;
    QSurfaceFormat format = m_glContext->format();

    // Set current rendering API
    EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
    if (eglResult != EGL_TRUE)
        qFatal("QQNX: failed to set EGL API, err=%d", eglGetError());

    // Get colour channel sizes from window format
    int alphaSize = format.alphaBufferSize();
    int redSize = format.redBufferSize();
    int greenSize = format.greenBufferSize();
    int blueSize = format.blueBufferSize();

    // Check if all channels are don't care
    if (alphaSize == -1 && redSize == -1 && greenSize == -1 && blueSize == -1) {
        // Set colour channels based on depth of window's screen
        QQnxScreen *screen = static_cast<QQnxScreen*>(glContext->screen()->handle());
        int depth = screen->depth();
        if (depth == 32) {
            // SCREEN_FORMAT_RGBA8888
            alphaSize = 8;
            redSize = 8;
            greenSize = 8;
            blueSize = 8;
        } else {
            // SCREEN_FORMAT_RGB565
            alphaSize = 0;
            redSize = 5;
            greenSize = 6;
            blueSize = 5;
        }
    } else {
        // Choose best match based on supported pixel formats
        if (alphaSize <= 0 && redSize <= 5 && greenSize <= 6 && blueSize <= 5) {
            // SCREEN_FORMAT_RGB565
            alphaSize = 0;
            redSize = 5;
            greenSize = 6;
            blueSize = 5;
        } else {
            // SCREEN_FORMAT_RGBA8888
            alphaSize = 8;
            redSize = 8;
            greenSize = 8;
            blueSize = 8;
        }
    }

    // Update colour channel sizes in window format
    format.setAlphaBufferSize(alphaSize);
    format.setRedBufferSize(redSize);
    format.setGreenBufferSize(greenSize);
    format.setBlueBufferSize(blueSize);

    // Select EGL config based on requested window format
    m_eglConfig = q_configFromGLFormat(ms_eglDisplay, format);
    if (m_eglConfig == 0)
        qFatal("QQnxGLContext: failed to find EGL config");

    QQnxGLContext *glShareContext = static_cast<QQnxGLContext*>(m_glContext->shareHandle());
    m_eglShareContext = glShareContext ? glShareContext->m_eglContext : EGL_NO_CONTEXT;

    m_eglContext = eglCreateContext(ms_eglDisplay, m_eglConfig, m_eglShareContext,
                                    contextAttrs(format));
    if (m_eglContext == EGL_NO_CONTEXT) {
        checkEGLError("eglCreateContext");
        qFatal("QQnxGLContext: failed to create EGL context, err=%d", eglGetError());
    }

    // Query/cache window format of selected EGL config
    m_windowFormat = q_glFormatFromConfig(ms_eglDisplay, m_eglConfig);
}
コード例 #7
0
ファイル: shutdowndlg.cpp プロジェクト: KDE/kde-workspace
KSMShutdownDlg::KSMShutdownDlg( QWindow* parent,
                                bool maysd, bool choose, KWorkSpace::ShutdownType sdtype,
                                const QString& theme)
  : QQuickView(parent), //krazy:exclude=qclasses
    m_result(false)
    // this is a WType_Popup on purpose. Do not change that! Not
    // having a popup here has severe side effects.
{
    // window stuff
    QSurfaceFormat format;
    format.setAlphaBufferSize(8);
    setFormat(format);
    setClearBeforeRendering(true);
    setColor(QColor(Qt::transparent));
    setFlags(Qt::FramelessWindowHint);

    winId(); // workaround for Qt4.3 setWindowRole() assert
//    setWindowRole( QStringLiteral("logoutdialog") );

    // Qt doesn't set this on unmanaged windows
    //FIXME: or does it?
    XChangeProperty( QX11Info::display(), winId(),
        XInternAtom( QX11Info::display(), "WM_WINDOW_ROLE", False ), XA_STRING, 8, PropModeReplace,
        (unsigned char *)"logoutdialog", strlen( "logoutdialog" ));

    setPosition(screen()->virtualGeometry().center().x() - width() / 2,
                screen()->virtualGeometry().center().y() - height() / 2);

     setMinimumSize(QSize(300, 200));
    //kDebug() << "Creating QML view";
    //QQuickView *windowContainer = QQuickView::createWindowContainer(m_view, this);
    //windowContainer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    QQmlContext *context = rootContext();
    context->setContextProperty(QStringLiteral("maysd"), maysd);
    context->setContextProperty(QStringLiteral("choose"), choose);
    context->setContextProperty(QStringLiteral("sdtype"), sdtype);

    QQmlPropertyMap *mapShutdownType = new QQmlPropertyMap(this);
    mapShutdownType->insert(QStringLiteral("ShutdownTypeDefault"), QVariant::fromValue((int)KWorkSpace::ShutdownTypeDefault));
    mapShutdownType->insert(QStringLiteral("ShutdownTypeNone"), QVariant::fromValue((int)KWorkSpace::ShutdownTypeNone));
    mapShutdownType->insert(QStringLiteral("ShutdownTypeReboot"), QVariant::fromValue((int)KWorkSpace::ShutdownTypeReboot));
    mapShutdownType->insert(QStringLiteral("ShutdownTypeHalt"), QVariant::fromValue((int)KWorkSpace::ShutdownTypeHalt));
    mapShutdownType->insert(QStringLiteral("ShutdownTypeLogout"), QVariant::fromValue((int)KWorkSpace::ShutdownTypeLogout));
    context->setContextProperty(QStringLiteral("ShutdownType"), mapShutdownType);

    QQmlPropertyMap *mapSpdMethods = new QQmlPropertyMap(this);
    QSet<Solid::PowerManagement::SleepState> spdMethods = Solid::PowerManagement::supportedSleepStates();
    mapSpdMethods->insert(QStringLiteral("StandbyState"), QVariant::fromValue(spdMethods.contains(Solid::PowerManagement::StandbyState)));
    mapSpdMethods->insert(QStringLiteral("SuspendState"), QVariant::fromValue(spdMethods.contains(Solid::PowerManagement::SuspendState)));
    mapSpdMethods->insert(QStringLiteral("HibernateState"), QVariant::fromValue(spdMethods.contains(Solid::PowerManagement::HibernateState)));
    context->setContextProperty(QStringLiteral("spdMethods"), mapSpdMethods);

    QString bootManager = KConfig(QStringLiteral(KDE_CONFDIR "/kdm/kdmrc"), KConfig::SimpleConfig)
                          .group("Shutdown")
                          .readEntry("BootManager", "None");
    context->setContextProperty(QStringLiteral("bootManager"), bootManager);

    QStringList options;
    int def, cur;
    if ( KDisplayManager().bootOptions( rebootOptions, def, cur ) ) {
        if ( cur > -1 ) {
            def = cur;
        }
    }
    QQmlPropertyMap *rebootOptionsMap = new QQmlPropertyMap(this);
    rebootOptionsMap->insert(QStringLiteral("options"), QVariant::fromValue(rebootOptions));
    rebootOptionsMap->insert(QStringLiteral("default"), QVariant::fromValue(def));
    context->setContextProperty(QStringLiteral("rebootOptions"), rebootOptionsMap);

    setModality(Qt::ApplicationModal);

    // engine stuff
    KDeclarative::KDeclarative kdeclarative;
    kdeclarative.setDeclarativeEngine(engine());
    kdeclarative.initialize();
    kdeclarative.setupBindings();
//    windowContainer->installEventFilter(this);

    QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("ksmserver/themes/%1/main.qml").arg(theme));
    if (QFile::exists(fileName)) {
        //kDebug() << "Using QML theme" << fileName;
        setSource(QUrl::fromLocalFile(fileName));
    }

    connect(rootObject(), SIGNAL(logoutRequested()), SLOT(slotLogout()));
    connect(rootObject(), SIGNAL(haltRequested()), SLOT(slotHalt()));
    connect(rootObject(), SIGNAL(suspendRequested(int)), SLOT(slotSuspend(int)) );
    connect(rootObject(), SIGNAL(rebootRequested()), SLOT(slotReboot()));
    connect(rootObject(), SIGNAL(rebootRequested2(int)), SLOT(slotReboot(int)) );
    connect(rootObject(), SIGNAL(cancelRequested()), SLOT(reject()));
    connect(rootObject(), SIGNAL(lockScreenRequested()), SLOT(slotLockScreen()));

    show();
//    adjustSize();
}