diff options
Diffstat (limited to 'examples/multimediawidgets')
57 files changed, 0 insertions, 6406 deletions
diff --git a/examples/multimediawidgets/camera/camera.cpp b/examples/multimediawidgets/camera/camera.cpp deleted file mode 100644 index d03a1d1dc..000000000 --- a/examples/multimediawidgets/camera/camera.cpp +++ /dev/null @@ -1,434 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "camera.h" -#include "ui_camera.h" -#include "videosettings.h" -#include "imagesettings.h" - -#include <QMediaService> -#include <QMediaRecorder> -#include <QCameraViewfinder> -#include <QCameraInfo> -#include <QMediaMetaData> - -#include <QMessageBox> -#include <QPalette> - -#include <QtWidgets> - -Q_DECLARE_METATYPE(QCameraInfo) - -Camera::Camera() : ui(new Ui::Camera) -{ - ui->setupUi(this); - - //Camera devices: - - QActionGroup *videoDevicesGroup = new QActionGroup(this); - videoDevicesGroup->setExclusive(true); - const QList<QCameraInfo> availableCameras = QCameraInfo::availableCameras(); - for (const QCameraInfo &cameraInfo : availableCameras) { - QAction *videoDeviceAction = new QAction(cameraInfo.description(), videoDevicesGroup); - videoDeviceAction->setCheckable(true); - videoDeviceAction->setData(QVariant::fromValue(cameraInfo)); - if (cameraInfo == QCameraInfo::defaultCamera()) - videoDeviceAction->setChecked(true); - - ui->menuDevices->addAction(videoDeviceAction); - } - - connect(videoDevicesGroup, &QActionGroup::triggered, this, &Camera::updateCameraDevice); - connect(ui->captureWidget, &QTabWidget::currentChanged, this, &Camera::updateCaptureMode); - - setCamera(QCameraInfo::defaultCamera()); -} - -void Camera::setCamera(const QCameraInfo &cameraInfo) -{ - m_camera.reset(new QCamera(cameraInfo)); - - connect(m_camera.data(), &QCamera::stateChanged, this, &Camera::updateCameraState); - connect(m_camera.data(), &QCamera::errorOccurred, this, &Camera::displayCameraError); - - m_mediaRecorder.reset(new QMediaRecorder(m_camera.data())); - connect(m_mediaRecorder.data(), &QMediaRecorder::stateChanged, this, &Camera::updateRecorderState); - - m_imageCapture.reset(new QCameraImageCapture(m_camera.data())); - - connect(m_mediaRecorder.data(), &QMediaRecorder::durationChanged, this, &Camera::updateRecordTime); - connect(m_mediaRecorder.data(), QOverload<QMediaRecorder::Error>::of(&QMediaRecorder::error), - this, &Camera::displayRecorderError); - - m_mediaRecorder->setMetaData(QMediaMetaData::Title, QVariant(QLatin1String("Test Title"))); - - connect(ui->exposureCompensation, &QAbstractSlider::valueChanged, this, &Camera::setExposureCompensation); - - m_camera->setViewfinder(ui->viewfinder); - - updateCameraState(m_camera->state()); - updateLockStatus(m_camera->lockStatus(), QCamera::UserRequest); - updateRecorderState(m_mediaRecorder->state()); - - connect(m_imageCapture.data(), &QCameraImageCapture::readyForCaptureChanged, this, &Camera::readyForCapture); - connect(m_imageCapture.data(), &QCameraImageCapture::imageCaptured, this, &Camera::processCapturedImage); - connect(m_imageCapture.data(), &QCameraImageCapture::imageSaved, this, &Camera::imageSaved); - connect(m_imageCapture.data(), QOverload<int, QCameraImageCapture::Error, const QString &>::of(&QCameraImageCapture::error), - this, &Camera::displayCaptureError); - - connect(m_camera.data(), QOverload<QCamera::LockStatus, QCamera::LockChangeReason>::of(&QCamera::lockStatusChanged), - this, &Camera::updateLockStatus); - - ui->captureWidget->setTabEnabled(0, (m_camera->isCaptureModeSupported(QCamera::CaptureStillImage))); - ui->captureWidget->setTabEnabled(1, (m_camera->isCaptureModeSupported(QCamera::CaptureVideo))); - - updateCaptureMode(); - m_camera->start(); -} - -void Camera::keyPressEvent(QKeyEvent * event) -{ - if (event->isAutoRepeat()) - return; - - switch (event->key()) { - case Qt::Key_CameraFocus: - displayViewfinder(); - m_camera->searchAndLock(); - event->accept(); - break; - case Qt::Key_Camera: - if (m_camera->captureMode() == QCamera::CaptureStillImage) { - takeImage(); - } else { - if (m_mediaRecorder->state() == QMediaRecorder::RecordingState) - stop(); - else - record(); - } - event->accept(); - break; - default: - QMainWindow::keyPressEvent(event); - } -} - -void Camera::keyReleaseEvent(QKeyEvent *event) -{ - if (event->isAutoRepeat()) - return; - - switch (event->key()) { - case Qt::Key_CameraFocus: - m_camera->unlock(); - break; - default: - QMainWindow::keyReleaseEvent(event); - } -} - -void Camera::updateRecordTime() -{ - QString str = QString("Recorded %1 sec").arg(m_mediaRecorder->duration()/1000); - ui->statusbar->showMessage(str); -} - -void Camera::processCapturedImage(int requestId, const QImage& img) -{ - Q_UNUSED(requestId); - QImage scaledImage = img.scaled(ui->viewfinder->size(), - Qt::KeepAspectRatio, - Qt::SmoothTransformation); - - ui->lastImagePreviewLabel->setPixmap(QPixmap::fromImage(scaledImage)); - - // Display captured image for 4 seconds. - displayCapturedImage(); - QTimer::singleShot(4000, this, &Camera::displayViewfinder); -} - -void Camera::configureCaptureSettings() -{ - switch (m_camera->captureMode()) { - case QCamera::CaptureStillImage: - configureImageSettings(); - break; - case QCamera::CaptureVideo: - configureVideoSettings(); - break; - default: - break; - } -} - -void Camera::configureVideoSettings() -{ - VideoSettings settingsDialog(m_mediaRecorder.data()); - settingsDialog.setWindowFlags(settingsDialog.windowFlags() & ~Qt::WindowContextHelpButtonHint); - - settingsDialog.setAudioSettings(m_audioSettings); - settingsDialog.setVideoSettings(m_videoSettings); - settingsDialog.setFormat(m_videoContainerFormat); - - if (settingsDialog.exec()) { - m_audioSettings = settingsDialog.audioSettings(); - m_videoSettings = settingsDialog.videoSettings(); - m_videoContainerFormat = settingsDialog.format(); - - m_mediaRecorder->setEncodingSettings( - m_audioSettings, - m_videoSettings, - m_videoContainerFormat); - - m_camera->unload(); - m_camera->start(); - } -} - -void Camera::configureImageSettings() -{ - ImageSettings settingsDialog(m_imageCapture.data()); - settingsDialog.setWindowFlags(settingsDialog.windowFlags() & ~Qt::WindowContextHelpButtonHint); - - settingsDialog.setImageSettings(m_imageSettings); - - if (settingsDialog.exec()) { - m_imageSettings = settingsDialog.imageSettings(); - m_imageCapture->setEncodingSettings(m_imageSettings); - } -} - -void Camera::record() -{ - m_mediaRecorder->record(); - updateRecordTime(); -} - -void Camera::pause() -{ - m_mediaRecorder->pause(); -} - -void Camera::stop() -{ - m_mediaRecorder->stop(); -} - -void Camera::setMuted(bool muted) -{ - m_mediaRecorder->setMuted(muted); -} - -void Camera::toggleLock() -{ - switch (m_camera->lockStatus()) { - case QCamera::Searching: - case QCamera::Locked: - m_camera->unlock(); - break; - case QCamera::Unlocked: - m_camera->searchAndLock(); - } -} - -void Camera::updateLockStatus(QCamera::LockStatus status, QCamera::LockChangeReason reason) -{ - QColor indicationColor = Qt::black; - - switch (status) { - case QCamera::Searching: - indicationColor = Qt::yellow; - ui->statusbar->showMessage(tr("Focusing...")); - ui->lockButton->setText(tr("Focusing...")); - break; - case QCamera::Locked: - indicationColor = Qt::darkGreen; - ui->lockButton->setText(tr("Unlock")); - ui->statusbar->showMessage(tr("Focused"), 2000); - break; - case QCamera::Unlocked: - indicationColor = reason == QCamera::LockFailed ? Qt::red : Qt::black; - ui->lockButton->setText(tr("Focus")); - if (reason == QCamera::LockFailed) - ui->statusbar->showMessage(tr("Focus Failed"), 2000); - } - - QPalette palette = ui->lockButton->palette(); - palette.setColor(QPalette::ButtonText, indicationColor); - ui->lockButton->setPalette(palette); -} - -void Camera::takeImage() -{ - m_isCapturingImage = true; - m_imageCapture->capture(); -} - -void Camera::displayCaptureError(int id, const QCameraImageCapture::Error error, const QString &errorString) -{ - Q_UNUSED(id); - Q_UNUSED(error); - QMessageBox::warning(this, tr("Image Capture Error"), errorString); - m_isCapturingImage = false; -} - -void Camera::startCamera() -{ - m_camera->start(); -} - -void Camera::stopCamera() -{ - m_camera->stop(); -} - -void Camera::updateCaptureMode() -{ - int tabIndex = ui->captureWidget->currentIndex(); - QCamera::CaptureModes captureMode = tabIndex == 0 ? QCamera::CaptureStillImage : QCamera::CaptureVideo; - - if (m_camera->isCaptureModeSupported(captureMode)) - m_camera->setCaptureMode(captureMode); -} - -void Camera::updateCameraState(QCamera::State state) -{ - switch (state) { - case QCamera::ActiveState: - ui->actionStartCamera->setEnabled(false); - ui->actionStopCamera->setEnabled(true); - ui->captureWidget->setEnabled(true); - ui->actionSettings->setEnabled(true); - break; - case QCamera::UnloadedState: - case QCamera::LoadedState: - ui->actionStartCamera->setEnabled(true); - ui->actionStopCamera->setEnabled(false); - ui->captureWidget->setEnabled(false); - ui->actionSettings->setEnabled(false); - } -} - -void Camera::updateRecorderState(QMediaRecorder::State state) -{ - switch (state) { - case QMediaRecorder::StoppedState: - ui->recordButton->setEnabled(true); - ui->pauseButton->setEnabled(true); - ui->stopButton->setEnabled(false); - break; - case QMediaRecorder::PausedState: - ui->recordButton->setEnabled(true); - ui->pauseButton->setEnabled(false); - ui->stopButton->setEnabled(true); - break; - case QMediaRecorder::RecordingState: - ui->recordButton->setEnabled(false); - ui->pauseButton->setEnabled(true); - ui->stopButton->setEnabled(true); - break; - } -} - -void Camera::setExposureCompensation(int index) -{ - m_camera->exposure()->setExposureCompensation(index*0.5); -} - -void Camera::displayRecorderError() -{ - QMessageBox::warning(this, tr("Capture Error"), m_mediaRecorder->errorString()); -} - -void Camera::displayCameraError() -{ - QMessageBox::warning(this, tr("Camera Error"), m_camera->errorString()); -} - -void Camera::updateCameraDevice(QAction *action) -{ - setCamera(qvariant_cast<QCameraInfo>(action->data())); -} - -void Camera::displayViewfinder() -{ - ui->stackedWidget->setCurrentIndex(0); -} - -void Camera::displayCapturedImage() -{ - ui->stackedWidget->setCurrentIndex(1); -} - -void Camera::readyForCapture(bool ready) -{ - ui->takeImageButton->setEnabled(ready); -} - -void Camera::imageSaved(int id, const QString &fileName) -{ - Q_UNUSED(id); - ui->statusbar->showMessage(tr("Captured \"%1\"").arg(QDir::toNativeSeparators(fileName))); - - m_isCapturingImage = false; - if (m_applicationExiting) - close(); -} - -void Camera::closeEvent(QCloseEvent *event) -{ - if (m_isCapturingImage) { - setEnabled(false); - m_applicationExiting = true; - event->ignore(); - } else { - event->accept(); - } -} diff --git a/examples/multimediawidgets/camera/camera.h b/examples/multimediawidgets/camera/camera.h deleted file mode 100644 index d06c770f6..000000000 --- a/examples/multimediawidgets/camera/camera.h +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 CAMERA_H -#define CAMERA_H - -#include <QCamera> -#include <QCameraImageCapture> -#include <QMediaRecorder> -#include <QScopedPointer> - -#include <QMainWindow> - -QT_BEGIN_NAMESPACE -namespace Ui { class Camera; } -QT_END_NAMESPACE - -class Camera : public QMainWindow -{ - Q_OBJECT - -public: - Camera(); - -private slots: - void setCamera(const QCameraInfo &cameraInfo); - - void startCamera(); - void stopCamera(); - - void record(); - void pause(); - void stop(); - void setMuted(bool); - - void toggleLock(); - void takeImage(); - void displayCaptureError(int, QCameraImageCapture::Error, const QString &errorString); - - void configureCaptureSettings(); - void configureVideoSettings(); - void configureImageSettings(); - - void displayRecorderError(); - void displayCameraError(); - - void updateCameraDevice(QAction *action); - - void updateCameraState(QCamera::State); - void updateCaptureMode(); - void updateRecorderState(QMediaRecorder::State state); - void setExposureCompensation(int index); - - void updateRecordTime(); - - void processCapturedImage(int requestId, const QImage &img); - void updateLockStatus(QCamera::LockStatus, QCamera::LockChangeReason); - - void displayViewfinder(); - void displayCapturedImage(); - - void readyForCapture(bool ready); - void imageSaved(int id, const QString &fileName); - -protected: - void keyPressEvent(QKeyEvent *event) override; - void keyReleaseEvent(QKeyEvent *event) override; - void closeEvent(QCloseEvent *event) override; - -private: - Ui::Camera *ui; - - QScopedPointer<QCamera> m_camera; - QScopedPointer<QCameraImageCapture> m_imageCapture; - QScopedPointer<QMediaRecorder> m_mediaRecorder; - - QImageEncoderSettings m_imageSettings; - QAudioEncoderSettings m_audioSettings; - QVideoEncoderSettings m_videoSettings; - QString m_videoContainerFormat; - bool m_isCapturingImage = false; - bool m_applicationExiting = false; -}; - -#endif diff --git a/examples/multimediawidgets/camera/camera.pro b/examples/multimediawidgets/camera/camera.pro deleted file mode 100644 index 52c511acb..000000000 --- a/examples/multimediawidgets/camera/camera.pro +++ /dev/null @@ -1,28 +0,0 @@ -TEMPLATE = app -TARGET = camera - -QT += multimedia multimediawidgets - -HEADERS = \ - camera.h \ - imagesettings.h \ - videosettings.h - -SOURCES = \ - main.cpp \ - camera.cpp \ - imagesettings.cpp \ - videosettings.cpp - -FORMS += \ - camera.ui \ - videosettings.ui \ - imagesettings.ui - -RESOURCES += camera.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/camera -INSTALLS += target - -QT+=widgets -include(../../multimedia/shared/shared.pri) diff --git a/examples/multimediawidgets/camera/camera.qrc b/examples/multimediawidgets/camera/camera.qrc deleted file mode 100644 index a915eb596..000000000 --- a/examples/multimediawidgets/camera/camera.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>images/shutter.svg</file> -</qresource> -</RCC> diff --git a/examples/multimediawidgets/camera/camera.ui b/examples/multimediawidgets/camera/camera.ui deleted file mode 100644 index e4ef5d7f0..000000000 --- a/examples/multimediawidgets/camera/camera.ui +++ /dev/null @@ -1,501 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Camera</class> - <widget class="QMainWindow" name="Camera"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>668</width> - <height>422</height> - </rect> - </property> - <property name="windowTitle"> - <string>Camera</string> - </property> - <widget class="QWidget" name="centralwidget"> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0" rowspan="3"> - <widget class="QStackedWidget" name="stackedWidget"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="palette"> - <palette> - <active> - <colorrole role="Base"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>255</red> - <green>255</green> - <blue>255</blue> - </color> - </brush> - </colorrole> - <colorrole role="Window"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>145</red> - <green>145</green> - <blue>145</blue> - </color> - </brush> - </colorrole> - </active> - <inactive> - <colorrole role="Base"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>255</red> - <green>255</green> - <blue>255</blue> - </color> - </brush> - </colorrole> - <colorrole role="Window"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>145</red> - <green>145</green> - <blue>145</blue> - </color> - </brush> - </colorrole> - </inactive> - <disabled> - <colorrole role="Base"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>145</red> - <green>145</green> - <blue>145</blue> - </color> - </brush> - </colorrole> - <colorrole role="Window"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>145</red> - <green>145</green> - <blue>145</blue> - </color> - </brush> - </colorrole> - </disabled> - </palette> - </property> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="viewfinderPage"> - <layout class="QGridLayout" name="gridLayout_5"> - <item row="0" column="0"> - <widget class="QCameraViewfinder" name="viewfinder" native="true"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="previewPage"> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="0"> - <widget class="QLabel" name="lastImagePreviewLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShape"> - <enum>QFrame::Box</enum> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </widget> - </widget> - </item> - <item row="1" column="1" colspan="2"> - <widget class="QPushButton" name="lockButton"> - <property name="text"> - <string>Focus</string> - </property> - </widget> - </item> - <item row="2" column="1" colspan="2"> - <widget class="QTabWidget" name="captureWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab_2"> - <attribute name="title"> - <string>Image</string> - </attribute> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QPushButton" name="takeImageButton"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Capture Photo</string> - </property> - <property name="icon"> - <iconset resource="camera.qrc"> - <normaloff>:/images/shutter.svg</normaloff>:/images/shutter.svg</iconset> - </property> - </widget> - </item> - <item row="1" column="0"> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>161</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Exposure Compensation:</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QSlider" name="exposureCompensation"> - <property name="minimum"> - <number>-4</number> - </property> - <property name="maximum"> - <number>4</number> - </property> - <property name="pageStep"> - <number>2</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="tickPosition"> - <enum>QSlider::TicksAbove</enum> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string>Video</string> - </attribute> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> - <widget class="QPushButton" name="recordButton"> - <property name="text"> - <string>Record</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QPushButton" name="pauseButton"> - <property name="text"> - <string>Pause</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QPushButton" name="stopButton"> - <property name="text"> - <string>Stop</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>76</height> - </size> - </property> - </spacer> - </item> - <item row="4" column="0"> - <widget class="QPushButton" name="muteButton"> - <property name="text"> - <string>Mute</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </widget> - </item> - </layout> - </widget> - <widget class="QMenuBar" name="menubar"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>668</width> - <height>21</height> - </rect> - </property> - <widget class="QMenu" name="menuFile"> - <property name="title"> - <string>File</string> - </property> - <addaction name="actionStartCamera"/> - <addaction name="actionStopCamera"/> - <addaction name="separator"/> - <addaction name="actionSettings"/> - <addaction name="separator"/> - <addaction name="actionExit"/> - </widget> - <widget class="QMenu" name="menuDevices"> - <property name="title"> - <string>Devices</string> - </property> - </widget> - <addaction name="menuFile"/> - <addaction name="menuDevices"/> - </widget> - <widget class="QStatusBar" name="statusbar"/> - <action name="actionExit"> - <property name="text"> - <string>Exit</string> - </property> - </action> - <action name="actionStartCamera"> - <property name="text"> - <string>Start Camera</string> - </property> - </action> - <action name="actionStopCamera"> - <property name="text"> - <string>Stop Camera</string> - </property> - </action> - <action name="actionSettings"> - <property name="text"> - <string>Settings</string> - </property> - </action> - </widget> - <customwidgets> - <customwidget> - <class>QCameraViewfinder</class> - <extends>QWidget</extends> - <header>qcameraviewfinder.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources> - <include location="camera.qrc"/> - </resources> - <connections> - <connection> - <sender>recordButton</sender> - <signal>clicked()</signal> - <receiver>Camera</receiver> - <slot>record()</slot> - <hints> - <hint type="sourcelabel"> - <x>647</x> - <y>149</y> - </hint> - <hint type="destinationlabel"> - <x>61</x> - <y>238</y> - </hint> - </hints> - </connection> - <connection> - <sender>stopButton</sender> - <signal>clicked()</signal> - <receiver>Camera</receiver> - <slot>stop()</slot> - <hints> - <hint type="sourcelabel"> - <x>647</x> - <y>225</y> - </hint> - <hint type="destinationlabel"> - <x>140</x> - <y>236</y> - </hint> - </hints> - </connection> - <connection> - <sender>pauseButton</sender> - <signal>clicked()</signal> - <receiver>Camera</receiver> - <slot>pause()</slot> - <hints> - <hint type="sourcelabel"> - <x>647</x> - <y>187</y> - </hint> - <hint type="destinationlabel"> - <x>234</x> - <y>237</y> - </hint> - </hints> - </connection> - <connection> - <sender>actionExit</sender> - <signal>triggered()</signal> - <receiver>Camera</receiver> - <slot>close()</slot> - <hints> - <hint type="sourcelabel"> - <x>-1</x> - <y>-1</y> - </hint> - <hint type="destinationlabel"> - <x>154</x> - <y>130</y> - </hint> - </hints> - </connection> - <connection> - <sender>takeImageButton</sender> - <signal>clicked()</signal> - <receiver>Camera</receiver> - <slot>takeImage()</slot> - <hints> - <hint type="sourcelabel"> - <x>625</x> - <y>132</y> - </hint> - <hint type="destinationlabel"> - <x>603</x> - <y>169</y> - </hint> - </hints> - </connection> - <connection> - <sender>lockButton</sender> - <signal>clicked()</signal> - <receiver>Camera</receiver> - <slot>toggleLock()</slot> - <hints> - <hint type="sourcelabel"> - <x>658</x> - <y>75</y> - </hint> - <hint type="destinationlabel"> - <x>453</x> - <y>119</y> - </hint> - </hints> - </connection> - <connection> - <sender>muteButton</sender> - <signal>toggled(bool)</signal> - <receiver>Camera</receiver> - <slot>setMuted(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>647</x> - <y>377</y> - </hint> - <hint type="destinationlabel"> - <x>5</x> - <y>280</y> - </hint> - </hints> - </connection> - <connection> - <sender>exposureCompensation</sender> - <signal>valueChanged(int)</signal> - <receiver>Camera</receiver> - <slot>setExposureCompensation(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>559</x> - <y>367</y> - </hint> - <hint type="destinationlabel"> - <x>665</x> - <y>365</y> - </hint> - </hints> - </connection> - <connection> - <sender>actionSettings</sender> - <signal>triggered()</signal> - <receiver>Camera</receiver> - <slot>configureCaptureSettings()</slot> - <hints> - <hint type="sourcelabel"> - <x>-1</x> - <y>-1</y> - </hint> - <hint type="destinationlabel"> - <x>333</x> - <y>210</y> - </hint> - </hints> - </connection> - <connection> - <sender>actionStartCamera</sender> - <signal>triggered()</signal> - <receiver>Camera</receiver> - <slot>startCamera()</slot> - <hints> - <hint type="sourcelabel"> - <x>-1</x> - <y>-1</y> - </hint> - <hint type="destinationlabel"> - <x>333</x> - <y>210</y> - </hint> - </hints> - </connection> - <connection> - <sender>actionStopCamera</sender> - <signal>triggered()</signal> - <receiver>Camera</receiver> - <slot>stopCamera()</slot> - <hints> - <hint type="sourcelabel"> - <x>-1</x> - <y>-1</y> - </hint> - <hint type="destinationlabel"> - <x>333</x> - <y>210</y> - </hint> - </hints> - </connection> - </connections> - <slots> - <slot>record()</slot> - <slot>pause()</slot> - <slot>stop()</slot> - <slot>enablePreview(bool)</slot> - <slot>configureCaptureSettings()</slot> - <slot>takeImage()</slot> - <slot>startCamera()</slot> - <slot>toggleLock()</slot> - <slot>setMuted(bool)</slot> - <slot>stopCamera()</slot> - <slot>setExposureCompensation(int)</slot> - </slots> -</ui> diff --git a/examples/multimediawidgets/camera/doc/images/camera-example.png b/examples/multimediawidgets/camera/doc/images/camera-example.png Binary files differdeleted file mode 100644 index 12e1b5728..000000000 --- a/examples/multimediawidgets/camera/doc/images/camera-example.png +++ /dev/null diff --git a/examples/multimediawidgets/camera/doc/src/camera.qdoc b/examples/multimediawidgets/camera/doc/src/camera.qdoc deleted file mode 100644 index 68e19aac3..000000000 --- a/examples/multimediawidgets/camera/doc/src/camera.qdoc +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** 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. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - - - -/*! - -\example multimediawidgets/camera -\title Camera Example -\ingroup multimedia_examples -\ingroup camera_examples -\brief The Camera Example shows how to use the API to capture a still image -or video. - -The Camera Example demonstrates how you can use \l{Qt Multimedia} to implement -some basic Camera functionality to take still images and record video clips -with audio. - -\include examples-run.qdocinc - -A Camera class is created that will act as our Camera. It has a user interface, -control functions, setting values and a means of defining the location where -the image or video clip is to be saved. It will also store the image and video -settings. - -The Camera class contains an instance of \l {QCamera}, the API class interface to -the hardware. It also has an instance of \l {QCameraImageCapture} to take still images -and an instance of \l {QMediaRecorder} to record video. It also contains the user -interface object. - -The Camera constructor does some basic initialization. The camera object is -set to '0', the user interface is initialized and UI signal are connected to -slots that react to the triggering event. However, most of the work is done when -the \e{setCamera()} function is called, passing in a \l {QByteArray}. - -\e{setCamera()} sets up various connections between the user interface and the functionality -of the Camera class using signals and slots. It also instantiates and initializes the \l {QCamera}, -\l {QCameraImageCapture} and \l {QMediaRecorder} objects mentioned above. The still -and video recording visual tabs are enabled and finally the -\l {QCamera::start()}{start()} function of the \l{QCamera} object is called. - -Now that the camera is ready for user commands it waits for a suitable event. -Such an event will be the key press of either the \l {Qt::Key_CameraFocus} or -\l {Qt::Key_Camera} buttons on the application window. Camera focus will -simply display the viewfinder and lock the camera settings. Key_Camera will -either call \e{takeImage()} if the \l {QCamera::captureMode()}{captureMode()} -is QCamera::CaptureStillImage, or if the capture mode is for video then one -of two actions will occur. If the recording state shows that we are currently -recording then the \e{stop()} function is called resulting in a call to -\l {QCamera::stop()}, whereas if we are not recording then a video recording -is started with a call to \l {QMediaRecorder::record()}. - -\image camera-example.png - -*/ diff --git a/examples/multimediawidgets/camera/images/shutter.svg b/examples/multimediawidgets/camera/images/shutter.svg deleted file mode 100644 index 18493361d..000000000 --- a/examples/multimediawidgets/camera/images/shutter.svg +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 20.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" - viewBox="0 0 23.3 19.4" style="enable-background:new 0 0 23.3 19.4;" xml:space="preserve"> -<style type="text/css"> - .st0{fill:none;} -</style> -<g> - <path class="st0" d="M6.2,4.8H2.4c-0.2,0-0.1-0.1-0.1,0.1V17c0,0.2-0.1,0.8,0.1,0.8h3.9V4.8z"/> - <circle class="st0" cx="14" cy="11" r="4.5"/> - <path class="st0" d="M20.9,4.8h-1.8c-0.3,0-0.6-0.4-0.8-0.6l-1.7-2.4h-5.3L9.7,4.2C9.5,4.4,9.2,4.8,8.9,4.8H7.2v13h13.7 - c0.2,0,0.3-0.6,0.3-0.8V4.9C21.2,4.7,21.1,4.8,20.9,4.8z M14,16.4c-3,0-5.5-2.4-5.5-5.5c0-3,2.4-5.5,5.5-5.5c3,0,5.5,2.4,5.5,5.5 - C19.5,14,17,16.4,14,16.4z"/> - <path d="M14,5.5C11,5.5,8.6,8,8.6,11c0,3,2.4,5.5,5.5,5.5c3,0,5.5-2.4,5.5-5.5C19.5,8,17,5.5,14,5.5z M14,15.4 - c-2.5,0-4.5-2-4.5-4.5c0-2.5,2-4.5,4.5-4.5c2.5,0,4.5,2,4.5,4.5C18.5,13.4,16.5,15.4,14,15.4z"/> - <path d="M20.9,2.8h-1.3l-1.7-2.4c-0.2-0.2-0.5-0.6-0.8-0.6h-6.3c-0.3,0-0.6,0.4-0.8,0.6L8.4,2.8h-6c-1.3,0-2.1,0.8-2.1,2.1V17 - c0,1.3,0.8,2.8,2.1,2.8h18.5c1.3,0,2.3-1.5,2.3-2.8V4.9C23.2,3.6,22.2,2.8,20.9,2.8z M2.2,17V4.9c0-0.2-0.1-0.1,0.1-0.1h3.9v13H2.4 - C2.2,17.8,2.2,17.2,2.2,17z M21.2,17c0,0.2-0.1,0.8-0.3,0.8H7.2v-13h1.7c0.3,0,0.6-0.4,0.8-0.6l1.7-2.4h5.3l1.7,2.4 - c0.2,0.2,0.5,0.6,0.8,0.6h1.8c0.2,0,0.3-0.1,0.3,0.1V17z"/> -</g> -</svg> diff --git a/examples/multimediawidgets/camera/imagesettings.cpp b/examples/multimediawidgets/camera/imagesettings.cpp deleted file mode 100644 index 1c8895e02..000000000 --- a/examples/multimediawidgets/camera/imagesettings.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "imagesettings.h" -#include "ui_imagesettings.h" - -#include <QComboBox> -#include <QDebug> -#include <QCameraImageCapture> -#include <QMediaService> - - -ImageSettings::ImageSettings(QCameraImageCapture *imageCapture, QWidget *parent) : - QDialog(parent), - ui(new Ui::ImageSettingsUi), - imagecapture(imageCapture) -{ - ui->setupUi(this); - - //image codecs - ui->imageCodecBox->addItem(tr("Default image format"), QVariant(QString())); - const QStringList supportedImageCodecs = imagecapture->supportedImageCodecs(); - for (const QString &codecName : supportedImageCodecs) { - QString description = imagecapture->imageCodecDescription(codecName); - ui->imageCodecBox->addItem(codecName + ": " + description, QVariant(codecName)); - } - - ui->imageQualitySlider->setRange(0, int(QMultimedia::VeryHighQuality)); - - ui->imageResolutionBox->addItem(tr("Default Resolution")); - const QList<QSize> supportedResolutions = imagecapture->supportedResolutions(); - for (const QSize &resolution : supportedResolutions) { - ui->imageResolutionBox->addItem(QString("%1x%2").arg(resolution.width()).arg(resolution.height()), - QVariant(resolution)); - } -} - -ImageSettings::~ImageSettings() -{ - delete ui; -} - -void ImageSettings::changeEvent(QEvent *e) -{ - QDialog::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} - -QImageEncoderSettings ImageSettings::imageSettings() const -{ - QImageEncoderSettings settings = imagecapture->encodingSettings(); - settings.setCodec(boxValue(ui->imageCodecBox).toString()); - settings.setQuality(QMultimedia::EncodingQuality(ui->imageQualitySlider->value())); - settings.setResolution(boxValue(ui->imageResolutionBox).toSize()); - - return settings; -} - -void ImageSettings::setImageSettings(const QImageEncoderSettings &imageSettings) -{ - selectComboBoxItem(ui->imageCodecBox, QVariant(imageSettings.codec())); - selectComboBoxItem(ui->imageResolutionBox, QVariant(imageSettings.resolution())); - ui->imageQualitySlider->setValue(imageSettings.quality()); -} - -QVariant ImageSettings::boxValue(const QComboBox *box) const -{ - int idx = box->currentIndex(); - if (idx == -1) - return QVariant(); - - return box->itemData(idx); -} - -void ImageSettings::selectComboBoxItem(QComboBox *box, const QVariant &value) -{ - for (int i = 0; i < box->count(); ++i) { - if (box->itemData(i) == value) { - box->setCurrentIndex(i); - break; - } - } -} diff --git a/examples/multimediawidgets/camera/imagesettings.h b/examples/multimediawidgets/camera/imagesettings.h deleted file mode 100644 index 1e4ac536e..000000000 --- a/examples/multimediawidgets/camera/imagesettings.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 IMAGESETTINGS_H -#define IMAGESETTINGS_H - -#include <QDialog> -#include <QAudioEncoderSettings> -#include <QVideoEncoderSettings> - -QT_BEGIN_NAMESPACE -class QComboBox; -class QCameraImageCapture; -namespace Ui { class ImageSettingsUi; } -QT_END_NAMESPACE - -class ImageSettings : public QDialog -{ - Q_OBJECT - -public: - explicit ImageSettings(QCameraImageCapture *imageCapture, QWidget *parent = nullptr); - ~ImageSettings(); - - QAudioEncoderSettings audioSettings() const; - void setAudioSettings(const QAudioEncoderSettings &settings); - - QImageEncoderSettings imageSettings() const; - void setImageSettings(const QImageEncoderSettings &settings); - - QString format() const; - void setFormat(const QString &format); - -protected: - void changeEvent(QEvent *e) override; - -private: - QVariant boxValue(const QComboBox *box) const; - void selectComboBoxItem(QComboBox *box, const QVariant &value); - - Ui::ImageSettingsUi *ui; - QCameraImageCapture *imagecapture; -}; - -#endif // IMAGESETTINGS_H diff --git a/examples/multimediawidgets/camera/imagesettings.ui b/examples/multimediawidgets/camera/imagesettings.ui deleted file mode 100644 index 8c59ca01d..000000000 --- a/examples/multimediawidgets/camera/imagesettings.ui +++ /dev/null @@ -1,123 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ImageSettingsUi</class> - <widget class="QDialog" name="ImageSettingsUi"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>332</width> - <height>270</height> - </rect> - </property> - <property name="windowTitle"> - <string>Image Settings</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Image</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0" colspan="2"> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>Resolution:</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QComboBox" name="imageResolutionBox"/> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Image Format:</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QComboBox" name="imageCodecBox"/> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Quality:</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QSlider" name="imageQualitySlider"> - <property name="maximum"> - <number>4</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="1" column="0"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>14</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ImageSettingsUi</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>322</x> - <y>272</y> - </hint> - <hint type="destinationlabel"> - <x>44</x> - <y>230</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ImageSettingsUi</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>405</x> - <y>262</y> - </hint> - <hint type="destinationlabel"> - <x>364</x> - <y>227</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/examples/multimediawidgets/camera/main.cpp b/examples/multimediawidgets/camera/main.cpp deleted file mode 100644 index 04982a725..000000000 --- a/examples/multimediawidgets/camera/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "camera.h" - -#include <QtWidgets> - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - Camera camera; - camera.show(); - - return app.exec(); -}; diff --git a/examples/multimediawidgets/camera/videosettings.cpp b/examples/multimediawidgets/camera/videosettings.cpp deleted file mode 100644 index f9c79fa12..000000000 --- a/examples/multimediawidgets/camera/videosettings.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videosettings.h" -#include "ui_videosettings.h" - -#include <QComboBox> -#include <QDebug> -#include <QMediaRecorder> -#include <QMediaService> - - -VideoSettings::VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent) : - QDialog(parent), - ui(new Ui::VideoSettingsUi), - mediaRecorder(mediaRecorder) -{ - ui->setupUi(this); - - //audio codecs - ui->audioCodecBox->addItem(tr("Default audio codec"), QVariant(QString())); - const QStringList supportedAudioCodecs = mediaRecorder->supportedAudioCodecs(); - for (const QString &codecName : supportedAudioCodecs) { - QString description = mediaRecorder->audioCodecDescription(codecName); - ui->audioCodecBox->addItem(codecName + ": " + description, QVariant(codecName)); - } - - //sample rate: - const QList<int>supportedAudioSampleRates = mediaRecorder->supportedAudioSampleRates(); - for (int sampleRate : supportedAudioSampleRates) - ui->audioSampleRateBox->addItem(QString::number(sampleRate), QVariant(sampleRate)); - - ui->audioQualitySlider->setRange(0, int(QMultimedia::VeryHighQuality)); - - //video codecs - ui->videoCodecBox->addItem(tr("Default video codec"), QVariant(QString())); - const QStringList supportedVideoCodecs = mediaRecorder->supportedVideoCodecs(); - for (const QString &codecName : supportedVideoCodecs) { - QString description = mediaRecorder->videoCodecDescription(codecName); - ui->videoCodecBox->addItem(codecName + ": " + description, QVariant(codecName)); - } - - ui->videoQualitySlider->setRange(0, int(QMultimedia::VeryHighQuality)); - - - ui->videoResolutionBox->addItem(tr("Default")); - const QList<QSize> supportedResolutions = mediaRecorder->supportedResolutions(); - for (const QSize &resolution : supportedResolutions) { - ui->videoResolutionBox->addItem(QString("%1x%2").arg(resolution.width()).arg(resolution.height()), - QVariant(resolution)); - } - - ui->videoFramerateBox->addItem(tr("Default")); - const QList<qreal> supportedFrameRates = mediaRecorder->supportedFrameRates(); - for (qreal rate : supportedFrameRates) { - QString rateString = QString("%1").arg(rate, 0, 'f', 2); - ui->videoFramerateBox->addItem(rateString, QVariant(rate)); - } - - //containers - ui->containerFormatBox->addItem(tr("Default container"), QVariant(QString())); - const QStringList formats = mediaRecorder->supportedContainers(); - for (const QString &format : formats) { - ui->containerFormatBox->addItem(format + ": " + mediaRecorder->containerDescription(format), - QVariant(format)); - } -} - -VideoSettings::~VideoSettings() -{ - delete ui; -} - -void VideoSettings::changeEvent(QEvent *e) -{ - QDialog::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} - -QAudioEncoderSettings VideoSettings::audioSettings() const -{ - QAudioEncoderSettings settings = mediaRecorder->audioSettings(); - settings.setCodec(boxValue(ui->audioCodecBox).toString()); - settings.setQuality(QMultimedia::EncodingQuality(ui->audioQualitySlider->value())); - settings.setSampleRate(boxValue(ui->audioSampleRateBox).toInt()); - return settings; -} - -void VideoSettings::setAudioSettings(const QAudioEncoderSettings &audioSettings) -{ - selectComboBoxItem(ui->audioCodecBox, QVariant(audioSettings.codec())); - selectComboBoxItem(ui->audioSampleRateBox, QVariant(audioSettings.sampleRate())); - ui->audioQualitySlider->setValue(audioSettings.quality()); -} - -QVideoEncoderSettings VideoSettings::videoSettings() const -{ - QVideoEncoderSettings settings = mediaRecorder->videoSettings(); - settings.setCodec(boxValue(ui->videoCodecBox).toString()); - settings.setQuality(QMultimedia::EncodingQuality(ui->videoQualitySlider->value())); - settings.setResolution(boxValue(ui->videoResolutionBox).toSize()); - settings.setFrameRate(boxValue(ui->videoFramerateBox).value<qreal>()); - - return settings; -} - -void VideoSettings::setVideoSettings(const QVideoEncoderSettings &videoSettings) -{ - selectComboBoxItem(ui->videoCodecBox, QVariant(videoSettings.codec())); - selectComboBoxItem(ui->videoResolutionBox, QVariant(videoSettings.resolution())); - ui->videoQualitySlider->setValue(videoSettings.quality()); - - //special case for frame rate - for (int i = 0; i < ui->videoFramerateBox->count(); ++i) { - qreal itemRate = ui->videoFramerateBox->itemData(i).value<qreal>(); - if (qFuzzyCompare(itemRate, videoSettings.frameRate())) { - ui->videoFramerateBox->setCurrentIndex(i); - break; - } - } -} - -QString VideoSettings::format() const -{ - return boxValue(ui->containerFormatBox).toString(); -} - -void VideoSettings::setFormat(const QString &format) -{ - selectComboBoxItem(ui->containerFormatBox, QVariant(format)); -} - -QVariant VideoSettings::boxValue(const QComboBox *box) const -{ - int idx = box->currentIndex(); - if (idx == -1) - return QVariant(); - - return box->itemData(idx); -} - -void VideoSettings::selectComboBoxItem(QComboBox *box, const QVariant &value) -{ - for (int i = 0; i < box->count(); ++i) { - if (box->itemData(i) == value) { - box->setCurrentIndex(i); - break; - } - } -} diff --git a/examples/multimediawidgets/camera/videosettings.h b/examples/multimediawidgets/camera/videosettings.h deleted file mode 100644 index a192942a9..000000000 --- a/examples/multimediawidgets/camera/videosettings.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 VIDEOSETTINGS_H -#define VIDEOSETTINGS_H - -#include <QDialog> -#include <QAudioEncoderSettings> -#include <QVideoEncoderSettings> - -QT_BEGIN_NAMESPACE -class QComboBox; -class QMediaRecorder; -namespace Ui { class VideoSettingsUi; } -QT_END_NAMESPACE - -class VideoSettings : public QDialog -{ - Q_OBJECT - -public: - explicit VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent = nullptr); - ~VideoSettings(); - - QAudioEncoderSettings audioSettings() const; - void setAudioSettings(const QAudioEncoderSettings&); - - QVideoEncoderSettings videoSettings() const; - void setVideoSettings(const QVideoEncoderSettings&); - - QString format() const; - void setFormat(const QString &format); - -protected: - void changeEvent(QEvent *e) override; - -private: - QVariant boxValue(const QComboBox*) const; - void selectComboBoxItem(QComboBox *box, const QVariant &value); - - Ui::VideoSettingsUi *ui; - QMediaRecorder *mediaRecorder; -}; - -#endif // VIDEOSETTINGS_H diff --git a/examples/multimediawidgets/camera/videosettings.ui b/examples/multimediawidgets/camera/videosettings.ui deleted file mode 100644 index 940b7db7a..000000000 --- a/examples/multimediawidgets/camera/videosettings.ui +++ /dev/null @@ -1,211 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>VideoSettingsUi</class> - <widget class="QDialog" name="VideoSettingsUi"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>561</width> - <height>369</height> - </rect> - </property> - <property name="windowTitle"> - <string>Video Settings</string> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="0"> - <widget class="QScrollArea" name="scrollArea"> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> - </property> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>543</width> - <height>250</height> - </rect> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0"> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Audio</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="2"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Audio Codec:</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QComboBox" name="audioCodecBox"/> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Sample Rate:</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QComboBox" name="audioSampleRateBox"/> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Quality:</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QSlider" name="audioQualitySlider"> - <property name="maximum"> - <number>4</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="0" column="1" rowspan="3"> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Video</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0" colspan="2"> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>Resolution:</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QComboBox" name="videoResolutionBox"/> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QLabel" name="label_9"> - <property name="text"> - <string>Framerate:</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QComboBox" name="videoFramerateBox"/> - </item> - <item row="4" column="0" colspan="2"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Video Codec:</string> - </property> - </widget> - </item> - <item row="5" column="0" colspan="2"> - <widget class="QComboBox" name="videoCodecBox"/> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Quality:</string> - </property> - </widget> - </item> - <item row="6" column="1"> - <widget class="QSlider" name="videoQualitySlider"> - <property name="maximum"> - <number>4</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Container Format:</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QComboBox" name="containerFormatBox"/> - </item> - </layout> - </widget> - </widget> - </item> - <item row="1" column="0"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>14</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>VideoSettingsUi</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>322</x> - <y>272</y> - </hint> - <hint type="destinationlabel"> - <x>44</x> - <y>230</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>VideoSettingsUi</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>405</x> - <y>262</y> - </hint> - <hint type="destinationlabel"> - <x>364</x> - <y>227</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro b/examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro deleted file mode 100644 index 2fb123e77..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro +++ /dev/null @@ -1,16 +0,0 @@ -TEMPLATE = app -TARGET = customvideoitem - -QT += multimedia multimediawidgets widgets - -qtHaveModule(opengl): QT += opengl - -HEADERS += videoplayer.h \ - videoitem.h - -SOURCES += main.cpp \ - videoplayer.cpp \ - videoitem.cpp - -target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/customvideosurface/customvideoitem -INSTALLS += target diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp deleted file mode 100644 index 8db790deb..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h" - -#include <QApplication> - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - VideoPlayer player; - player.show(); - - return app.exec(); -} - diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp deleted file mode 100644 index c51673344..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videoitem.h" - -#include <QPainter> -#include <QTransform> -#include <QVideoSurfaceFormat> - -VideoItem::VideoItem(QGraphicsItem *parent) - : QGraphicsItem(parent) - , imageFormat(QImage::Format_Invalid) - , framePainted(false) -{ -} - -VideoItem::~VideoItem() -{ -} - -QRectF VideoItem::boundingRect() const -{ - return QRectF(QPointF(0,0), surfaceFormat().sizeHint()); -} - -void VideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - - if (currentFrame.map(QAbstractVideoBuffer::ReadOnly)) { - const QTransform oldTransform = painter->transform(); - - if (surfaceFormat().scanLineDirection() == QVideoSurfaceFormat::BottomToTop) { - painter->scale(1, -1); - painter->translate(0, -boundingRect().height()); - } - - painter->drawImage(boundingRect(), QImage( - currentFrame.bits(), - imageSize.width(), - imageSize.height(), - imageFormat)); - - painter->setTransform(oldTransform); - - framePainted = true; - - currentFrame.unmap(); - } -} - -QList<QVideoFrame::PixelFormat> VideoItem::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - if (handleType == QAbstractVideoBuffer::NoHandle) { - return QList<QVideoFrame::PixelFormat>() - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_ARGB32 - << QVideoFrame::Format_ARGB32_Premultiplied - << QVideoFrame::Format_RGB565 - << QVideoFrame::Format_RGB555; - } else { - return QList<QVideoFrame::PixelFormat>(); - } -} - -bool VideoItem::start(const QVideoSurfaceFormat &format) -{ - if (isFormatSupported(format)) { - imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); - imageSize = format.frameSize(); - framePainted = true; - - QAbstractVideoSurface::start(format); - - prepareGeometryChange(); - - return true; - } else { - return false; - } -} - -void VideoItem::stop() -{ - currentFrame = QVideoFrame(); - framePainted = false; - - QAbstractVideoSurface::stop(); -} - -bool VideoItem::present(const QVideoFrame &frame) -{ - if (!framePainted) { - if (!QAbstractVideoSurface::isActive()) - setError(StoppedError); - - return false; - } else { - currentFrame = frame; - framePainted = false; - - update(); - - return true; - } -} diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h b/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h deleted file mode 100644 index 2dc121d92..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 VIDEOITEM_H -#define VIDEOITEM_H - -#include <QAbstractVideoSurface> -#include <QGraphicsItem> - -class VideoItem - : public QAbstractVideoSurface, - public QGraphicsItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsItem) - -public: - explicit VideoItem(QGraphicsItem *parentItem = 0); - ~VideoItem(); - - QRectF boundingRect() const override; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override; - - //video surface - QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const override; - - bool start(const QVideoSurfaceFormat &format) override; - void stop() override; - bool present(const QVideoFrame &frame) override; - -private: - QImage::Format imageFormat; - QSize imageSize; - - QVideoFrame currentFrame; - bool framePainted; -}; - -#endif // VIDEOITEM_H - diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp deleted file mode 100644 index 2a9900c2b..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h" -#include "videoitem.h" - -#include <QtWidgets> -#include <QVideoSurfaceFormat> - -#if !defined(QT_NO_OPENGL) -# include <QOpenGLWidget> -#endif - -VideoPlayer::VideoPlayer(QWidget *parent) - : QWidget(parent) - , mediaPlayer(0, QMediaPlayer::VideoSurface) - , videoItem(0) - , playButton(0) - , positionSlider(0) -{ - videoItem = new VideoItem; - - QGraphicsScene *scene = new QGraphicsScene(this); - QGraphicsView *graphicsView = new QGraphicsView(scene); - -#if !defined(QT_NO_OPENGL) - graphicsView->setViewport(new QOpenGLWidget); -#endif - - scene->addItem(videoItem); - - QSlider *rotateSlider = new QSlider(Qt::Horizontal); - rotateSlider->setRange(-180, 180); - rotateSlider->setValue(0); - - connect(rotateSlider, &QSlider::valueChanged, - this, &VideoPlayer::rotateVideo); - - QAbstractButton *openButton = new QPushButton(tr("Open...")); - connect(openButton, &QAbstractButton::clicked, - this, &VideoPlayer::openFile); - - playButton = new QPushButton; - playButton->setEnabled(false); - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - - connect(playButton, &QAbstractButton::clicked, - this, &VideoPlayer::play); - - positionSlider = new QSlider(Qt::Horizontal); - positionSlider->setRange(0, 0); - - connect(positionSlider, &QSlider::sliderMoved, - this, &VideoPlayer::setPosition); - - QBoxLayout *controlLayout = new QHBoxLayout; - controlLayout->setContentsMargins(0, 0, 0, 0); - controlLayout->addWidget(openButton); - controlLayout->addWidget(playButton); - controlLayout->addWidget(positionSlider); - - QBoxLayout *layout = new QVBoxLayout; - layout->addWidget(graphicsView); - layout->addWidget(rotateSlider); - layout->addLayout(controlLayout); - - setLayout(layout); - - mediaPlayer.setVideoOutput(videoItem); - connect(&mediaPlayer, &QMediaPlayer::stateChanged, - this, &VideoPlayer::mediaStateChanged); - connect(&mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged); - connect(&mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged); -} - -VideoPlayer::~VideoPlayer() -{ -} - - -void VideoPlayer::openFile() -{ - QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"),QDir::homePath()); - - if (!fileName.isEmpty()) { - mediaPlayer.setMedia(QUrl::fromLocalFile(fileName)); - - playButton->setEnabled(true); - } -} - -void VideoPlayer::play() -{ - switch(mediaPlayer.state()) { - case QMediaPlayer::PlayingState: - mediaPlayer.pause(); - break; - default: - mediaPlayer.play(); - break; - } -} - -void VideoPlayer::mediaStateChanged(QMediaPlayer::State state) -{ - switch(state) { - case QMediaPlayer::PlayingState: - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); - break; - default: - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - } -} - -void VideoPlayer::positionChanged(qint64 position) -{ - positionSlider->setValue(position); -} - -void VideoPlayer::durationChanged(qint64 duration) -{ - positionSlider->setRange(0, duration); -} - -void VideoPlayer::setPosition(int position) -{ - mediaPlayer.setPosition(position); -} - - -void VideoPlayer::rotateVideo(int angle) -{ - //rotate around the center of video element - qreal x = videoItem->boundingRect().width() / 2.0; - qreal y = videoItem->boundingRect().height() / 2.0; - videoItem->setTransform(QTransform().translate(x, y).rotate(angle).translate(-x, -y)); -} diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h b/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h deleted file mode 100644 index 0ee7d751e..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 VIDEOPLAYER_H -#define VIDEOPLAYER_H - -#include <QMediaPlayer> -#include <QMovie> -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QAbstractButton; -class QSlider; -QT_END_NAMESPACE - -class VideoItem; - -class VideoPlayer : public QWidget -{ - Q_OBJECT - -public: - VideoPlayer(QWidget *parent = 0); - ~VideoPlayer(); - - QSize sizeHint() const override { return QSize(800, 600); } - -public slots: - void openFile(); - void play(); - -private slots: - void mediaStateChanged(QMediaPlayer::State state); - void positionChanged(qint64 position); - void durationChanged(qint64 duration); - void setPosition(int position); - void rotateVideo(int angle); - -private: - QMediaPlayer mediaPlayer; - VideoItem *videoItem; - QAbstractButton *playButton; - QSlider *positionSlider; -}; - -#endif // VIDEOPLAYER_H - diff --git a/examples/multimediawidgets/customvideosurface/customvideosurface.pro b/examples/multimediawidgets/customvideosurface/customvideosurface.pro deleted file mode 100644 index baffdaba7..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideosurface.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += customvideoitem customvideowidget - diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/customvideowidget.pro b/examples/multimediawidgets/customvideosurface/customvideowidget/customvideowidget.pro deleted file mode 100644 index b4476dfb7..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideowidget/customvideowidget.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = app -TARGET = customvideowidget - -QT += multimedia multimediawidgets widgets - -HEADERS = \ - videoplayer.h \ - videowidget.h \ - videowidgetsurface.h - -SOURCES = \ - main.cpp \ - videoplayer.cpp \ - videowidget.cpp \ - videowidgetsurface.cpp - -target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/customvideosurface/customvideowidget -INSTALLS += target diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/main.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/main.cpp deleted file mode 100644 index 0d5e30849..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideowidget/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h" - -#include <QtWidgets/QApplication> - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - VideoPlayer player; - player.show(); - - return app.exec(); -} diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp deleted file mode 100644 index 5c1ca4221..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h" - -#include "videowidget.h" - -#include <QtWidgets> -#include <qvideosurfaceformat.h> - -VideoPlayer::VideoPlayer(QWidget *parent) - : QWidget(parent) - , mediaPlayer(0, QMediaPlayer::VideoSurface) - , playButton(0) - , positionSlider(0) -{ - VideoWidget *videoWidget = new VideoWidget; - - QAbstractButton *openButton = new QPushButton(tr("Open...")); - connect(openButton, &QAbstractButton::clicked, - this, &VideoPlayer::openFile); - - playButton = new QPushButton; - playButton->setEnabled(false); - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - - connect(playButton, &QAbstractButton::clicked, - this, &VideoPlayer::play); - - positionSlider = new QSlider(Qt::Horizontal); - positionSlider->setRange(0, 0); - - connect(positionSlider, &QSlider::sliderMoved, - this, &VideoPlayer::setPosition); - - QBoxLayout *controlLayout = new QHBoxLayout; - controlLayout->setContentsMargins(0, 0, 0, 0); - controlLayout->addWidget(openButton); - controlLayout->addWidget(playButton); - controlLayout->addWidget(positionSlider); - - QBoxLayout *layout = new QVBoxLayout; - layout->addWidget(videoWidget); - layout->addLayout(controlLayout); - - setLayout(layout); - - mediaPlayer.setVideoOutput(videoWidget->videoSurface()); - connect(&mediaPlayer, &QMediaPlayer::stateChanged, - this, &VideoPlayer::mediaStateChanged); - connect(&mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged); - connect(&mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged); -} - -VideoPlayer::~VideoPlayer() -{ -} - -void VideoPlayer::openFile() -{ - QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"),QDir::homePath()); - - if (!fileName.isEmpty()) { - mediaPlayer.setMedia(QUrl::fromLocalFile(fileName)); - - playButton->setEnabled(true); - } -} - -void VideoPlayer::play() -{ - switch(mediaPlayer.state()) { - case QMediaPlayer::PlayingState: - mediaPlayer.pause(); - break; - default: - mediaPlayer.play(); - break; - } -} - -void VideoPlayer::mediaStateChanged(QMediaPlayer::State state) -{ - switch(state) { - case QMediaPlayer::PlayingState: - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); - break; - default: - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - } -} - -void VideoPlayer::positionChanged(qint64 position) -{ - positionSlider->setValue(position); -} - -void VideoPlayer::durationChanged(qint64 duration) -{ - positionSlider->setRange(0, duration); -} - -void VideoPlayer::setPosition(int position) -{ - mediaPlayer.setPosition(position); -} diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.h b/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.h deleted file mode 100644 index ea9b6cf6b..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 VIDEOPLAYER_H -#define VIDEOPLAYER_H - -#include <QMediaPlayer> -#include <QMovie> -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QAbstractButton; -class QSlider; -QT_END_NAMESPACE - -class VideoPlayer : public QWidget -{ - Q_OBJECT - -public: - VideoPlayer(QWidget *parent = 0); - ~VideoPlayer(); - -public slots: - void openFile(); - void play(); - -private slots: - void mediaStateChanged(QMediaPlayer::State state); - void positionChanged(qint64 position); - void durationChanged(qint64 duration); - void setPosition(int position); - -private: - QMediaPlayer mediaPlayer; - QAbstractButton *playButton; - QSlider *positionSlider; -}; - -#endif // VIDEOPLAYER_H diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.cpp deleted file mode 100644 index 12ac34a35..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videowidget.h" - -#include "videowidgetsurface.h" - -#include <QtWidgets> -#include <qvideosurfaceformat.h> - -//! [0] -VideoWidget::VideoWidget(QWidget *parent) - : QWidget(parent) - , surface(0) -{ - setAutoFillBackground(false); - setAttribute(Qt::WA_NoSystemBackground, true); - - QPalette palette = this->palette(); - palette.setColor(QPalette::Window, Qt::black); - setPalette(palette); - - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - - surface = new VideoWidgetSurface(this); -} -//! [0] - -//! [1] -VideoWidget::~VideoWidget() -{ - delete surface; -} -//! [1] - -//! [2] -QSize VideoWidget::sizeHint() const -{ - return surface->surfaceFormat().sizeHint(); -} -//! [2] - - -//! [3] -void VideoWidget::paintEvent(QPaintEvent *event) -{ - QPainter painter(this); - - if (surface->isActive()) { - const QRect videoRect = surface->videoRect(); - - if (!videoRect.contains(event->rect())) { - QRegion region = event->region(); - region = region.subtracted(videoRect); - - QBrush brush = palette().window(); - - for (const QRect &rect : region) - painter.fillRect(rect, brush); - } - - surface->paint(&painter); - } else { - painter.fillRect(event->rect(), palette().window()); - } -} -//! [3] - -//! [4] -void VideoWidget::resizeEvent(QResizeEvent *event) -{ - QWidget::resizeEvent(event); - - surface->updateVideoRect(); -} -//! [4] diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.h b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.h deleted file mode 100644 index 1b90c3642..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include "videowidgetsurface.h" - -#include <QWidget> - -//! [0] -class VideoWidget : public QWidget -{ - Q_OBJECT - -public: - VideoWidget(QWidget *parent = 0); - ~VideoWidget(); - - QAbstractVideoSurface *videoSurface() const { return surface; } - - QSize sizeHint() const override; - -protected: - void paintEvent(QPaintEvent *event) override; - void resizeEvent(QResizeEvent *event) override; - -private: - VideoWidgetSurface *surface; -}; -//! [0] - -#endif // VIDEOWIDGET_H diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp deleted file mode 100644 index 9937f1824..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videowidgetsurface.h" - -#include <QtWidgets> -#include <qabstractvideosurface.h> -#include <qvideosurfaceformat.h> - -VideoWidgetSurface::VideoWidgetSurface(QWidget *widget, QObject *parent) - : QAbstractVideoSurface(parent) - , widget(widget) - , imageFormat(QImage::Format_Invalid) -{ -} - -//! [0] -QList<QVideoFrame::PixelFormat> VideoWidgetSurface::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - if (handleType == QAbstractVideoBuffer::NoHandle) { - return QList<QVideoFrame::PixelFormat>() - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_ARGB32 - << QVideoFrame::Format_ARGB32_Premultiplied - << QVideoFrame::Format_RGB565 - << QVideoFrame::Format_RGB555; - } else { - return QList<QVideoFrame::PixelFormat>(); - } -} -//! [0] - -//! [1] -bool VideoWidgetSurface::isFormatSupported(const QVideoSurfaceFormat &format) const -{ - const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); - const QSize size = format.frameSize(); - - return imageFormat != QImage::Format_Invalid - && !size.isEmpty() - && format.handleType() == QAbstractVideoBuffer::NoHandle; -} -//! [1] - -//! [2] -bool VideoWidgetSurface::start(const QVideoSurfaceFormat &format) -{ - const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); - const QSize size = format.frameSize(); - - if (imageFormat != QImage::Format_Invalid && !size.isEmpty()) { - this->imageFormat = imageFormat; - imageSize = size; - sourceRect = format.viewport(); - - QAbstractVideoSurface::start(format); - - widget->updateGeometry(); - updateVideoRect(); - - return true; - } else { - return false; - } -} -//! [2] - -//! [3] -void VideoWidgetSurface::stop() -{ - currentFrame = QVideoFrame(); - targetRect = QRect(); - - QAbstractVideoSurface::stop(); - - widget->update(); -} -//! [3] - -//! [4] -bool VideoWidgetSurface::present(const QVideoFrame &frame) -{ - if (surfaceFormat().pixelFormat() != frame.pixelFormat() - || surfaceFormat().frameSize() != frame.size()) { - setError(IncorrectFormatError); - stop(); - - return false; - } else { - currentFrame = frame; - - widget->repaint(targetRect); - - return true; - } -} -//! [4] - -//! [5] -void VideoWidgetSurface::updateVideoRect() -{ - QSize size = surfaceFormat().sizeHint(); - size.scale(widget->size().boundedTo(size), Qt::KeepAspectRatio); - - targetRect = QRect(QPoint(0, 0), size); - targetRect.moveCenter(widget->rect().center()); -} -//! [5] - -//! [6] -void VideoWidgetSurface::paint(QPainter *painter) -{ - if (currentFrame.map(QAbstractVideoBuffer::ReadOnly)) { - const QTransform oldTransform = painter->transform(); - - if (surfaceFormat().scanLineDirection() == QVideoSurfaceFormat::BottomToTop) { - painter->scale(1, -1); - painter->translate(0, -widget->height()); - } - - QImage image( - currentFrame.bits(), - currentFrame.width(), - currentFrame.height(), - currentFrame.bytesPerLine(), - imageFormat); - - painter->drawImage(targetRect, image, sourceRect); - - painter->setTransform(oldTransform); - - currentFrame.unmap(); - } -} -//! [6] diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h deleted file mode 100644 index d9765d836..000000000 --- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 VIDEOWIDGETSURFACE_H -#define VIDEOWIDGETSURFACE_H - -#include <QAbstractVideoSurface> -#include <QImage> -#include <QRect> -#include <QVideoFrame> - -//! [0] -class VideoWidgetSurface : public QAbstractVideoSurface -{ - Q_OBJECT - -public: - VideoWidgetSurface(QWidget *widget, QObject *parent = 0); - - QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const override; - bool isFormatSupported(const QVideoSurfaceFormat &format) const override; - - bool start(const QVideoSurfaceFormat &format) override; - void stop() override; - - bool present(const QVideoFrame &frame) override; - - QRect videoRect() const { return targetRect; } - void updateVideoRect(); - - void paint(QPainter *painter); - -private: - QWidget *widget; - QImage::Format imageFormat; - QRect targetRect; - QSize imageSize; - QRect sourceRect; - QVideoFrame currentFrame; -}; -//! [0] - -#endif diff --git a/examples/multimediawidgets/multimediawidgets.pro b/examples/multimediawidgets/multimediawidgets.pro deleted file mode 100644 index 001a78d50..000000000 --- a/examples/multimediawidgets/multimediawidgets.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = subdirs - -# These examples all need widgets for now (using creator templates that use widgets) -qtHaveModule(widgets) { - SUBDIRS += \ - camera \ - videographicsitem \ - videowidget \ - player \ - customvideosurface -} diff --git a/examples/multimediawidgets/player/doc/images/mediaplayerex.jpg b/examples/multimediawidgets/player/doc/images/mediaplayerex.jpg Binary files differdeleted file mode 100644 index e875bd134..000000000 --- a/examples/multimediawidgets/player/doc/images/mediaplayerex.jpg +++ /dev/null diff --git a/examples/multimediawidgets/player/doc/src/player.qdoc b/examples/multimediawidgets/player/doc/src/player.qdoc deleted file mode 100644 index 901b57fd1..000000000 --- a/examples/multimediawidgets/player/doc/src/player.qdoc +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** 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. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example multimediawidgets/player - \title Media Player Example - \ingroup multimedia_examples - \brief Playing audio and video. - - \image mediaplayerex.jpg - - \e{Media Player} demonstrates a simple multimedia player that can play - audio and or video files using various codecs. - - \include examples-run.qdocinc - - The example uses a QMediaPlayer object passed into a QVideoWidget to - control the video output. To give the application playlist capability - we also use a QPlayList object. - - To activate the various functions such as play and stop on the dialog, - the button clicked events emit the play() and stop() signals, which - are connected to the play() and stop() slots of QMediaPlayer. - - \code - connect(controls, SIGNAL(play()), player, SLOT(play())); - connect(controls, SIGNAL(pause()), player, SLOT(pause())); - connect(controls, SIGNAL(stop()), player, SLOT(stop())); - \endcode - - We can get the volume (and set our user interface representation) - - \code - controls->setVolume(player->volume()); - \endcode - - and we can make widget 'volume' changes change the volume - - \code - connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int))); - \endcode - - The example also allows us to change various video properties by means - of the QVideoWidget object. We can go to Full Screen mode with a single - button click, and back again. Or if we press the "Color Options" dialog - button we can have access to more subtle influences. The dialog has a - set of sliders so that we can change the brightness, contrast, hue and - saturation of the video being watched. The connect() statements are in - pairs so that changes to either the user interface widget (the relevant - slider) or the QVideoWidget object will update the other object. - - \code - connect(brightnessSlider, SIGNAL(sliderMoved(int)), videoWidget, - SLOT(setBrightness(int))); - connect(videoWidget, SIGNAL(brightnessChanged(int)), - brightnessSlider, SLOT(setValue(int))); - - connect(contrastSlider, SIGNAL(sliderMoved(int)), videoWidget, - SLOT(setContrast(int))); - connect(videoWidget, SIGNAL(contrastChanged(int)), contrastSlider, - SLOT(setValue(int))); - - connect(hueSlider, SIGNAL(sliderMoved(int)), videoWidget, - SLOT(setHue(int))); - connect(videoWidget, SIGNAL(hueChanged(int)), hueSlider, - SLOT(setValue(int))); - - connect(saturationSlider, SIGNAL(sliderMoved(int)), videoWidget, - SLOT(setSaturation(int))); - connect(videoWidget, SIGNAL(saturationChanged(int)), - saturationSlider, SLOT(setValue(int))); - \endcode - -*/ diff --git a/examples/multimediawidgets/player/histogramwidget.cpp b/examples/multimediawidgets/player/histogramwidget.cpp deleted file mode 100644 index bb214cad5..000000000 --- a/examples/multimediawidgets/player/histogramwidget.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "histogramwidget.h" -#include <QPainter> -#include <QHBoxLayout> - -template<class T> -static QList<qreal> getBufferLevels(const T *buffer, int frames, int channels); - -class QAudioLevel : public QWidget -{ - Q_OBJECT -public: - explicit QAudioLevel(QWidget *parent = nullptr); - - // Using [0; 1.0] range - void setLevel(qreal level); - -protected: - void paintEvent(QPaintEvent *event); - -private: - qreal m_level = 0; -}; - -QAudioLevel::QAudioLevel(QWidget *parent) - : QWidget(parent) -{ - setMinimumHeight(15); - setMaximumHeight(50); -} - -void QAudioLevel::setLevel(qreal level) -{ - if (m_level != level) { - m_level = level; - update(); - } -} - -void QAudioLevel::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - - QPainter painter(this); - // draw level - qreal widthLevel = m_level * width(); - painter.fillRect(0, 0, widthLevel, height(), Qt::red); - // clear the rest of the control - painter.fillRect(widthLevel, 0, width(), height(), Qt::black); -} - -HistogramWidget::HistogramWidget(QWidget *parent) - : QWidget(parent) -{ - m_processor.moveToThread(&m_processorThread); - qRegisterMetaType<QList<qreal>>("QList<qreal>"); - connect(&m_processor, &FrameProcessor::histogramReady, this, &HistogramWidget::setHistogram); - m_processorThread.start(QThread::LowestPriority); - setLayout(new QHBoxLayout); -} - -HistogramWidget::~HistogramWidget() -{ - m_processorThread.quit(); - m_processorThread.wait(10000); -} - -void HistogramWidget::processFrame(const QVideoFrame &frame) -{ - if (m_isBusy && frame.isValid()) - return; //drop frame - - m_isBusy = true; - QMetaObject::invokeMethod(&m_processor, "processFrame", - Qt::QueuedConnection, Q_ARG(QVideoFrame, frame), Q_ARG(int, m_levels)); -} - -// This function returns the maximum possible sample value for a given audio format -qreal getPeakValue(const QAudioFormat& format) -{ - // Note: Only the most common sample formats are supported - if (!format.isValid()) - return qreal(0); - - if (format.codec() != "audio/pcm") - return qreal(0); - - switch (format.sampleType()) { - case QAudioFormat::Unknown: - break; - case QAudioFormat::Float: - if (format.sampleSize() != 32) // other sample formats are not supported - return qreal(0); - return qreal(1.00003); - case QAudioFormat::SignedInt: - if (format.sampleSize() == 32) - return qreal(INT_MAX); - if (format.sampleSize() == 16) - return qreal(SHRT_MAX); - if (format.sampleSize() == 8) - return qreal(CHAR_MAX); - break; - case QAudioFormat::UnSignedInt: - if (format.sampleSize() == 32) - return qreal(UINT_MAX); - if (format.sampleSize() == 16) - return qreal(USHRT_MAX); - if (format.sampleSize() == 8) - return qreal(UCHAR_MAX); - break; - } - - return qreal(0); -} - -// returns the audio level for each channel -QList<qreal> getBufferLevels(const QAudioBuffer &buffer) -{ - QList<qreal> values; - - if (!buffer.isValid()) - return values; - - if (!buffer.format().isValid() || buffer.format().byteOrder() != QAudioFormat::LittleEndian) - return values; - - if (buffer.format().codec() != "audio/pcm") - return values; - - int channelCount = buffer.format().channelCount(); - values.fill(0, channelCount); - qreal peak_value = getPeakValue(buffer.format()); - if (qFuzzyCompare(peak_value, qreal(0))) - return values; - - switch (buffer.format().sampleType()) { - case QAudioFormat::Unknown: - case QAudioFormat::UnSignedInt: - if (buffer.format().sampleSize() == 32) - values = getBufferLevels(buffer.constData<quint32>(), buffer.frameCount(), channelCount); - if (buffer.format().sampleSize() == 16) - values = getBufferLevels(buffer.constData<quint16>(), buffer.frameCount(), channelCount); - if (buffer.format().sampleSize() == 8) - values = getBufferLevels(buffer.constData<quint8>(), buffer.frameCount(), channelCount); - for (int i = 0; i < values.size(); ++i) - values[i] = qAbs(values.at(i) - peak_value / 2) / (peak_value / 2); - break; - case QAudioFormat::Float: - if (buffer.format().sampleSize() == 32) { - values = getBufferLevels(buffer.constData<float>(), buffer.frameCount(), channelCount); - for (int i = 0; i < values.size(); ++i) - values[i] /= peak_value; - } - break; - case QAudioFormat::SignedInt: - if (buffer.format().sampleSize() == 32) - values = getBufferLevels(buffer.constData<qint32>(), buffer.frameCount(), channelCount); - if (buffer.format().sampleSize() == 16) - values = getBufferLevels(buffer.constData<qint16>(), buffer.frameCount(), channelCount); - if (buffer.format().sampleSize() == 8) - values = getBufferLevels(buffer.constData<qint8>(), buffer.frameCount(), channelCount); - for (int i = 0; i < values.size(); ++i) - values[i] /= peak_value; - break; - } - - return values; -} - -template<class T> -QList<qreal> getBufferLevels(const T *buffer, int frames, int channels) -{ - QList<qreal> max_values; - max_values.fill(0, channels); - - for (int i = 0; i < frames; ++i) { - for (int j = 0; j < channels; ++j) { - qreal value = qAbs(qreal(buffer[i * channels + j])); - if (value > max_values.at(j)) - max_values.replace(j, value); - } - } - - return max_values; -} - -void HistogramWidget::processBuffer(const QAudioBuffer &buffer) -{ - if (m_audioLevels.count() != buffer.format().channelCount()) { - qDeleteAll(m_audioLevels); - m_audioLevels.clear(); - for (int i = 0; i < buffer.format().channelCount(); ++i) { - QAudioLevel *level = new QAudioLevel(this); - m_audioLevels.append(level); - layout()->addWidget(level); - } - } - - QList<qreal> levels = getBufferLevels(buffer); - for (int i = 0; i < levels.count(); ++i) - m_audioLevels.at(i)->setLevel(levels.at(i)); -} - -void HistogramWidget::setHistogram(const QList<qreal> &histogram) -{ - m_isBusy = false; - m_histogram = histogram; - update(); -} - -void HistogramWidget::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - - if (!m_audioLevels.isEmpty()) - return; - - QPainter painter(this); - - if (m_histogram.isEmpty()) { - painter.fillRect(0, 0, width(), height(), QColor::fromRgb(0, 0, 0)); - return; - } - - qreal barWidth = width() / (qreal)m_histogram.size(); - - for (int i = 0; i < m_histogram.size(); ++i) { - qreal h = m_histogram[i] * height(); - // draw level - painter.fillRect(barWidth * i, height() - h, barWidth * (i + 1), height(), Qt::red); - // clear the rest of the control - painter.fillRect(barWidth * i, 0, barWidth * (i + 1), height() - h, Qt::black); - } -} - -void FrameProcessor::processFrame(QVideoFrame frame, int levels) -{ - QList<qreal> histogram(levels); - - do { - if (!levels) - break; - - if (!frame.map(QAbstractVideoBuffer::ReadOnly)) - break; - - if (frame.pixelFormat() == QVideoFrame::Format_YUV420P || - frame.pixelFormat() == QVideoFrame::Format_NV12) { - // Process YUV data - uchar *b = frame.bits(); - for (int y = 0; y < frame.height(); ++y) { - uchar *lastPixel = b + frame.width(); - for (uchar *curPixel = b; curPixel < lastPixel; curPixel++) - histogram[(*curPixel * levels) >> 8] += 1.0; - b += frame.bytesPerLine(); - } - } else { - QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat()); - if (imageFormat != QImage::Format_Invalid) { - // Process RGB data - QImage image(frame.bits(), frame.width(), frame.height(), imageFormat); - image = image.convertToFormat(QImage::Format_RGB32); - - const QRgb* b = (const QRgb*)image.bits(); - for (int y = 0; y < image.height(); ++y) { - const QRgb *lastPixel = b + frame.width(); - for (const QRgb *curPixel = b; curPixel < lastPixel; curPixel++) - histogram[(qGray(*curPixel) * levels) >> 8] += 1.0; - b = (const QRgb*)((uchar*)b + image.bytesPerLine()); - } - } - } - - // find maximum value - qreal maxValue = 0.0; - for (int i = 0; i < histogram.size(); i++) { - if (histogram[i] > maxValue) - maxValue = histogram[i]; - } - - if (maxValue > 0.0) { - for (int i = 0; i < histogram.size(); i++) - histogram[i] /= maxValue; - } - - frame.unmap(); - } while (false); - - emit histogramReady(histogram); -} - -#include "histogramwidget.moc" diff --git a/examples/multimediawidgets/player/histogramwidget.h b/examples/multimediawidgets/player/histogramwidget.h deleted file mode 100644 index 08ba4f342..000000000 --- a/examples/multimediawidgets/player/histogramwidget.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 HISTOGRAMWIDGET_H -#define HISTOGRAMWIDGET_H - -#include <QThread> -#include <QVideoFrame> -#include <QAudioBuffer> -#include <QWidget> - -class QAudioLevel; - -class FrameProcessor: public QObject -{ - Q_OBJECT - -public slots: - void processFrame(QVideoFrame frame, int levels); - -signals: - void histogramReady(const QList<qreal> &histogram); -}; - -class HistogramWidget : public QWidget -{ - Q_OBJECT - -public: - explicit HistogramWidget(QWidget *parent = nullptr); - ~HistogramWidget(); - void setLevels(int levels) { m_levels = levels; } - -public slots: - void processFrame(const QVideoFrame &frame); - void processBuffer(const QAudioBuffer &buffer); - void setHistogram(const QList<qreal> &histogram); - -protected: - void paintEvent(QPaintEvent *event) override; - -private: - QList<qreal> m_histogram; - int m_levels = 128; - FrameProcessor m_processor; - QThread m_processorThread; - bool m_isBusy = false; - QList<QAudioLevel *> m_audioLevels; -}; - -#endif // HISTOGRAMWIDGET_H diff --git a/examples/multimediawidgets/player/main.cpp b/examples/multimediawidgets/player/main.cpp deleted file mode 100644 index a20fb1c4f..000000000 --- a/examples/multimediawidgets/player/main.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "player.h" - -#include <QApplication> -#include <QCommandLineParser> -#include <QCommandLineOption> -#include <QDir> - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QCoreApplication::setApplicationName("Player Example"); - QCoreApplication::setOrganizationName("QtProject"); - QCoreApplication::setApplicationVersion(QT_VERSION_STR); - QCommandLineParser parser; - QCommandLineOption customAudioRoleOption("custom-audio-role", - "Set a custom audio role for the player.", - "role"); - parser.setApplicationDescription("Qt MultiMedia Player Example"); - parser.addHelpOption(); - parser.addVersionOption(); - parser.addOption(customAudioRoleOption); - parser.addPositionalArgument("url", "The URL(s) to open."); - parser.process(app); - - Player player; - - if (parser.isSet(customAudioRoleOption)) - player.setCustomAudioRole(parser.value(customAudioRoleOption)); - - if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) { - QList<QUrl> urls; - for (auto &a: parser.positionalArguments()) - urls.append(QUrl::fromUserInput(a, QDir::currentPath(), QUrl::AssumeLocalFile)); - player.addToPlaylist(urls); - } - - player.show(); - return app.exec(); -} diff --git a/examples/multimediawidgets/player/player.cpp b/examples/multimediawidgets/player/player.cpp deleted file mode 100644 index 04da42587..000000000 --- a/examples/multimediawidgets/player/player.cpp +++ /dev/null @@ -1,483 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "player.h" - -#include "playercontrols.h" -#include "playlistmodel.h" -#include "histogramwidget.h" -#include "videowidget.h" - -#include <QMediaService> -#include <QMediaPlaylist> -#include <QVideoProbe> -#include <QAudioProbe> -#include <QMediaMetaData> -#include <QtWidgets> - -Player::Player(QWidget *parent) - : QWidget(parent) -{ -//! [create-objs] - m_player = new QMediaPlayer(this); - m_player->setAudioRole(QAudio::VideoRole); - qInfo() << "Supported audio roles:"; - for (QAudio::Role role : m_player->supportedAudioRoles()) - qInfo() << " " << role; - // owned by PlaylistModel - m_playlist = new QMediaPlaylist(); - m_player->setPlaylist(m_playlist); -//! [create-objs] - - connect(m_player, &QMediaPlayer::durationChanged, this, &Player::durationChanged); - connect(m_player, &QMediaPlayer::positionChanged, this, &Player::positionChanged); - connect(m_player, QOverload<>::of(&QMediaPlayer::metaDataChanged), this, &Player::metaDataChanged); - connect(m_playlist, &QMediaPlaylist::currentIndexChanged, this, &Player::playlistPositionChanged); - connect(m_player, &QMediaPlayer::mediaStatusChanged, this, &Player::statusChanged); - connect(m_player, &QMediaPlayer::bufferStatusChanged, this, &Player::bufferingProgress); - connect(m_player, &QMediaPlayer::videoAvailableChanged, this, &Player::videoAvailableChanged); - connect(m_player, QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error), this, &Player::displayErrorMessage); - connect(m_player, &QMediaPlayer::stateChanged, this, &Player::stateChanged); - -//! [2] - m_videoWidget = new VideoWidget(this); - m_player->setVideoOutput(m_videoWidget); - - m_playlistModel = new PlaylistModel(this); - m_playlistModel->setPlaylist(m_playlist); -//! [2] - - m_playlistView = new QListView(this); - m_playlistView->setModel(m_playlistModel); - m_playlistView->setCurrentIndex(m_playlistModel->index(m_playlist->currentIndex(), 0)); - - connect(m_playlistView, &QAbstractItemView::activated, this, &Player::jump); - - m_slider = new QSlider(Qt::Horizontal, this); - m_slider->setRange(0, m_player->duration() / 1000); - - m_labelDuration = new QLabel(this); - connect(m_slider, &QSlider::sliderMoved, this, &Player::seek); - - m_labelHistogram = new QLabel(this); - m_labelHistogram->setText("Histogram:"); - m_videoHistogram = new HistogramWidget(this); - m_audioHistogram = new HistogramWidget(this); - QHBoxLayout *histogramLayout = new QHBoxLayout; - histogramLayout->addWidget(m_labelHistogram); - histogramLayout->addWidget(m_videoHistogram, 1); - histogramLayout->addWidget(m_audioHistogram, 2); - - m_videoProbe = new QVideoProbe(this); - connect(m_videoProbe, &QVideoProbe::videoFrameProbed, m_videoHistogram, &HistogramWidget::processFrame); - m_videoProbe->setSource(m_player); - - m_audioProbe = new QAudioProbe(this); - connect(m_audioProbe, &QAudioProbe::audioBufferProbed, m_audioHistogram, &HistogramWidget::processBuffer); - m_audioProbe->setSource(m_player); - - QPushButton *openButton = new QPushButton(tr("Open"), this); - - connect(openButton, &QPushButton::clicked, this, &Player::open); - - PlayerControls *controls = new PlayerControls(this); - controls->setState(m_player->state()); - controls->setVolume(m_player->volume()); - controls->setMuted(controls->isMuted()); - - connect(controls, &PlayerControls::play, m_player, &QMediaPlayer::play); - connect(controls, &PlayerControls::pause, m_player, &QMediaPlayer::pause); - connect(controls, &PlayerControls::stop, m_player, &QMediaPlayer::stop); - connect(controls, &PlayerControls::next, m_playlist, &QMediaPlaylist::next); - connect(controls, &PlayerControls::previous, this, &Player::previousClicked); - connect(controls, &PlayerControls::changeVolume, m_player, &QMediaPlayer::setVolume); - connect(controls, &PlayerControls::changeMuting, m_player, &QMediaPlayer::setMuted); - connect(controls, &PlayerControls::changeRate, m_player, &QMediaPlayer::setPlaybackRate); - connect(controls, &PlayerControls::stop, m_videoWidget, QOverload<>::of(&QVideoWidget::update)); - - connect(m_player, &QMediaPlayer::stateChanged, controls, &PlayerControls::setState); - connect(m_player, &QMediaPlayer::volumeChanged, controls, &PlayerControls::setVolume); - connect(m_player, &QMediaPlayer::mutedChanged, controls, &PlayerControls::setMuted); - - m_fullScreenButton = new QPushButton(tr("FullScreen"), this); - m_fullScreenButton->setCheckable(true); - - m_colorButton = new QPushButton(tr("Color Options..."), this); - m_colorButton->setEnabled(false); - connect(m_colorButton, &QPushButton::clicked, this, &Player::showColorDialog); - - QBoxLayout *displayLayout = new QHBoxLayout; - displayLayout->addWidget(m_videoWidget, 2); - displayLayout->addWidget(m_playlistView); - - QBoxLayout *controlLayout = new QHBoxLayout; - controlLayout->setContentsMargins(0, 0, 0, 0); - controlLayout->addWidget(openButton); - controlLayout->addStretch(1); - controlLayout->addWidget(controls); - controlLayout->addStretch(1); - controlLayout->addWidget(m_fullScreenButton); - controlLayout->addWidget(m_colorButton); - - QBoxLayout *layout = new QVBoxLayout; - layout->addLayout(displayLayout); - QHBoxLayout *hLayout = new QHBoxLayout; - hLayout->addWidget(m_slider); - hLayout->addWidget(m_labelDuration); - layout->addLayout(hLayout); - layout->addLayout(controlLayout); - layout->addLayout(histogramLayout); -#if defined(Q_OS_QNX) - // On QNX, the main window doesn't have a title bar (or any other decorations). - // Create a status bar for the status information instead. - m_statusLabel = new QLabel; - m_statusBar = new QStatusBar; - m_statusBar->addPermanentWidget(m_statusLabel); - m_statusBar->setSizeGripEnabled(false); // Without mouse grabbing, it doesn't work very well. - layout->addWidget(m_statusBar); -#endif - - setLayout(layout); - - if (!isPlayerAvailable()) { - QMessageBox::warning(this, tr("Service not available"), - tr("The QMediaPlayer object does not have a valid service.\n"\ - "Please check the media service plugins are installed.")); - - controls->setEnabled(false); - m_playlistView->setEnabled(false); - openButton->setEnabled(false); - m_colorButton->setEnabled(false); - m_fullScreenButton->setEnabled(false); - } - - metaDataChanged(); -} - -Player::~Player() -{ -} - -bool Player::isPlayerAvailable() const -{ - return m_player->isAvailable(); -} - -void Player::open() -{ - QFileDialog fileDialog(this); - fileDialog.setAcceptMode(QFileDialog::AcceptOpen); - fileDialog.setWindowTitle(tr("Open Files")); - QStringList supportedMimeTypes = m_player->supportedMimeTypes(); - if (!supportedMimeTypes.isEmpty()) { - supportedMimeTypes.append("audio/x-m3u"); // MP3 playlists - fileDialog.setMimeTypeFilters(supportedMimeTypes); - } - fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath())); - if (fileDialog.exec() == QDialog::Accepted) - addToPlaylist(fileDialog.selectedUrls()); -} - -static bool isPlaylist(const QUrl &url) // Check for ".m3u" playlists. -{ - if (!url.isLocalFile()) - return false; - const QFileInfo fileInfo(url.toLocalFile()); - return fileInfo.exists() && !fileInfo.suffix().compare(QLatin1String("m3u"), Qt::CaseInsensitive); -} - -void Player::addToPlaylist(const QList<QUrl> &urls) -{ - for (auto &url: urls) { - if (isPlaylist(url)) - m_playlist->load(url); - else - m_playlist->addMedia(url); - } -} - -void Player::setCustomAudioRole(const QString &role) -{ - m_player->setCustomAudioRole(role); -} - -void Player::durationChanged(qint64 duration) -{ - m_duration = duration / 1000; - m_slider->setMaximum(m_duration); -} - -void Player::positionChanged(qint64 progress) -{ - if (!m_slider->isSliderDown()) - m_slider->setValue(progress / 1000); - - updateDurationInfo(progress / 1000); -} - -void Player::metaDataChanged() -{ - if (m_player->isMetaDataAvailable()) { - setTrackInfo(QString("%1 - %2") - .arg(m_player->metaData(QMediaMetaData::AlbumArtist).toString()) - .arg(m_player->metaData(QMediaMetaData::Title).toString())); - - if (m_coverLabel) { - QUrl url = m_player->metaData(QMediaMetaData::CoverArtUrlLarge).value<QUrl>(); - - m_coverLabel->setPixmap(!url.isEmpty() - ? QPixmap(url.toString()) - : QPixmap()); - } - } -} - -void Player::previousClicked() -{ - // Go to previous track if we are within the first 5 seconds of playback - // Otherwise, seek to the beginning. - if (m_player->position() <= 5000) - m_playlist->previous(); - else - m_player->setPosition(0); -} - -void Player::jump(const QModelIndex &index) -{ - if (index.isValid()) { - m_playlist->setCurrentIndex(index.row()); - m_player->play(); - } -} - -void Player::playlistPositionChanged(int currentItem) -{ - clearHistogram(); - m_playlistView->setCurrentIndex(m_playlistModel->index(currentItem, 0)); -} - -void Player::seek(int seconds) -{ - m_player->setPosition(seconds * 1000); -} - -void Player::statusChanged(QMediaPlayer::MediaStatus status) -{ - handleCursor(status); - - // handle status message - switch (status) { - case QMediaPlayer::UnknownMediaStatus: - case QMediaPlayer::NoMedia: - case QMediaPlayer::LoadedMedia: - setStatusInfo(QString()); - break; - case QMediaPlayer::LoadingMedia: - setStatusInfo(tr("Loading...")); - break; - case QMediaPlayer::BufferingMedia: - case QMediaPlayer::BufferedMedia: - setStatusInfo(tr("Buffering %1%").arg(m_player->bufferStatus())); - break; - case QMediaPlayer::StalledMedia: - setStatusInfo(tr("Stalled %1%").arg(m_player->bufferStatus())); - break; - case QMediaPlayer::EndOfMedia: - QApplication::alert(this); - break; - case QMediaPlayer::InvalidMedia: - displayErrorMessage(); - break; - } -} - -void Player::stateChanged(QMediaPlayer::State state) -{ - if (state == QMediaPlayer::StoppedState) - clearHistogram(); -} - -void Player::handleCursor(QMediaPlayer::MediaStatus status) -{ -#ifndef QT_NO_CURSOR - if (status == QMediaPlayer::LoadingMedia || - status == QMediaPlayer::BufferingMedia || - status == QMediaPlayer::StalledMedia) - setCursor(QCursor(Qt::BusyCursor)); - else - unsetCursor(); -#endif -} - -void Player::bufferingProgress(int progress) -{ - if (m_player->mediaStatus() == QMediaPlayer::StalledMedia) - setStatusInfo(tr("Stalled %1%").arg(progress)); - else - setStatusInfo(tr("Buffering %1%").arg(progress)); -} - -void Player::videoAvailableChanged(bool available) -{ - if (!available) { - disconnect(m_fullScreenButton, &QPushButton::clicked, m_videoWidget, &QVideoWidget::setFullScreen); - disconnect(m_videoWidget, &QVideoWidget::fullScreenChanged, m_fullScreenButton, &QPushButton::setChecked); - m_videoWidget->setFullScreen(false); - } else { - connect(m_fullScreenButton, &QPushButton::clicked, m_videoWidget, &QVideoWidget::setFullScreen); - connect(m_videoWidget, &QVideoWidget::fullScreenChanged, m_fullScreenButton, &QPushButton::setChecked); - - if (m_fullScreenButton->isChecked()) - m_videoWidget->setFullScreen(true); - } - m_colorButton->setEnabled(available); -} - -void Player::setTrackInfo(const QString &info) -{ - m_trackInfo = info; - - if (m_statusBar) { - m_statusBar->showMessage(m_trackInfo); - m_statusLabel->setText(m_statusInfo); - } else { - if (!m_statusInfo.isEmpty()) - setWindowTitle(QString("%1 | %2").arg(m_trackInfo).arg(m_statusInfo)); - else - setWindowTitle(m_trackInfo); - } -} - -void Player::setStatusInfo(const QString &info) -{ - m_statusInfo = info; - - if (m_statusBar) { - m_statusBar->showMessage(m_trackInfo); - m_statusLabel->setText(m_statusInfo); - } else { - if (!m_statusInfo.isEmpty()) - setWindowTitle(QString("%1 | %2").arg(m_trackInfo).arg(m_statusInfo)); - else - setWindowTitle(m_trackInfo); - } -} - -void Player::displayErrorMessage() -{ - setStatusInfo(m_player->errorString()); -} - -void Player::updateDurationInfo(qint64 currentInfo) -{ - QString tStr; - if (currentInfo || m_duration) { - QTime currentTime((currentInfo / 3600) % 60, (currentInfo / 60) % 60, - currentInfo % 60, (currentInfo * 1000) % 1000); - QTime totalTime((m_duration / 3600) % 60, (m_duration / 60) % 60, - m_duration % 60, (m_duration * 1000) % 1000); - QString format = "mm:ss"; - if (m_duration > 3600) - format = "hh:mm:ss"; - tStr = currentTime.toString(format) + " / " + totalTime.toString(format); - } - m_labelDuration->setText(tStr); -} - -void Player::showColorDialog() -{ - if (!m_colorDialog) { - QSlider *brightnessSlider = new QSlider(Qt::Horizontal); - brightnessSlider->setRange(-100, 100); - brightnessSlider->setValue(m_videoWidget->brightness()); - connect(brightnessSlider, &QSlider::sliderMoved, m_videoWidget, &QVideoWidget::setBrightness); - connect(m_videoWidget, &QVideoWidget::brightnessChanged, brightnessSlider, &QSlider::setValue); - - QSlider *contrastSlider = new QSlider(Qt::Horizontal); - contrastSlider->setRange(-100, 100); - contrastSlider->setValue(m_videoWidget->contrast()); - connect(contrastSlider, &QSlider::sliderMoved, m_videoWidget, &QVideoWidget::setContrast); - connect(m_videoWidget, &QVideoWidget::contrastChanged, contrastSlider, &QSlider::setValue); - - QSlider *hueSlider = new QSlider(Qt::Horizontal); - hueSlider->setRange(-100, 100); - hueSlider->setValue(m_videoWidget->hue()); - connect(hueSlider, &QSlider::sliderMoved, m_videoWidget, &QVideoWidget::setHue); - connect(m_videoWidget, &QVideoWidget::hueChanged, hueSlider, &QSlider::setValue); - - QSlider *saturationSlider = new QSlider(Qt::Horizontal); - saturationSlider->setRange(-100, 100); - saturationSlider->setValue(m_videoWidget->saturation()); - connect(saturationSlider, &QSlider::sliderMoved, m_videoWidget, &QVideoWidget::setSaturation); - connect(m_videoWidget, &QVideoWidget::saturationChanged, saturationSlider, &QSlider::setValue); - - QFormLayout *layout = new QFormLayout; - layout->addRow(tr("Brightness"), brightnessSlider); - layout->addRow(tr("Contrast"), contrastSlider); - layout->addRow(tr("Hue"), hueSlider); - layout->addRow(tr("Saturation"), saturationSlider); - - QPushButton *button = new QPushButton(tr("Close")); - layout->addRow(button); - - m_colorDialog = new QDialog(this); - m_colorDialog->setWindowTitle(tr("Color Options")); - m_colorDialog->setLayout(layout); - - connect(button, &QPushButton::clicked, m_colorDialog, &QDialog::close); - } - m_colorDialog->show(); -} - -void Player::clearHistogram() -{ - QMetaObject::invokeMethod(m_videoHistogram, "processFrame", Qt::QueuedConnection, Q_ARG(QVideoFrame, QVideoFrame())); - QMetaObject::invokeMethod(m_audioHistogram, "processBuffer", Qt::QueuedConnection, Q_ARG(QAudioBuffer, QAudioBuffer())); -} diff --git a/examples/multimediawidgets/player/player.h b/examples/multimediawidgets/player/player.h deleted file mode 100644 index 3002c9811..000000000 --- a/examples/multimediawidgets/player/player.h +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 PLAYER_H -#define PLAYER_H - -#include <QWidget> -#include <QMediaPlayer> -#include <QMediaPlaylist> - -QT_BEGIN_NAMESPACE -class QAbstractItemView; -class QLabel; -class QMediaPlayer; -class QModelIndex; -class QPushButton; -class QSlider; -class QStatusBar; -class QVideoProbe; -class QVideoWidget; -class QAudioProbe; -QT_END_NAMESPACE - -class PlaylistModel; -class HistogramWidget; - -class Player : public QWidget -{ - Q_OBJECT - -public: - explicit Player(QWidget *parent = nullptr); - ~Player(); - - bool isPlayerAvailable() const; - - void addToPlaylist(const QList<QUrl> &urls); - void setCustomAudioRole(const QString &role); - -signals: - void fullScreenChanged(bool fullScreen); - -private slots: - void open(); - void durationChanged(qint64 duration); - void positionChanged(qint64 progress); - void metaDataChanged(); - - void previousClicked(); - - void seek(int seconds); - void jump(const QModelIndex &index); - void playlistPositionChanged(int); - - void statusChanged(QMediaPlayer::MediaStatus status); - void stateChanged(QMediaPlayer::State state); - void bufferingProgress(int progress); - void videoAvailableChanged(bool available); - - void displayErrorMessage(); - - void showColorDialog(); - -private: - void clearHistogram(); - void setTrackInfo(const QString &info); - void setStatusInfo(const QString &info); - void handleCursor(QMediaPlayer::MediaStatus status); - void updateDurationInfo(qint64 currentInfo); - - QMediaPlayer *m_player = nullptr; - QMediaPlaylist *m_playlist = nullptr; - QVideoWidget *m_videoWidget = nullptr; - QLabel *m_coverLabel = nullptr; - QSlider *m_slider = nullptr; - QLabel *m_labelDuration = nullptr; - QPushButton *m_fullScreenButton = nullptr; - QPushButton *m_colorButton = nullptr; - QDialog *m_colorDialog = nullptr; - QLabel *m_statusLabel = nullptr; - QStatusBar *m_statusBar = nullptr; - - QLabel *m_labelHistogram = nullptr; - HistogramWidget *m_videoHistogram = nullptr; - HistogramWidget *m_audioHistogram = nullptr; - QVideoProbe *m_videoProbe = nullptr; - QAudioProbe *m_audioProbe = nullptr; - - PlaylistModel *m_playlistModel = nullptr; - QAbstractItemView *m_playlistView = nullptr; - QString m_trackInfo; - QString m_statusInfo; - qint64 m_duration; -}; - -#endif // PLAYER_H diff --git a/examples/multimediawidgets/player/player.pro b/examples/multimediawidgets/player/player.pro deleted file mode 100644 index 0c5be6888..000000000 --- a/examples/multimediawidgets/player/player.pro +++ /dev/null @@ -1,24 +0,0 @@ -TEMPLATE = app -TARGET = player - -QT += network \ - xml \ - multimedia \ - multimediawidgets \ - widgets - -HEADERS = \ - player.h \ - playercontrols.h \ - playlistmodel.h \ - videowidget.h \ - histogramwidget.h -SOURCES = main.cpp \ - player.cpp \ - playercontrols.cpp \ - playlistmodel.cpp \ - videowidget.cpp \ - histogramwidget.cpp - -target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/player -INSTALLS += target diff --git a/examples/multimediawidgets/player/playercontrols.cpp b/examples/multimediawidgets/player/playercontrols.cpp deleted file mode 100644 index 3c06c01c6..000000000 --- a/examples/multimediawidgets/player/playercontrols.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "playercontrols.h" - -#include <QBoxLayout> -#include <QSlider> -#include <QStyle> -#include <QToolButton> -#include <QComboBox> -#include <QAudio> - -PlayerControls::PlayerControls(QWidget *parent) - : QWidget(parent) -{ - m_playButton = new QToolButton(this); - m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - - connect(m_playButton, &QAbstractButton::clicked, this, &PlayerControls::playClicked); - - m_stopButton = new QToolButton(this); - m_stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop)); - m_stopButton->setEnabled(false); - - connect(m_stopButton, &QAbstractButton::clicked, this, &PlayerControls::stop); - - m_nextButton = new QToolButton(this); - m_nextButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward)); - - connect(m_nextButton, &QAbstractButton::clicked, this, &PlayerControls::next); - - m_previousButton = new QToolButton(this); - m_previousButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward)); - - connect(m_previousButton, &QAbstractButton::clicked, this, &PlayerControls::previous); - - m_muteButton = new QToolButton(this); - m_muteButton->setIcon(style()->standardIcon(QStyle::SP_MediaVolume)); - - connect(m_muteButton, &QAbstractButton::clicked, this, &PlayerControls::muteClicked); - - m_volumeSlider = new QSlider(Qt::Horizontal, this); - m_volumeSlider->setRange(0, 100); - - connect(m_volumeSlider, &QSlider::valueChanged, this, &PlayerControls::onVolumeSliderValueChanged); - - m_rateBox = new QComboBox(this); - m_rateBox->addItem("0.5x", QVariant(0.5)); - m_rateBox->addItem("1.0x", QVariant(1.0)); - m_rateBox->addItem("2.0x", QVariant(2.0)); - m_rateBox->setCurrentIndex(1); - - connect(m_rateBox, QOverload<int>::of(&QComboBox::activated), this, &PlayerControls::updateRate); - - QBoxLayout *layout = new QHBoxLayout; - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(m_stopButton); - layout->addWidget(m_previousButton); - layout->addWidget(m_playButton); - layout->addWidget(m_nextButton); - layout->addWidget(m_muteButton); - layout->addWidget(m_volumeSlider); - layout->addWidget(m_rateBox); - setLayout(layout); -} - -QMediaPlayer::State PlayerControls::state() const -{ - return m_playerState; -} - -void PlayerControls::setState(QMediaPlayer::State state) -{ - if (state != m_playerState) { - m_playerState = state; - - switch (state) { - case QMediaPlayer::StoppedState: - m_stopButton->setEnabled(false); - m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - case QMediaPlayer::PlayingState: - m_stopButton->setEnabled(true); - m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); - break; - case QMediaPlayer::PausedState: - m_stopButton->setEnabled(true); - m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - } - } -} - -int PlayerControls::volume() const -{ - qreal linearVolume = QAudio::convertVolume(m_volumeSlider->value() / qreal(100), - QAudio::LogarithmicVolumeScale, - QAudio::LinearVolumeScale); - - return qRound(linearVolume * 100); -} - -void PlayerControls::setVolume(int volume) -{ - qreal logarithmicVolume = QAudio::convertVolume(volume / qreal(100), - QAudio::LinearVolumeScale, - QAudio::LogarithmicVolumeScale); - - m_volumeSlider->setValue(qRound(logarithmicVolume * 100)); -} - -bool PlayerControls::isMuted() const -{ - return m_playerMuted; -} - -void PlayerControls::setMuted(bool muted) -{ - if (muted != m_playerMuted) { - m_playerMuted = muted; - - m_muteButton->setIcon(style()->standardIcon(muted - ? QStyle::SP_MediaVolumeMuted - : QStyle::SP_MediaVolume)); - } -} - -void PlayerControls::playClicked() -{ - switch (m_playerState) { - case QMediaPlayer::StoppedState: - case QMediaPlayer::PausedState: - emit play(); - break; - case QMediaPlayer::PlayingState: - emit pause(); - break; - } -} - -void PlayerControls::muteClicked() -{ - emit changeMuting(!m_playerMuted); -} - -qreal PlayerControls::playbackRate() const -{ - return m_rateBox->itemData(m_rateBox->currentIndex()).toDouble(); -} - -void PlayerControls::setPlaybackRate(float rate) -{ - for (int i = 0; i < m_rateBox->count(); ++i) { - if (qFuzzyCompare(rate, float(m_rateBox->itemData(i).toDouble()))) { - m_rateBox->setCurrentIndex(i); - return; - } - } - - m_rateBox->addItem(QString("%1x").arg(rate), QVariant(rate)); - m_rateBox->setCurrentIndex(m_rateBox->count() - 1); -} - -void PlayerControls::updateRate() -{ - emit changeRate(playbackRate()); -} - -void PlayerControls::onVolumeSliderValueChanged() -{ - emit changeVolume(volume()); -} diff --git a/examples/multimediawidgets/player/playercontrols.h b/examples/multimediawidgets/player/playercontrols.h deleted file mode 100644 index bf1f676c1..000000000 --- a/examples/multimediawidgets/player/playercontrols.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 PLAYERCONTROLS_H -#define PLAYERCONTROLS_H - -#include <QMediaPlayer> -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QAbstractButton; -class QAbstractSlider; -class QComboBox; -QT_END_NAMESPACE - -class PlayerControls : public QWidget -{ - Q_OBJECT - -public: - explicit PlayerControls(QWidget *parent = nullptr); - - QMediaPlayer::State state() const; - int volume() const; - bool isMuted() const; - qreal playbackRate() const; - -public slots: - void setState(QMediaPlayer::State state); - void setVolume(int volume); - void setMuted(bool muted); - void setPlaybackRate(float rate); - -signals: - void play(); - void pause(); - void stop(); - void next(); - void previous(); - void changeVolume(int volume); - void changeMuting(bool muting); - void changeRate(qreal rate); - -private slots: - void playClicked(); - void muteClicked(); - void updateRate(); - void onVolumeSliderValueChanged(); - -private: - QMediaPlayer::State m_playerState = QMediaPlayer::StoppedState; - bool m_playerMuted = false; - QAbstractButton *m_playButton = nullptr; - QAbstractButton *m_stopButton = nullptr; - QAbstractButton *m_nextButton = nullptr; - QAbstractButton *m_previousButton = nullptr; - QAbstractButton *m_muteButton = nullptr; - QAbstractSlider *m_volumeSlider = nullptr; - QComboBox *m_rateBox = nullptr; -}; - -#endif // PLAYERCONTROLS_H diff --git a/examples/multimediawidgets/player/playlistmodel.cpp b/examples/multimediawidgets/player/playlistmodel.cpp deleted file mode 100644 index 718c24d2d..000000000 --- a/examples/multimediawidgets/player/playlistmodel.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "playlistmodel.h" - -#include <QFileInfo> -#include <QUrl> -#include <QMediaPlaylist> - -PlaylistModel::PlaylistModel(QObject *parent) - : QAbstractItemModel(parent) -{ -} - -PlaylistModel::~PlaylistModel() -{ -} - -int PlaylistModel::rowCount(const QModelIndex &parent) const -{ - return m_playlist && !parent.isValid() ? m_playlist->mediaCount() : 0; -} - -int PlaylistModel::columnCount(const QModelIndex &parent) const -{ - return !parent.isValid() ? ColumnCount : 0; -} - -QModelIndex PlaylistModel::index(int row, int column, const QModelIndex &parent) const -{ - return m_playlist && !parent.isValid() - && row >= 0 && row < m_playlist->mediaCount() - && column >= 0 && column < ColumnCount - ? createIndex(row, column) - : QModelIndex(); -} - -QModelIndex PlaylistModel::parent(const QModelIndex &child) const -{ - Q_UNUSED(child); - - return QModelIndex(); -} - -QVariant PlaylistModel::data(const QModelIndex &index, int role) const -{ - if (index.isValid() && role == Qt::DisplayRole) { - QVariant value = m_data[index]; - if (!value.isValid() && index.column() == Title) { - QUrl location = m_playlist->media(index.row()).request().url(); - return QFileInfo(location.path()).fileName(); - } - - return value; - } - return QVariant(); -} - -QMediaPlaylist *PlaylistModel::playlist() const -{ - return m_playlist.data(); -} - -void PlaylistModel::setPlaylist(QMediaPlaylist *playlist) -{ - if (m_playlist) { - disconnect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeInserted, this, &PlaylistModel::beginInsertItems); - disconnect(m_playlist.data(), &QMediaPlaylist::mediaInserted, this, &PlaylistModel::endInsertItems); - disconnect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeRemoved, this, &PlaylistModel::beginRemoveItems); - disconnect(m_playlist.data(), &QMediaPlaylist::mediaRemoved, this, &PlaylistModel::endRemoveItems); - disconnect(m_playlist.data(), &QMediaPlaylist::mediaChanged, this, &PlaylistModel::changeItems); - } - - beginResetModel(); - m_playlist.reset(playlist); - - if (m_playlist) { - connect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeInserted, this, &PlaylistModel::beginInsertItems); - connect(m_playlist.data(), &QMediaPlaylist::mediaInserted, this, &PlaylistModel::endInsertItems); - connect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeRemoved, this, &PlaylistModel::beginRemoveItems); - connect(m_playlist.data(), &QMediaPlaylist::mediaRemoved, this, &PlaylistModel::endRemoveItems); - connect(m_playlist.data(), &QMediaPlaylist::mediaChanged, this, &PlaylistModel::changeItems); - } - - endResetModel(); -} - -bool PlaylistModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - Q_UNUSED(role); - m_data[index] = value; - emit dataChanged(index, index); - return true; -} - -void PlaylistModel::beginInsertItems(int start, int end) -{ - m_data.clear(); - beginInsertRows(QModelIndex(), start, end); -} - -void PlaylistModel::endInsertItems() -{ - endInsertRows(); -} - -void PlaylistModel::beginRemoveItems(int start, int end) -{ - m_data.clear(); - beginRemoveRows(QModelIndex(), start, end); -} - -void PlaylistModel::endRemoveItems() -{ - endInsertRows(); -} - -void PlaylistModel::changeItems(int start, int end) -{ - m_data.clear(); - emit dataChanged(index(start,0), index(end,ColumnCount)); -} diff --git a/examples/multimediawidgets/player/playlistmodel.h b/examples/multimediawidgets/player/playlistmodel.h deleted file mode 100644 index a0df0e9e7..000000000 --- a/examples/multimediawidgets/player/playlistmodel.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 PLAYLISTMODEL_H -#define PLAYLISTMODEL_H - -#include <QAbstractItemModel> -#include <QScopedPointer> - -QT_BEGIN_NAMESPACE -class QMediaPlaylist; -QT_END_NAMESPACE - -class PlaylistModel : public QAbstractItemModel -{ - Q_OBJECT - -public: - enum Column - { - Title = 0, - ColumnCount - }; - - explicit PlaylistModel(QObject *parent = nullptr); - ~PlaylistModel(); - - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; - - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; - QModelIndex parent(const QModelIndex &child) const override; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - - QMediaPlaylist *playlist() const; - void setPlaylist(QMediaPlaylist *playlist); - - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole) override; - -private slots: - void beginInsertItems(int start, int end); - void endInsertItems(); - void beginRemoveItems(int start, int end); - void endRemoveItems(); - void changeItems(int start, int end); - -private: - QScopedPointer<QMediaPlaylist> m_playlist; - QMap<QModelIndex, QVariant> m_data; -}; - -#endif // PLAYLISTMODEL_H diff --git a/examples/multimediawidgets/player/videowidget.cpp b/examples/multimediawidgets/player/videowidget.cpp deleted file mode 100644 index dfed01d1d..000000000 --- a/examples/multimediawidgets/player/videowidget.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videowidget.h" - -#include <QKeyEvent> -#include <QMouseEvent> - -VideoWidget::VideoWidget(QWidget *parent) - : QVideoWidget(parent) -{ - setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); - - QPalette p = palette(); - p.setColor(QPalette::Window, Qt::black); - setPalette(p); - - setAttribute(Qt::WA_OpaquePaintEvent); -} - -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); - } -} - -void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event) -{ - setFullScreen(!isFullScreen()); - event->accept(); -} - -void VideoWidget::mousePressEvent(QMouseEvent *event) -{ - QVideoWidget::mousePressEvent(event); -} - diff --git a/examples/multimediawidgets/player/videowidget.h b/examples/multimediawidgets/player/videowidget.h deleted file mode 100644 index c01632e7b..000000000 --- a/examples/multimediawidgets/player/videowidget.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include <QVideoWidget> - -class VideoWidget : public QVideoWidget -{ - Q_OBJECT - -public: - explicit VideoWidget(QWidget *parent = nullptr); - -protected: - void keyPressEvent(QKeyEvent *event) override; - void mouseDoubleClickEvent(QMouseEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; -}; - -#endif // VIDEOWIDGET_H diff --git a/examples/multimediawidgets/videographicsitem/doc/images/video-videographicsitem.png b/examples/multimediawidgets/videographicsitem/doc/images/video-videographicsitem.png Binary files differdeleted file mode 100644 index e333c54a2..000000000 --- a/examples/multimediawidgets/videographicsitem/doc/images/video-videographicsitem.png +++ /dev/null diff --git a/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc b/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc deleted file mode 100644 index f820a38b4..000000000 --- a/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** 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. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\example multimediawidgets/videographicsitem -\title Video Graphics Item Example -\ingroup multimedia_examples -\brief Streaming video on a graphics scene. - - \e{Video Graphics Item} demonstrates how to implement a QGraphicsItem that - displays video on a graphics scene using QAbstractVideoSurface. - - \image video-videographicsitem.png - - \sa {Video Widget Example} - - \include examples-run.qdocinc -*/ diff --git a/examples/multimediawidgets/videographicsitem/main.cpp b/examples/multimediawidgets/videographicsitem/main.cpp deleted file mode 100644 index 58542b619..000000000 --- a/examples/multimediawidgets/videographicsitem/main.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h" - -#include <QApplication> -#include <QCommandLineParser> -#include <QCommandLineOption> -#include <QDir> - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - QCoreApplication::setApplicationName("Player Example"); - QCoreApplication::setOrganizationName("QtProject"); - QCoreApplication::setApplicationVersion(QT_VERSION_STR); - QCommandLineParser parser; - parser.setApplicationDescription("Qt MultiMedia Player QGraphicsView Example"); - parser.addHelpOption(); - parser.addVersionOption(); - parser.addPositionalArgument("url", "The URL to open."); - parser.process(app); - - VideoPlayer player; - - if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) { - const QUrl url = - QUrl::fromUserInput(parser.positionalArguments().constFirst(), - QDir::currentPath(), QUrl::AssumeLocalFile); - player.load(url); - } - - player.show(); - - return app.exec(); -} - diff --git a/examples/multimediawidgets/videographicsitem/videographicsitem.pro b/examples/multimediawidgets/videographicsitem/videographicsitem.pro deleted file mode 100644 index 30a9b6f21..000000000 --- a/examples/multimediawidgets/videographicsitem/videographicsitem.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = app -TARGET = videographicsitem - -QT += multimedia multimediawidgets - -HEADERS += videoplayer.h - -SOURCES += main.cpp \ - videoplayer.cpp - -target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/videographicsitem -INSTALLS += target - -QT+=widgets diff --git a/examples/multimediawidgets/videographicsitem/videoplayer.cpp b/examples/multimediawidgets/videographicsitem/videoplayer.cpp deleted file mode 100644 index 917a71f64..000000000 --- a/examples/multimediawidgets/videographicsitem/videoplayer.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h" - -#include <QtWidgets> -#include <QGraphicsVideoItem> - -VideoPlayer::VideoPlayer(QWidget *parent) - : QWidget(parent) -{ - m_mediaPlayer = new QMediaPlayer(this, QMediaPlayer::VideoSurface); - const QSize screenGeometry = screen()->availableSize(); - m_videoItem = new QGraphicsVideoItem; - m_videoItem->setSize(QSizeF(screenGeometry.width() / 3, screenGeometry.height() / 2)); - - QGraphicsScene *scene = new QGraphicsScene(this); - QGraphicsView *graphicsView = new QGraphicsView(scene); - - scene->addItem(m_videoItem); - - QSlider *rotateSlider = new QSlider(Qt::Horizontal); - rotateSlider->setToolTip(tr("Rotate Video")); - rotateSlider->setRange(-180, 180); - rotateSlider->setValue(0); - - connect(rotateSlider, &QAbstractSlider::valueChanged, - this, &VideoPlayer::rotateVideo); - - QAbstractButton *openButton = new QPushButton(tr("Open...")); - connect(openButton, &QAbstractButton::clicked, this, &VideoPlayer::openFile); - - m_playButton = new QPushButton; - m_playButton->setEnabled(false); - m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - - connect(m_playButton, &QAbstractButton::clicked, this, &VideoPlayer::play); - - m_positionSlider = new QSlider(Qt::Horizontal); - m_positionSlider->setRange(0, 0); - - connect(m_positionSlider, &QAbstractSlider::sliderMoved, - this, &VideoPlayer::setPosition); - - QBoxLayout *controlLayout = new QHBoxLayout; - controlLayout->setContentsMargins(0, 0, 0, 0); - controlLayout->addWidget(openButton); - controlLayout->addWidget(m_playButton); - controlLayout->addWidget(m_positionSlider); - - QBoxLayout *layout = new QVBoxLayout(this); - layout->addWidget(graphicsView); - layout->addWidget(rotateSlider); - layout->addLayout(controlLayout); - - m_mediaPlayer->setVideoOutput(m_videoItem); - connect(m_mediaPlayer, &QMediaPlayer::stateChanged, - this, &VideoPlayer::mediaStateChanged); - connect(m_mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged); - connect(m_mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged); -} - -VideoPlayer::~VideoPlayer() -{ -} - -QSize VideoPlayer::sizeHint() const -{ - return (m_videoItem->size() * qreal(3) / qreal(2)).toSize(); -} - -bool VideoPlayer::isPlayerAvailable() const -{ - return m_mediaPlayer->isAvailable(); -} - -void VideoPlayer::openFile() -{ - QFileDialog fileDialog(this); - fileDialog.setAcceptMode(QFileDialog::AcceptOpen); - fileDialog.setWindowTitle(tr("Open Movie")); - const QStringList supportedMimeTypes = m_mediaPlayer->supportedMimeTypes(); - if (!supportedMimeTypes.isEmpty()) - fileDialog.setMimeTypeFilters(supportedMimeTypes); - fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath())); - if (fileDialog.exec() == QDialog::Accepted) - load(fileDialog.selectedUrls().constFirst()); -} - -void VideoPlayer::load(const QUrl &url) -{ - m_mediaPlayer->setMedia(url); - m_playButton->setEnabled(true); -} - -void VideoPlayer::play() -{ - switch (m_mediaPlayer->state()) { - case QMediaPlayer::PlayingState: - m_mediaPlayer->pause(); - break; - default: - m_mediaPlayer->play(); - break; - } -} - -void VideoPlayer::mediaStateChanged(QMediaPlayer::State state) -{ - switch(state) { - case QMediaPlayer::PlayingState: - m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); - break; - default: - m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - } -} - -void VideoPlayer::positionChanged(qint64 position) -{ - m_positionSlider->setValue(position); -} - -void VideoPlayer::durationChanged(qint64 duration) -{ - m_positionSlider->setRange(0, duration); -} - -void VideoPlayer::setPosition(int position) -{ - m_mediaPlayer->setPosition(position); -} - - -void VideoPlayer::rotateVideo(int angle) -{ - //rotate around the center of video element - qreal x = m_videoItem->boundingRect().width() / 2.0; - qreal y = m_videoItem->boundingRect().height() / 2.0; - m_videoItem->setTransform(QTransform().translate(x, y).rotate(angle).translate(-x, -y)); -} diff --git a/examples/multimediawidgets/videographicsitem/videoplayer.h b/examples/multimediawidgets/videographicsitem/videoplayer.h deleted file mode 100644 index 87c20c804..000000000 --- a/examples/multimediawidgets/videographicsitem/videoplayer.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 VIDEOPLAYER_H -#define VIDEOPLAYER_H - -#include <QMediaPlayer> -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QAbstractButton; -class QSlider; -class QGraphicsVideoItem; -QT_END_NAMESPACE - -class VideoPlayer : public QWidget -{ - Q_OBJECT - -public: - VideoPlayer(QWidget *parent = nullptr); - ~VideoPlayer(); - - void load(const QUrl &url); - bool isPlayerAvailable() const; - - QSize sizeHint() const override; - -public slots: - void openFile(); - void play(); - -private slots: - void mediaStateChanged(QMediaPlayer::State state); - void positionChanged(qint64 position); - void durationChanged(qint64 duration); - void setPosition(int position); - void rotateVideo(int angle); - -private: - QMediaPlayer *m_mediaPlayer = nullptr; - QGraphicsVideoItem *m_videoItem = nullptr; - QAbstractButton *m_playButton = nullptr; - QSlider *m_positionSlider = nullptr; -}; - -#endif - diff --git a/examples/multimediawidgets/videowidget/doc/images/video-videowidget.png b/examples/multimediawidgets/videowidget/doc/images/video-videowidget.png Binary files differdeleted file mode 100644 index a3c7bcb44..000000000 --- a/examples/multimediawidgets/videowidget/doc/images/video-videowidget.png +++ /dev/null diff --git a/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc b/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc deleted file mode 100644 index a766243b6..000000000 --- a/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** 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. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example multimediawidgets/videowidget - \title Video Widget Example - \ingroup multimedia_examples - \brief Implementing a video player widget. - - \e{Video Widget} demonstrates how to implement a video widget using - QAbstractVideoSurface. - - \image video-videowidget.png - - \include examples-run.qdocinc -*/ diff --git a/examples/multimediawidgets/videowidget/main.cpp b/examples/multimediawidgets/videowidget/main.cpp deleted file mode 100644 index 367bc9526..000000000 --- a/examples/multimediawidgets/videowidget/main.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h" - -#include <QtWidgets/QApplication> -#include <QtCore/QCommandLineParser> -#include <QtCore/QCommandLineOption> -#include <QtCore/QDir> -#include <QScreen> - -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; - if (!parser.positionalArguments().isEmpty()) { - const QUrl url = - QUrl::fromUserInput(parser.positionalArguments().constFirst(), - QDir::currentPath(), QUrl::AssumeLocalFile); - player.setUrl(url); - } - - const QSize availableGeometry = player.screen()->availableSize(); - 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 deleted file mode 100644 index 1db269503..000000000 --- a/examples/multimediawidgets/videowidget/videoplayer.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h" - -#include <QtWidgets> -#include <QVideoWidget> - -VideoPlayer::VideoPlayer(QWidget *parent) - : QWidget(parent) -{ - m_mediaPlayer = new QMediaPlayer(this, QMediaPlayer::VideoSurface); - QVideoWidget *videoWidget = new QVideoWidget; - - QAbstractButton *openButton = new QPushButton(tr("Open...")); - connect(openButton, &QAbstractButton::clicked, this, &VideoPlayer::openFile); - - m_playButton = new QPushButton; - m_playButton->setEnabled(false); - m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - - connect(m_playButton, &QAbstractButton::clicked, - this, &VideoPlayer::play); - - m_positionSlider = new QSlider(Qt::Horizontal); - m_positionSlider->setRange(0, 0); - - connect(m_positionSlider, &QAbstractSlider::sliderMoved, - this, &VideoPlayer::setPosition); - - m_errorLabel = new QLabel; - m_errorLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); - - QBoxLayout *controlLayout = new QHBoxLayout; - controlLayout->setContentsMargins(0, 0, 0, 0); - controlLayout->addWidget(openButton); - controlLayout->addWidget(m_playButton); - controlLayout->addWidget(m_positionSlider); - - QBoxLayout *layout = new QVBoxLayout; - layout->addWidget(videoWidget); - layout->addLayout(controlLayout); - layout->addWidget(m_errorLabel); - - setLayout(layout); - - m_mediaPlayer->setVideoOutput(videoWidget); - connect(m_mediaPlayer, &QMediaPlayer::stateChanged, - this, &VideoPlayer::mediaStateChanged); - connect(m_mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged); - connect(m_mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged); - connect(m_mediaPlayer, QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error), - this, &VideoPlayer::handleError); -} - -VideoPlayer::~VideoPlayer() -{ -} - -void VideoPlayer::openFile() -{ - QFileDialog fileDialog(this); - fileDialog.setAcceptMode(QFileDialog::AcceptOpen); - fileDialog.setWindowTitle(tr("Open Movie")); - QStringList supportedMimeTypes = m_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()); -} - -void VideoPlayer::setUrl(const QUrl &url) -{ - m_errorLabel->setText(QString()); - setWindowFilePath(url.isLocalFile() ? url.toLocalFile() : QString()); - m_mediaPlayer->setMedia(url); - m_playButton->setEnabled(true); -} - -void VideoPlayer::play() -{ - switch (m_mediaPlayer->state()) { - case QMediaPlayer::PlayingState: - m_mediaPlayer->pause(); - break; - default: - m_mediaPlayer->play(); - break; - } -} - -void VideoPlayer::mediaStateChanged(QMediaPlayer::State state) -{ - switch(state) { - case QMediaPlayer::PlayingState: - m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); - break; - default: - m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - } -} - -void VideoPlayer::positionChanged(qint64 position) -{ - m_positionSlider->setValue(position); -} - -void VideoPlayer::durationChanged(qint64 duration) -{ - m_positionSlider->setRange(0, duration); -} - -void VideoPlayer::setPosition(int position) -{ - m_mediaPlayer->setPosition(position); -} - -void VideoPlayer::handleError() -{ - m_playButton->setEnabled(false); - const QString errorString = m_mediaPlayer->errorString(); - QString message = "Error: "; - if (errorString.isEmpty()) - message += " #" + QString::number(int(m_mediaPlayer->error())); - else - message += errorString; - m_errorLabel->setText(message); -} diff --git a/examples/multimediawidgets/videowidget/videoplayer.h b/examples/multimediawidgets/videowidget/videoplayer.h deleted file mode 100644 index 62260d167..000000000 --- a/examples/multimediawidgets/videowidget/videoplayer.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 VIDEOPLAYER_H -#define VIDEOPLAYER_H - -#include <QMediaPlayer> -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QAbstractButton; -class QSlider; -class QLabel; -class QUrl; -QT_END_NAMESPACE - -class VideoPlayer : public QWidget -{ - Q_OBJECT -public: - VideoPlayer(QWidget *parent = nullptr); - ~VideoPlayer(); - - void setUrl(const QUrl &url); - -public slots: - void openFile(); - void play(); - -private slots: - void mediaStateChanged(QMediaPlayer::State state); - void positionChanged(qint64 position); - void durationChanged(qint64 duration); - void setPosition(int position); - void handleError(); - -private: - QMediaPlayer* m_mediaPlayer; - QAbstractButton *m_playButton; - QSlider *m_positionSlider; - QLabel *m_errorLabel; -}; - -#endif diff --git a/examples/multimediawidgets/videowidget/videowidget.pro b/examples/multimediawidgets/videowidget/videowidget.pro deleted file mode 100644 index 603996b2e..000000000 --- a/examples/multimediawidgets/videowidget/videowidget.pro +++ /dev/null @@ -1,16 +0,0 @@ -TEMPLATE = app -TARGET = videowidget - -QT += multimedia multimediawidgets - -HEADERS = \ - videoplayer.h - -SOURCES = \ - main.cpp \ - videoplayer.cpp - -target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/videowidget -INSTALLS += target - -QT+=widgets |