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