コード例 #1
0
bool
MozQOrientationSensorFilter::filter(QOrientationReading* reading)
{
    switch (reading->orientation()) {
    //The Top edge of the device is pointing up.
    case QOrientationReading::TopDown:
        mWindowRotationAngle = 90;
        break;
    //The Top edge of the device is pointing down.
    case QOrientationReading::TopUp:
        mWindowRotationAngle = 270;
        break;
    //The Left edge of the device is pointing up.
    case QOrientationReading::LeftUp:
        mWindowRotationAngle = 180;
        break;
    //The Right edge of the device is pointing up.
    case QOrientationReading::RightUp:
        mWindowRotationAngle = 0;
        break;
    //The Face of the device is pointing up.
    case QOrientationReading::FaceUp:
    //The Face of the device is pointing down.
    case QOrientationReading::FaceDown:
    //The orientation is unknown.
    case QOrientationReading::Undefined:
    default:
        return true;
    }

    mWindowRotationTransform = QTransform();
    mWindowRotationTransform.rotate(mWindowRotationAngle);

#ifdef MOZ_ENABLE_MEEGOTOUCH
    if (XRE_GetProcessType() == GoannaProcessType_Default) {
        MWindow* window = MApplication::activeWindow();
        if (window && window->sceneManager()) {
            window->sceneManager()->
                setOrientationAngle((M::OrientationAngle)mWindowRotationAngle,
                                    MSceneManager::ImmediateTransition);
        }
    }
#else
    Q_EMIT orientationChanged();
#endif

    return true; // don't store the reading in the sensor
}