diff options
author | Liang Qi <liang.qi@qt.io> | 2016-05-10 19:26:21 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-05-10 19:26:21 +0200 |
commit | 08e13bfcdb23eabfbc47bca7499b0b8aadce0ac7 (patch) | |
tree | 406ffa7e3ae0a346a14175ccccb8ac7e596d8f8f /examples | |
parent | fa9fe9ff8c3aba25fbae4f8f32588dd6477d6df8 (diff) | |
parent | f0e0d5d901d4e28fff9f29caf86ada84906b3db4 (diff) | |
download | qtmultimedia-08e13bfcdb23eabfbc47bca7499b0b8aadce0ac7.tar.gz |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
src/plugins/winrt/qwinrtcameracontrol.cpp
Change-Id: I45d3042adf19577a72794610fa1c310cb22e26c4
Diffstat (limited to 'examples')
10 files changed, 78 insertions, 22 deletions
diff --git a/examples/multimedia/declarative-camera/declarative-camera.pro b/examples/multimedia/declarative-camera/declarative-camera.pro index f977e1cb3..71d4f68b0 100644 --- a/examples/multimedia/declarative-camera/declarative-camera.pro +++ b/examples/multimedia/declarative-camera/declarative-camera.pro @@ -9,6 +9,3 @@ RESOURCES += declarative-camera.qrc target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/declarative-camera INSTALLS += target -winrt { - WINRT_MANIFEST.capabilities_device += webcam microphone -} diff --git a/examples/multimedia/spectrum/3rdparty/fftreal/fftreal.pro b/examples/multimedia/spectrum/3rdparty/fftreal/fftreal.pro index f6abeeb15..b2c96f96c 100644 --- a/examples/multimedia/spectrum/3rdparty/fftreal/fftreal.pro +++ b/examples/multimedia/spectrum/3rdparty/fftreal/fftreal.pro @@ -42,3 +42,4 @@ EXAMPLE_FILES = bwins/fftreal.def eabi/fftreal.def readme.txt license.txt target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/spectrum INSTALLS += target +CONFIG += install_ok # Do not cargo-cult this! diff --git a/examples/multimedia/spectrum/app/app.pro b/examples/multimedia/spectrum/app/app.pro index 8262372c4..76aa02cdf 100644 --- a/examples/multimedia/spectrum/app/app.pro +++ b/examples/multimedia/spectrum/app/app.pro @@ -57,6 +57,8 @@ RESOURCES = spectrum.qrc target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/spectrum INSTALLS += target +CONFIG += install_ok # Do not cargo-cult this! + # Deployment DESTDIR = ..$${spectrum_build_dir} diff --git a/examples/multimedia/spectrum/spectrum.pro b/examples/multimedia/spectrum/spectrum.pro index 81006a24c..0ca2ee554 100644 --- a/examples/multimedia/spectrum/spectrum.pro +++ b/examples/multimedia/spectrum/spectrum.pro @@ -10,3 +10,6 @@ SUBDIRS += app TARGET = spectrum +EXAMPLE_FILES += \ + README.txt \ + TODO.txt diff --git a/examples/multimedia/video/qmlvideo/qmlvideo.pro b/examples/multimedia/video/qmlvideo/qmlvideo.pro index 26865c59a..022835f12 100644 --- a/examples/multimedia/video/qmlvideo/qmlvideo.pro +++ b/examples/multimedia/video/qmlvideo/qmlvideo.pro @@ -16,3 +16,6 @@ include($$SNIPPETS_PATH/performancemonitor/performancemonitordeclarative.pri) target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/video/qmlvideo INSTALLS += target +EXAMPLE_FILES += \ + qmlvideo.png \ + qmlvideo.svg diff --git a/examples/multimedia/video/qmlvideofx/qmlvideofx.pro b/examples/multimedia/video/qmlvideofx/qmlvideofx.pro index 678ba4c97..097ad7516 100644 --- a/examples/multimedia/video/qmlvideofx/qmlvideofx.pro +++ b/examples/multimedia/video/qmlvideofx/qmlvideofx.pro @@ -14,3 +14,7 @@ target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/video/qmlvideofx INSTALLS += target QMAKE_INFO_PLIST = Info.plist + +EXAMPLE_FILES += \ + qmlvideofx.png \ + qmlvideofx.svg diff --git a/examples/multimedia/video/video.pro b/examples/multimedia/video/video.pro index 3127a4e49..f38cbc124 100644 --- a/examples/multimedia/video/video.pro +++ b/examples/multimedia/video/video.pro @@ -2,3 +2,6 @@ TEMPLATE = subdirs SUBDIRS += qmlvideo qmlvideofx +EXAMPLE_FILES += \ + qmlvideofilter_opencl \ # FIXME: this one should use a configure check instead + snippets diff --git a/examples/multimediawidgets/videowidget/main.cpp b/examples/multimediawidgets/videowidget/main.cpp index c9940e10e..fd726884b 100644 --- a/examples/multimediawidgets/videowidget/main.cpp +++ b/examples/multimediawidgets/videowidget/main.cpp @@ -41,13 +41,36 @@ #include "videoplayer.h" #include <QtWidgets/QApplication> +#include <QtWidgets/QDesktopWidget> +#include <QtCore/QCommandLineParser> +#include <QtCore/QCommandLineOption> +#include <QtCore/QDir> int main(int argc, char *argv[]) { QApplication app(argc, argv); + QCoreApplication::setApplicationName("Video Widget Example"); + QCoreApplication::setOrganizationName("QtProject"); + QGuiApplication::setApplicationDisplayName(QCoreApplication::applicationName()); + QCoreApplication::setApplicationVersion(QT_VERSION_STR); + QCommandLineParser parser; + parser.setApplicationDescription("Qt Video Widget Example"); + parser.addHelpOption(); + parser.addVersionOption(); + parser.addPositionalArgument("url", "The URL to open."); + parser.process(app); + VideoPlayer player; - player.resize(320, 240); + if (!parser.positionalArguments().isEmpty()) { + const QUrl url = + QUrl::fromUserInput(parser.positionalArguments().constFirst(), + QDir::currentPath(), QUrl::AssumeLocalFile); + player.setUrl(url); + } + + const QRect availableGeometry = QApplication::desktop()->availableGeometry(&player); + player.resize(availableGeometry.width() / 6, availableGeometry.height() / 4); player.show(); return app.exec(); diff --git a/examples/multimediawidgets/videowidget/videoplayer.cpp b/examples/multimediawidgets/videowidget/videoplayer.cpp index c3554ff04..8504746c4 100644 --- a/examples/multimediawidgets/videowidget/videoplayer.cpp +++ b/examples/multimediawidgets/videowidget/videoplayer.cpp @@ -54,20 +54,20 @@ VideoPlayer::VideoPlayer(QWidget *parent) QVideoWidget *videoWidget = new QVideoWidget; QAbstractButton *openButton = new QPushButton(tr("Open...")); - connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); + connect(openButton, &QAbstractButton::clicked, this, &VideoPlayer::openFile); playButton = new QPushButton; playButton->setEnabled(false); playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - connect(playButton, SIGNAL(clicked()), - this, SLOT(play())); + connect(playButton, &QAbstractButton::clicked, + this, &VideoPlayer::play); positionSlider = new QSlider(Qt::Horizontal); positionSlider->setRange(0, 0); - connect(positionSlider, SIGNAL(sliderMoved(int)), - this, SLOT(setPosition(int))); + connect(positionSlider, &QAbstractSlider::sliderMoved, + this, &VideoPlayer::setPosition); errorLabel = new QLabel; errorLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); @@ -86,11 +86,13 @@ VideoPlayer::VideoPlayer(QWidget *parent) setLayout(layout); mediaPlayer.setVideoOutput(videoWidget); - connect(&mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), - this, SLOT(mediaStateChanged(QMediaPlayer::State))); - connect(&mediaPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64))); - connect(&mediaPlayer, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64))); - connect(&mediaPlayer, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(handleError())); + connect(&mediaPlayer, &QMediaPlayer::stateChanged, + this, &VideoPlayer::mediaStateChanged); + connect(&mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged); + connect(&mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged); + typedef void (QMediaPlayer::*ErrorSignal)(QMediaPlayer::Error); + connect(&mediaPlayer, static_cast<ErrorSignal>(&QMediaPlayer::error), + this, &VideoPlayer::handleError); } VideoPlayer::~VideoPlayer() @@ -99,14 +101,23 @@ VideoPlayer::~VideoPlayer() void VideoPlayer::openFile() { - errorLabel->setText(""); - - QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"),QDir::homePath()); + QFileDialog fileDialog(this); + fileDialog.setAcceptMode(QFileDialog::AcceptOpen); + fileDialog.setWindowTitle(tr("Open Movie")); + QStringList supportedMimeTypes = mediaPlayer.supportedMimeTypes(); + if (!supportedMimeTypes.isEmpty()) + fileDialog.setMimeTypeFilters(supportedMimeTypes); + fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath())); + if (fileDialog.exec() == QDialog::Accepted) + setUrl(fileDialog.selectedUrls().constFirst()); +} - if (!fileName.isEmpty()) { - mediaPlayer.setMedia(QUrl::fromLocalFile(fileName)); - playButton->setEnabled(true); - } +void VideoPlayer::setUrl(const QUrl &url) +{ + errorLabel->setText(QString()); + setWindowFilePath(url.isLocalFile() ? url.toLocalFile() : QString()); + mediaPlayer.setMedia(url); + playButton->setEnabled(true); } void VideoPlayer::play() @@ -151,5 +162,11 @@ void VideoPlayer::setPosition(int position) void VideoPlayer::handleError() { playButton->setEnabled(false); - errorLabel->setText("Error: " + mediaPlayer.errorString()); + const QString errorString = mediaPlayer.errorString(); + QString message = "Error: "; + if (errorString.isEmpty()) + message += " #" + QString::number(int(mediaPlayer.error())); + else + message += errorString; + errorLabel->setText(message); } diff --git a/examples/multimediawidgets/videowidget/videoplayer.h b/examples/multimediawidgets/videowidget/videoplayer.h index 24589f542..f9f3b692b 100644 --- a/examples/multimediawidgets/videowidget/videoplayer.h +++ b/examples/multimediawidgets/videowidget/videoplayer.h @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE class QAbstractButton; class QSlider; class QLabel; +class QUrl; QT_END_NAMESPACE class VideoPlayer : public QWidget @@ -59,6 +60,8 @@ public: VideoPlayer(QWidget *parent = 0); ~VideoPlayer(); + void setUrl(const QUrl &url); + public slots: void openFile(); void play(); |