|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "s60videowidget.h" |
|
43 #ifdef USE_PRIVATE_QWIDGET_METHODS |
|
44 #include <QtGui/private/qwidget_p.h> |
|
45 #endif |
|
46 #include <QEvent> |
|
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 } |
|
80 |
|
81 QBlackWidget::QBlackWidget(QWidget *parent) |
|
82 : QAbstractVideoWidget(parent) |
|
83 { |
|
84 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
85 setAttribute(Qt::WA_OpaquePaintEvent, true); |
|
86 setAttribute(Qt::WA_NoSystemBackground, true); |
|
87 setAutoFillBackground(false); |
|
88 setPalette(QPalette(Qt::black)); |
|
89 #ifdef USE_PRIVATE_QWIDGET_METHODS |
|
90 #if QT_VERSION >= 0x040601 && !defined(__WINSCW__) |
|
91 qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::ZeroFill; |
|
92 qt_widget_private(this)->extraData()->receiveNativePaintEvents = true; |
|
93 #endif |
|
94 #endif |
|
95 winId(); |
|
96 } |
|
97 |
|
98 QBlackWidget::~QBlackWidget() |
|
99 { |
|
100 } |
|
101 |
|
102 void QBlackWidget::beginNativePaintEvent(const QRect& /*controlRect*/) |
|
103 { |
|
104 emit beginVideoWindowNativePaint(); |
|
105 } |
|
106 |
|
107 void QBlackWidget::endNativePaintEvent(const QRect& /*controlRect*/) |
|
108 { |
|
109 CCoeEnv::Static()->WsSession().Flush(); |
|
110 emit endVideoWindowNativePaint(); |
|
111 } |
|
112 |
|
113 void QBlackWidget::paintEvent(QPaintEvent *event) |
|
114 { |
|
115 Q_UNUSED(event); |
|
116 // Do nothing |
|
117 } |
|
118 |
|
119 S60VideoWidgetControl::S60VideoWidgetControl(QObject *parent) |
|
120 : QVideoWidgetControl(parent) |
|
121 , m_widget(0) |
|
122 , m_aspectRatioMode(Qt::KeepAspectRatio) |
|
123 , m_fullScreenEnabled(0) |
|
124 { |
|
125 initializeVideoOutput(); |
|
126 } |
|
127 |
|
128 void S60VideoWidgetControl::initializeVideoOutput() |
|
129 { |
|
130 #ifdef MMF_VIDEO_SURFACES_SUPPORTED |
|
131 m_widget = new QBlackSurface(); |
|
132 #else |
|
133 m_widget = new QBlackWidget(); |
|
134 connect(m_widget, SIGNAL(beginVideoWindowNativePaint()), this, SIGNAL(beginVideoWindowNativePaint())); |
|
135 connect(m_widget, SIGNAL(endVideoWindowNativePaint()), this, SIGNAL(endVideoWindowNativePaint())); |
|
136 #endif |
|
137 m_widget->installEventFilter(this); |
|
138 } |
|
139 |
|
140 S60VideoWidgetControl::~S60VideoWidgetControl() |
|
141 { |
|
142 } |
|
143 |
|
144 QWidget *S60VideoWidgetControl::videoWidget() |
|
145 { |
|
146 return m_widget; |
|
147 } |
|
148 |
|
149 Qt::AspectRatioMode S60VideoWidgetControl::aspectRatioMode() const |
|
150 { |
|
151 return m_aspectRatioMode; |
|
152 } |
|
153 |
|
154 void S60VideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode ratio) |
|
155 { |
|
156 if (m_aspectRatioMode == ratio) |
|
157 return; |
|
158 |
|
159 m_aspectRatioMode = ratio; |
|
160 emit widgetUpdated(); |
|
161 } |
|
162 |
|
163 bool S60VideoWidgetControl::isFullScreen() const |
|
164 { |
|
165 return m_fullScreenEnabled; |
|
166 } |
|
167 |
|
168 void S60VideoWidgetControl::setFullScreen(bool fullScreen) |
|
169 { |
|
170 if (m_fullScreenEnabled == fullScreen) |
|
171 return; |
|
172 |
|
173 m_fullScreenEnabled = fullScreen; |
|
174 |
|
175 if (fullScreen && m_widget) |
|
176 m_widget->showFullScreen(); |
|
177 else if (m_widget) |
|
178 m_widget->showNormal(); |
|
179 |
|
180 emit fullScreenChanged(fullScreen); |
|
181 } |
|
182 |
|
183 int S60VideoWidgetControl::brightness() const |
|
184 { |
|
185 return 0; |
|
186 } |
|
187 |
|
188 void S60VideoWidgetControl::setBrightness(int brightness) |
|
189 { |
|
190 Q_UNUSED(brightness); |
|
191 } |
|
192 |
|
193 int S60VideoWidgetControl::contrast() const |
|
194 { |
|
195 return 0; |
|
196 } |
|
197 |
|
198 void S60VideoWidgetControl::setContrast(int contrast) |
|
199 { |
|
200 Q_UNUSED(contrast); |
|
201 } |
|
202 |
|
203 int S60VideoWidgetControl::hue() const |
|
204 { |
|
205 return 0; |
|
206 } |
|
207 |
|
208 void S60VideoWidgetControl::setHue(int hue) |
|
209 { |
|
210 Q_UNUSED(hue); |
|
211 } |
|
212 |
|
213 int S60VideoWidgetControl::saturation() const |
|
214 { |
|
215 return 0; |
|
216 } |
|
217 |
|
218 void S60VideoWidgetControl::setSaturation(int saturation) |
|
219 { |
|
220 Q_UNUSED(saturation); |
|
221 } |
|
222 |
|
223 bool S60VideoWidgetControl::eventFilter(QObject *object, QEvent *e) |
|
224 { |
|
225 if (object == m_widget) { |
|
226 if (e->type() == QEvent::WinIdChange |
|
227 || e->type() == QEvent::ParentChange |
|
228 || e->type() == QEvent::Show) { |
|
229 emit widgetUpdated(); |
|
230 } else if (e->type() == QEvent::Resize |
|
231 || e->type() == QEvent::Move) { |
|
232 #ifdef MMF_VIDEO_SURFACES_SUPPORTED |
|
233 emit widgetResized(); |
|
234 #else |
|
235 emit widgetUpdated(); |
|
236 #endif //MMF_VIDEO_SURFACES_SUPPORTED |
|
237 |
|
238 } |
|
239 } |
|
240 return false; |
|
241 } |
|
242 |
|
243 WId S60VideoWidgetControl::videoWidgetWId() |
|
244 { |
|
245 if (m_widget->internalWinId()) |
|
246 return m_widget->internalWinId(); |
|
247 |
|
248 if (m_widget->effectiveWinId()) |
|
249 return m_widget->effectiveWinId(); |
|
250 |
|
251 return NULL; |
|
252 } |
|
253 |
|
254 QSize S60VideoWidgetControl::videoWidgetSize() |
|
255 { |
|
256 QSize result; |
|
257 RWindowBase *window = NULL; |
|
258 CCoeControl *control = videoWidgetWId(); |
|
259 if (control) |
|
260 window = control->DrawableWindow(); |
|
261 if (window) { |
|
262 const TSize size = window->Size(); |
|
263 result = QSize(size.iWidth, size.iHeight); |
|
264 } |
|
265 return result; |
|
266 } |
|
267 |
|
268 void S60VideoWidgetControl::videoStateChanged(QMediaPlayer::State state) |
|
269 { |
|
270 if (state == QMediaPlayer::StoppedState) { |
|
271 #ifdef USE_PRIVATE_QWIDGET_METHODS |
|
272 #if QT_VERSION <= 0x040600 && !defined(FF_QT) |
|
273 qDebug()<<"S60VideoPlayerSession::videoStateChanged() - state == QMediaPlayer::StoppedState"; |
|
274 qt_widget_private(m_widget)->extraData()->disableBlit = false; |
|
275 #endif |
|
276 #endif |
|
277 m_widget->repaint(); |
|
278 } else if (state == QMediaPlayer::PlayingState) { |
|
279 #ifdef USE_PRIVATE_QWIDGET_METHODS |
|
280 #if QT_VERSION <= 0x040600 && !defined(FF_QT) |
|
281 qDebug()<<"S60VideoPlayerSession::videoStateChanged() - state == QMediaPlayer::PlayingState"; |
|
282 qt_widget_private(m_widget)->extraData()->disableBlit = true; |
|
283 #endif |
|
284 #endif |
|
285 } |
|
286 } |