X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=src%2Fsettings.cpp;h=52c87d570677c38638618490fc5e482c5fadb389;hb=f64ec59e63bc8379b80393ff7c8e241e448e8234;hp=2cf7b0392b6e4226903cdf7753c5b0fac04613dd;hpb=522b856a02afa4251ae41aadc9f133b4fafe1550;p=harmattan%2Fcameraplus diff --git a/src/settings.cpp b/src/settings.cpp index 2cf7b03..52c87d5 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,7 +1,7 @@ /*! * This file is part of CameraPlus. * - * Copyright (C) 2012 Mohammed Sameer + * Copyright (C) 2012-2013 Mohammed Sameer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,21 +24,33 @@ #define PATH QString("%1%2.config%2/cameraplus.conf").arg(QDir::homePath()).arg(QDir::separator()) -#define DEFAULT_MODE 1 -#define DEFAULT_SCENE_MODE 6 // Auto -#define DEFAULT_TIMEOUT 0 -#define DEFAULT_USE_GPS true -#define DEFAULT_USE_GEOTAGS true -#define DEFAULT_COLOR_FILTER 0 -#define DEFAULT_WHITE_BALANCE 0 -#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_MODE 1 +#define DEFAULT_SCENE_MODE 6 // Auto +#define DEFAULT_USE_GPS true +#define DEFAULT_USE_GEOTAGS true +#define DEFAULT_COLOR_FILTER 0 +#define DEFAULT_WHITE_BALANCE 0 +#define DEFAULT_EV_COMP 0.0 +#define DEFAULT_FLASH_MODE 0 +#define DEFAULT_IMAGE_ISO 0 +#define DEFAULT_SOUND_ENABLED true +#define DEFAULT_VIDEO_TORCH_ON false +#define DEFAULT_SHOW_TOOL_BAR false +#define DEFAULT_VIDEO_MUTE false +#define DEFAULT_GRID_ENABLED false +#define DEFAULT_FACE_DETECTION_ENABLED true +#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), @@ -74,18 +86,6 @@ void Settings::setCreatorName(const QString& name) { } } -int Settings::postCaptureTimeout() const { - return m_settings->value("camera/postCaptureTimeout", DEFAULT_TIMEOUT).toInt(); -} - -void Settings::setPostCaptureTimeout(int timeout) { - if (timeout != postCaptureTimeout()) { - m_settings->setValue("camera/postCaptureTimeout", timeout); - - emit postCaptureTimeoutChanged(); - } -} - bool Settings::useGps() const { return m_settings->value("camera/useGps", DEFAULT_USE_GPS).toBool(); } @@ -229,70 +229,188 @@ void Settings::setImageIso(int iso) { } } -QString Settings::imageAspectRatio() const { - return m_settings->value("image/aspectRatio", DEFAULT_IMAGE_ASPECT_RATIO).toString(); +bool Settings::isSoundEnabled() const { + return m_settings->value("camera/soundEnabled", DEFAULT_SOUND_ENABLED).toBool(); } -void Settings::setImageAspectRatio(const QString& aspectRatio) { - if (aspectRatio != imageAspectRatio()) { - m_settings->setValue("image/aspectRatio", aspectRatio); - emit imageAspectRatioChanged(); +void Settings::setSoundEnabled(bool enabled) { + if (isSoundEnabled() != enabled) { + m_settings->setValue("camera/soundEnabled", enabled); + emit soundEnabledChanged(); } } -QString Settings::imageResolution() const { - return m_settings->value("image/resolution", DEFAULT_IMAGE_RESOLUTION).toString(); +bool Settings::isVideoTorchOn() const { + return m_settings->value("video/torchOn", DEFAULT_VIDEO_TORCH_ON).toBool(); } -void Settings::setImageResolution(const QString& resolution) { - if (resolution != imageResolution()) { - m_settings->setValue("image/resolution", resolution); - emit imageResolutionChanged(); +void Settings::setVideoTorchOn(bool on) { + if (isVideoTorchOn() != on) { + m_settings->setValue("video/torchOn", on); + emit videoTorchOnChanged(); } } -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. +bool Settings::isToolBarShown() const { + return m_settings->value("camera/showToolBar", DEFAULT_SHOW_TOOL_BAR).toBool(); +} - return QString(); +void Settings::setToolBarShown(bool shown) { + if (isToolBarShown() != shown) { + m_settings->setValue("camera/showToolBar", shown); + + emit toolBarShownChanged(); + } } -void Settings::setVideoAspectRatio(const QString& aspectRatio) { - Q_UNUSED(aspectRatio); +bool Settings::isVideoMuted() const { + return m_settings->value("video/mute", DEFAULT_VIDEO_MUTE).toBool(); +} - // This is not used for anything so we will just ignore it. +void Settings::setVideoMuted(bool muted) { + if (isVideoMuted() != muted) { + m_settings->setValue("video/mute", muted); + emit videoMutedChanged(); + } } -QString Settings::videoResolution() const { - return m_settings->value("video/resolution", DEFAULT_VIDEO_RESOLUTION).toString(); +bool Settings::isGridEnabled() const { + return m_settings->value("camera/gridEnabled", DEFAULT_GRID_ENABLED).toBool(); } -void Settings::setVideoResolution(const QString& resolution) { - if (resolution != videoResolution()) { - m_settings->setValue("video/resolution", resolution); - emit videoResolutionChanged(); +void Settings::setGridEnabled(bool enabled) { + if (enabled != isGridEnabled()) { + m_settings->setValue("camera/gridEnabled", enabled); + emit gridEnabledChanged(); } } -bool Settings::isSoundEnabled() const { - return m_settings->value("camera/soundEnabled", DEFAULT_SOUND_ENABLED).toBool(); +bool Settings::isFaceDetectionEnabled() const { + return m_settings->value("image/faceDetectionEnabled", DEFAULT_FACE_DETECTION_ENABLED).toBool(); } -void Settings::setSoundEnabled(bool enabled) { - if (isSoundEnabled() != enabled) { - m_settings->setValue("camera/soundEnabled", enabled); - emit soundEnabledChanged(); +void Settings::setFaceDetectionEnabled(bool enabled) { + if (isFaceDetectionEnabled() != enabled) { + m_settings->setValue("image/faceDetectionEnabled", enabled); + emit faceDetectionEnabledChanged(); } } -bool Settings::isVideoTorchOn() const { - return m_settings->value("video/torchOn", DEFAULT_VIDEO_TORCH_ON).toBool(); +bool Settings::isZoomAsShutterEnabled() { + return m_settings->value("camera/zoomAsShutter", DEFAULT_ZOOM_AS_SHUTTER).toBool(); } -void Settings::setVideoTorchOn(bool on) { - if (isVideoTorchOn() != on) { - m_settings->setValue("video/torchOn", on); - emit videoTorchOnChanged(); +void Settings::setZoomAsShutterEnabled(bool enabled) { + if (isZoomAsShutterEnabled() != enabled) { + m_settings->setValue("camera/zoomAsShutter", enabled); + + emit zoomAsShutterChanged(); + } +} + +int Settings::device() const { + return m_settings->value("camera/device", DEFAULT_DEVICE).toInt(); +} + +void Settings::setDevice(int device) { + if (device != Settings::device()) { + m_settings->setValue("camera/device", 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(); } }