Remove QMediaImageViewer (SC break).

This class has turned out to be not very useful at this point in time.

Change-Id: Ic07132bdcd01a912a6dd1160c867979fd1307b6a
Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
Michael Goddard
2012-01-06 14:29:20 +10:00
committed by Qt by Nokia
parent 4bbe267f30
commit 78ffd1bc18
28 changed files with 3 additions and 3074 deletions

View File

@@ -1,75 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example slideshow
\title SlideShow Example
\image slideshow-img1.png
Slideshow displays a series of time delayed images after you select a
source image directory to use. The folder button presents a list of three
options: browse for a directory, load a playlist or enter a location.
This implementation uses a QMediaImageViewer object for the image with
a QVideoWidget used to do the display. Whether the the source is a
browsed directory, a playlist file or a URL to a local or remote
location the playlist object in Slideshow is updated with the file or
multiple file locations.
\code
connect(imageViewer, SIGNAL(stateChanged(QMediaImageViewer::State)),
this, SLOT(stateChanged(QMediaImageViewer::State)));
playlist = new QMediaPlaylist;
playlist->setMediaObject(imageViewer);
\endcode
We create a QVideoWidget to display the viewer and add it to the dialog.
\code
QVideoWidget *videoWidget = new QVideoWidget;
videoWidget->setMediaObject(imageViewer);
\endcode
\code
layout->addWidget(videoWidget, Qt::AlignCenter);
\endcode
The timeout between images is set by changing the timeout property in
QMediaImageViewer which is in milliseconds. So to change the timeout
to five seconds
\code
imageViewer->setTimeout( 5000 );
\endcode
*/

View File

