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 |
|
44 #include <QtGui/private/qwidget_p.h> |
|
45 |
|
46 class QBlackWidget : public QWidget |
|
47 { |
|
48 public: |
|
49 |
|
50 QBlackWidget(QWidget *parent = 0) |
|
51 : QWidget(parent) |
|
52 { |
|
53 setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); |
|
54 setAttribute(Qt::WA_OpaquePaintEvent, true); |
|
55 setAttribute(Qt::WA_NoSystemBackground, true); |
|
56 setAutoFillBackground(false); |
|
57 } |
|
58 |
|
59 protected: |
|
60 |
|
61 void paintEvent(QPaintEvent *) |
|
62 { |
|
63 if (!updatesEnabled()) |
|
64 return; |
|
65 |
|
66 QPainter painter(this); |
|
67 painter.fillRect(rect(), Qt::black); |
|
68 } |
|
69 }; |
|
70 |
|
71 S60VideoWidgetControl::S60VideoWidgetControl(QObject *parent) |
|
72 : QVideoWidgetControl(parent) |
|
73 , m_widget(0) |
|
74 , m_windowId(0) |
|
75 , m_aspectRatioMode(QVideoWidget::KeepAspectRatio) |
|
76 { |
|
77 m_widget = new QBlackWidget(); |
|
78 m_windowId = m_widget->winId(); |
|
79 m_widget->installEventFilter(this); |
|
80 } |
|
81 |
|
82 S60VideoWidgetControl::~S60VideoWidgetControl() |
|
83 { |
|
84 delete m_widget; |
|
85 } |
|
86 |
|
87 QWidget *S60VideoWidgetControl::videoWidget() |
|
88 { |
|
89 return m_widget; |
|
90 } |
|
91 |
|
92 QVideoWidget::AspectRatioMode S60VideoWidgetControl::aspectRatioMode() const |
|
93 { |
|
94 return m_aspectRatioMode; |
|
95 } |
|
96 |
|
97 void S60VideoWidgetControl::setAspectRatioMode(QVideoWidget::AspectRatioMode ratio) |
|
98 { |
|
99 if (m_aspectRatioMode != ratio) |
|
100 m_aspectRatioMode = ratio; |
|
101 } |
|
102 |
|
103 bool S60VideoWidgetControl::isFullScreen() const |
|
104 { |
|
105 return m_widget->isFullScreen(); |
|
106 } |
|
107 |
|
108 void S60VideoWidgetControl::setFullScreen(bool fullScreen) |
|
109 { |
|
110 emit fullScreenChanged(fullScreen); |
|
111 } |
|
112 |
|
113 int S60VideoWidgetControl::brightness() const |
|
114 { |
|
115 return 0; |
|
116 } |
|
117 |
|
118 void S60VideoWidgetControl::setBrightness(int brightness) |
|
119 { |
|
120 Q_UNUSED(brightness); |
|
121 } |
|
122 |
|
123 int S60VideoWidgetControl::contrast() const |
|
124 { |
|
125 return 0; |
|
126 } |
|
127 |
|
128 void S60VideoWidgetControl::setContrast(int contrast) |
|
129 { |
|
130 Q_UNUSED(contrast); |
|
131 } |
|
132 |
|
133 int S60VideoWidgetControl::hue() const |
|
134 { |
|
135 return 0; |
|
136 } |
|
137 |
|
138 void S60VideoWidgetControl::setHue(int hue) |
|
139 { |
|
140 Q_UNUSED(hue); |
|
141 } |
|
142 |
|
143 int S60VideoWidgetControl::saturation() const |
|
144 { |
|
145 return 0; |
|
146 } |
|
147 |
|
148 void S60VideoWidgetControl::setSaturation(int saturation) |
|
149 { |
|
150 Q_UNUSED(saturation); |
|
151 } |
|
152 |
|
153 bool S60VideoWidgetControl::eventFilter(QObject *object, QEvent *e) |
|
154 { |
|
155 if (object == m_widget) { |
|
156 if ((e->type() == QEvent::ParentChange || e->type() == QEvent::Show) && |
|
157 m_widget->winId() != m_windowId) { |
|
158 m_windowId = m_widget->winId(); |
|
159 emit widgetUpdated(); |
|
160 } |
|
161 |
|
162 if (e->type() == QEvent::Resize || e->type() == QEvent::Move) |
|
163 emit widgetUpdated(); |
|
164 } |
|
165 return QVideoWidgetControl::eventFilter(object, e); |
|
166 } |
|
167 |
|
168 void S60VideoWidgetControl::videoStateChanged(QMediaPlayer::State state) |
|
169 { |
|
170 if (state == QMediaPlayer::StoppedState) { |
|
171 qt_widget_private(m_widget)->extraData()->nativePaintMode = QWExtra::ZeroFill; |
|
172 m_widget->setUpdatesEnabled(true); |
|
173 m_widget->repaint(); |
|
174 } else if (state == QMediaPlayer::PlayingState) { |
|
175 qt_widget_private(m_widget)->extraData()->nativePaintMode = QWExtra::Default; |
|
176 m_widget->setUpdatesEnabled(false); |
|
177 } |
|
178 } |
|