camerauis/cameraxui/cxengine/src/cxeautofocuscontroldesktop.cpp
branchRCL_3
changeset 53 61bc0f252b2b
equal deleted inserted replaced
50:f54ad444594d 53:61bc0f252b2b
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QMetaType>
       
    19 #include <QImage>
       
    20 
       
    21 //#include "cxesettings.h"
       
    22 #include "cxeautofocuscontroldesktop.h"
       
    23 #include "cxutils.h"
       
    24 #include "cxestate.h"
       
    25 
       
    26 /*
       
    27 * CxeAutoFocusControlSymbian::CxeAutoFocusControlSymbian
       
    28 */
       
    29 CxeAutoFocusControlDesktop::CxeAutoFocusControlDesktop()
       
    30     : mCancelled(false),
       
    31       mState(Unknown)
       
    32 {
       
    33     CX_DEBUG_ENTER_FUNCTION();
       
    34 
       
    35     qRegisterMetaType<CxeAutoFocusControl::State>();
       
    36 
       
    37     initializeStates();
       
    38     initializeResources();
       
    39 
       
    40     CX_DEBUG_EXIT_FUNCTION();
       
    41 }
       
    42 
       
    43 /*
       
    44 * CxeAutoFocusControlDesktop::~CxeAutoFocusControlDesktop
       
    45 */
       
    46 CxeAutoFocusControlDesktop::~CxeAutoFocusControlDesktop()
       
    47 {
       
    48     CX_DEBUG_ENTER_FUNCTION();
       
    49     CX_DEBUG_EXIT_FUNCTION();
       
    50 }
       
    51 
       
    52 /*
       
    53 * Start Autofocus
       
    54 */
       
    55 CxeError::Id CxeAutoFocusControlDesktop::start(bool soundEnabled)
       
    56 {
       
    57     Q_UNUSED(soundEnabled);
       
    58 
       
    59     CX_DEBUG( ("CxeAutoFocusControlDesktop::start() <> state: %d", state() ) );
       
    60 
       
    61     CxeError::Id err = CxeError::None;
       
    62 
       
    63     if (state() != CxeAutoFocusControl::InProgress && state() != CxeAutoFocusControl::Canceling) {
       
    64         CX_DEBUG(("CxeAutoFocusControlDesktop::start() calling SetAutoFocusType"));
       
    65         mCancelled = false;
       
    66         mState = Ready;
       
    67         emit stateChanged(mState, CxeError::None);
       
    68     } else { // AF was started earlier, can't start until it completes
       
    69         err = CxeError::InUse;
       
    70     }
       
    71 
       
    72     CX_DEBUG( ("CxeAutoFocusControlDesktop::start() <= err : %d", err ) );
       
    73 
       
    74     return err;
       
    75 }
       
    76 
       
    77 /*
       
    78 * Cancel Autofocus
       
    79 */
       
    80 void CxeAutoFocusControlDesktop::cancel()
       
    81 {
       
    82     CX_DEBUG( ("CxeAutoFocusControlSymbian::cancel <> state: %d", state() ) );
       
    83 
       
    84     if (!mCancelled) {
       
    85         if (state() == CxeAutoFocusControl::InProgress) {
       
    86             // Need to stop current AF first. Wait for AF event to proceed.
       
    87             mState = Canceling;
       
    88             emit stateChanged(mState, CxeError::None);
       
    89         } else if (state() != CxeAutoFocusControl::Canceling) {
       
    90             // Cancel means move to hyperfocal.
       
    91             mState = Canceling;
       
    92             emit stateChanged(mState, CxeError::None);
       
    93         }
       
    94     }
       
    95     CX_DEBUG_EXIT_FUNCTION();
       
    96 }
       
    97 
       
    98 /*
       
    99 * Set Autofocus mode
       
   100 */
       
   101 void CxeAutoFocusControlDesktop::setMode(CxeAutoFocusControl::Mode newMode)
       
   102 {
       
   103     CX_DEBUG_ENTER_FUNCTION();
       
   104 
       
   105     mAfMode = newMode;
       
   106     mCancelled = false;
       
   107 
       
   108     CX_DEBUG_EXIT_FUNCTION();
       
   109 }
       
   110 
       
   111 /*
       
   112 * returns Autofocus mode
       
   113 */
       
   114 CxeAutoFocusControl::Mode CxeAutoFocusControlDesktop::mode() const
       
   115 {
       
   116     return mAfMode;
       
   117 }
       
   118 
       
   119 /**
       
   120 * Is the given mode a fixed focus mode?
       
   121 */
       
   122 bool CxeAutoFocusControlDesktop::isFixedFocusMode(CxeAutoFocusControl::Mode mode) const
       
   123 {
       
   124     return (mode == CxeAutoFocusControl::Hyperfocal
       
   125          || mode == CxeAutoFocusControl::Infinity);
       
   126 }
       
   127 
       
   128 /*
       
   129 * To check if Autofocus is supported
       
   130 */
       
   131 bool CxeAutoFocusControlDesktop::supported() const
       
   132 {
       
   133     CX_DEBUG_ENTER_FUNCTION();
       
   134 
       
   135     bool supported = true;
       
   136     CX_DEBUG_EXIT_FUNCTION();
       
   137     return supported;
       
   138 }
       
   139 
       
   140 /*
       
   141 * CxeAutoFocusControlDesktop::state
       
   142 */
       
   143 CxeAutoFocusControl::State CxeAutoFocusControlDesktop::state() const
       
   144 {
       
   145     return mState;
       
   146 }
       
   147 
       
   148 /*
       
   149 * CxeAutoFocusControlDesktop::initializeStates
       
   150 */
       
   151 void CxeAutoFocusControlDesktop::initializeStates()
       
   152 {
       
   153 }
       
   154 
       
   155 /*
       
   156 * CxeAutoFocusControlDesktop::initializeResources
       
   157 */
       
   158 void CxeAutoFocusControlDesktop::initializeResources()
       
   159 {
       
   160     CX_DEBUG_ENTER_FUNCTION();
       
   161     CX_DEBUG_EXIT_FUNCTION();
       
   162 }
       
   163 
       
   164 /*!
       
   165   * Public method for checking if auto focus sound is enabled
       
   166   * \return true if enabled
       
   167   */
       
   168 bool CxeAutoFocusControlDesktop::isSoundEnabled() const
       
   169 {
       
   170     return false; // should actually return mSoundEnabled
       
   171 }
       
   172 
       
   173 // end of file