@@ -46,8 +46,6 @@
#include "qmediaplaylist.h" #include "qmediaplaylist.h"
#include "qmediarecorder.h" #include "qmediarecorder.h"
#include "qmediaservice.h" #include "qmediaservice.h"
#include "qmediaimageviewer.h"
#include "qmediaimageviewer.h"
#include "qmediaplayercontrol.h" #include "qmediaplayercontrol.h"
#include "qmediaplayer.h" #include "qmediaplayer.h"
#include "qradiotuner.h" #include "qradiotuner.h"
@@ -59,7 +57,6 @@ class MediaExample : public QObject {
Q_OBJECT Q_OBJECT
void MediaControl(); void MediaControl();
void MediaImageViewer();
void MediaPlayer(); void MediaPlayer();
void RadioTuna(); void RadioTuna();
void MediaRecorder(); void MediaRecorder();
@@ -75,7 +72,6 @@ private:
QMediaPlaylist *playlist; QMediaPlaylist *playlist;
QMediaContent video; QMediaContent video;
QMediaRecorder *recorder; QMediaRecorder *recorder;
QMediaImageViewer *viewer;
QCamera *camera; QCamera *camera;
QCameraImageCapture *imageCapture; QCameraImageCapture *imageCapture;
QString fileName; QString fileName;
@@ -136,29 +132,6 @@ void MediaExample::ImageEncoderSettings()
//! [Image encoder settings] //! [Image encoder settings]
} }
void MediaExample::MediaImageViewer()
{
//! [Binding]
viewer = new QMediaImageViewer(this);
videoWidget = new QVideoWidget;
viewer->bind(videoWidget);
videoWidget->show();
//! [Binding]
//! [Playlist]
playlist = new QMediaPlaylist(this);
playlist->setPlaybackMode(QMediaPlaylist::Loop);
playlist->addMedia(image1);
playlist->addMedia(image2);
playlist->addMedia(image3);
viewer->setPlaylist(playlist);
viewer->setTimeout(5000);
viewer->play();
//! [Playlist]
}
void MediaExample::MediaPlayer() void MediaExample::MediaPlayer()
{ {
//! [Player] //! [Player]

View File

@@ -5,7 +5,6 @@ TEMPLATE = subdirs
SUBDIRS += \ SUBDIRS += \
radio \ radio \
camera \ camera \
slideshow \
spectrum \ spectrum \
audiorecorder \ audiorecorder \
audiodevices \ audiodevices \

View File

@@ -1,53 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "slideshow.h"
#include <QtWidgets>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
SlideShow slideShow;
slideShow.show();
return app.exec();
}

View File

@@ -1,215 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "slideshow.h"
#include <qmediaservice.h>
#include <qmediaplaylist.h>
#include <qvideowidget.h>
#include <QtWidgets>
SlideShow::SlideShow(QWidget *parent)
: QMainWindow(parent)
, imageViewer(0)
, playlist(0)
, statusLabel(0)
, countdownLabel(0)
, playAction(0)
, stopAction(0)
{
imageViewer = new QMediaImageViewer(this);
connect(imageViewer, SIGNAL(stateChanged(QMediaImageViewer::State)),
this, SLOT(stateChanged(QMediaImageViewer::State)));
connect(imageViewer, SIGNAL(mediaStatusChanged(QMediaImageViewer::MediaStatus)),
this, SLOT(statusChanged(QMediaImageViewer::MediaStatus)));
connect(imageViewer, SIGNAL(elapsedTimeChanged(int)), this, SLOT(elapsedTimeChanged(int)));
playlist = new QMediaPlaylist;
imageViewer->bind(playlist);
connect(playlist, SIGNAL(loaded()), this, SLOT(playlistLoaded()));
connect(playlist, SIGNAL(loadFailed()), this, SLOT(playlistLoadFailed()));
QVideoWidget *videoWidget = new QVideoWidget;
imageViewer->setVideoOutput(videoWidget);
menuBar()->addAction(tr("Open Directory..."), this, SLOT(openDirectory()));
menuBar()->addAction(tr("Open Playlist..."), this, SLOT(openPlaylist()));
toolBar = new QToolBar;
toolBar->setMovable(false);
toolBar->setFloatable(false);
toolBar->setEnabled(false);
toolBar->addAction(
style()->standardIcon(QStyle::SP_MediaSkipBackward),
tr("Previous"),
playlist,
SLOT(previous()));
stopAction = toolBar->addAction(
style()->standardIcon(QStyle::SP_MediaStop), tr("Stop"), imageViewer, SLOT(stop()));
playAction = toolBar->addAction(
style()->standardIcon(QStyle::SP_MediaPlay), tr("Play"), this, SLOT(play()));
toolBar->addAction(
style()->standardIcon(QStyle::SP_MediaSkipForward), tr("Next"), playlist, SLOT(next()));
addToolBar(Qt::BottomToolBarArea, toolBar);
statusLabel = new QLabel(tr("%1 Images").arg(0));
statusLabel->setAlignment(Qt::AlignCenter);
countdownLabel = new QLabel;
countdownLabel->setAlignment(Qt::AlignRight);
statusBar()->addPermanentWidget(statusLabel, 1);
statusBar()->addPermanentWidget(countdownLabel);
setCentralWidget(videoWidget);
}
void SlideShow::openPlaylist()
{
QString path = QFileDialog::getOpenFileName(this);
if (!path.isEmpty()) {
playlist->clear();
playlist->load(QUrl::fromLocalFile(path));
}
}
void SlideShow::openDirectory()
{
QString path = QFileDialog::getExistingDirectory(this);
if (!path.isEmpty()) {
playlist->clear();
QDir dir(path);
foreach (const QString &fileName, dir.entryList(QDir::Files))
playlist->addMedia(QUrl::fromLocalFile(dir.absoluteFilePath(fileName)));
statusChanged(imageViewer->mediaStatus());
toolBar->setEnabled(playlist->mediaCount() > 0);
}
}
void SlideShow::play()
{
switch (imageViewer->state()) {
case QMediaImageViewer::StoppedState:
case QMediaImageViewer::PausedState:
imageViewer->play();
break;
case QMediaImageViewer::PlayingState:
imageViewer->pause();
break;
}
}
void SlideShow::stateChanged(QMediaImageViewer::State state)
{
switch (state) {
case QMediaImageViewer::StoppedState:
stopAction->setEnabled(false);
playAction->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
break;
case QMediaImageViewer::PlayingState:
stopAction->setEnabled(true);
playAction->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
break;
case QMediaImageViewer::PausedState:
stopAction->setEnabled(true);
playAction->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
break;
}
}
void SlideShow::statusChanged(QMediaImageViewer::MediaStatus status)
{
switch (status) {
case QMediaImageViewer::NoMedia:
statusLabel->setText(tr("%1 Images").arg(playlist->mediaCount()));
break;
case QMediaImageViewer::LoadingMedia:
statusLabel->setText(tr("Image %1 of %2\nLoading...")
.arg(playlist->currentIndex())
.arg(playlist->mediaCount()));
break;
case QMediaImageViewer::LoadedMedia:
statusLabel->setText(tr("Image %1 of %2")
.arg(playlist->currentIndex())
.arg(playlist->mediaCount()));
break;
case QMediaImageViewer::InvalidMedia:
statusLabel->setText(tr("Image %1 of %2\nInvalid")
.arg(playlist->currentIndex())
.arg(playlist->mediaCount()));
break;
default:
break;
}
}
void SlideShow::playlistLoaded()
{
statusChanged(imageViewer->mediaStatus());
toolBar->setEnabled(playlist->mediaCount() > 0);
}
void SlideShow::playlistLoadFailed()
{
statusLabel->setText(playlist->errorString());
toolBar->setEnabled(false);
}
void SlideShow::elapsedTimeChanged(int time)
{
const int remaining = (imageViewer->timeout() - time) / 1000;
countdownLabel->setText(tr("%1:%2")
.arg(remaining / 60, 2, 10, QLatin1Char('0'))
.arg(remaining % 60, 2, 10, QLatin1Char('0')));
}

View File

@@ -1,87 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef SLIDESHOW_H
#define SLIDESHOW_H
#include <QMainWindow>
#include <qmediaimageviewer.h>
QT_BEGIN_NAMESPACE
class QAbstractButton;
class QLabel;
class QStackedLayout;
class QMediaPlaylist;
QT_END_NAMESPACE
QT_USE_NAMESPACE
class SlideShow : public QMainWindow
{
Q_OBJECT
public:
SlideShow(QWidget *parent = 0);
private slots:
void openPlaylist();
void openDirectory();
void play();
void stateChanged(QMediaImageViewer::State state);
void statusChanged(QMediaImageViewer::MediaStatus status);
void playlistLoaded();
void playlistLoadFailed();
void elapsedTimeChanged(int time);
private:
QMediaImageViewer *imageViewer;
QMediaPlaylist *playlist;
QLabel *statusLabel;
QLabel *countdownLabel;
QAction *playAction;
QAction *stopAction;
QToolBar *toolBar;
};
#endif

View File

@@ -1,19 +0,0 @@
TEMPLATE = app
TARGET = slideshow
QT += multimedia multimediawidgets
HEADERS = \
slideshow.h
SOURCES = \
main.cpp \
slideshow.cpp
target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/slideshow
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/slideshow
INSTALLS += target sources
QT+=widgets

View File

@@ -1,13 +0,0 @@
INCLUDEPATH += imageviewer
PUBLIC_HEADERS += \
imageviewer/qmediaimageviewer.h
PRIVATE_HEADERS += \
imageviewer/qmediaimageviewerservice_p.h
SOURCES += \
imageviewer/qmediaimageviewer.cpp \
imageviewer/qmediaimageviewerservice.cpp

View File

@@ -1,596 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qmediaimageviewer.h"
#include "qmediaobject_p.h"
#include "qmediaimageviewerservice_p.h"
#include <qmediaplaylist.h>
#include <qmediaplaylistsourcecontrol.h>
#include <qmediacontent.h>
#include <qmediaresource.h>
#include "qvideosurfaceoutput_p.h"
#include <QtCore/qcoreevent.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qpointer.h>
#include <QtCore/qtextstream.h>
QT_BEGIN_NAMESPACE
namespace
{
class QMediaImageViewerPrivateRegisterMetaTypes
{
public:
QMediaImageViewerPrivateRegisterMetaTypes()
{
qRegisterMetaType<QMediaImageViewer::MediaStatus>();
qRegisterMetaType<QMediaImageViewer::State>();
}
} _registerMetaTypes;
}
class QMediaImageViewerPrivate : public QMediaObjectPrivate
{
Q_DECLARE_NON_CONST_PUBLIC(QMediaImageViewer)
public:
QMediaImageViewerPrivate():
viewerControl(0), playlist(0),
state(QMediaImageViewer::StoppedState), timeout(3000), pauseTime(0)
{
}
void _q_mediaStatusChanged(QMediaImageViewer::MediaStatus status);
void _q_playlistMediaChanged(const QMediaContent &content);
void _q_playlistDestroyed();
QMediaImageViewerControl *viewerControl;
QMediaPlaylist *playlist;
QPointer<QObject> videoOutput;
QVideoSurfaceOutput surfaceOutput;
QMediaImageViewer::State state;
int timeout;
int pauseTime;
QTime time;
QBasicTimer timer;
QMediaContent media;
};
void QMediaImageViewerPrivate::_q_mediaStatusChanged(QMediaImageViewer::MediaStatus status)
{
switch (status) {
case QMediaImageViewer::NoMedia:
case QMediaImageViewer::LoadingMedia:
emit q_func()->mediaStatusChanged(status);
break;
case QMediaImageViewer::LoadedMedia:
if (state == QMediaImageViewer::PlayingState) {
time.start();
timer.start(qMax(0, timeout), q_func());
q_func()->addPropertyWatch("elapsedTime");
}
emit q_func()->mediaStatusChanged(status);
emit q_func()->elapsedTimeChanged(0);
break;
case QMediaImageViewer::InvalidMedia:
emit q_func()->mediaStatusChanged(status);
if (state == QMediaImageViewer::PlayingState) {
playlist->next();
if (playlist->currentIndex() < 0)
emit q_func()->stateChanged(state = QMediaImageViewer::StoppedState);
}
break;
}
}
void QMediaImageViewerPrivate::_q_playlistMediaChanged(const QMediaContent &content)
{
media = content;
pauseTime = 0;
viewerControl->showMedia(media);
emit q_func()->mediaChanged(media);
}
void QMediaImageViewerPrivate::_q_playlistDestroyed()
{
playlist = 0;
timer.stop();
if (state != QMediaImageViewer::StoppedState)
emit q_func()->stateChanged(state = QMediaImageViewer::StoppedState);
q_func()->setMedia(QMediaContent());
}
/*!
\class QMediaImageViewer
\brief The QMediaImageViewer class provides a means of viewing image media.
\inmodule QtMultimedia
\ingroup multimedia
QMediaImageViewer is used together with a media display object such as
QVideoWidget to present an image. A display object is attached to the
image viewer by means of the bind function.
\snippet doc/src/snippets/multimedia-snippets/media.cpp Binding
QMediaImageViewer can be paired with a QMediaPlaylist to create a slide
show of images. Constructing a QMediaPlaylist with a pointer to an
instance of QMediaImageViewer will attach it to the image viewer;
changing the playlist's selection will then change the media displayed
by the image viewer. With a playlist attached QMediaImageViewer's
play(), pause(), and stop() slots can be control the progression of the
playlist. The \l timeout property determines how long an image is
displayed for before progressing to the next in the playlist, and the
\l elapsedTime property holds how the duration the current image has
been displayed for.
\snippet doc/src/snippets/multimedia-snippets/media.cpp Playlist
*/
/*!
\enum QMediaImageViewer::State
Enumerates the possible control states an image viewer may be in. The
control state of an image viewer determines whether the image viewer is
automatically progressing through images in an attached playlist.
\value StoppedState The image viewer is stopped, and will not automatically move to the next
image. The \l elapsedTime is fixed at 0.
\value PlayingState The slide show is playing, and will move to the next image when the
\l elapsedTime reaches the \l timeout. The \l elapsedTime is being incremented.
\value PausedState The image viewer is paused, and will not automatically move the to next
image. The \l elapsedTime is fixed at the time the image viewer was paused.
*/
/*!
\enum QMediaImageViewer::MediaStatus
Enumerates the status of an image viewer's current media.
\value NoMedia There is no current media.
\value LoadingMedia The image viewer is loading the current media.
\value LoadedMedia The image viewer has loaded the current media.
\value InvalidMedia The current media cannot be loaded.
*/
/*!
Constructs a new image viewer with the given \a parent.
*/
QMediaImageViewer::QMediaImageViewer(QObject *parent)
: QMediaObject(*new QMediaImageViewerPrivate, parent, new QMediaImageViewerService)
{
Q_D(QMediaImageViewer);
d->viewerControl = qobject_cast<QMediaImageViewerControl*>(
d->service->requestControl(QMediaImageViewerControl_iid));
connect(d->viewerControl, SIGNAL(mediaStatusChanged(QMediaImageViewer::MediaStatus)),
this, SLOT(_q_mediaStatusChanged(QMediaImageViewer::MediaStatus)));
}
/*!
Destroys an image viewer.
*/
QMediaImageViewer::~QMediaImageViewer()
{
Q_D(QMediaImageViewer);
delete d->service;
}
/*!
\property QMediaImageViewer::state
\brief the playlist control state of a slide show.
*/
QMediaImageViewer::State QMediaImageViewer::state() const
{
return d_func()->state;
}
/*!
\fn QMediaImageViewer::stateChanged(QMediaImageViewer::State state)
Signals that the playlist control \a state of an image viewer has changed.
*/
/*!
\property QMediaImageViewer::mediaStatus
\brief the status of the current media.
*/
QMediaImageViewer::MediaStatus QMediaImageViewer::mediaStatus() const
{
return d_func()->viewerControl->mediaStatus();
}
/*!
\fn QMediaImageViewer::mediaStatusChanged(QMediaImageViewer::MediaStatus status)
Signals the the \a status of the current media has changed.
*/
/*!
\property QMediaImageViewer::media
\brief the media an image viewer is presenting.
*/
QMediaContent QMediaImageViewer::media() const
{
Q_D(const QMediaImageViewer);
return d->media;
}
void QMediaImageViewer::setMedia(const QMediaContent &media)
{
Q_D(QMediaImageViewer);
if (d->playlist && d->playlist->currentMedia() != media) {
disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)),
this, SLOT(_q_playlistMediaChanged(QMediaContent)));
disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed()));
d->playlist = 0;
}
d->media = media;
if (d->timer.isActive()) {
d->pauseTime = 0;
d->timer.stop();
removePropertyWatch("elapsedTime");
emit elapsedTimeChanged(0);
}
if (d->state != QMediaImageViewer::StoppedState)
emit stateChanged(d->state = QMediaImageViewer::StoppedState);
d->viewerControl->showMedia(d->media);
emit mediaChanged(d->media);
}
/*!
Use \a playlist as the source of images to be displayed in the viewer.
*/
void QMediaImageViewer::setPlaylist(QMediaPlaylist *playlist)
{
Q_D(QMediaImageViewer);
if (d->playlist) {
disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)),
this, SLOT(_q_playlistMediaChanged(QMediaContent)));
disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed()));
QMediaObject::unbind(d->playlist);
}
d->playlist = playlist;
if (d->playlist) {
connect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)),
this, SLOT(_q_playlistMediaChanged(QMediaContent)));
connect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed()));
QMediaObject::bind(d->playlist);
setMedia(d->playlist->currentMedia());
} else {
setMedia(QMediaContent());
}
}
/*!
Returns the current playlist, or 0 if none.
*/
QMediaPlaylist *QMediaImageViewer::playlist() const
{
return d_func()->playlist;
}
/*!
\fn QMediaImageViewer::mediaChanged(const QMediaContent &media)
Signals that the \a media an image viewer is presenting has changed.
*/
/*!
\property QMediaImageViewer::timeout
\brief the amount of time in milliseconds an image is displayed for before moving to the next
image.
The timeout only applies if the image viewer has a playlist attached and is in the PlayingState.
*/
int QMediaImageViewer::timeout() const
{
return d_func()->timeout;
}
void QMediaImageViewer::setTimeout(int timeout)
{
Q_D(QMediaImageViewer);
d->timeout = qMax(0, timeout);
if (d->timer.isActive())
d->timer.start(qMax(0, d->timeout - d->pauseTime - d->time.elapsed()), this);
}
/*!
\property QMediaImageViewer::elapsedTime
\brief the amount of time in milliseconds that has elapsed since the current image was loaded.
The elapsed time only increases while the image viewer is in the PlayingState. If stopped the
elapsed time will be reset to 0.
*/
int QMediaImageViewer::elapsedTime() const
{
Q_D(const QMediaImageViewer);
int elapsedTime = d->pauseTime;
if (d->timer.isActive())
elapsedTime += d->time.elapsed();
return elapsedTime;
}
/*!
\fn QMediaImageViewer::elapsedTimeChanged(int time)
Signals that the amount of \a time in milliseconds since the current
image was loaded has changed.
This signal is emitted at a regular interval when the image viewer is
in the PlayingState and an image is loaded. The notification interval
is controlled by the QMediaObject::notifyInterval property.
\sa timeout, QMediaObject::notifyInterval
*/
/*!
Sets a video \a widget as the current video output.
This will unbind any previous video output bound with setVideoOutput().
*/
void QMediaImageViewer::setVideoOutput(QVideoWidget *widget)
{
Q_D(QMediaImageViewer);
if (d->videoOutput)
unbind(d->videoOutput);
// We don't know (in this library) that QVideoWidget inherits QObject
QObject *widgetObject = reinterpret_cast<QObject*>(widget);
d->videoOutput = widgetObject && bind(widgetObject) ? widgetObject : 0;
}
/*!
Sets a video \a item as the current video output.
This will unbind any previous video output bound with setVideoOutput().
*/
void QMediaImageViewer::setVideoOutput(QGraphicsVideoItem *item)
{
Q_D(QMediaImageViewer);
if (d->videoOutput)
unbind(d->videoOutput);
// We don't know (in this library) that QGraphicsVideoItem (multiply) inherits QObject
// but QObject inheritance depends on QObject coming first, so try this out.
QObject *itemObject = reinterpret_cast<QObject*>(item);
d->videoOutput = itemObject && bind(itemObject) ? itemObject : 0;
}
/*!
Sets a video \a surface as the video output of a image viewer.
If a video output has already been set on the image viewer the new surface
will replace it.
*/
void QMediaImageViewer::setVideoOutput(QAbstractVideoSurface *surface)
{
Q_D(QMediaImageViewer);
d->surfaceOutput.setVideoSurface(surface);
if (d->videoOutput != &d->surfaceOutput) {
if (d->videoOutput)
unbind(d->videoOutput);
d->videoOutput = bind(&d->surfaceOutput) ? &d->surfaceOutput : 0;
}
}
/*!
\internal
*/
bool QMediaImageViewer::bind(QObject *object)
{
if (QMediaPlaylist *playlist = qobject_cast<QMediaPlaylist *>(object)) {
setPlaylist(playlist);
return true;
} else {
return QMediaObject::bind(object);
}
}
/*!
\internal
*/
void QMediaImageViewer::unbind(QObject *object)
{
if (object == d_func()->playlist)
setPlaylist(0);
else
QMediaObject::unbind(object);
}
/*!
Starts a slide show.
If the playlist has no current media this will start at the beginning of the playlist, otherwise
it will resume from the current media.
If no playlist is attached to an image viewer this will do nothing.
*/
void QMediaImageViewer::play()
{
Q_D(QMediaImageViewer);
if (d->playlist && d->playlist->mediaCount() > 0 && d->state != PlayingState) {
d->state = PlayingState;
switch (d->viewerControl->mediaStatus()) {
case NoMedia:
case InvalidMedia:
d->playlist->next();
if (d->playlist->currentIndex() < 0)
d->state = StoppedState;
break;
case LoadingMedia:
break;
case LoadedMedia:
d->time.start();
d->timer.start(qMax(0, d->timeout - d->pauseTime), this);
break;
}
if (d->state == PlayingState)
emit stateChanged(d->state);
}
}
/*!
Pauses a slide show.
The current media and elapsed time are retained. If resumed, the current image will be
displayed for the remainder of the time out period before the next image is loaded.
*/
void QMediaImageViewer::pause()
{
Q_D(QMediaImageViewer);
if (d->state == PlayingState) {
if (d->viewerControl->mediaStatus() == LoadedMedia) {
d->pauseTime += d->timeout - d->time.elapsed();
d->timer.stop();
removePropertyWatch("elapsedTime");
}
emit stateChanged(d->state = PausedState);
emit elapsedTimeChanged(d->pauseTime);
}
}
/*!
Stops a slide show.
The current media is retained, but the elapsed time is discarded. If resumed, the current
image will be displayed for the full time out period before the next image is loaded.
*/
void QMediaImageViewer::stop()
{
Q_D(QMediaImageViewer);
switch (d->state) {
case PlayingState:
d->timer.stop();
removePropertyWatch("elapsedTime");
// fall through.
case PausedState:
d->pauseTime = 0;
d->state = QMediaImageViewer::StoppedState;
emit stateChanged(d->state);
emit elapsedTimeChanged(0);
break;
case StoppedState:
break;
}
}
/*!
\reimp
\internal
*/
void QMediaImageViewer::timerEvent(QTimerEvent *event)
{
Q_D(QMediaImageViewer);
if (event->timerId() == d->timer.timerId()) {
d->timer.stop();
removePropertyWatch("elapsedTime");
emit elapsedTimeChanged(d->pauseTime = d->timeout);
d->playlist->next();
if (d->playlist->currentIndex() < 0) {
d->pauseTime = 0;
emit stateChanged(d->state = StoppedState);
emit elapsedTimeChanged(0);
}
} else {
QMediaObject::timerEvent(event);
}
}
#include "moc_qmediaimageviewer.cpp"
QT_END_NAMESPACE

