camerauis/cameraxui/cxui/src/cxuicapturekeyhandler_desktop_p.cpp
branchRCL_3
changeset 54 bac7acad7cb3
parent 53 61bc0f252b2b
child 57 2c87b2808fd7
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
     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 *   Private implementation for CxuiCaptureKeyHandler
       
    16 */
       
    17 
       
    18 #include <QVariant>
       
    19 #include <QKeyEvent>
       
    20 
       
    21 #include "cxuicapturekeyhandler.h"
       
    22 #include "cxuicapturekeyhandler_desktop_p.h"
       
    23 #include "cxutils.h"
       
    24 #include "cxeengine.h"
       
    25 #include "cxenamespace.h"
       
    26 #include "cxefeaturemanager.h"
       
    27 
       
    28 #define CXUIDESKTOP_SCANCODE_LOWERCASE_A  30
       
    29 #define CXUIDESKTOP_SCANCODE_LOWERCASE_C  46
       
    30 
       
    31 CxuiCaptureKeyHandlerPrivate::CxuiCaptureKeyHandlerPrivate(CxeEngine &aEngine, CxuiCaptureKeyHandler *parent) :
       
    32     q_ptr(parent),
       
    33     mEngine(aEngine),
       
    34     mAutofocusKeyPressed(false),
       
    35     mCaptureKeyPressed(false)
       
    36 {
       
    37     CX_DEBUG_IN_FUNCTION();
       
    38 }
       
    39 
       
    40 CxuiCaptureKeyHandlerPrivate::~CxuiCaptureKeyHandlerPrivate()
       
    41 {
       
    42     CX_DEBUG_IN_FUNCTION();
       
    43 }
       
    44 
       
    45 void CxuiCaptureKeyHandlerPrivate::startListeningKeys()
       
    46 {
       
    47     CX_DEBUG_IN_FUNCTION();
       
    48 }
       
    49 
       
    50 void CxuiCaptureKeyHandlerPrivate::stopListeningKeys()
       
    51 {
       
    52     CX_DEBUG_IN_FUNCTION();
       
    53 }
       
    54 
       
    55 bool CxuiCaptureKeyHandlerPrivate::handleKeyEvent(QEvent *event)
       
    56 {
       
    57     CX_DEBUG_ENTER_FUNCTION();
       
    58     Q_Q(CxuiCaptureKeyHandler);
       
    59 
       
    60     bool wasEventConsumed = false;
       
    61 
       
    62     if (event->type() == QEvent::KeyPress) {
       
    63         QKeyEvent *keyEvent = static_cast<QKeyEvent*> (event);
       
    64         if (keyEvent->nativeScanCode() == CXUIDESKTOP_SCANCODE_LOWERCASE_A) {
       
    65             mAutofocusKeyPressed = true;
       
    66             wasEventConsumed = true;
       
    67             emit q->autofocusKeyPressed();
       
    68         } else if (keyEvent->nativeScanCode() == CXUIDESKTOP_SCANCODE_LOWERCASE_C) {
       
    69             mCaptureKeyPressed = true;
       
    70             wasEventConsumed = true;
       
    71             emit q->captureKeyPressed();
       
    72         }
       
    73     } else if (event->type() == QEvent::KeyRelease) {
       
    74         QKeyEvent *keyEvent = static_cast<QKeyEvent*> (event);
       
    75         if (keyEvent->nativeScanCode() == CXUIDESKTOP_SCANCODE_LOWERCASE_A) {
       
    76             mAutofocusKeyPressed = false;
       
    77             wasEventConsumed = true;
       
    78             emit q->autofocusKeyReleased();
       
    79         } else if (keyEvent->nativeScanCode() == CXUIDESKTOP_SCANCODE_LOWERCASE_C) {
       
    80             mCaptureKeyPressed = false;
       
    81             wasEventConsumed = true;
       
    82             emit q->captureKeyReleased();
       
    83         }
       
    84     }
       
    85 
       
    86     CX_DEBUG_EXIT_FUNCTION();
       
    87     return wasEventConsumed;
       
    88 }
       
    89 
       
    90 bool CxuiCaptureKeyHandlerPrivate::isAutofocusKeyPressed()
       
    91 {
       
    92     return mAutofocusKeyPressed;
       
    93 }
       
    94 
       
    95 bool CxuiCaptureKeyHandlerPrivate::isCaptureKeyPressed()
       
    96 {
       
    97     return mCaptureKeyPressed;
       
    98 }