File indexing completed on 2025-02-09 05:31:54
0001 /* This file is part of the KDE project 0002 Copyright (C) 2005-2007 Matthias Kretz <kretz@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Lesser General Public 0006 License as published by the Free Software Foundation; either 0007 version 2.1 of the License, or (at your option) version 3, or any 0008 later version accepted by the membership of KDE e.V. (or its 0009 successor approved by the membership of KDE e.V.), Nokia Corporation 0010 (or its successors, if any) and the KDE Free Qt Foundation, which shall 0011 act as a proxy defined in Section 6 of version 3 of the license. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Lesser General Public License for more details. 0017 0018 You should have received a copy of the GNU Lesser General Public 0019 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0020 0021 */ 0022 #ifndef Phonon_VIDEOWIDGET_H 0023 #define Phonon_VIDEOWIDGET_H 0024 0025 #include "phonon_export.h" 0026 #include "phonondefs.h" 0027 #include "abstractvideooutput.h" 0028 #include <QWidget> 0029 0030 0031 class QString; 0032 0033 #ifndef QT_NO_PHONON_VIDEO 0034 0035 namespace Phonon 0036 { 0037 class AbstractVideoOutput; 0038 class VideoWidgetPrivate; 0039 /** \class VideoWidget videowidget.h phonon/VideoWidget 0040 * \short Widget to display video. 0041 * 0042 * This widget shows the video signal. 0043 * 0044 * \code 0045 * MediaObject *media = new MediaObject(parent); 0046 * VideoWidget *vwidget = new VideoWidget(parent); 0047 * Phonon::createPath(media, vwidget); 0048 * \endcode 0049 * 0050 * \ingroup PhononVideo 0051 * \ingroup PhononWidgets 0052 * \author Matthias Kretz <kretz@kde.org> 0053 */ 0054 class PHONON_EXPORT VideoWidget : public QWidget, public Phonon::AbstractVideoOutput 0055 { 0056 P_DECLARE_PRIVATE(VideoWidget) 0057 Q_OBJECT 0058 Q_ENUMS(AspectRatio ScaleMode) 0059 /** 0060 * This property holds whether the video is shown using the complete 0061 * screen. 0062 * 0063 * The property differs from QWidget::fullScreen in that it is 0064 * writeable. 0065 * 0066 * By default the widget is not shown in fullScreen. 0067 * 0068 * \warning When switching the video to fullscreen using setFullScreen 0069 * your application loses control over the widget that actually shows 0070 * the video (which is then shown as a toplevel window while your 0071 * application still uses this widget). If you only need to capture key 0072 * events the event forwarding done internally should suffice for your 0073 * needs. If you need to map mouse coordinates or add widgets (that are 0074 * not overlays) you should probably handle fullscreen yourself. 0075 */ 0076 Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen) 0077 /** 0078 * 0079 * Defaults to AspectRatioAuto. 0080 * 0081 * \see AspectRatio 0082 */ 0083 Q_PROPERTY(AspectRatio aspectRatio READ aspectRatio WRITE setAspectRatio) 0084 0085 /** 0086 * If the size of the widget and the size of the video are not equal. 0087 * The video will be zoomed to fit the widget. The smaller zoom 0088 * (AddBarsScaleMode) adds black bars at the left/right or top/bottom to 0089 * make all of the image visible (default). The bigger zoom (ExpandMode) 0090 * fills the widget completely, keeping all information in one direction 0091 * and leaving parts of the image outside of the widget in the other 0092 * direction. 0093 */ 0094 Q_PROPERTY(ScaleMode scaleMode READ scaleMode WRITE setScaleMode) 0095 0096 /** 0097 * This property holds brightness of the video. 0098 * 0099 * Default is 0. Acceptable values are in range of -1, 1. 0100 */ 0101 Q_PROPERTY(qreal brightness READ brightness WRITE setBrightness) 0102 /** 0103 * This property holds the contrast of the video. 0104 * 0105 * Default is 0. Acceptable values are in range of -1, 1. 0106 */ 0107 Q_PROPERTY(qreal contrast READ contrast WRITE setContrast) 0108 /** 0109 * This property holds the hue of the video. 0110 * 0111 * Default is 0. Acceptable values are in range of -1, 1. 0112 */ 0113 Q_PROPERTY(qreal hue READ hue WRITE setHue) 0114 /** 0115 * This property holds saturation of the video. 0116 * 0117 * Default is 0. Acceptable values are in range of -1, 1. 0118 */ 0119 Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation) 0120 0121 public: 0122 /** 0123 * Defines the width:height to be used for the video. 0124 */ 0125 enum AspectRatio 0126 { 0127 /** 0128 * Let the decoder find the aspect ratio automatically from the 0129 * media file (this is the default). 0130 */ 0131 AspectRatioAuto = 0, 0132 /** 0133 * Fits the video into the widget making the aspect ratio depend 0134 * solely on the size of the widget. This way the aspect ratio 0135 * is freely resizeable by the user. 0136 */ 0137 AspectRatioWidget = 1, 0138 /** 0139 * Make width/height == 4/3, which is the old TV size and 0140 * monitor size (1024/768 == 4/3). (4:3) 0141 */ 0142 AspectRatio4_3 = 2, 0143 /** 0144 * Make width/height == 16/9, which is the size of most current 0145 * media. (16:9) 0146 */ 0147 AspectRatio16_9 = 3 0148 //X /** 0149 //X * Assume that every pixel of the video image needs to be displayed with the same 0150 //X * physical width and height. (1:1 image pixels, not imagewidth 0151 //X * = imageheight) 0152 //X */ 0153 //X AspectRatioSquare = 4, 0154 }; 0155 0156 enum ScaleMode { 0157 FitInView = 0, 0158 ScaleAndCrop = 1 0159 }; 0160 0161 /** 0162 * Constructs a new video widget with a \p parent. 0163 */ 0164 VideoWidget(QWidget *parent = nullptr); 0165 0166 AspectRatio aspectRatio() const; 0167 ScaleMode scaleMode() const; 0168 0169 qreal brightness() const; 0170 qreal contrast() const; 0171 qreal hue() const; 0172 qreal saturation() const; 0173 QImage snapshot() const; 0174 0175 //TODO: bar colors property 0176 public Q_SLOTS: 0177 void setFullScreen(bool fullscreen); 0178 0179 /** 0180 * Convenience slot, calling setFullScreen(false) 0181 */ 0182 void exitFullScreen(); 0183 0184 /** 0185 * Convenience slot, calling setFullScreen(true) 0186 */ 0187 void enterFullScreen(); 0188 0189 void setAspectRatio(AspectRatio); 0190 void setScaleMode(ScaleMode); 0191 0192 void setBrightness(qreal value); 0193 void setContrast(qreal value); 0194 void setHue(qreal value); 0195 void setSaturation(qreal value); 0196 0197 protected: 0198 /** 0199 * \internal 0200 * 0201 * Constructs a new video widget with private data pointer \p d and 0202 * a \p parent. 0203 */ 0204 VideoWidget(VideoWidgetPrivate &d, QWidget *parent); 0205 0206 void mouseMoveEvent(QMouseEvent *) override; 0207 bool event(QEvent *) override; 0208 }; 0209 0210 } //namespace Phonon 0211 0212 #endif //QT_NO_PHONON_VIDEO 0213 0214 0215 // vim: sw=4 ts=4 tw=80 0216 #endif // Phonon_VIDEOWIDGET_H