View File

@@ -1,142 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QMEDIAIMAGEVIEWER_H
#define QMEDIAIMAGEVIEWER_H
#include "qmediaobject.h"
#include "qmediacontent.h"
#include <qmediaenumdebug.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Multimedia)
class QAbstractVideoSurface;
class QGraphicsVideoItem;
class QMediaPlaylist;
class QVideoWidget;
class QMediaImageViewerPrivate;
class Q_MULTIMEDIA_EXPORT QMediaImageViewer : public QMediaObject
{
Q_OBJECT
Q_PROPERTY(State state READ state NOTIFY stateChanged)
Q_PROPERTY(MediaStatus mediaStatus READ mediaStatus NOTIFY mediaStatusChanged)
Q_PROPERTY(QMediaContent media READ media WRITE setMedia NOTIFY mediaChanged)
Q_PROPERTY(int timeout READ timeout WRITE setTimeout)
Q_PROPERTY(int elapsedTime READ elapsedTime NOTIFY elapsedTimeChanged)
Q_ENUMS(State MediaStatus)
public:
enum State
{
StoppedState,
PlayingState,
PausedState
};
enum MediaStatus
{
NoMedia,
LoadingMedia,
LoadedMedia,
InvalidMedia
};
explicit QMediaImageViewer(QObject *parent = 0);
~QMediaImageViewer();
State state() const;
MediaStatus mediaStatus() const;
QMediaContent media() const;
QMediaPlaylist *playlist() const;
int timeout() const;
int elapsedTime() const;
void setVideoOutput(QVideoWidget *widget);
void setVideoOutput(QGraphicsVideoItem *item);
void setVideoOutput(QAbstractVideoSurface *surface);
bool bind(QObject *);
void unbind(QObject *);
public Q_SLOTS:
void setMedia(const QMediaContent &media);
void setPlaylist(QMediaPlaylist *playlist);
void play();
void pause();
void stop();
void setTimeout(int timeout);
Q_SIGNALS:
void stateChanged(QMediaImageViewer::State state);
void mediaStatusChanged(QMediaImageViewer::MediaStatus status);
void mediaChanged(const QMediaContent &media);
void elapsedTimeChanged(int time);
protected:
void timerEvent(QTimerEvent *event);
private:
Q_DECLARE_PRIVATE(QMediaImageViewer)
Q_PRIVATE_SLOT(d_func(), void _q_mediaStatusChanged(QMediaImageViewer::MediaStatus))
Q_PRIVATE_SLOT(d_func(), void _q_playlistMediaChanged(const QMediaContent &))
Q_PRIVATE_SLOT(d_func(), void _q_playlistDestroyed())
};
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QMediaImageViewer::State)
Q_DECLARE_METATYPE(QMediaImageViewer::MediaStatus)
Q_MEDIA_ENUM_DEBUG(QMediaImageViewer, State)
Q_MEDIA_ENUM_DEBUG(QMediaImageViewer, MediaStatus)
QT_END_HEADER
#endif

