diff options
author | Liang Qi <liang.qi@qt.io> | 2017-07-06 13:55:05 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-07-06 13:56:19 +0200 |
commit | 2282cd01267159a373d7b4a33e768814769d1435 (patch) | |
tree | db2e1310e4a8eb407e60aa460cde7149bc4cf2b5 /examples/multimediawidgets | |
parent | 5f56ec9c4f32ff06fb3daa30c0e961997d5fe964 (diff) | |
parent | 2b343affb7b16ff195bbc8139d2873b183292852 (diff) | |
download | qtmultimedia-2282cd01267159a373d7b4a33e768814769d1435.tar.gz |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
.qmake.conf
Change-Id: I5f9bed6cb611471db61b9c69004f16786822625d
Diffstat (limited to 'examples/multimediawidgets')
-rw-r--r-- | examples/multimediawidgets/camera/camera.cpp | 51 | ||||
-rw-r--r-- | examples/multimediawidgets/camera/camera.h | 12 | ||||
-rw-r--r-- | examples/multimediawidgets/camera/camera.pro | 2 | ||||
-rw-r--r-- | examples/multimediawidgets/camera/camera.qrc | 5 | ||||
-rw-r--r-- | examples/multimediawidgets/camera/camera.ui | 10 | ||||
-rw-r--r-- | examples/multimediawidgets/camera/images/shutter.svg | 21 | ||||
-rw-r--r-- | examples/multimediawidgets/camera/imagesettings.cpp | 9 | ||||
-rw-r--r-- | examples/multimediawidgets/camera/imagesettings.h | 2 | ||||
-rw-r--r-- | examples/multimediawidgets/camera/imagesettings.ui | 2 | ||||
-rw-r--r-- | examples/multimediawidgets/camera/videosettings.cpp | 28 | ||||
-rw-r--r-- | examples/multimediawidgets/camera/videosettings.h | 2 | ||||
-rw-r--r-- | examples/multimediawidgets/camera/videosettings.ui | 2 |
12 files changed, 91 insertions, 55 deletions
diff --git a/examples/multimediawidgets/camera/camera.cpp b/examples/multimediawidgets/camera/camera.cpp index 2a1af875d..7a9955b01 100644 --- a/examples/multimediawidgets/camera/camera.cpp +++ b/examples/multimediawidgets/camera/camera.cpp @@ -58,12 +58,7 @@ Q_DECLARE_METATYPE(QCameraInfo) Camera::Camera(QWidget *parent) : QMainWindow(parent), - ui(new Ui::Camera), - camera(0), - imageCapture(0), - mediaRecorder(0), - isCapturingImage(false), - applicationExiting(false) + ui(new Ui::Camera) { ui->setupUi(this); @@ -71,7 +66,8 @@ Camera::Camera(QWidget *parent) : QActionGroup *videoDevicesGroup = new QActionGroup(this); videoDevicesGroup->setExclusive(true); - foreach (const QCameraInfo &cameraInfo, QCameraInfo::availableCameras()) { + 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)); @@ -81,8 +77,8 @@ Camera::Camera(QWidget *parent) : ui->menuDevices->addAction(videoDeviceAction); } - connect(videoDevicesGroup, SIGNAL(triggered(QAction*)), SLOT(updateCameraDevice(QAction*))); - connect(ui->captureWidget, SIGNAL(currentChanged(int)), SLOT(updateCaptureMode())); + connect(videoDevicesGroup, &QActionGroup::triggered, this, &Camera::updateCameraDevice); + connect(ui->captureWidget, &QTabWidget::currentChanged, this, &Camera::updateCaptureMode); setCamera(QCameraInfo::defaultCamera()); } @@ -102,20 +98,21 @@ void Camera::setCamera(const QCameraInfo &cameraInfo) camera = new QCamera(cameraInfo); - connect(camera, SIGNAL(stateChanged(QCamera::State)), this, SLOT(updateCameraState(QCamera::State))); - connect(camera, SIGNAL(error(QCamera::Error)), this, SLOT(displayCameraError())); + connect(camera, &QCamera::stateChanged, this, &Camera::updateCameraState); + connect(camera, QOverload<QCamera::Error>::of(&QCamera::error), this, &Camera::displayCameraError); mediaRecorder = new QMediaRecorder(camera); - connect(mediaRecorder, SIGNAL(stateChanged(QMediaRecorder::State)), this, SLOT(updateRecorderState(QMediaRecorder::State))); + connect(mediaRecorder, &QMediaRecorder::stateChanged, this, &Camera::updateRecorderState); imageCapture = new QCameraImageCapture(camera); - connect(mediaRecorder, SIGNAL(durationChanged(qint64)), this, SLOT(updateRecordTime())); - connect(mediaRecorder, SIGNAL(error(QMediaRecorder::Error)), this, SLOT(displayRecorderError())); + connect(mediaRecorder, &QMediaRecorder::durationChanged, this, &Camera::updateRecordTime); + connect(mediaRecorder, QOverload<QMediaRecorder::Error>::of(&QMediaRecorder::error), + this, &Camera::displayRecorderError); mediaRecorder->setMetaData(QMediaMetaData::Title, QVariant(QLatin1String("Test Title"))); - connect(ui->exposureCompensation, SIGNAL(valueChanged(int)), SLOT(setExposureCompensation(int))); + connect(ui->exposureCompensation, &QAbstractSlider::valueChanged, this, &Camera::setExposureCompensation); camera->setViewfinder(ui->viewfinder); @@ -123,14 +120,14 @@ void Camera::setCamera(const QCameraInfo &cameraInfo) updateLockStatus(camera->lockStatus(), QCamera::UserRequest); updateRecorderState(mediaRecorder->state()); - connect(imageCapture, SIGNAL(readyForCaptureChanged(bool)), this, SLOT(readyForCapture(bool))); - connect(imageCapture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(processCapturedImage(int,QImage))); - connect(imageCapture, SIGNAL(imageSaved(int,QString)), this, SLOT(imageSaved(int,QString))); - connect(imageCapture, SIGNAL(error(int,QCameraImageCapture::Error,QString)), this, - SLOT(displayCaptureError(int,QCameraImageCapture::Error,QString))); + connect(imageCapture, &QCameraImageCapture::readyForCaptureChanged, this, &Camera::readyForCapture); + connect(imageCapture, &QCameraImageCapture::imageCaptured, this, &Camera::processCapturedImage); + connect(imageCapture, &QCameraImageCapture::imageSaved, this, &Camera::imageSaved); + connect(imageCapture, QOverload<int, QCameraImageCapture::Error, const QString &>::of(&QCameraImageCapture::error), + this, &Camera::displayCaptureError); - connect(camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)), - this, SLOT(updateLockStatus(QCamera::LockStatus,QCamera::LockChangeReason))); + connect(camera, QOverload<QCamera::LockStatus, QCamera::LockChangeReason>::of(&QCamera::lockStatusChanged), + this, &Camera::updateLockStatus); ui->captureWidget->setTabEnabled(0, (camera->isCaptureModeSupported(QCamera::CaptureStillImage))); ui->captureWidget->setTabEnabled(1, (camera->isCaptureModeSupported(QCamera::CaptureVideo))); @@ -197,7 +194,7 @@ void Camera::processCapturedImage(int requestId, const QImage& img) // Display captured image for 4 seconds. displayCapturedImage(); - QTimer::singleShot(4000, this, SLOT(displayViewfinder())); + QTimer::singleShot(4000, this, &Camera::displayViewfinder); } void Camera::configureCaptureSettings() @@ -217,6 +214,7 @@ void Camera::configureCaptureSettings() void Camera::configureVideoSettings() { VideoSettings settingsDialog(mediaRecorder); + settingsDialog.setWindowFlags(settingsDialog.windowFlags() & ~Qt::WindowContextHelpButtonHint); settingsDialog.setAudioSettings(audioSettings); settingsDialog.setVideoSettings(videoSettings); @@ -237,6 +235,7 @@ void Camera::configureVideoSettings() void Camera::configureImageSettings() { ImageSettings settingsDialog(imageCapture); + settingsDialog.setWindowFlags(settingsDialog.windowFlags() & ~Qt::WindowContextHelpButtonHint); settingsDialog.setImageSettings(imageSettings); @@ -385,12 +384,12 @@ void Camera::setExposureCompensation(int index) void Camera::displayRecorderError() { - QMessageBox::warning(this, tr("Capture error"), mediaRecorder->errorString()); + QMessageBox::warning(this, tr("Capture Error"), mediaRecorder->errorString()); } void Camera::displayCameraError() { - QMessageBox::warning(this, tr("Camera error"), camera->errorString()); + QMessageBox::warning(this, tr("Camera Error"), camera->errorString()); } void Camera::updateCameraDevice(QAction *action) @@ -416,7 +415,7 @@ void Camera::readyForCapture(bool ready) void Camera::imageSaved(int id, const QString &fileName) { Q_UNUSED(id); - Q_UNUSED(fileName); + ui->statusbar->showMessage(tr("Captured \"%1\"").arg(QDir::toNativeSeparators(fileName))); isCapturingImage = false; if (applicationExiting) diff --git a/examples/multimediawidgets/camera/camera.h b/examples/multimediawidgets/camera/camera.h index 3db1347b6..45a73176c 100644 --- a/examples/multimediawidgets/camera/camera.h +++ b/examples/multimediawidgets/camera/camera.h @@ -56,7 +56,7 @@ class Camera : public QMainWindow Q_OBJECT public: - Camera(QWidget *parent = 0); + explicit Camera(QWidget *parent = nullptr); ~Camera(); private slots: @@ -107,16 +107,16 @@ protected: private: Ui::Camera *ui; - QCamera *camera; - QCameraImageCapture *imageCapture; - QMediaRecorder* mediaRecorder; + QCamera *camera = nullptr; + QCameraImageCapture *imageCapture = nullptr; + QMediaRecorder* mediaRecorder = nullptr; QImageEncoderSettings imageSettings; QAudioEncoderSettings audioSettings; QVideoEncoderSettings videoSettings; QString videoContainerFormat; - bool isCapturingImage; - bool applicationExiting; + bool isCapturingImage = false; + bool applicationExiting = false; }; #endif diff --git a/examples/multimediawidgets/camera/camera.pro b/examples/multimediawidgets/camera/camera.pro index acd4d9228..d4f8df5c4 100644 --- a/examples/multimediawidgets/camera/camera.pro +++ b/examples/multimediawidgets/camera/camera.pro @@ -19,6 +19,8 @@ FORMS += \ videosettings.ui \ imagesettings.ui +RESOURCES += camera.qrc + target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/camera INSTALLS += target diff --git a/examples/multimediawidgets/camera/camera.qrc b/examples/multimediawidgets/camera/camera.qrc new file mode 100644 index 000000000..a915eb596 --- /dev/null +++ b/examples/multimediawidgets/camera/camera.qrc @@ -0,0 +1,5 @@ +<!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 index 8a5ee519c..e4ef5d7f0 100644 --- a/examples/multimediawidgets/camera/camera.ui +++ b/examples/multimediawidgets/camera/camera.ui @@ -144,6 +144,10 @@ <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"> @@ -248,7 +252,7 @@ <x>0</x> <y>0</y> <width>668</width> - <height>25</height> + <height>21</height> </rect> </property> <widget class="QMenu" name="menuFile"> @@ -300,7 +304,9 @@ <container>1</container> </customwidget> </customwidgets> - <resources/> + <resources> + <include location="camera.qrc"/> + </resources> <connections> <connection> <sender>recordButton</sender> diff --git a/examples/multimediawidgets/camera/images/shutter.svg b/examples/multimediawidgets/camera/images/shutter.svg new file mode 100644 index 000000000..18493361d --- /dev/null +++ b/examples/multimediawidgets/camera/images/shutter.svg @@ -0,0 +1,21 @@ +<?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 index 55441b4e3..658176369 100644 --- a/examples/multimediawidgets/camera/imagesettings.cpp +++ b/examples/multimediawidgets/camera/imagesettings.cpp @@ -56,16 +56,17 @@ ImageSettings::ImageSettings(QCameraImageCapture *imageCapture, QWidget *parent) //image codecs ui->imageCodecBox->addItem(tr("Default image format"), QVariant(QString())); - foreach(const QString &codecName, imagecapture->supportedImageCodecs()) { + const QStringList supportedImageCodecs = imagecapture->supportedImageCodecs(); + for (const QString &codecName : supportedImageCodecs) { QString description = imagecapture->imageCodecDescription(codecName); - ui->imageCodecBox->addItem(codecName+": "+description, QVariant(codecName)); + ui->imageCodecBox->addItem(codecName + ": " + description, QVariant(codecName)); } ui->imageQualitySlider->setRange(0, int(QMultimedia::VeryHighQuality)); ui->imageResolutionBox->addItem(tr("Default Resolution")); - QList<QSize> supportedResolutions = imagecapture->supportedResolutions(); - foreach(const QSize &resolution, supportedResolutions) { + 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)); } diff --git a/examples/multimediawidgets/camera/imagesettings.h b/examples/multimediawidgets/camera/imagesettings.h index 31afbd2f5..5e23ef8e4 100644 --- a/examples/multimediawidgets/camera/imagesettings.h +++ b/examples/multimediawidgets/camera/imagesettings.h @@ -56,7 +56,7 @@ class ImageSettings : public QDialog Q_OBJECT public: - ImageSettings(QCameraImageCapture *imageCapture, QWidget *parent = 0); + explicit ImageSettings(QCameraImageCapture *imageCapture, QWidget *parent = nullptr); ~ImageSettings(); QAudioEncoderSettings audioSettings() const; diff --git a/examples/multimediawidgets/camera/imagesettings.ui b/examples/multimediawidgets/camera/imagesettings.ui index f790c770d..8c59ca01d 100644 --- a/examples/multimediawidgets/camera/imagesettings.ui +++ b/examples/multimediawidgets/camera/imagesettings.ui @@ -11,7 +11,7 @@ </rect> </property> <property name="windowTitle"> - <string>Dialog</string> + <string>Image Settings</string> </property> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> diff --git a/examples/multimediawidgets/camera/videosettings.cpp b/examples/multimediawidgets/camera/videosettings.cpp index 3e0c2afd0..38e8e476b 100644 --- a/examples/multimediawidgets/camera/videosettings.cpp +++ b/examples/multimediawidgets/camera/videosettings.cpp @@ -56,47 +56,49 @@ VideoSettings::VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent) : //audio codecs ui->audioCodecBox->addItem(tr("Default audio codec"), QVariant(QString())); - foreach (const QString &codecName, mediaRecorder->supportedAudioCodecs()) { + const QStringList supportedAudioCodecs = mediaRecorder->supportedAudioCodecs(); + for (const QString &codecName : supportedAudioCodecs) { QString description = mediaRecorder->audioCodecDescription(codecName); - ui->audioCodecBox->addItem(codecName+": "+description, QVariant(codecName)); + ui->audioCodecBox->addItem(codecName + ": " + description, QVariant(codecName)); } //sample rate: - foreach (int sampleRate, mediaRecorder->supportedAudioSampleRates()) { + 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())); - foreach (const QString &codecName, mediaRecorder->supportedVideoCodecs()) { + const QStringList supportedVideoCodecs = mediaRecorder->supportedVideoCodecs(); + for (const QString &codecName : supportedVideoCodecs) { QString description = mediaRecorder->videoCodecDescription(codecName); - ui->videoCodecBox->addItem(codecName+": "+description, QVariant(codecName)); + ui->videoCodecBox->addItem(codecName + ": " + description, QVariant(codecName)); } ui->videoQualitySlider->setRange(0, int(QMultimedia::VeryHighQuality)); ui->videoResolutionBox->addItem(tr("Default")); - QList<QSize> supportedResolutions = mediaRecorder->supportedResolutions(); - foreach (const QSize &resolution, supportedResolutions) { + 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")); - QList<qreal> supportedFrameRates = mediaRecorder->supportedFrameRates(); - qreal rate; - foreach (rate, supportedFrameRates) { + 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())); - foreach (const QString &format, mediaRecorder->supportedContainers()) { - ui->containerFormatBox->addItem(format+":"+mediaRecorder->containerDescription(format), + const QStringList formats = mediaRecorder->supportedContainers(); + for (const QString &format : formats) { + ui->containerFormatBox->addItem(format + ": " + mediaRecorder->containerDescription(format), QVariant(format)); } } diff --git a/examples/multimediawidgets/camera/videosettings.h b/examples/multimediawidgets/camera/videosettings.h index c4a05face..1751025fb 100644 --- a/examples/multimediawidgets/camera/videosettings.h +++ b/examples/multimediawidgets/camera/videosettings.h @@ -56,7 +56,7 @@ class VideoSettings : public QDialog Q_OBJECT public: - VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent = 0); + explicit VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent = nullptr); ~VideoSettings(); QAudioEncoderSettings audioSettings() const; diff --git a/examples/multimediawidgets/camera/videosettings.ui b/examples/multimediawidgets/camera/videosettings.ui index f6aa004c5..940b7db7a 100644 --- a/examples/multimediawidgets/camera/videosettings.ui +++ b/examples/multimediawidgets/camera/videosettings.ui @@ -11,7 +11,7 @@ </rect> </property> <property name="windowTitle"> - <string>Dialog</string> + <string>Video Settings</string> </property> <layout class="QGridLayout" name="gridLayout_4"> <item row="0" column="0"> |