Phonon

videowidget.h
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
9 successor approved by the membership of KDE e.V.), Nokia Corporation
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#ifndef Phonon_VIDEOWIDGET_H
23#define Phonon_VIDEOWIDGET_H
24
25#include "phonon_export.h"
26#include "phonondefs.h"
27#include "abstractvideooutput.h"
28#include <QWidget>
29
30
31class QString;
32
33#ifndef QT_NO_PHONON_VIDEO
34
35namespace Phonon
36{
37class AbstractVideoOutput;
38 class VideoWidgetPrivate;
39 /** \class VideoWidget videowidget.h phonon/VideoWidget
40 * \short Widget to display video.
41 *
42 * This widget shows the video signal.
43 *
44 * \code
45 * MediaObject *media = new MediaObject(parent);
46 * VideoWidget *vwidget = new VideoWidget(parent);
47 * Phonon::createPath(media, vwidget);
48 * \endcode
49 *
50 * \ingroup PhononVideo
51 * \ingroup PhononWidgets
52 * \author Matthias Kretz <kretz@kde.org>
53 */
54 class PHONON_EXPORT VideoWidget : public QWidget, public Phonon::AbstractVideoOutput
55 {
56 P_DECLARE_PRIVATE(VideoWidget)
57 Q_OBJECT
58 Q_ENUMS(AspectRatio ScaleMode)
59 /**
60 * This property holds whether the video is shown using the complete
61 * screen.
62 *
63 * The property differs from QWidget::fullScreen in that it is
64 * writeable.
65 *
66 * By default the widget is not shown in fullScreen.
67 *
68 * \warning When switching the video to fullscreen using setFullScreen
69 * your application loses control over the widget that actually shows
70 * the video (which is then shown as a toplevel window while your
71 * application still uses this widget). If you only need to capture key
72 * events the event forwarding done internally should suffice for your
73 * needs. If you need to map mouse coordinates or add widgets (that are
74 * not overlays) you should probably handle fullscreen yourself.
75 */
76 Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen)
77 /**
78 *
79 * Defaults to AspectRatioAuto.
80 *
81 * \see AspectRatio
82 */
83 Q_PROPERTY(AspectRatio aspectRatio READ aspectRatio WRITE setAspectRatio)
84
85 /**
86 * If the size of the widget and the size of the video are not equal.
87 * The video will be zoomed to fit the widget. The smaller zoom
88 * (AddBarsScaleMode) adds black bars at the left/right or top/bottom to
89 * make all of the image visible (default). The bigger zoom (ExpandMode)
90 * fills the widget completely, keeping all information in one direction
91 * and leaving parts of the image outside of the widget in the other
92 * direction.
93 */
94 Q_PROPERTY(ScaleMode scaleMode READ scaleMode WRITE setScaleMode)
95
96 /**
97 * This property holds brightness of the video.
98 *
99 * Default is 0. Acceptable values are in range of -1, 1.
100 */
101 Q_PROPERTY(qreal brightness READ brightness WRITE setBrightness)
102 /**
103 * This property holds the contrast of the video.
104 *
105 * Default is 0. Acceptable values are in range of -1, 1.
106 */
107 Q_PROPERTY(qreal contrast READ contrast WRITE setContrast)
108 /**
109 * This property holds the hue of the video.
110 *
111 * Default is 0. Acceptable values are in range of -1, 1.
112 */
113 Q_PROPERTY(qreal hue READ hue WRITE setHue)
114 /**
115 * This property holds saturation of the video.
116 *
117 * Default is 0. Acceptable values are in range of -1, 1.
118 */
119 Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation)
120
121 public:
122 /**
123 * Defines the width:height to be used for the video.
124 */
126 {
127 /**
128 * Let the decoder find the aspect ratio automatically from the
129 * media file (this is the default).
130 */
131 AspectRatioAuto = 0,
132 /**
133 * Fits the video into the widget making the aspect ratio depend
134 * solely on the size of the widget. This way the aspect ratio
135 * is freely resizeable by the user.
136 */
137 AspectRatioWidget = 1,
138 /**
139 * Make width/height == 4/3, which is the old TV size and
140 * monitor size (1024/768 == 4/3). (4:3)
141 */
142 AspectRatio4_3 = 2,
143 /**
144 * Make width/height == 16/9, which is the size of most current
145 * media. (16:9)
146 */
147 AspectRatio16_9 = 3
148//X /**
149//X * Assume that every pixel of the video image needs to be displayed with the same
150//X * physical width and height. (1:1 image pixels, not imagewidth
151//X * = imageheight)
152//X */
153//X AspectRatioSquare = 4,
154 };
155
156 enum ScaleMode {
157 FitInView = 0,
158 ScaleAndCrop = 1
159 };
160
161 /**
162 * Constructs a new video widget with a \p parent.
163 */
164 VideoWidget(QWidget *parent = nullptr);
165
166 AspectRatio aspectRatio() const;
167 ScaleMode scaleMode() const;
168
169 qreal brightness() const;
170 qreal contrast() const;
171 qreal hue() const;
172 qreal saturation() const;
173 QImage snapshot() const;
174
175 //TODO: bar colors property
176 public Q_SLOTS:
177 void setFullScreen(bool fullscreen);
178
179 /**
180 * Convenience slot, calling setFullScreen(false)
181 */
182 void exitFullScreen();
183
184 /**
185 * Convenience slot, calling setFullScreen(true)
186 */
187 void enterFullScreen();
188
189 void setAspectRatio(AspectRatio);
190 void setScaleMode(ScaleMode);
191
192 void setBrightness(qreal value);
193 void setContrast(qreal value);
194 void setHue(qreal value);
195 void setSaturation(qreal value);
196
197 protected:
198 /**
199 * \internal
200 *
201 * Constructs a new video widget with private data pointer \p d and
202 * a \p parent.
203 */
204 VideoWidget(VideoWidgetPrivate &d, QWidget *parent);
205
206 void mouseMoveEvent(QMouseEvent *) override;
207 bool event(QEvent *) override;
208 };
209
210} //namespace Phonon
211
212#endif //QT_NO_PHONON_VIDEO
213
214
215// vim: sw=4 ts=4 tw=80
216#endif // Phonon_VIDEOWIDGET_H
Common base class for all video outputs.
Widget to display video.
Definition videowidget.h:55
AspectRatio
Defines the width:height to be used for the video.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.