Multimedia: examples coding style unification
Change-Id: Iffae3a276bb2b01f871aee76dc069ce006d69fce Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -41,13 +41,12 @@
|
||||
#ifndef HISTOGRAMWIDGET_H
|
||||
#define HISTOGRAMWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <qvideoframe.h>
|
||||
#include <QThread>
|
||||
#include <QVideoFrame>
|
||||
#include <QWidget>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class FrameProcessor: public QObject {
|
||||
class FrameProcessor: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
@@ -60,6 +59,7 @@ signals:
|
||||
class HistogramWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HistogramWidget(QWidget *parent = 0);
|
||||
~HistogramWidget();
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#include "player.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -53,18 +53,10 @@ int main(int argc, char *argv[])
|
||||
Player player;
|
||||
|
||||
#if defined(Q_WS_SIMULATOR)
|
||||
# if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 2))
|
||||
player.setAttribute(Qt::WA_LockLandscapeOrientation);
|
||||
# else
|
||||
// lock screen orientation
|
||||
CAknAppUi* appUi = dynamic_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
|
||||
if(appUi){
|
||||
QT_TRAP_THROWING(appUi ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape));
|
||||
}
|
||||
# endif
|
||||
player.showMaximized();
|
||||
#else
|
||||
player.show();
|
||||
#endif
|
||||
return app.exec();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -44,10 +44,9 @@
|
||||
#include "playlistmodel.h"
|
||||
#include "histogramwidget.h"
|
||||
|
||||
#include <qmediaservice.h>
|
||||
#include <qmediaplaylist.h>
|
||||
#include <qvideoprobe.h>
|
||||
|
||||
#include <QMediaService>
|
||||
#include <QMediaPlaylist>
|
||||
#include <QVideoProbe>
|
||||
#include <QtWidgets>
|
||||
|
||||
|
||||
@@ -308,7 +307,7 @@ void Player::statusChanged(QMediaPlayer::MediaStatus status)
|
||||
void Player::handleCursor(QMediaPlayer::MediaStatus status)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
if( status == QMediaPlayer::LoadingMedia ||
|
||||
if (status == QMediaPlayer::LoadingMedia ||
|
||||
status == QMediaPlayer::BufferingMedia ||
|
||||
status == QMediaPlayer::StalledMedia)
|
||||
setCursor(QCursor(Qt::BusyCursor));
|
||||
@@ -427,4 +426,3 @@ void Player::showColorDialog()
|
||||
colorDialog->show();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -41,38 +41,35 @@
|
||||
#ifndef PLAYER_H
|
||||
#define PLAYER_H
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
#include <qmediaplayer.h>
|
||||
#include <qmediaplaylist.h>
|
||||
#include "videowidget.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMediaPlayer>
|
||||
#include <QMediaPlaylist>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractItemView;
|
||||
class QLabel;
|
||||
class QModelIndex;
|
||||
class QSlider;
|
||||
class QPushButton;
|
||||
class QVideoProbe;
|
||||
|
||||
class QMediaPlayer;
|
||||
class QModelIndex;
|
||||
class QPushButton;
|
||||
class QSlider;
|
||||
class QVideoProbe;
|
||||
class QVideoWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class PlaylistModel;
|
||||
class HistogramWidget;
|
||||
|
||||
class Player : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Player(QWidget *parent = 0);
|
||||
~Player();
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void fullScreenChanged(bool fullScreen);
|
||||
|
||||
private slots:
|
||||
@@ -96,7 +93,7 @@ private slots:
|
||||
#ifndef PLAYER_NO_COLOROPTIONS
|
||||
void showColorDialog();
|
||||
#endif
|
||||
void addToPlaylist(const QStringList& fileNames);
|
||||
void addToPlaylist(const QStringList &fileNames);
|
||||
|
||||
private:
|
||||
void setTrackInfo(const QString &info);
|
||||
@@ -127,4 +124,4 @@ private:
|
||||
qint64 duration;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // PLAYER_H
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
TEMPLATE = app
|
||||
TARGET = player
|
||||
|
||||
CONFIG += qt warn_on
|
||||
|
||||
QT += network \
|
||||
xml \
|
||||
multimedia \
|
||||
multimediawidgets
|
||||
multimediawidgets \
|
||||
widgets
|
||||
|
||||
HEADERS = \
|
||||
player.h \
|
||||
@@ -25,10 +24,7 @@ maemo* {
|
||||
DEFINES += PLAYER_NO_COLOROPTIONS
|
||||
}
|
||||
|
||||
#install
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/player
|
||||
sources.files = $$SOURCES $HEADERS $$RESOURCES $$FORMS *.pro
|
||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/player
|
||||
INSTALLS += target sources
|
||||
|
||||
QT+=widgets
|
||||
|
||||
@@ -40,11 +40,11 @@
|
||||
|
||||
#include "playercontrols.h"
|
||||
|
||||
#include <QtWidgets/qboxlayout.h>
|
||||
#include <QtWidgets/qslider.h>
|
||||
#include <QtWidgets/qstyle.h>
|
||||
#include <QtWidgets/qtoolbutton.h>
|
||||
#include <QtWidgets/qcombobox.h>
|
||||
#include <QBoxLayout>
|
||||
#include <QSlider>
|
||||
#include <QStyle>
|
||||
#include <QToolButton>
|
||||
#include <QComboBox>
|
||||
|
||||
PlayerControls::PlayerControls(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@@ -89,7 +89,6 @@ PlayerControls::PlayerControls(QWidget *parent)
|
||||
|
||||
connect(volumeSlider, SIGNAL(sliderMoved(int)), this, SIGNAL(changeVolume(int)));
|
||||
|
||||
|
||||
rateBox = new QComboBox(this);
|
||||
rateBox->addItem("0.5x", QVariant(0.5));
|
||||
rateBox->addItem("1.0x", QVariant(1.0));
|
||||
@@ -105,11 +104,8 @@ PlayerControls::PlayerControls(QWidget *parent)
|
||||
layout->addWidget(playButton);
|
||||
layout->addWidget(nextButton);
|
||||
layout->addWidget(muteButton);
|
||||
if (volumeSlider)
|
||||
layout->addWidget(volumeSlider);
|
||||
|
||||
if (rateBox)
|
||||
layout->addWidget(rateBox);
|
||||
layout->addWidget(volumeSlider);
|
||||
layout->addWidget(rateBox);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
@@ -192,15 +188,15 @@ qreal PlayerControls::playbackRate() const
|
||||
|
||||
void PlayerControls::setPlaybackRate(float rate)
|
||||
{
|
||||
for (int i=0; i<rateBox->count(); i++) {
|
||||
for (int i = 0; i < rateBox->count(); ++i) {
|
||||
if (qFuzzyCompare(rate, float(rateBox->itemData(i).toDouble()))) {
|
||||
rateBox->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rateBox->addItem( QString("%1x").arg(rate), QVariant(rate));
|
||||
rateBox->setCurrentIndex(rateBox->count()-1);
|
||||
rateBox->addItem(QString("%1x").arg(rate), QVariant(rate));
|
||||
rateBox->setCurrentIndex(rateBox->count() - 1);
|
||||
}
|
||||
|
||||
void PlayerControls::updateRate()
|
||||
|
||||
@@ -41,9 +41,8 @@
|
||||
#ifndef PLAYERCONTROLS_H
|
||||
#define PLAYERCONTROLS_H
|
||||
|
||||
#include <qmediaplayer.h>
|
||||
|
||||
#include <QtWidgets/qwidget.h>
|
||||
#include <QMediaPlayer>
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractButton;
|
||||
@@ -51,16 +50,14 @@ class QAbstractSlider;
|
||||
class QComboBox;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class PlayerControls : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PlayerControls(QWidget *parent = 0);
|
||||
|
||||
QMediaPlayer::State state() const;
|
||||
|
||||
int volume() const;
|
||||
bool isMuted() const;
|
||||
qreal playbackRate() const;
|
||||
@@ -98,4 +95,4 @@ private:
|
||||
QComboBox *rateBox;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // PLAYERCONTROLS_H
|
||||
|
||||
@@ -40,10 +40,9 @@
|
||||
|
||||
#include "playlistmodel.h"
|
||||
|
||||
#include <QtCore/qfileinfo.h>
|
||||
#include <QtCore/qurl.h>
|
||||
|
||||
#include <qmediaplaylist.h>
|
||||
#include <QFileInfo>
|
||||
#include <QUrl>
|
||||
#include <QMediaPlaylist>
|
||||
|
||||
PlaylistModel::PlaylistModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
@@ -155,5 +154,3 @@ void PlaylistModel::changeItems(int start, int end)
|
||||
m_data.clear();
|
||||
emit dataChanged(index(start,0), index(end,ColumnCount));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -41,18 +41,16 @@
|
||||
#ifndef PLAYLISTMODEL_H
|
||||
#define PLAYLISTMODEL_H
|
||||
|
||||
#include <qtmultimediadefs.h>
|
||||
#include <QtCore/qabstractitemmodel.h>
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMediaPlaylist;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class PlaylistModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Column
|
||||
{
|
||||
@@ -87,4 +85,4 @@ private:
|
||||
QMap<QModelIndex, QVariant> m_data;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // PLAYLISTMODEL_H
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
|
||||
#include "videowidget.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QKeyEvent>
|
||||
#include <QMouseEvent>
|
||||
|
||||
VideoWidget::VideoWidget(QWidget *parent)
|
||||
: QVideoWidget(parent)
|
||||
@@ -58,11 +59,9 @@ void VideoWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Escape && isFullScreen()) {
|
||||
setFullScreen(false);
|
||||
|
||||
event->accept();
|
||||
} else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) {
|
||||
setFullScreen(!isFullScreen());
|
||||
|
||||
event->accept();
|
||||
} else {
|
||||
QVideoWidget::keyPressEvent(event);
|
||||
@@ -72,7 +71,6 @@ void VideoWidget::keyPressEvent(QKeyEvent *event)
|
||||
void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
setFullScreen(!isFullScreen());
|
||||
|
||||
event->accept();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,16 +37,16 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef VIDEOWIDGET_H
|
||||
#define VIDEOWIDGET_H
|
||||
|
||||
#include <qvideowidget.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
#include <QVideoWidget>
|
||||
|
||||
class VideoWidget : public QVideoWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VideoWidget(QWidget *parent = 0);
|
||||
|
||||
@@ -56,4 +56,4 @@ protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // VIDEOWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user