From: Mohammed Sameer Date: Sat, 3 Aug 2013 05:04:39 +0000 (+0300) Subject: Implemented per device resolution setting and selection X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=commitdiff_plain;h=04e7179e1a1fe4957dd38ccf9b9555f02e9b4b83 Implemented per device resolution setting and selection --- diff --git a/qml/CameraSettings.qml b/qml/CameraSettings.qml index e68b3ce..8d104f4 100644 --- a/qml/CameraSettings.qml +++ b/qml/CameraSettings.qml @@ -44,7 +44,7 @@ Column { CameraButtonRow { anchors.horizontalCenter: parent.horizontalCenter // TODO: test this - enabled: camera.running && camera.idle + enabled: camera != null && camera.running && camera.idle CameraButton { text: qsTr("Back (Primary)"); diff --git a/qml/ImageOverlay.qml b/qml/ImageOverlay.qml index 377bd19..25b6e79 100644 --- a/qml/ImageOverlay.qml +++ b/qml/ImageOverlay.qml @@ -174,7 +174,9 @@ Item { Indicator { id: resolutionIndicator - source: "image://theme/" + Data.imageIcon(settings.imageAspectRatio, settings.imageResolution) + property string imageAspectRatio: settings.device == 1 ? settings.secondaryImageAspectRatio : settings.primaryImageAspectRatio + property string imageResolution: settings.device == 1 ? settings.secondaryImageResolution : settings.primaryImageResolution + source: "image://theme/" + Data.imageIcon(imageAspectRatio, imageResolution) } Indicator { diff --git a/qml/ImageResolutionSettings.qml b/qml/ImageResolutionSettings.qml index df1b6b1..b968b95 100644 --- a/qml/ImageResolutionSettings.qml +++ b/qml/ImageResolutionSettings.qml @@ -28,6 +28,11 @@ Column { spacing: 10 + property string __aspectRatio: settings.device == 1 ? + settings.secondaryImageAspectRatio : settings.primaryImageAspectRatio + property string __resolution: settings.device == 1 ? + settings.secondaryImageResolution : settings.primaryImageResolution + SectionHeader { text: qsTr("Aspect ratio") visible: aspectRatioRow.visible @@ -44,8 +49,14 @@ Column { model: imageSettings.aspectRatios delegate: CameraButton { text: qsTr(modelData) - checked: settings.imageAspectRatio == modelData - onClicked: settings.imageAspectRatio = modelData + checked: __aspectRatio == modelData + onClicked: { + if (settings.device == 1) { + settings.secondaryImageAspectRatio = modelData + } else { + settings.primaryImageAspectRatio = modelData + } + } } } } @@ -65,19 +76,34 @@ Column { Binding { target: imageSettings.resolutions property: "aspectRatio" - value: settings.imageAspectRatio + value: settings.primaryImageAspectRatio + when: settings.device == 0 + } + + Binding { + target: imageSettings.resolutions + property: "aspectRatio" + value: settings.secondaryImageAspectRatio + when: settings.device == 1 } Repeater { id: resolutions - model: imageSettings.resolutions.aspectRatio == settings.imageAspectRatio ? + + model: imageSettings.resolutions.aspectRatio == __aspectRatio ? imageSettings.resolutions : undefined delegate: CameraButton { capitalize: true text: qsTr("%1 %2 Mpx").arg(resolutionName).arg(megaPixels) - checked: settings.imageResolution == resolutionName - onClicked: settings.imageResolution = resolutionName + checked: __resolution == resolutionName + onClicked: { + if (settings.device == 1) { + settings.secondaryImageResolution = resolutionName + } else { + settings.primaryImageResolution = resolutionName + } + } } } } diff --git a/qml/MainPage.qml b/qml/MainPage.qml index 0f5c517..d650b9d 100644 --- a/qml/MainPage.qml +++ b/qml/MainPage.qml @@ -197,7 +197,10 @@ CameraPage { camera: viewfinder.camera function setImageResolution() { - if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) { + var aspectRatio = settings.device == 1 ? settings.secondaryImageAspectRatio : settings.primaryImageAspectRatio + var resolution = settings.device == 1 ? settings.secondaryImageResolution : settings.primaryImageResolution + + if (!imageSettings.setResolution(aspectRatio, resolution)) { showError(qsTr("Failed to set required resolution")) } } @@ -214,7 +217,10 @@ CameraPage { camera: viewfinder.camera function setVideoResolution() { - if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) { + var aspectRatio = settings.device == 1 ? settings.secondaryVideoAspectRatio : settings.primaryVideoAspectRatio + var resolution = settings.device == 1 ? settings.secondaryVideoResolution : settings.primaryVideoResolution + + if (!videoSettings.setResolution(aspectRatio, resolution)) { showError(qsTr("Failed to set required resolution")) } } @@ -229,17 +235,15 @@ CameraPage { Connections { target: settings - onImageAspectRatioChanged: { - imageSettings.setImageResolution() - } - - onImageResolutionChanged: { - imageSettings.setImageResolution() - } + onPrimaryImageResolutionChanged: imageSettings.setImageResolution() + onPrimaryImageAspectRatioChanged: imageSettings.setImageResolution() + onSecondaryImageResolutionChanged: imageSettings.setImageResolution() + onSecondaryImageAspectRatioChanged: imageSettings.setImageResolution() - onVideoResolutionChanged: { - videoSettings.setVideoResolution() - } + onPrimaryVideoResolutionChanged: videoSettings.setVideoResolution() + onPrimaryVideoAspectRatioChanged: videoSettings.setVideoResolution() + onSecondaryVideoResolutionChanged: videoSettings.setVideoResolution() + onSecondaryVideoAspectRatioChanged: videoSettings.setVideoResolution() } ModeController { diff --git a/qml/VideoOverlay.qml b/qml/VideoOverlay.qml index c66c60f..9bce237 100644 --- a/qml/VideoOverlay.qml +++ b/qml/VideoOverlay.qml @@ -149,7 +149,8 @@ Item { Indicator { id: resolutionIndicator - source: "image://theme/" + Data.videoIcon(settings.videoResolution) + property string videoResolution: settings.device == 1 ? settings.secondaryVideoResolution : settings.primaryVideoResolution + source: "image://theme/" + Data.videoIcon(videoResolution) } Indicator { diff --git a/qml/VideoResolutionSettings.qml b/qml/VideoResolutionSettings.qml index c105c55..aa89d10 100644 --- a/qml/VideoResolutionSettings.qml +++ b/qml/VideoResolutionSettings.qml @@ -28,6 +28,9 @@ Column { spacing: 10 + property string __resolution: settings.device == 1 ? + settings.secondaryVideoResolution : settings.primaryVideoResolution + visible: videoSettings.resolutions.count > 1 SectionHeader { @@ -47,8 +50,14 @@ Column { delegate: CameraButton { capitalize: true text: qsTr("%1 %2").arg(resolutionName).arg(resolution) - checked: settings.videoResolution == resolutionName - onClicked: settings.videoResolution = resolutionName + checked: __resolution == resolutionName + onClicked: { + if (settings.device == 1) { + settings.secondaryVideoResolution = resolutionName + } else { + settings.primaryVideoResolution = resolutionName + } + } } } } diff --git a/src/settings.cpp b/src/settings.cpp index 1d099a0..52c87d5 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -33,9 +33,6 @@ #define DEFAULT_EV_COMP 0.0 #define DEFAULT_FLASH_MODE 0 #define DEFAULT_IMAGE_ISO 0 -#define DEFAULT_IMAGE_RESOLUTION "high" -#define DEFAULT_IMAGE_ASPECT_RATIO "16:9" -#define DEFAULT_VIDEO_RESOLUTION "high" #define DEFAULT_SOUND_ENABLED true #define DEFAULT_VIDEO_TORCH_ON false #define DEFAULT_SHOW_TOOL_BAR false @@ -45,6 +42,16 @@ #define DEFAULT_ZOOM_AS_SHUTTER false #define DEFAULT_DEVICE 0 +#define DEFAULT_PRIMARY_IMAGE_RESOLUTION "high" +#define DEFAULT_PRIMARY_IMAGE_ASPECT_RATIO "16:9" +#define DEFAULT_PRIMARY_VIDEO_RESOLUTION "high" +#define DEFAULT_PRIMARY_VIDEO_ASPECT_RATIO "16:9" + +#define DEFAULT_SECONDARY_IMAGE_RESOLUTION "low" +#define DEFAULT_SECONDARY_IMAGE_ASPECT_RATIO "4:3" +#define DEFAULT_SECONDARY_VIDEO_RESOLUTION "low" +#define DEFAULT_SECONDARY_VIDEO_ASPECT_RATIO "4:3" + Settings::Settings(QObject *parent) : QObject(parent), m_settings(new QSettings(PATH, QSettings::IniFormat, this)) { @@ -222,52 +229,6 @@ void Settings::setImageIso(int iso) { } } -QString Settings::imageAspectRatio() const { - return m_settings->value("image/aspectRatio", DEFAULT_IMAGE_ASPECT_RATIO).toString(); -} - -void Settings::setImageAspectRatio(const QString& aspectRatio) { - if (aspectRatio != imageAspectRatio()) { - m_settings->setValue("image/aspectRatio", aspectRatio); - emit imageAspectRatioChanged(); - } -} - -QString Settings::imageResolution() const { - return m_settings->value("image/resolution", DEFAULT_IMAGE_RESOLUTION).toString(); -} - -void Settings::setImageResolution(const QString& resolution) { - if (resolution != imageResolution()) { - m_settings->setValue("image/resolution", resolution); - emit imageResolutionChanged(); - } -} - -QString Settings::videoAspectRatio() const { - // This is not used for anything so we will return an empty string for now - // which will make the backend return all resolutions. - - return QString(); -} - -void Settings::setVideoAspectRatio(const QString& aspectRatio) { - Q_UNUSED(aspectRatio); - - // This is not used for anything so we will just ignore it. -} - -QString Settings::videoResolution() const { - return m_settings->value("video/resolution", DEFAULT_VIDEO_RESOLUTION).toString(); -} - -void Settings::setVideoResolution(const QString& resolution) { - if (resolution != videoResolution()) { - m_settings->setValue("video/resolution", resolution); - emit videoResolutionChanged(); - } -} - bool Settings::isSoundEnabled() const { return m_settings->value("camera/soundEnabled", DEFAULT_SOUND_ENABLED).toBool(); } @@ -357,3 +318,99 @@ void Settings::setDevice(int device) { emit deviceChanged(); } } + +QString Settings::primaryImageAspectRatio() const { + return m_settings->value("image/primaryAspectRatio", + DEFAULT_PRIMARY_IMAGE_ASPECT_RATIO).toString(); +} + +void Settings::setPrimaryImageAspectRatio(const QString& aspectRatio) { + if (primaryImageAspectRatio() != aspectRatio) { + m_settings->setValue("image/primaryAspectRatio", aspectRatio); + emit primaryImageAspectRatioChanged(); + } +} + +QString Settings::primaryImageResolution() const { + return m_settings->value("image/primaryResolution", + DEFAULT_PRIMARY_IMAGE_RESOLUTION).toString(); +} + +void Settings::setPrimaryImageResolution(const QString& resolution) { + if (primaryImageResolution() != resolution) { + m_settings->setValue("image/primaryResolution", resolution); + emit primaryImageResolutionChanged(); + } +} + +QString Settings::primaryVideoAspectRatio() const { + return m_settings->value("video/primaryAspectRatio", + DEFAULT_PRIMARY_VIDEO_ASPECT_RATIO).toString(); +} + +void Settings::setPrimaryVideoAspectRatio(const QString& aspectRatio) { + if (primaryVideoAspectRatio() != aspectRatio) { + m_settings->setValue("video/primaryAspectRatio", aspectRatio); + emit primaryVideoAspectRatioChanged(); + } +} + +QString Settings::primaryVideoResolution() const { + return m_settings->value("video/primaryResolution", + DEFAULT_PRIMARY_VIDEO_RESOLUTION).toString(); +} + +void Settings::setPrimaryVideoResolution(const QString& resolution) { + if (primaryVideoResolution() != resolution) { + m_settings->setValue("video/primaryResolution", resolution); + emit primaryVideoResolutionChanged(); + } +} + +QString Settings::secondaryImageAspectRatio() const { + return m_settings->value("image/secondaryAspectRatio", + DEFAULT_SECONDARY_IMAGE_ASPECT_RATIO).toString(); +} + +void Settings::setSecondaryImageAspectRatio(const QString& aspectRatio) { + if (secondaryImageAspectRatio() != aspectRatio) { + m_settings->setValue("image/secondaryAspectRatio", aspectRatio); + emit secondaryImageAspectRatioChanged(); + } +} + +QString Settings::secondaryImageResolution() const { + return m_settings->value("image/secondaryResolution", + DEFAULT_SECONDARY_IMAGE_RESOLUTION).toString(); +} + +void Settings::setSecondaryImageResolution(const QString& resolution) { + if (secondaryImageResolution() != resolution) { + m_settings->setValue("image/secondaryResolution", resolution); + emit secondaryImageResolutionChanged(); + } +} + +QString Settings::secondaryVideoAspectRatio() const { + return m_settings->value("video/secondaryAspectRatio", + DEFAULT_SECONDARY_VIDEO_ASPECT_RATIO).toString(); +} + +void Settings::setSecondaryVideoAspectRatio(const QString& aspectRatio) { + if (secondaryVideoAspectRatio() != aspectRatio) { + m_settings->setValue("video/secondaryAspectRatio", aspectRatio); + emit secondaryVideoAspectRatioChanged(); + } +} + +QString Settings::secondaryVideoResolution() const { + return m_settings->value("video/secondaryResolution", + DEFAULT_SECONDARY_VIDEO_RESOLUTION).toString(); +} + +void Settings::setSecondaryVideoResolution(const QString& resolution) { + if (secondaryVideoResolution() != resolution) { + m_settings->setValue("video/secondaryResolution", resolution); + emit secondaryVideoResolutionChanged(); + } +} diff --git a/src/settings.h b/src/settings.h index b27dea6..807712d 100644 --- a/src/settings.h +++ b/src/settings.h @@ -47,11 +47,14 @@ class Settings : public QObject { Q_PROPERTY(int imageFlashMode READ imageFlashMode WRITE setImageFlashMode NOTIFY imageFlashModeChanged); Q_PROPERTY(int imageIso READ imageIso WRITE setImageIso NOTIFY imageIsoChanged); - Q_PROPERTY(QString imageAspectRatio READ imageAspectRatio WRITE setImageAspectRatio NOTIFY imageAspectRatioChanged); - Q_PROPERTY(QString imageResolution READ imageResolution WRITE setImageResolution NOTIFY imageResolutionChanged); - - Q_PROPERTY(QString videoAspectRatio READ videoAspectRatio WRITE setVideoAspectRatio NOTIFY videoAspectRatioChanged); - Q_PROPERTY(QString videoResolution READ videoResolution WRITE setVideoResolution NOTIFY videoResolutionChanged); + Q_PROPERTY(QString primaryImageAspectRatio READ primaryImageAspectRatio WRITE setPrimaryImageAspectRatio NOTIFY primaryImageAspectRatioChanged); + Q_PROPERTY(QString primaryImageResolution READ primaryImageResolution WRITE setPrimaryImageResolution NOTIFY primaryImageResolutionChanged); + Q_PROPERTY(QString primaryVideoAspectRatio READ primaryVideoAspectRatio WRITE setPrimaryVideoAspectRatio NOTIFY primaryVideoAspectRatioChanged); + Q_PROPERTY(QString primaryVideoResolution READ primaryVideoResolution WRITE setPrimaryVideoResolution NOTIFY primaryVideoResolutionChanged); + Q_PROPERTY(QString secondaryImageAspectRatio READ secondaryImageAspectRatio WRITE setSecondaryImageAspectRatio NOTIFY secondaryImageAspectRatioChanged); + Q_PROPERTY(QString secondaryImageResolution READ secondaryImageResolution WRITE setSecondaryImageResolution NOTIFY secondaryImageResolutionChanged); + Q_PROPERTY(QString secondaryVideoAspectRatio READ secondaryVideoAspectRatio WRITE setSecondaryVideoAspectRatio NOTIFY secondaryVideoAspectRatioChanged); + Q_PROPERTY(QString secondaryVideoResolution READ secondaryVideoResolution WRITE setSecondaryVideoResolution NOTIFY secondaryVideoResolutionChanged); Q_PROPERTY(bool soundEnabled READ isSoundEnabled WRITE setSoundEnabled NOTIFY soundEnabledChanged); Q_PROPERTY(bool videoTorchOn READ isVideoTorchOn WRITE setVideoTorchOn NOTIFY videoTorchOnChanged); @@ -111,18 +114,6 @@ public: int imageIso() const; void setImageIso(int iso); - QString imageAspectRatio() const; - void setImageAspectRatio(const QString& aspectRatio); - - QString imageResolution() const; - void setImageResolution(const QString& resolution); - - QString videoAspectRatio() const; - void setVideoAspectRatio(const QString& aspectRatio); - - QString videoResolution() const; - void setVideoResolution(const QString& resolution); - bool isSoundEnabled() const; void setSoundEnabled(bool enabled); @@ -147,6 +138,30 @@ public: int device() const; void setDevice(int device); + QString primaryImageAspectRatio() const; + void setPrimaryImageAspectRatio(const QString& aspectRatio); + + QString primaryImageResolution() const; + void setPrimaryImageResolution(const QString& resolution); + + QString primaryVideoAspectRatio() const; + void setPrimaryVideoAspectRatio(const QString& aspectRatio); + + QString primaryVideoResolution() const; + void setPrimaryVideoResolution(const QString& resolution); + + QString secondaryImageAspectRatio() const; + void setSecondaryImageAspectRatio(const QString& aspectRatio); + + QString secondaryImageResolution() const; + void setSecondaryImageResolution(const QString& resolution); + + QString secondaryVideoAspectRatio() const; + void setSecondaryVideoAspectRatio(const QString& aspectRatio); + + QString secondaryVideoResolution() const; + void setSecondaryVideoResolution(const QString& resolution); + signals: void modeChanged(); void creatorNameChanged(); @@ -162,10 +177,6 @@ signals: void videoEvCompChanged(); void imageFlashModeChanged(); void imageIsoChanged(); - void imageAspectRatioChanged(); - void imageResolutionChanged(); - void videoAspectRatioChanged(); - void videoResolutionChanged(); void soundEnabledChanged(); void videoTorchOnChanged(); void toolBarShownChanged(); @@ -174,6 +185,14 @@ signals: void faceDetectionEnabledChanged(); void zoomAsShutterChanged(); void deviceChanged(); + void primaryImageAspectRatioChanged(); + void primaryImageResolutionChanged(); + void primaryVideoAspectRatioChanged(); + void primaryVideoResolutionChanged(); + void secondaryImageAspectRatioChanged(); + void secondaryImageResolutionChanged(); + void secondaryVideoAspectRatioChanged(); + void secondaryVideoResolutionChanged(); private: QSettings *m_settings;