View File

@@ -1,458 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qmediaimageviewerservice_p.h"
#include "qmediacontrol_p.h"
#include "qmediaservice_p.h"
#include <qmediacontent.h>
#include <qmediaresource.h>
#include "qmediaobject_p.h"
#include <qvideorenderercontrol.h>
#include <QtCore/qdebug.h>
#include <QtCore/qurl.h>
#include <QtGui/qimagereader.h>
#include <QtNetwork/qnetworkaccessmanager.h>
#include <QtNetwork/qnetworkreply.h>
#include <QtNetwork/qnetworkrequest.h>
#include <qabstractvideosurface.h>
#include <qvideosurfaceformat.h>
QT_BEGIN_NAMESPACE
class QMediaImageViewerServicePrivate : public QMediaServicePrivate
{
public:
QMediaImageViewerServicePrivate()
: viewerControl(0)
, rendererControl(0)
, network(0)
, internalNetwork(0)
{
}
bool load(QIODevice *device);
void clear();
QMediaImageViewerControl *viewerControl;
QMediaImageViewerRenderer *rendererControl;
QNetworkAccessManager *network;
QNetworkAccessManager *internalNetwork;
QImage m_image;
};
QMediaImageViewerRenderer::QMediaImageViewerRenderer(QObject *parent)
: QVideoRendererControl(parent)
, m_surface(0)
{
}
QMediaImageViewerRenderer::~QMediaImageViewerRenderer()
{
if (m_surface)
m_surface->stop();
}
QAbstractVideoSurface *QMediaImageViewerRenderer::surface() const
{
return m_surface;
}
void QMediaImageViewerRenderer::setSurface(QAbstractVideoSurface *surface)
{
if (m_surface)
m_surface->stop();
m_surface = surface;
if (m_surface && !m_image.isNull())
showImage(m_image);
}
void QMediaImageViewerRenderer::showImage(const QImage &image)
{
m_image = image;
if (m_surface) {
if (m_image.isNull()) {
m_surface->stop();
} else {
QVideoSurfaceFormat format(
image.size(), QVideoFrame::pixelFormatFromImageFormat(image.format()));
if (!m_surface->isFormatSupported(format)) {
foreach (QVideoFrame::PixelFormat pixelFormat, m_surface->supportedPixelFormats()) {
const QImage::Format imageFormat
= QVideoFrame::imageFormatFromPixelFormat(pixelFormat);
if (imageFormat != QImage::Format_Invalid) {
format = QVideoSurfaceFormat(image.size(), pixelFormat);
if (m_surface->isFormatSupported(format) && m_surface->start(format)) {
m_image = image.convertToFormat(imageFormat);
m_surface->present(QVideoFrame(m_image));
return;
}
}
}
} else if (m_surface->start(format)) {
m_surface->present(QVideoFrame(image));
}
}
}
}
bool QMediaImageViewerServicePrivate::load(QIODevice *device)
{
QImageReader reader(device);
if (!reader.canRead()) {
m_image = QImage();
} else {
m_image = reader.read();
}
if (rendererControl)
rendererControl->showImage(m_image);
return !m_image.isNull();
}
void QMediaImageViewerServicePrivate::clear()
{
m_image = QImage();
if (rendererControl)
rendererControl->showImage(m_image);
}
/*!
\class QMediaImageViewerService
\internal
*/
/*!
*/
QMediaImageViewerService::QMediaImageViewerService(QObject *parent)
: QMediaService(*new QMediaImageViewerServicePrivate, parent)
{
Q_D(QMediaImageViewerService);
d->viewerControl = new QMediaImageViewerControl(this);
}
/*!
*/
QMediaImageViewerService::~QMediaImageViewerService()
{
Q_D(QMediaImageViewerService);
delete d->rendererControl;
delete d->viewerControl;
}
/*!
*/
QMediaControl *QMediaImageViewerService::requestControl(const char *name)
{
Q_D(QMediaImageViewerService);
if (qstrcmp(name, QMediaImageViewerControl_iid) == 0) {
return d->viewerControl;
} else if (qstrcmp(name, QVideoRendererControl_iid) == 0) {
if (!d->rendererControl) {
d->rendererControl = new QMediaImageViewerRenderer;
d->rendererControl->showImage(d->m_image);
return d->rendererControl;
}
}
return 0;
}
void QMediaImageViewerService::releaseControl(QMediaControl *control)
{
Q_D(QMediaImageViewerService);
if (!control) {
qWarning("QMediaService::releaseControl():"
" Attempted release of null control");
} else if (control == d->rendererControl) {
delete d->rendererControl;
d->rendererControl = 0;
}
}
/*!
*/
QNetworkAccessManager *QMediaImageViewerService::networkManager() const
{
Q_D(const QMediaImageViewerService);
if (!d->network) {
QMediaImageViewerServicePrivate *_d = const_cast<QMediaImageViewerServicePrivate *>(d);
if (!_d->internalNetwork)
_d->internalNetwork = new QNetworkAccessManager(
const_cast<QMediaImageViewerService *>(this));
_d->network = d->internalNetwork;
}
return d->network;
}
void QMediaImageViewerService::setNetworkManager(QNetworkAccessManager *manager)
{
d_func()->network = manager;
}
class QMediaImageViewerControlPrivate : public QMediaControlPrivate
{
Q_DECLARE_NON_CONST_PUBLIC(QMediaImageViewerControl)
public:
QMediaImageViewerControlPrivate()
: service(0)
, getReply(0)
, headReply(0)
, status(QMediaImageViewer::NoMedia)
{
foreach (const QByteArray &format, QImageReader::supportedImageFormats()) {
supportedExtensions.append(
QLatin1Char('.') + QString::fromLatin1(format.data(), format.size()));
}
}
bool isImageType(const QUrl &url, const QString &mimeType) const;
void loadImage();
void cancelRequests();
void _q_getFinished();
void _q_headFinished();
QMediaImageViewerService *service;
QNetworkReply *getReply;
QNetworkReply *headReply;
QMediaImageViewer::MediaStatus status;
QMediaContent media;
QMediaResource currentMedia;
QList<QMediaResource> possibleResources;
QStringList supportedExtensions;
};
bool QMediaImageViewerControlPrivate::isImageType(const QUrl &url, const QString &mimeType) const
{
if (!mimeType.isEmpty()) {
return mimeType.startsWith(QLatin1String("image/"))
|| mimeType == QLatin1String("application/xml+svg");
} else if (url.scheme() == QLatin1String("file")) {
QString path = url.path();
foreach (const QString &extension, supportedExtensions) {
if (path.endsWith(extension, Qt::CaseInsensitive))
return true;
}
}
return false;
}
void QMediaImageViewerControlPrivate::loadImage()
{
cancelRequests();
QMediaImageViewer::MediaStatus currentStatus = status;
status = QMediaImageViewer::InvalidMedia;
QNetworkAccessManager *network = service->networkManager();
while (!possibleResources.isEmpty() && !headReply && !getReply) {
currentMedia = possibleResources.takeFirst();
QUrl url = currentMedia.url();
QString mimeType = currentMedia.mimeType();
if (isImageType(url, mimeType)) {
getReply = network->get(QNetworkRequest(url));
QObject::connect(getReply, SIGNAL(finished()), q_func(), SLOT(_q_getFinished()));
status = QMediaImageViewer::LoadingMedia;
} else if (mimeType.isEmpty() && url.scheme() != QLatin1String("file")) {
headReply = network->head(QNetworkRequest(currentMedia.url()));
QObject::connect(headReply, SIGNAL(finished()), q_func(), SLOT(_q_headFinished()));
status = QMediaImageViewer::LoadingMedia;
}
}
if (status == QMediaImageViewer::InvalidMedia)
currentMedia = QMediaResource();
if (status != currentStatus)
emit q_func()->mediaStatusChanged(status);
}
void QMediaImageViewerControlPrivate::cancelRequests()
{
if (getReply) {
getReply->abort();
getReply->deleteLater();
getReply = 0;
}
if (headReply) {
headReply->abort();
headReply->deleteLater();
headReply = 0;
}
}
void QMediaImageViewerControlPrivate::_q_getFinished()
{
if (getReply != q_func()->sender())
return;
QImage image;
if (service->d_func()->load(getReply)) {
possibleResources.clear();
status = QMediaImageViewer::LoadedMedia;
emit q_func()->mediaStatusChanged(status);
} else {
loadImage();
}
}
void QMediaImageViewerControlPrivate::_q_headFinished()
{
if (headReply != q_func()->sender())
return;
QString mimeType = headReply->header(QNetworkRequest::ContentTypeHeader)
.toString().section(QLatin1Char(';'), 0, 0);
QUrl url = headReply->url();
if (url.isEmpty())
url = headReply->request().url();
headReply->deleteLater();
headReply = 0;
if (isImageType(url, mimeType) || mimeType.isEmpty()) {
QNetworkAccessManager *network = service->networkManager();
getReply = network->get(QNetworkRequest(url));
QObject::connect(getReply, SIGNAL(finished()), q_func(), SLOT(_q_getFinished()));
} else {
loadImage();
}
}
/*!
\class QMediaImageViewerControl
\internal
*/
QMediaImageViewerControl::QMediaImageViewerControl(QMediaImageViewerService *parent)
: QMediaControl(*new QMediaImageViewerControlPrivate, parent)
{
Q_D(QMediaImageViewerControl);
d->service = parent;
}
/*!
*/
QMediaImageViewerControl::~QMediaImageViewerControl()
{
Q_D(QMediaImageViewerControl);
delete d->getReply;
}
/*!
*/
QMediaImageViewer::MediaStatus QMediaImageViewerControl::mediaStatus() const
{
return d_func()->status;
}
/*!
\fn QMediaImageViewerControl::mediaStatusChanged(QMediaImageViewer::MediaStatus status);
*/
/*!
*/
void QMediaImageViewerControl::showMedia(const QMediaContent &media)
{
Q_D(QMediaImageViewerControl);
d->media = media;
d->currentMedia = QMediaResource();
d->cancelRequests();
if (media.isNull()) {
d->service->d_func()->clear();
if (d->status != QMediaImageViewer::NoMedia) {
d->status = QMediaImageViewer::NoMedia;
emit mediaStatusChanged(d->status);
}
} else {
d->possibleResources = media.resources();
d->loadImage();
}
}
#include "moc_qmediaimageviewerservice_p.cpp"
QT_END_NAMESPACE

