Пример #1
0
/*!
  Destructor.
*/
CameraKeyListener::~CameraKeyListener()
{
    if (!m_widget)
        return;

    // Get view's native Symbian window
    WId windowId = 0;

    if (m_widget->internalWinId())
        windowId = m_widget->internalWinId();
    else if (m_widget->parentWidget() && m_widget->effectiveWinId())
        windowId = m_widget->effectiveWinId();

    RWindowBase *window =
            windowId ? static_cast<RWindowBase*>(windowId->DrawableWindow())
                     : 0;

    // Get hold of the window group
    TInt wGroupId = window ? window->WindowGroupId() : 0;

    if (!wGroupId)
        return;

    RWsSession &wsSession = CCoeEnv::Static()->WsSession();
    TUint wGroupHandle = wsSession.GetWindowGroupHandle(wGroupId);

    if (wGroupHandle) {
        RWindowGroup wGroup(wsSession);
        wGroup.Construct(wGroupHandle);
        wGroup.CancelCaptureKey(EKeyCamera);
        wGroup.CancelCaptureKeyUpAndDowns(EKeyCamera);
    }
}
Пример #2
0
/*!
  Constructor, captures the HW camera (shutter) button events and directs them
  to the given widget. Note that the widget must be visible before this
  constructor is called.
*/
CameraKeyListener::CameraKeyListener(QWidget *widget)
    : QObject(widget),
      m_widget(widget)
{
    if (!m_widget) {
        return;
    }

    // Get view's native Symbian window
    WId windowId = 0;

    if (m_widget->internalWinId()) {
        windowId = m_widget->internalWinId();
    }
    else if (m_widget->parentWidget() && m_widget->effectiveWinId()) {
        windowId = m_widget->effectiveWinId();
    }

    RWindowBase *window =
            windowId ? static_cast<RWindowBase*>(windowId->DrawableWindow())
                     : 0;

    // Get hold of the window group
    TInt wGroupId = window ? window->WindowGroupId() : 0;
    if (!wGroupId) {
        return;
    }

    RWsSession &wsSession = CCoeEnv::Static()->WsSession();
    TUint wGroupHandle = wsSession.GetWindowGroupHandle(wGroupId);

    if (wGroupHandle) {
        RWindowGroup wGroup(wsSession);
        wGroup.Construct(wGroupHandle);

        TBool captureOK = ETrue;

        // Capture camera key, in Symbian Belle the key up and downs must
        // be also handled in order to prevent the native camera application
        // to start.
        captureOK = captureOK && (wGroup.CaptureKey(EKeyCamera, 0, 0, 100) > 0);
        captureOK = captureOK && (wGroup.CaptureKeyUpAndDowns(EStdKeyDevice7, 0, 0, 100) > 0);

        if (!captureOK)
            qWarning() << "Unable to register for camera capture key events, "
                       << "SwEvent capability may be missing";
    }
}
/*!
    Constructs the CVideoPlayerUtility2 object with given \a service and \a object.
    And Registers for Video Loading Notifications.
*/
S60VideoPlayerSession::S60VideoPlayerSession(QMediaService *service, S60MediaNetworkAccessControl *object)
    : S60MediaPlayerSession(service)
    , m_accessPointId(0)
    , m_wsSession(&CCoeEnv::Static()->WsSession())
    , m_screenDevice(CCoeEnv::Static()->ScreenDevice())
    , m_service(service)
    , m_player(0)
#ifndef VIDEOOUTPUT_GRAPHICS_SURFACES
    , m_dsaActive(false)
    , m_dsaStopped(false)
#endif
    , m_videoOutputControl(0)
    , m_videoOutputDisplay(0)
    , m_displayWindow(0)
#ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER
    , m_audioOutput(0)
