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