qtmobility/plugins/multimedia/symbian/mmf/mediaplayer/s60videowidget.cpp
changeset 14 6fbed849b4f4
parent 11 06b8e2af4411
equal deleted inserted replaced
11:06b8e2af4411 14:6fbed849b4f4
    43 #ifdef USE_PRIVATE_QWIDGET_METHODS
    43 #ifdef USE_PRIVATE_QWIDGET_METHODS
    44 #include <QtGui/private/qwidget_p.h>
    44 #include <QtGui/private/qwidget_p.h>
    45 #endif
    45 #endif
    46 #include <QEvent>
    46 #include <QEvent>
    47 #include <coemain.h>    // For CCoeEnv
    47 #include <coemain.h>    // For CCoeEnv
       
    48 #include <coecntrl.h>   // For CCoeControl
       
    49 
       
    50 QAbstractVideoWidget::QAbstractVideoWidget(QWidget *parent)
       
    51     : QWidget(parent)
       
    52 {
       
    53 }
       
    54 
       
    55 QAbstractVideoWidget::~QAbstractVideoWidget()
       
    56 {
       
    57 }
       
    58 
       
    59 QBlackSurface::QBlackSurface(QWidget *parent)
       
    60     : QAbstractVideoWidget(parent)
       
    61 {
       
    62 #ifdef USE_PRIVATE_QWIDGET_METHODS
       
    63 #if QT_VERSION >= 0x040601 && !defined(__WINSCW__)
       
    64     qt_widget_private(this)->createExtra();
       
    65     qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::Disable;
       
    66 #endif
       
    67 #endif
       
    68     winId();
       
    69 }
       
    70 
       
    71 QBlackSurface::~QBlackSurface()
       
    72 {
       
    73 }
       
    74 
       
    75 void QBlackSurface::paintEvent(QPaintEvent *event)
       
    76 {
       
    77     Q_UNUSED(event);
       
    78     // Do nothing
       
    79 }
    48 
    80 
    49 QBlackWidget::QBlackWidget(QWidget *parent)
    81 QBlackWidget::QBlackWidget(QWidget *parent)
    50     : QWidget(parent)
    82     : QAbstractVideoWidget(parent)
    51 {
    83 {
    52     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    84     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    53     setAttribute(Qt::WA_OpaquePaintEvent, true);
    85     setAttribute(Qt::WA_OpaquePaintEvent, true);
    54     setAttribute(Qt::WA_NoSystemBackground, true);
    86     setAttribute(Qt::WA_NoSystemBackground, true);
    55     setAutoFillBackground(false);
    87     setAutoFillBackground(false);
    58 #if QT_VERSION >= 0x040601 && !defined(__WINSCW__)
    90 #if QT_VERSION >= 0x040601 && !defined(__WINSCW__)
    59     qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::ZeroFill;
    91     qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::ZeroFill;
    60     qt_widget_private(this)->extraData()->receiveNativePaintEvents = true;
    92     qt_widget_private(this)->extraData()->receiveNativePaintEvents = true;
    61 #endif
    93 #endif
    62 #endif
    94 #endif
       
    95     winId();
    63 }
    96 }
    64 
    97 
    65 QBlackWidget::~QBlackWidget()
    98 QBlackWidget::~QBlackWidget()
    66 {
    99 {
    67 }
   100 }
    86 S60VideoWidgetControl::S60VideoWidgetControl(QObject *parent)
   119 S60VideoWidgetControl::S60VideoWidgetControl(QObject *parent)
    87     : QVideoWidgetControl(parent)
   120     : QVideoWidgetControl(parent)
    88     , m_widget(0)
   121     , m_widget(0)
    89     , m_aspectRatioMode(Qt::KeepAspectRatio)
   122     , m_aspectRatioMode(Qt::KeepAspectRatio)
    90 {
   123 {
       
   124     initializeVideoOutput();
       
   125 }
       
   126 
       
   127 void S60VideoWidgetControl::initializeVideoOutput()
       
   128 {
       
   129 #ifdef MMF_VIDEO_SURFACES_SUPPORTED
       
   130     m_widget = new QBlackSurface();
       
   131 #else
    91     m_widget = new QBlackWidget();
   132     m_widget = new QBlackWidget();
    92     connect(m_widget, SIGNAL(beginVideoWindowNativePaint()), this, SIGNAL(beginVideoWindowNativePaint()));
   133     connect(m_widget, SIGNAL(beginVideoWindowNativePaint()), this, SIGNAL(beginVideoWindowNativePaint()));
    93     connect(m_widget, SIGNAL(endVideoWindowNativePaint()), this, SIGNAL(endVideoWindowNativePaint()));
   134     connect(m_widget, SIGNAL(endVideoWindowNativePaint()), this, SIGNAL(endVideoWindowNativePaint()));
       
   135 #endif
    94     m_widget->installEventFilter(this);
   136     m_widget->installEventFilter(this);
    95     m_widget->winId();
       
    96 }
   137 }
    97 
   138 
    98 S60VideoWidgetControl::~S60VideoWidgetControl()
   139 S60VideoWidgetControl::~S60VideoWidgetControl()
    99 {
   140 {
   100     delete m_widget;
       
   101 }
   141 }
   102 
   142 
   103 QWidget *S60VideoWidgetControl::videoWidget()
   143 QWidget *S60VideoWidgetControl::videoWidget()
   104 {
   144 {
   105     return m_widget;
   145     return m_widget;
   174     if (object == m_widget) {
   214     if (object == m_widget) {
   175         if (   e->type() == QEvent::Resize 
   215         if (   e->type() == QEvent::Resize 
   176             || e->type() == QEvent::Move 
   216             || e->type() == QEvent::Move 
   177             || e->type() == QEvent::WinIdChange
   217             || e->type() == QEvent::WinIdChange
   178             || e->type() == QEvent::ParentChange 
   218             || e->type() == QEvent::ParentChange 
   179             || e->type() == QEvent::Show) 
   219             || e->type() == QEvent::Show)
   180             emit widgetUpdated();
   220             emit widgetUpdated();
   181     }    
   221     }    
   182     return false;
   222     return false;
   183 }
   223 }
   184 
   224 
   191         return m_widget->effectiveWinId();
   231         return m_widget->effectiveWinId();
   192      
   232      
   193     return NULL;
   233     return NULL;
   194 }
   234 }
   195 
   235 
       
   236 QSize S60VideoWidgetControl::videoWidgetSize()
       
   237 {
       
   238     QSize result;
       
   239     RWindowBase *window = NULL;
       
   240     CCoeControl *control = videoWidgetWId();
       
   241     if (control)
       
   242         window = control->DrawableWindow();
       
   243     if (window) {
       
   244         const TSize size = window->Size();
       
   245         result = QSize(size.iWidth, size.iHeight);
       
   246     }
       
   247     return result;
       
   248 }
       
   249 
   196 void S60VideoWidgetControl::videoStateChanged(QMediaPlayer::State state)
   250 void S60VideoWidgetControl::videoStateChanged(QMediaPlayer::State state)
   197 {
   251 {
   198     if (state == QMediaPlayer::StoppedState) {
   252     if (state == QMediaPlayer::StoppedState) {
   199 #ifdef USE_PRIVATE_QWIDGET_METHODS
   253 #ifdef USE_PRIVATE_QWIDGET_METHODS
   200 #if QT_VERSION <= 0x040600 && !defined(FF_QT)
   254 #if QT_VERSION <= 0x040600 && !defined(FF_QT)
       
   255         qDebug()<<"S60VideoPlayerSession::videoStateChanged() - state == QMediaPlayer::StoppedState";
   201         qt_widget_private(m_widget)->extraData()->disableBlit = false;
   256         qt_widget_private(m_widget)->extraData()->disableBlit = false;
   202 #endif        
   257 #endif        
   203 #endif
   258 #endif
   204         m_widget->repaint();
   259         m_widget->repaint();
   205     } else if (state == QMediaPlayer::PlayingState) {
   260     } else if (state == QMediaPlayer::PlayingState) {
   206 #ifdef USE_PRIVATE_QWIDGET_METHODS
   261 #ifdef USE_PRIVATE_QWIDGET_METHODS
   207 #if QT_VERSION <= 0x040600 && !defined(FF_QT)       
   262 #if QT_VERSION <= 0x040600 && !defined(FF_QT)       
       
   263         qDebug()<<"S60VideoPlayerSession::videoStateChanged() - state == QMediaPlayer::PlayingState";
   208         qt_widget_private(m_widget)->extraData()->disableBlit = true;
   264         qt_widget_private(m_widget)->extraData()->disableBlit = true;
   209 #endif  
   265 #endif  
   210 #endif
   266 #endif
   211     }
   267     }
   212 }
   268 }