View File

@@ -1,147 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QMEDIASLIDESHOWSERVICE_P_H
#define QMEDIASLIDESHOWSERVICE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <qtmultimediadefs.h>
#include <qmediaservice.h>
#include <qmediaimageviewer.h>
#include <qvideorenderercontrol.h>
#include <QtCore/qpointer.h>
#include <QtGui/qimage.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Multimedia)
class QAbstractVideoSurface;
class QNetworkAccessManager;
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
class QMediaImageViewerServicePrivate;
class Q_AUTOTEST_EXPORT QMediaImageViewerService : public QMediaService
{
Q_OBJECT
public:
explicit QMediaImageViewerService(QObject *parent = 0);
~QMediaImageViewerService();
QMediaControl *requestControl(const char *name);
void releaseControl(QMediaControl *);
QNetworkAccessManager *networkManager() const;
void setNetworkManager(QNetworkAccessManager *manager);
private:
Q_DECLARE_PRIVATE(QMediaImageViewerService)
friend class QMediaImageViewerControl;
friend class QMediaImageViewerControlPrivate;
};
class QMediaImageViewerControlPrivate;
class QMediaImageViewerControl : public QMediaControl
{
Q_OBJECT
public:
explicit QMediaImageViewerControl(QMediaImageViewerService *parent);
~QMediaImageViewerControl();
QMediaImageViewer::MediaStatus mediaStatus() const;
void showMedia(const QMediaContent &media);
Q_SIGNALS:
void mediaStatusChanged(QMediaImageViewer::MediaStatus status);
private:
Q_DECLARE_PRIVATE(QMediaImageViewerControl)
Q_PRIVATE_SLOT(d_func(), void _q_headFinished())
Q_PRIVATE_SLOT(d_func(), void _q_getFinished())
};
#define QMediaImageViewerControl_iid "com.nokia.Qt.QMediaImageViewerControl/1.0"
Q_MEDIA_DECLARE_CONTROL(QMediaImageViewerControl, QMediaImageViewerControl_iid)
class QMediaImageViewerRenderer : public QVideoRendererControl
{
Q_OBJECT
public:
QMediaImageViewerRenderer(QObject *parent = 0);
~QMediaImageViewerRenderer();
QAbstractVideoSurface *surface() const;
void setSurface(QAbstractVideoSurface *surface);
void showImage(const QImage &image);
Q_SIGNALS:
void surfaceChanged(QAbstractVideoSurface *surface);
private:
QPointer<QAbstractVideoSurface> m_surface;
QImage m_image;
};
QT_END_NAMESPACE
QT_END_HEADER
#endif

