diff options
author | Kurt Korbatits <kurt.korbatits@nokia.com> | 2010-06-16 05:08:43 (GMT) |
---|---|---|
committer | Kurt Korbatits <kurt.korbatits@nokia.com> | 2010-06-16 05:08:43 (GMT) |
commit | f2e1860147eaf42f82feeb4316f083ca0de879c9 (patch) | |
tree | 40b43a3a9942bc95b27df51127c863509dfb3f73 | |
parent | aa97c7b7a71ddaf3f01f312658b9a43428846aee (diff) | |
download | Qt-f2e1860147eaf42f82feeb4316f083ca0de879c9.zip Qt-f2e1860147eaf42f82feeb4316f083ca0de879c9.tar.gz Qt-f2e1860147eaf42f82feeb4316f083ca0de879c9.tar.bz2 |
VideoWidget example
Added file filters to videowidget and videographicsitem examples
to only allow supported file formats to be opened.
Task-number:QTBUG-702
Reviewed-by:Andrew den Exter
-rw-r--r-- | examples/multimedia/videographicsitem/videoplayer.cpp | 15 | ||||
-rw-r--r-- | examples/multimedia/videowidget/videoplayer.cpp | 15 |
2 files changed, 28 insertions, 2 deletions
diff --git a/examples/multimedia/videographicsitem/videoplayer.cpp b/examples/multimedia/videographicsitem/videoplayer.cpp index 4e1f5ca..a08cc57 100644 --- a/examples/multimedia/videographicsitem/videoplayer.cpp +++ b/examples/multimedia/videographicsitem/videoplayer.cpp @@ -116,7 +116,20 @@ VideoPlayer::~VideoPlayer() void VideoPlayer::openFile() { - QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie")); + QStringList supportedFormats; + foreach (QString fmt, QMovie::supportedFormats()) + supportedFormats << fmt; + foreach (QString fmt, QImageReader::supportedImageFormats()) + supportedFormats << fmt; + + QString filter = "Images ("; + foreach ( QString fmt, supportedFormats) { + filter.append(QString("*.%1 ").arg(fmt)); + } + filter.append(")"); + + QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"), + QDir::homePath(), filter); if (!fileName.isEmpty()) { videoItem->stop(); diff --git a/examples/multimedia/videowidget/videoplayer.cpp b/examples/multimedia/videowidget/videoplayer.cpp index 12d17cf..9d79b70 100644 --- a/examples/multimedia/videowidget/videoplayer.cpp +++ b/examples/multimedia/videowidget/videoplayer.cpp @@ -97,7 +97,20 @@ VideoPlayer::~VideoPlayer() void VideoPlayer::openFile() { - QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie")); + QStringList supportedFormats; + foreach (QString fmt, QMovie::supportedFormats()) + supportedFormats << fmt; + foreach (QString fmt, QImageReader::supportedImageFormats()) + supportedFormats << fmt; + + QString filter = "Images ("; + foreach ( QString fmt, supportedFormats) { + filter.append(QString("*.%1 ").arg(fmt)); + } + filter.append(")"); + + QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"), + QDir::homePath(), filter); if (!fileName.isEmpty()) { surface->stop(); |