author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 28 Apr 2010 13:15:16 +0300 | |
branch | RCL_3 |
changeset 15 | b25b6dc3ff8b |
parent 3 | 41300fa6a67c |
permissions | -rw-r--r-- |
0 | 1 |
/* This file is part of the KDE project |
2 |
Copyright (C) 2005-2007 Matthias Kretz <kretz@kde.org> |
|
3 |
||
4 |
This library is free software; you can redistribute it and/or |
|
5 |
modify it under the terms of the GNU Lesser General Public |
|
6 |
License as published by the Free Software Foundation; either |
|
7 |
version 2.1 of the License, or (at your option) version 3, or any |
|
8 |
later version accepted by the membership of KDE e.V. (or its |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
9 |
successor approved by the membership of KDE e.V.), Nokia Corporation |
0 | 10 |
(or its successors, if any) and the KDE Free Qt Foundation, which shall |
11 |
act as a proxy defined in Section 6 of version 3 of the license. |
|
12 |
||
13 |
This library is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 |
Lesser General Public License for more details. |
|
17 |
||
18 |
You should have received a copy of the GNU Lesser General Public |
|
19 |
License along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
||
21 |
*/ |
|
22 |
||
23 |
#include "videowidget.h" |
|
24 |
#include "videowidget_p.h" |
|
25 |
#include "videowidgetinterface.h" |
|
26 |
#include "factory_p.h" |
|
27 |
#include "phonondefs_p.h" |
|
28 |
#include "phononnamespace_p.h" |
|
29 |
||
30 |
#include <QtGui/QAction> |
|
31 |
||
32 |
#define PHONON_INTERFACENAME VideoWidgetInterface |
|
33 |
||
34 |
QT_BEGIN_NAMESPACE |
|
35 |
||
36 |
#ifndef QT_NO_PHONON_VIDEO |
|
37 |
||
38 |
namespace Phonon |
|
39 |
{ |
|
40 |
||
41 |
VideoWidget::VideoWidget(QWidget *parent) |
|
42 |
: QWidget(parent) |
|
43 |
, Phonon::AbstractVideoOutput(*new VideoWidgetPrivate(this)) |
|
44 |
{ |
|
45 |
K_D(VideoWidget); |
|
46 |
d->init(); |
|
47 |
d->createBackendObject(); |
|
48 |
setMouseTracking(true); |
|
49 |
} |
|
50 |
||
51 |
VideoWidget::VideoWidget(VideoWidgetPrivate &dd, QWidget *parent) |
|
52 |
: QWidget(parent), |
|
53 |
Phonon::AbstractVideoOutput(dd) |
|
54 |
{ |
|
55 |
K_D(VideoWidget); |
|
56 |
d->init(); |
|
57 |
} |
|
58 |
||
59 |
void VideoWidgetPrivate::init() |
|
60 |
{ |
|
61 |
Q_Q(VideoWidget); |
|
62 |
changeFlags = q->windowFlags() & (Qt::SubWindow | Qt::Window); |
|
63 |
} |
|
64 |
||
65 |
void VideoWidget::mouseMoveEvent(QMouseEvent *e) |
|
66 |
{ |
|
67 |
QWidget::mouseMoveEvent(e); |
|
68 |
} |
|
69 |
||
70 |
void VideoWidgetPrivate::createBackendObject() |
|
71 |
{ |
|
72 |
if (m_backendObject) |
|
73 |
return; |
|
74 |
Q_Q(VideoWidget); |
|
75 |
m_backendObject = Factory::createVideoWidget(q); |
|
76 |
if (m_backendObject) { |
|
77 |
setupBackendObject(); |
|
78 |
} |
|
79 |
} |
|
80 |
||
81 |
#define PHONON_CLASSNAME VideoWidget |
|
82 |
||
83 |
PHONON_INTERFACE_GETTER(Phonon::VideoWidget::AspectRatio, aspectRatio, d->aspectRatio) |
|
84 |
PHONON_INTERFACE_SETTER(setAspectRatio, aspectRatio, Phonon::VideoWidget::AspectRatio) |
|
85 |
||
86 |
PHONON_INTERFACE_GETTER(Phonon::VideoWidget::ScaleMode, scaleMode, d->scaleMode) |
|
87 |
PHONON_INTERFACE_SETTER(setScaleMode, scaleMode, Phonon::VideoWidget::ScaleMode) |
|
88 |
||
89 |
PHONON_INTERFACE_GETTER(qreal, brightness, d->brightness) |
|
90 |
PHONON_INTERFACE_SETTER(setBrightness, brightness, qreal) |
|
91 |
||
92 |
PHONON_INTERFACE_GETTER(qreal, contrast, d->contrast) |
|
93 |
PHONON_INTERFACE_SETTER(setContrast, contrast, qreal) |
|
94 |
||
95 |
PHONON_INTERFACE_GETTER(qreal, hue, d->hue) |
|
96 |
PHONON_INTERFACE_SETTER(setHue, hue, qreal) |
|
97 |
||
98 |
PHONON_INTERFACE_GETTER(qreal, saturation, d->saturation) |
|
99 |
PHONON_INTERFACE_SETTER(setSaturation, saturation, qreal) |
|
100 |
||
101 |
void VideoWidget::setFullScreen(bool newFullScreen) |
|
102 |
{ |
|
103 |
pDebug() << Q_FUNC_INFO << newFullScreen; |
|
104 |
K_D(VideoWidget); |
|
105 |
// TODO: disable screensaver? or should we leave that responsibility to the |
|
106 |
// application? |
|
107 |
Qt::WindowFlags flags = windowFlags(); |
|
108 |
if (newFullScreen) { |
|
109 |
if (!isFullScreen()) { |
|
110 |
//we only update that value if it is not already fullscreen |
|
111 |
d->changeFlags = flags & (Qt::Window | Qt::SubWindow); |
|
112 |
flags |= Qt::Window; |
|
113 |
flags ^= Qt::SubWindow; |
|
114 |
setWindowFlags(flags); |
|
115 |
#ifdef Q_WS_X11 |
|
116 |
// This works around a bug with Compiz |
|
117 |
// as the window must be visible before we can set the state |
|
118 |
show(); |
|
119 |
raise(); |
|
120 |
setWindowState( windowState() | Qt::WindowFullScreen ); // set |
|
121 |
#else |
|
122 |
setWindowState( windowState() | Qt::WindowFullScreen ); // set |
|
123 |
show(); |
|
124 |
#endif |
|
125 |
} |
|
126 |
} else if (isFullScreen()) { |
|
127 |
flags ^= (Qt::Window | Qt::SubWindow); //clear the flags... |
|
128 |
flags |= d->changeFlags; //then we reset the flags (window and subwindow) |
|
129 |
setWindowFlags(flags); |
|
130 |
setWindowState( windowState() ^ Qt::WindowFullScreen ); // reset |
|
131 |
show(); |
|
132 |
} |
|
133 |
} |
|
134 |
||
135 |
void VideoWidget::exitFullScreen() |
|
136 |
{ |
|
137 |
setFullScreen(false); |
|
138 |
} |
|
139 |
||
140 |
void VideoWidget::enterFullScreen() |
|
141 |
{ |
|
142 |
setFullScreen(true); |
|
143 |
} |
|
144 |
||
145 |
bool VideoWidgetPrivate::aboutToDeleteBackendObject() |
|
146 |
{ |
|
147 |
aspectRatio = pINTERFACE_CALL(aspectRatio()); |
|
148 |
scaleMode = pINTERFACE_CALL(scaleMode()); |
|
149 |
return AbstractVideoOutputPrivate::aboutToDeleteBackendObject(); |
|
150 |
} |
|
151 |
||
152 |
void VideoWidgetPrivate::setupBackendObject() |
|
153 |
{ |
|
154 |
Q_Q(VideoWidget); |
|
155 |
Q_ASSERT(m_backendObject); |
|
156 |
//AbstractVideoOutputPrivate::setupBackendObject(); |
|
157 |
pDebug() << "calling setAspectRatio on the backend " << aspectRatio; |
|
158 |
pINTERFACE_CALL(setAspectRatio(aspectRatio)); |
|
159 |
pINTERFACE_CALL(setScaleMode(scaleMode)); |
|
160 |
||
161 |
QWidget *w = pINTERFACE_CALL(widget()); |
|
162 |
if (w) { |
|
163 |
layout.addWidget(w); |
|
164 |
q->setSizePolicy(w->sizePolicy()); |
|
165 |
w->setMouseTracking(true); |
|
166 |
} |
|
167 |
} |
|
168 |
||
169 |
bool VideoWidget::event(QEvent *e) |
|
170 |
{ |
|
171 |
return QWidget::event(e); |
|
172 |
} |
|
173 |
||
174 |
} //namespace Phonon |
|
175 |
||
176 |
#endif //QT_NO_PHONON_VIDEO |
|
177 |
||
178 |
QT_END_NAMESPACE |
|
179 |
||
180 |
#include "moc_videowidget.cpp" |
|
181 |
||
182 |
#undef PHONON_CLASSNAME |
|
183 |
// vim: sw=4 ts=4 tw=80 |