View File

@@ -52,7 +52,6 @@ SOURCES += \
include(audio/audio.pri) include(audio/audio.pri)
include(camera/camera.pri) include(camera/camera.pri)
include(controls/controls.pri) include(controls/controls.pri)
include(imageviewer/imageviewer.pri)
include(playback/playback.pri) include(playback/playback.pri)
include(radio/radio.pri) include(radio/radio.pri)
include(recording/recording.pri) include(recording/recording.pri)

View File

@@ -85,7 +85,7 @@ namespace
\brief The QMediaPlaylist class provides a list of media content to play. \brief The QMediaPlaylist class provides a list of media content to play.
QMediaPlaylist is intended to be used with other media objects, QMediaPlaylist is intended to be used with other media objects,
like QMediaPlayer or QMediaImageViewer. like QMediaPlayer.
QMediaPlaylist allows to access the service intrinsic playlist functionality QMediaPlaylist allows to access the service intrinsic playlist functionality
if available, otherwise it provides the the local memory playlist implementation. if available, otherwise it provides the the local memory playlist implementation.

View File

@@ -34,6 +34,5 @@ SUBDIRS += \
# these interfaces are exported. # these interfaces are exported.
contains (QT_CONFIG, private_tests) { contains (QT_CONFIG, private_tests) {
SUBDIRS += \ SUBDIRS += \
qdeclarativeaudio \ qdeclarativeaudio
qmediaimageviewer
} }

