|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 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 |
|
49 QBlackWidget::QBlackWidget(QWidget *parent) |
|
50 : QWidget(parent) |
|
51 { |
|
52 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
53 setAttribute(Qt::WA_OpaquePaintEvent, true); |
|
54 setAttribute(Qt::WA_NoSystemBackground, true); |
|
55 setAutoFillBackground(false); |
|
56 setPalette(QPalette(Qt::black)); |
|
57 #ifdef USE_PRIVATE_QWIDGET_METHODS |
|
58 #if QT_VERSION >= 0x040601 && !defined(__WINSCW__) |
|
59 qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::ZeroFill; |
|
60 qt_widget_private(this)->extraData()->receiveNativePaintEvents = true; |
|
61 #endif |
|
62 #endif |
|
63 } |
|
64 |
|
65 QBlackWidget::~QBlackWidget() |
|
66 { |
|
67 } |
|
68 |
|
69 void QBlackWidget::beginNativePaintEvent(const QRect& /*controlRect*/) |
|
70 { |
|
71 emit beginVideoWindowNativePaint(); |
|
72 } |
|
73 |
|
74 void QBlackWidget::endNativePaintEvent(const QRect& /*controlRect*/) |
|
75 { |
|
76 CCoeEnv::Static()->WsSession().Flush(); |
|
77 emit endVideoWindowNativePaint(); |
|
78 } |
|
79 |
|
80 void QBlackWidget::paintEvent(QPaintEvent *event) |
|
81 { |
|
82 Q_UNUSED(event); |
|
83 // Do nothing |
|
84 } |
|
85 |
|
86 S60VideoWidgetControl::S60VideoWidgetControl(QObject *parent) |
|
87 : QVideoWidgetControl(parent) |
|
88 , m_widget(0) |
|
89 , m_aspectRatioMode(Qt::KeepAspectRatio) |
|
90 { |
|
91 m_widget = new QBlackWidget(); |
|
92 connect(m_widget, SIGNAL(beginVideoWindowNativePaint()), this, SIGNAL(beginVideoWindowNativePaint())); |
|
93 connect(m_widget, SIGNAL(endVideoWindowNativePaint()), this, SIGNAL(endVideoWindowNativePaint())); |
|
94 m_widget->installEventFilter(this); |
|
95 m_widget->winId(); |
|
96 } |
|
97 |
|
98 S60VideoWidgetControl::~S60VideoWidgetControl() |
|
99 { |
|
100 delete m_widget; |
|
101 } |
|
102 |
|
103 QWidget *S60VideoWidgetControl::videoWidget() |
|
104 { |
|
105 return m_widget; |
|
106 } |
|
107 |
|
108 Qt::AspectRatioMode S60VideoWidgetControl::aspectRatioMode() const |
|
109 { |
|
110 return m_aspectRatioMode; |
|
111 } |
|
112 |
|
113 void S60VideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode ratio) |
|
114 { |
|
115 if (m_aspectRatioMode == ratio) |
|
116 return; |
|
117 |
|
118 m_aspectRatioMode = ratio; |
|
119 emit widgetUpdated(); |
|
120 } |
|
121 |
|
122 bool S60VideoWidgetControl::isFullScreen() const |
|
123 { |
|
124 return m_widget->isFullScreen(); |
|
125 } |
|
126 |
|
127 void S60VideoWidgetControl::setFullScreen(bool fullScreen) |
|
128 { |
|
129 emit fullScreenChanged(fullScreen); |
|
130 } |
|
131 |
|
132 int S60VideoWidgetControl::brightness() const |
|
133 { |
|
134 return 0; |
|
135 } |
|
136 |
|
137 void S60VideoWidgetControl::setBrightness(int brightness) |
|
138 { |
|
139 Q_UNUSED(brightness); |
|
140 } |
|
141 |
|
142 int S60VideoWidgetControl::contrast() const |
|
143 { |
|
144 return 0; |
|
145 } |
|
146 |
|
147 void S60VideoWidgetControl::setContrast(int contrast) |
|
148 { |
|
149 Q_UNUSED(contrast); |
|
150 } |
|
151 |
|
152 int S60VideoWidgetControl::hue() const |
|
153 { |
|
154 return 0; |
|
155 } |
|
156 |
|
157 void S60VideoWidgetControl::setHue(int hue) |
|
158 { |
|
159 Q_UNUSED(hue); |
|
160 } |
|
161 |
|
162 int S60VideoWidgetControl::saturation() const |
|
163 { |
|
164 return 0; |
|
165 } |
|
166 |
|
167 void S60VideoWidgetControl::setSaturation(int saturation) |
|
168 { |
|
169 Q_UNUSED(saturation); |
|
170 } |
|
171 |
|
172 bool S60VideoWidgetControl::eventFilter(QObject *object, QEvent *e) |
|
173 { |
|
174 if (object == m_widget) { |
|
175 if ( e->type() == QEvent::Resize |
|
176 || e->type() == QEvent::Move |
|
177 || e->type() == QEvent::WinIdChange |
|
178 || e->type() == QEvent::ParentChange |
|
179 || e->type() == QEvent::Show) |
|
180 emit widgetUpdated(); |
|
181 } |
|
182 return false; |
|
183 } |
|
184 |
|
185 WId S60VideoWidgetControl::videoWidgetWId() |
|
186 { |
|
187 if (m_widget->internalWinId()) |
|
188 return m_widget->internalWinId(); |
|
189 |
|
190 if (m_widget->effectiveWinId()) |
|
191 return m_widget->effectiveWinId(); |
|
192 |
|
193 return NULL; |
|
194 } |
|
195 |
|
196 void S60VideoWidgetControl::videoStateChanged(QMediaPlayer::State state) |
|
197 { |
|
198 if (state == QMediaPlayer::StoppedState) { |
|
199 #ifdef USE_PRIVATE_QWIDGET_METHODS |
|
200 #if QT_VERSION <= 0x040600 && !defined(FF_QT) |
|
201 qt_widget_private(m_widget)->extraData()->disableBlit = false; |
|
202 #endif |
|
203 #endif |
|
204 m_widget->repaint(); |
|
205 } else if (state == QMediaPlayer::PlayingState) { |
|
206 #ifdef USE_PRIVATE_QWIDGET_METHODS |
|
207 #if QT_VERSION <= 0x040600 && !defined(FF_QT) |
|
208 qt_widget_private(m_widget)->extraData()->disableBlit = true; |
|
209 #endif |
|
210 #endif |
|
211 } |
|
212 } |