示例#1
0
void PaintedWindow::rotationDone()
{
    reportContentOrientationChange(m_targetOrientation);
    if (m_nextTargetOrientation != Qt::PrimaryOrientation) {
        Q_ASSERT(m_animation->state() != QAbstractAnimation::Running);
        orientationChanged(m_nextTargetOrientation);
        m_nextTargetOrientation = Qt::PrimaryOrientation;
    }
}
void BrowserWindowMobile::setupDeclarativeEnvironment()
{
    QQmlContext* context = rootContext();
    context->setContextProperty("BrowserWindow", this);

    DatabaseManager* dbManager = DatabaseManager::instance();
    context->setContextProperty("HistoryModel", dbManager->historyDataBaseModel());
    context->setContextProperty("BookmarkModel", dbManager->bookmarkDataBaseModel());
    context->setContextProperty("TabsModel", new TabsModel(this));
    context->setContextProperty("UrlTools", new UrlTools(this));

    QObject::connect(engine(), SIGNAL(quit()), qApp, SLOT(quit()));

    setResizeMode(QQuickView::SizeRootObjectToView);
#if defined(SNOWSHOE_MEEGO_HARMATTAN)
    reportContentOrientationChange(Qt::PortraitOrientation);
    setSource(QUrl("qrc:///mobile/qml/main-harmattan.qml"));
#else
    setSource(QUrl("qrc:///mobile/qml/Main.qml"));
#endif
}
示例#3
0
PaintedWindow::PaintedWindow()
{
    QSurfaceFormat format;
    format.setStencilBufferSize(8);
    format.setSamples(4);

    setSurfaceType(QWindow::OpenGLSurface);
    setFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
    setFormat(format);

    create();

    m_context = new QOpenGLContext(this);
    m_context->setFormat(format);
    m_context->create();

    m_animation = new QPropertyAnimation(this, "rotation");
    m_animation->setStartValue(qreal(0));
    m_animation->setEndValue(qreal(1));
    m_animation->setDuration(500);

    QRect screenGeometry = screen()->availableGeometry();

    QPoint center = screenGeometry.center();
    QRect windowRect = screen()->isLandscape(screen()->orientation()) ? QRect(0, 0, 640, 480) : QRect(0, 0, 480, 640);
    setGeometry(QRect(center - windowRect.center(), windowRect.size()));

    m_rotation = 0;

    reportContentOrientationChange(screen()->orientation());

    m_targetOrientation = contentOrientation();
    m_nextTargetOrientation = Qt::PrimaryOrientation;

    connect(screen(), &QScreen::orientationChanged, this, &PaintedWindow::orientationChanged);
    connect(m_animation, &QAbstractAnimation::finished, this, &PaintedWindow::rotationDone);
    typedef void (PaintedWindow::*PaintedWindowVoidSlot)();
    connect(this, &PaintedWindow::rotationChanged,
            this, static_cast<PaintedWindowVoidSlot>(&PaintedWindow::paint));
}