#endif
    , m_audioEndpoint(DefaultAudioEndpoint)
    , m_pendingChanges(0)
    , m_backendInitiatedPause(false)
{
    DP0("S60VideoPlayerSession::S60VideoPlayerSession +++");

    m_networkAccessControl = object;
#ifdef VIDEOOUTPUT_GRAPHICS_SURFACES
    QT_TRAP_THROWING(m_player = CVideoPlayerUtility2::NewL(
                                    *this,
                                    0,
                                    EMdaPriorityPreferenceNone
                                ));
    m_player->RegisterForVideoLoadingNotification(*this);
#else
    RWindow *window = 0;
    QRect extentRect;
    QWidget *widget = QApplication::activeWindow();
    if (!widget)
        widget = QApplication::allWidgets().at(0);
    Q_ASSERT(widget);
    WId wid = widget->effectiveWinId();
    if (!wid)
        wid = widget->winId();
    window = static_cast<RWindow *>(wid->DrawableWindow());
    extentRect = QRect(widget->mapToGlobal(widget->pos()), widget->size());
    TRect clipRect = QRect2TRect(extentRect);
    const TRect desktopRect = QRect2TRect(QApplication::desktop()->screenGeometry());
    clipRect.Intersection(desktopRect);
    QT_TRAP_THROWING(m_player = CVideoPlayerUtility::NewL(
                                    *this,
                                    0,
                                    EMdaPriorityPreferenceNone,
                                    *m_wsSession,
                                    *m_screenDevice,
                                    *window,
                                    QRect2TRect(extentRect),
                                    clipRect));
    m_dsaActive = true;
    m_player->RegisterForVideoLoadingNotification(*this);
#endif // VIDEOOUTPUT_GRAPHICS_SURFACES
    S60VideoPlayerEventHandler::instance()->addApplicationFocusObserver(this);
    DP0("S60VideoPlayerSession::S60VideoPlayerSession ---");
}
Пример #4
0
void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool destroyOldWindow)
{
    Q_Q(QWidget);

    Qt::WindowType type = q->windowType();
    Qt::WindowFlags &flags = data.window_flags;
    QWidget *parentWidget = q->parentWidget();

    bool topLevel = (flags & Qt::Window);
    bool popup = (type == Qt::Popup);
    bool dialog = (type == Qt::Dialog
                   || type == Qt::Sheet
                   || (flags & Qt::MSWindowsFixedSizeDialogHint));
    bool desktop = (type == Qt::Desktop);
    //bool tool = (type == Qt::Tool || type == Qt::Drawer);

    if (popup)
        flags |= Qt::WindowStaysOnTopHint; // a popup stays on top

    TRect clientRect = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
    int sw = clientRect.Width();
    int sh = clientRect.Height();

    if (desktop) {
        TSize screenSize = S60->screenDevice()->SizeInPixels();
        data.crect.setRect(0, 0, screenSize.iWidth, screenSize.iHeight);
        q->setAttribute(Qt::WA_DontShowOnScreen);
    } else if (topLevel && !q->testAttribute(Qt::WA_Resized)){
        int width = sw;
        int height = sh;
        if (extra) {
            width = qMax(qMin(width, extra->maxw), extra->minw);
            height = qMax(qMin(height, extra->maxh), extra->minh);
        }
        data.crect.setSize(QSize(width, height));
    }

    CCoeControl *const destroyw = destroyOldWindow ? data.winid : 0;

    createExtra();
    if (window) {
        setWinId(window);
        TRect tr = window->Rect();
        data.crect.setRect(tr.iTl.iX, tr.iTl.iY, tr.Width(), tr.Height());

    } else if (topLevel) {
        if (!q->testAttribute(Qt::WA_Moved) && !q->testAttribute(Qt::WA_DontShowOnScreen))
            data.crect.moveTopLeft(QPoint(clientRect.iTl.iX, clientRect.iTl.iY));

        QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) );
        QT_TRAP_THROWING(control->ConstructL(true, desktop));
        control->SetMopParent(static_cast<CEikAppUi*>(S60->appUi()));

        // Symbian windows are always created in an inactive state
        // We perform this assignment for the case where the window is being re-created
        // as a result of a call to setParent_sys, on either this widget or one of its
        // ancestors.
        extra->activated = 0;

        if (!desktop) {
            TInt stackingFlags;
            if ((q->windowType() & Qt::Popup) == Qt::Popup) {
                stackingFlags = ECoeStackFlagRefusesAllKeys | ECoeStackFlagRefusesFocus;
            } else {
                stackingFlags = ECoeStackFlagStandard;
            }
            control->MakeVisible(false);
            QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control.data(), ECoeStackPriorityDefault, stackingFlags));
            // Avoid keyboard focus to a hidden window.
            control->setFocusSafely(false);

            RDrawableWindow *const drawableWindow = control->DrawableWindow();
            // Request mouse move events.
            drawableWindow->PointerFilter(EPointerFilterEnterExit
                | EPointerFilterMove | EPointerFilterDrag, 0);
            drawableWindow->EnableVisibilityChangeEvents();

        }

        q->setAttribute(Qt::WA_WState_Created);

        int x, y, w, h;
        data.crect.getRect(&x, &y, &w, &h);
        control->SetRect(TRect(TPoint(x, y), TSize(w, h)));

        // We wait until the control is fully constructed before calling setWinId, because
        // this generates a WinIdChanged event.
        setWinId(control.take());

        if (!desktop)
            s60UpdateIsOpaque(); // must be called after setWinId()

    } else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget

        QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) );
        QT_TRAP_THROWING(control->ConstructL(!parentWidget));

        // Symbian windows are always created in an inactive state
        // We perform this assignment for the case where the window is being re-created
        // as a result of a call to setParent_sys, on either this widget or one of its
        // ancestors.
        extra->activated = 0;

        TInt stackingFlags;
        if ((q->windowType() & Qt::Popup) == Qt::Popup) {
            stackingFlags = ECoeStackFlagRefusesAllKeys | ECoeStackFlagRefusesFocus;
        } else {
            stackingFlags = ECoeStackFlagStandard;
        }
        control->MakeVisible(false);
        QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control.data(), ECoeStackPriorityDefault, stackingFlags));
        // Avoid keyboard focus to a hidden window.
        control->setFocusSafely(false);

        q->setAttribute(Qt::WA_WState_Created);
        int x, y, w, h;
        data.crect.getRect(&x, &y, &w, &h);
        control->SetRect(TRect(TPoint(x, y), TSize(w, h)));

        RDrawableWindow *const drawableWindow = control->DrawableWindow();
        // Request mouse move events.
        drawableWindow->PointerFilter(EPointerFilterEnterExit
            | EPointerFilterMove | EPointerFilterDrag, 0);
        drawableWindow->EnableVisibilityChangeEvents();

        if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) {
            activateSymbianWindow(control.data());
            control->MakeVisible(true);
        }

        // We wait until the control is fully constructed before calling setWinId, because
        // this generates a WinIdChanged event.
        setWinId(control.take());
    }

    if (destroyw) {
        destroyw->ControlEnv()->AppUi()->RemoveFromStack(destroyw);

        // Delay deletion of the control in case this function is called in the
        // context of a CONE event handler such as
        // CCoeControl::ProcessPointerEventL
        QMetaObject::invokeMethod(q, "_q_delayedDestroy",
            Qt::QueuedConnection, Q_ARG(WId, destroyw));
    }

    if (q->testAttribute(Qt::WA_AcceptTouchEvents))
        registerTouchWindow();
}