View File

@@ -11,7 +11,6 @@ contains (QT_CONFIG, private_tests) {
SUBDIRS += \ SUBDIRS += \
qgraphicsvideoitem \ qgraphicsvideoitem \
qpaintervideosurface \ qpaintervideosurface \
qmediaimageviewerwidgets \ qvideowidget
qvideowidget \
} }

View File

@@ -1,9 +0,0 @@
<RCC>
<qresource prefix="/">
<file>images/coverart.png</file>
<file>images/image.jpg</file>
<file>images/image.png</file>
<file>images/invalid.png</file>
<file>images/poster.png</file>
</qresource>
</RCC>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

View File

@@ -1,2 +0,0 @@
This is not really a PNG file.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

View File

@@ -1,16 +0,0 @@
CONFIG += testcase
TARGET = tst_qmediaimageviewer
QT += multimedia-private network testlib
CONFIG += no_private_qt_headers_warning
SOURCES += tst_qmediaimageviewer.cpp
RESOURCES += \
images.qrc
!contains(QT_CONFIG, no-jpeg):DEFINES += QTEST_HAVE_JPEG
wince* {
!contains(QT_CONFIG, no-jpeg): DEPLOYMENT_PLUGIN += qjpeg
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>images/image.png</file>
</qresource>
</RCC>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

View File

@@ -1,17 +0,0 @@
CONFIG += testcase
TARGET = tst_qmediaimageviewerwidgets
QT += multimedia-private multimediawidgets-private network testlib
CONFIG += no_private_qt_headers_warning
SOURCES += tst_qmediaimageviewerwidgets.cpp
RESOURCES += \
images.qrc
!contains(QT_CONFIG, no-jpeg):DEFINES += QTEST_HAVE_JPEG
wince* {
!contains(QT_CONFIG, no-jpeg): DEPLOYMENT_PLUGIN += qjpeg
}
QT+=widgets

View File

@@ -1,142 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
//TESTED_COMPONENT=src/multimedia
#include <qtmultimediadefs.h>
#include <QtTest/QtTest>
#include <QtCore/qdir.h>
#include <qgraphicsvideoitem.h>
#include <qmediaimageviewer.h>
#include <private/qmediaimageviewerservice_p.h>
#include <qmediaplaylist.h>
#include <qmediaservice.h>
#include <qvideorenderercontrol.h>
#include <qvideowidget.h>
#include <qvideowidgetcontrol.h>
#include <qabstractvideosurface.h>
#include <qvideosurfaceformat.h>
QT_USE_NAMESPACE
class tst_QMediaImageViewerWidgets : public QObject
{
Q_OBJECT
private slots:
void setVideoOutput();
};
class QtTestVideoSurface : public QAbstractVideoSurface
{
public:
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
QAbstractVideoBuffer::HandleType handleType) const {
QList<QVideoFrame::PixelFormat> formats;
if (handleType == QAbstractVideoBuffer::NoHandle) {
formats << QVideoFrame::Format_RGB32;
}
return formats;
}
QVideoFrame frame() const { return m_frame; }
bool present(const QVideoFrame &frame) { m_frame = frame; return true; }
private:
QVideoFrame m_frame;
};
void tst_QMediaImageViewerWidgets::setVideoOutput()
{
QMediaImageViewer imageViewer;
imageViewer.setMedia(QMediaContent(QUrl("qrc:///images/image.png")));
connect(&imageViewer, SIGNAL(mediaStatusChanged(QMediaImageViewer::MediaStatus)),
&QTestEventLoop::instance(), SLOT(exitLoop()));
QTestEventLoop::instance().enterLoop(2);
if (imageViewer.mediaStatus() != QMediaImageViewer::LoadedMedia)
QSKIP("failed to load test image");
QVideoWidget widget;
QGraphicsVideoItem item;
QtTestVideoSurface surface;
imageViewer.setVideoOutput(&widget);
QVERIFY(widget.mediaObject() == &imageViewer);
imageViewer.setVideoOutput(&item);
QVERIFY(widget.mediaObject() == 0);
QVERIFY(item.mediaObject() == &imageViewer);
imageViewer.setVideoOutput(reinterpret_cast<QVideoWidget *>(0));
QVERIFY(item.mediaObject() == 0);
imageViewer.setVideoOutput(&widget);
QVERIFY(widget.mediaObject() == &imageViewer);
imageViewer.setVideoOutput(reinterpret_cast<QGraphicsVideoItem *>(0));
QVERIFY(widget.mediaObject() == 0);
imageViewer.setVideoOutput(&surface);
QVERIFY(surface.isActive());
imageViewer.setVideoOutput(reinterpret_cast<QAbstractVideoSurface *>(0));
QVERIFY(!surface.isActive());
imageViewer.setVideoOutput(&surface);
QVERIFY(surface.isActive());
imageViewer.setVideoOutput(&widget);
QVERIFY(!surface.isActive());
QVERIFY(widget.mediaObject() == &imageViewer);
imageViewer.setVideoOutput(&surface);
QVERIFY(surface.isActive());
QVERIFY(widget.mediaObject() == 0);
}
QTEST_MAIN(tst_QMediaImageViewerWidgets)
#include "tst_qmediaimageviewerwidgets.moc"