diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-11-09 20:42:00 +0100 |
---|---|---|
committer | Michael Goddard <michael.goddard@nokia.com> | 2011-11-10 04:15:38 +0100 |
commit | 1d76e399c5d9277895786c6edc2cec76f99d0531 (patch) | |
tree | f56640988d767202cc8f449ff78ad26ff739d314 /examples/camera | |
parent | 1e542df82fbcc4e3a8f75537af204f83827a4587 (diff) |
Change-Id: Id6de29b7c1e96aed16be8251195c744f68a2d46b
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Diffstat (limited to 'examples/camera')
-rw-r--r-- | examples/camera/camera.cpp | 440 | ||||
-rw-r--r-- | examples/camera/camera.h | 126 | ||||
-rw-r--r-- | examples/camera/camera.pro | 28 | ||||
-rw-r--r-- | examples/camera/camera.ui | 492 | ||||
-rw-r--r-- | examples/camera/imagesettings.cpp | 126 | ||||
-rw-r--r-- | examples/camera/imagesettings.h | 84 | ||||
-rw-r--r-- | examples/camera/imagesettings.ui | 123 | ||||
-rw-r--r-- | examples/camera/main.cpp | 53 | ||||
-rw-r--r-- | examples/camera/videosettings.cpp | 191 | ||||
-rw-r--r-- | examples/camera/videosettings.h | 84 | ||||
-rw-r--r-- | examples/camera/videosettings.ui | 211 |
11 files changed, 0 insertions, 1958 deletions
diff --git a/examples/camera/camera.cpp b/examples/camera/camera.cpp deleted file mode 100644 index d30d6c1..0000000 --- a/examples/camera/camera.cpp +++ /dev/null @@ -1,440 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "camera.h" -#include "ui_camera.h" -#include "videosettings.h" -#include "imagesettings.h" - -#include <qmediaservice.h> -#include <qmediarecorder.h> -#include <qcamera.h> -#include <qcameraviewfinder.h> - -#include <qmessagebox.h> -#include <qpalette.h> - -#include <QtWidgets> - -#if (defined(Q_WS_MAEMO_6)) && QT_VERSION >= 0x040700 -#define HAVE_CAMERA_BUTTONS -#endif - -Camera::Camera(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::Camera), - camera(0), - imageCapture(0), - mediaRecorder(0), - isCapturingImage(false), - applicationExiting(false) -{ - ui->setupUi(this); - - //Camera devices: - QByteArray cameraDevice; - - QActionGroup *videoDevicesGroup = new QActionGroup(this); - videoDevicesGroup->setExclusive(true); - foreach(const QByteArray &deviceName, QCamera::availableDevices()) { - QString description = camera->deviceDescription(deviceName); - QAction *videoDeviceAction = new QAction(description, videoDevicesGroup); - videoDeviceAction->setCheckable(true); - videoDeviceAction->setData(QVariant(deviceName)); - if (cameraDevice.isEmpty()) { - cameraDevice = deviceName; - videoDeviceAction->setChecked(true); - } - ui->menuDevices->addAction(videoDeviceAction); - } - - connect(videoDevicesGroup, SIGNAL(triggered(QAction*)), this, SLOT(updateCameraDevice(QAction*))); - connect(ui->captureWidget, SIGNAL(currentChanged(int)), SLOT(updateCaptureMode())); - -#ifdef HAVE_CAMERA_BUTTONS - ui->lockButton->hide(); -#endif - - setCamera(cameraDevice); -} - -Camera::~Camera() -{ - delete mediaRecorder; - delete imageCapture; - delete camera; -} - -void Camera::setCamera(const QByteArray &cameraDevice) -{ - delete imageCapture; - delete mediaRecorder; - delete camera; - - if (cameraDevice.isEmpty()) - camera = new QCamera; - else - camera = new QCamera(cameraDevice); - - connect(camera, SIGNAL(stateChanged(QCamera::State)), this, SLOT(updateCameraState(QCamera::State))); - connect(camera, SIGNAL(error(QCamera::Error)), this, SLOT(displayCameraError())); - - mediaRecorder = new QMediaRecorder(camera); - connect(mediaRecorder, SIGNAL(stateChanged(QMediaRecorder::State)), this, SLOT(updateRecorderState(QMediaRecorder::State))); - - imageCapture = new QCameraImageCapture(camera); - - connect(mediaRecorder, SIGNAL(durationChanged(qint64)), this, SLOT(updateRecordTime())); - connect(mediaRecorder, SIGNAL(error(QMediaRecorder::Error)), this, SLOT(displayRecorderError())); - - mediaRecorder->setMetaData(QtMultimedia::Title, QVariant(QLatin1String("Test Title"))); - - connect(ui->exposureCompensation, SIGNAL(valueChanged(int)), SLOT(setExposureCompensation(int))); - - camera->setViewfinder(ui->viewfinder); - - updateCameraState(camera->state()); - 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(camera, SIGNAL(lockStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)), - this, SLOT(updateLockStatus(QCamera::LockStatus, QCamera::LockChangeReason))); - - ui->captureWidget->setTabEnabled(0, (camera->isCaptureModeSupported(QCamera::CaptureStillImage))); - ui->captureWidget->setTabEnabled(1, (camera->isCaptureModeSupported(QCamera::CaptureVideo))); - - updateCaptureMode(); - camera->start(); -} - -void Camera::keyPressEvent(QKeyEvent * event) -{ - if (event->isAutoRepeat()) - return; - - switch (event->key()) { -#if QT_VERSION >= 0x040700 - case Qt::Key_CameraFocus: - displayViewfinder(); - camera->searchAndLock(); - event->accept(); - break; - case Qt::Key_Camera: - if (camera->captureMode() == QCamera::CaptureStillImage) { - takeImage(); - } else { - if (mediaRecorder->state() == QMediaRecorder::RecordingState) - stop(); - else - record(); - } - event->accept(); - break; -#endif - default: - QMainWindow::keyPressEvent(event); - } -} - -void Camera::keyReleaseEvent(QKeyEvent * event) -{ - if (event->isAutoRepeat()) - return; - - switch (event->key()) { -#if QT_VERSION >= 0x040700 - case Qt::Key_CameraFocus: - camera->unlock(); - break; -#endif - default: - QMainWindow::keyReleaseEvent(event); - } -} - -void Camera::updateRecordTime() -{ - QString str = QString("Recorded %1 sec").arg(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, SLOT(displayViewfinder())); -} - -void Camera::configureCaptureSettings() -{ - switch (camera->captureMode()) { - case QCamera::CaptureStillImage: - configureImageSettings(); - break; - case QCamera::CaptureVideo: - configureVideoSettings(); - break; - default: - break; - } -} - -void Camera::configureVideoSettings() -{ - VideoSettings settingsDialog(mediaRecorder); - - settingsDialog.setAudioSettings(audioSettings); - settingsDialog.setVideoSettings(videoSettings); - settingsDialog.setFormat(videoContainerFormat); - - if (settingsDialog.exec()) { - audioSettings = settingsDialog.audioSettings(); - videoSettings = settingsDialog.videoSettings(); - videoContainerFormat = settingsDialog.format(); - - mediaRecorder->setEncodingSettings( - audioSettings, - videoSettings, - videoContainerFormat); - } -} - -void Camera::configureImageSettings() -{ - ImageSettings settingsDialog(imageCapture); - - settingsDialog.setImageSettings(imageSettings); - - if (settingsDialog.exec()) { - imageSettings = settingsDialog.imageSettings(); - imageCapture->setEncodingSettings(imageSettings); - } -} - -void Camera::record() -{ - mediaRecorder->record(); - updateRecordTime(); -} - -void Camera::pause() -{ - mediaRecorder->pause(); -} - -void Camera::stop() -{ - mediaRecorder->stop(); -} - -void Camera::setMuted(bool muted) -{ - mediaRecorder->setMuted(muted); -} - -void Camera::toggleLock() -{ - switch (camera->lockStatus()) { - case QCamera::Searching: - case QCamera::Locked: - camera->unlock(); - break; - case QCamera::Unlocked: - 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() - -{ - isCapturingImage = true; - imageCapture->capture(); -} - -void Camera::startCamera() -{ - camera->start(); -} - -void Camera::stopCamera() -{ - camera->stop(); -} - -void Camera::updateCaptureMode() -{ - int tabIndex = ui->captureWidget->currentIndex(); - QCamera::CaptureMode captureMode = tabIndex == 0 ? QCamera::CaptureStillImage : QCamera::CaptureVideo; - - if (camera->isCaptureModeSupported(captureMode)) - 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) -{ - camera->exposure()->setExposureCompensation(index*0.5); -} - -void Camera::displayRecorderError() -{ - QMessageBox::warning(this, tr("Capture error"), mediaRecorder->errorString()); -} - -void Camera::displayCameraError() -{ - QMessageBox::warning(this, tr("Camera error"), camera->errorString()); -} - -void Camera::updateCameraDevice(QAction *action) -{ - setCamera(action->data().toByteArray()); -} - -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); - Q_UNUSED(fileName); - - isCapturingImage = false; - if (applicationExiting) - close(); -} - -void Camera::closeEvent(QCloseEvent *event) -{ - if (isCapturingImage) { - setEnabled(false); - applicationExiting = true; - event->ignore(); - } else { - event->accept(); - } -} diff --git a/examples/camera/camera.h b/examples/camera/camera.h deleted file mode 100644 index ee54409..0000000 --- a/examples/camera/camera.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CAMERA_H -#define CAMERA_H - -#include <qcamera.h> -#include <qmediarecorder.h> -#include <qcameraimagecapture.h> - -QT_BEGIN_NAMESPACE -namespace Ui { - class Camera; -} -class QCameraViewfinder; -QT_END_NAMESPACE - -#include <QMainWindow> -#include <QDir> - -QT_USE_NAMESPACE - -class Camera : public QMainWindow -{ - Q_OBJECT -public: - Camera(QWidget *parent = 0); - ~Camera(); - -private slots: - void setCamera(const QByteArray &cameraDevice); - - void startCamera(); - void stopCamera(); - - void record(); - void pause(); - void stop(); - void setMuted(bool); - - void toggleLock(); - void takeImage(); - - void configureCaptureSettings(); - void configureVideoSettings(); - void configureImageSettings(); - - void displayRecorderError(); - void displayCameraError(); - - void updateCameraDevice(QAction*); - - 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); - void imageSaved(int, const QString&); - -protected: - void keyPressEvent(QKeyEvent * event); - void keyReleaseEvent(QKeyEvent * event); - void closeEvent(QCloseEvent *event ); - -private: - Ui::Camera *ui; - - QCamera *camera; - QCameraImageCapture *imageCapture; - QMediaRecorder* mediaRecorder; - - QImageEncoderSettings imageSettings; - QAudioEncoderSettings audioSettings; - QVideoEncoderSettings videoSettings; - QString videoContainerFormat; - bool isCapturingImage; - bool applicationExiting; -}; - -#endif diff --git a/examples/camera/camera.pro b/examples/camera/camera.pro deleted file mode 100644 index f7dd8b7..0000000 --- a/examples/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 - -target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/camera -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/camera - -INSTALLS += target sources - -QT+=widgets diff --git a/examples/camera/camera.ui b/examples/camera/camera.ui deleted file mode 100644 index ea790fa..0000000 --- a/examples/camera/camera.ui +++ /dev/null @@ -1,492 +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="text"> - <string>Capture Photo</string> - </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>29</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/> - <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/camera/imagesettings.cpp b/examples/camera/imagesettings.cpp deleted file mode 100644 index bb73f3a..0000000 --- a/examples/camera/imagesettings.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "imagesettings.h" -#include "ui_imagesettings.h" - -#include <QtWidgets/qcombobox.h> -#include <QtCore/qdebug.h> -#include <qcameraimagecapture.h> -#include <qmediaservice.h> - - - -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())); - foreach(const QString &codecName, imagecapture->supportedImageCodecs()) { - QString description = imagecapture->imageCodecDescription(codecName); - ui->imageCodecBox->addItem(codecName+": "+description, QVariant(codecName)); - } - - ui->imageQualitySlider->setRange(0, int(QtMultimedia::VeryHighQuality)); - - ui->imageResolutionBox->addItem(tr("Default Resolution")); - QList<QSize> supportedResolutions = imagecapture->supportedResolutions(); - foreach(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(QtMultimedia::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/camera/imagesettings.h b/examples/camera/imagesettings.h deleted file mode 100644 index 74bca37..0000000 --- a/examples/camera/imagesettings.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef IMAGESETTINGS_H -#define IMAGESETTINGS_H - -#include <QtWidgets/QDialog> -#include <qmediaencodersettings.h> - -QT_BEGIN_NAMESPACE -class QComboBox; -namespace Ui { - class ImageSettingsUi; -} - -class QCameraImageCapture; -QT_END_NAMESPACE - -QT_USE_NAMESPACE - -class ImageSettings : public QDialog { - Q_OBJECT -public: - ImageSettings(QCameraImageCapture *imageCapture, QWidget *parent = 0); - ~ImageSettings(); - - QAudioEncoderSettings audioSettings() const; - void setAudioSettings(const QAudioEncoderSettings&); - - QImageEncoderSettings imageSettings() const; - void setImageSettings(const QImageEncoderSettings&); - - QString format() const; - void setFormat(const QString &format); - -protected: - void changeEvent(QEvent *e); - -private: - QVariant boxValue(const QComboBox*) const; - void selectComboBoxItem(QComboBox *box, const QVariant &value); - - Ui::ImageSettingsUi *ui; - QCameraImageCapture *imagecapture; -}; - -#endif // IMAGESETTINGS_H diff --git a/examples/camera/imagesettings.ui b/examples/camera/imagesettings.ui deleted file mode 100644 index f790c77..0000000 --- a/examples/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>Dialog</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/camera/main.cpp b/examples/camera/main.cpp deleted file mode 100644 index af2fa4c..0000000 --- a/examples/camera/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "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/camera/videosettings.cpp b/examples/camera/videosettings.cpp deleted file mode 100644 index f97f4ad..0000000 --- a/examples/camera/videosettings.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "videosettings.h" -#include "ui_videosettings.h" - -#include <QtWidgets/qcombobox.h> -#include <QtCore/qdebug.h> -#include <qmediarecorder.h> -#include <qmediaservice.h> - - -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())); - foreach(const QString &codecName, mediaRecorder->supportedAudioCodecs()) { - QString description = mediaRecorder->audioCodecDescription(codecName); - ui->audioCodecBox->addItem(codecName+": "+description, QVariant(codecName)); - } - - //sample rate: - foreach(int sampleRate, mediaRecorder->supportedAudioSampleRates()) { - ui->audioSampleRateBox->addItem(QString::number(sampleRate), QVariant(sampleRate)); - } - - ui->audioQualitySlider->setRange(0, int(QtMultimedia::VeryHighQuality)); - - //video codecs - ui->videoCodecBox->addItem(tr("Default video codec"), QVariant(QString())); - foreach(const QString &codecName, mediaRecorder->supportedVideoCodecs()) { - QString description = mediaRecorder->videoCodecDescription(codecName); - ui->videoCodecBox->addItem(codecName+": "+description, QVariant(codecName)); - } - - ui->videoQualitySlider->setRange(0, int(QtMultimedia::VeryHighQuality)); - - - ui->videoResolutionBox->addItem(tr("Default")); - QList<QSize> supportedResolutions = mediaRecorder->supportedResolutions(); - foreach(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) { - 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), - 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(QtMultimedia::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(QtMultimedia::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/camera/videosettings.h b/examples/camera/videosettings.h deleted file mode 100644 index 6cce31d..0000000 --- a/examples/camera/videosettings.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef VIDEOSETTINGS_H -#define VIDEOSETTINGS_H - -#include <QtWidgets/QDialog> -#include <qmediaencodersettings.h> - -QT_BEGIN_NAMESPACE -class QComboBox; -namespace Ui { - class VideoSettingsUi; -} - -class QMediaRecorder; -QT_END_NAMESPACE - -QT_USE_NAMESPACE - -class VideoSettings : public QDialog { - Q_OBJECT -public: - VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent = 0); - ~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); - -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/camera/videosettings.ui b/examples/camera/videosettings.ui deleted file mode 100644 index f6aa004..0000000 --- a/examples/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>Dialog</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> |