camerauis/cameraxui/cxui/src/cxuiscenemodeview.cpp
author hgs
Thu, 15 Jul 2010 01:55:05 +0300
changeset 43 0e652f8f1fbd
parent 28 3075d9b614e6
child 45 24fd82631616
permissions -rw-r--r--
201027_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     1
/*
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     3
* All rights reserved.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     8
*
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     9
* Initial Contributors:
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    11
*
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    12
* Contributors:
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    13
*
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    14
* Description:
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    15
*
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    16
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    17
#include <hbframeitem.h>
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    18
#include <hbactivitymanager.h>
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    19
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    20
#include "cxenamespace.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    21
#include "cxesettings.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    22
#include "cxuiscenemodeview.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    23
#include "cxuienums.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    24
#include "cxutils.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    25
#include "cxuicapturekeyhandler.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    26
#include "cxuisettingsinfo.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    27
#include "cxeviewfindercontrol.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    28
#include "cxecameradevicecontrol.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    29
#include "cxuidocumentloader.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    30
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    31
using namespace Cxe;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    32
using namespace CxUi;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    33
using namespace CxUiLayout;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    34
using namespace CxUiSettings;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    35
using namespace CxeSettingIds;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    36
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    37
const int CXUI_SCENES_TRANSITION_TIME = 350; // 350 milliseconds
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    38
const int CXUI_SCENES_CAMERA_TIMEOUT = 60000; // 60 seconds for the camera hw release timeout
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    39
const QString CXUI_SCENES_AUTOMATIC_IMAGE=":/camerax/scene_automatic.png";
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    40
const QString CXUI_SCENES_LANDSCAPE_IMAGE=":/camerax/scene_landscape.png";
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    41
const QString CXUI_SCENES_CLOSEUP_IMAGE=":/camerax/scene_close-up.png";
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    42
const QString CXUI_SCENES_PORTRAIT_IMAGE=":/camerax/scene_portrait.png";
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    43
const QString CXUI_SCENES_SPORT_IMAGE=":/camerax/scene_sport.png";
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    44
const QString CXUI_SCENES_NIGHT_IMAGE=":/camerax/scene_night.png";
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    45
const QString CXUI_SCENES_NIGHT_PORTRAIT_IMAGE=":/camerax/scene_nightportrait.png";
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    46
const QString CXUI_SCENES_LOW_LIGHT_IMAGE=":/camerax/scene_lowlight.png";
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    47
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    48
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    49
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    50
* Constructor
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    51
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    52
CxuiSceneModeView::CxuiSceneModeView(QGraphicsItem *parent) :
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    53
    CxuiView(parent),
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    54
    mSettingsInfo(NULL),
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    55
    mScenesBackground(NULL),
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    56
    mScenesHeading(NULL)
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    57
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    58
    CX_DEBUG_IN_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    59
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    60
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    61
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    62
* Destructor
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    63
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    64
CxuiSceneModeView::~CxuiSceneModeView()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    65
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    66
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    67
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    68
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    69
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    70
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    71
* Construct-method handles initialisation tasks for this class. Needs to be called
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    72
* before the instance of this class is used.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    73
* @param mainwindow
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    74
* @param engine
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    75
* @param documentLoader
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    76
* @param keyHandler
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    77
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    78
void CxuiSceneModeView::construct(HbMainWindow *mainwindow,
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    79
                               CxeEngine *engine,
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    80
                               CxuiDocumentLoader *documentLoader,
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    81
                               CxuiCaptureKeyHandler *keyHandler,
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    82
                               HbActivityManager *activityManager)
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    83
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    84
    CX_DEBUG_ENTER_FUNCTION();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    85
    CxuiView::construct(mainwindow, engine, documentLoader, keyHandler, activityManager);
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    86
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    87
    mSettingsInfo = new CxuiSettingsInfo(mEngine);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    88
    setContentFullScreen(true);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    89
    loadDefaultWidgets();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    90
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    91
    mCameraReleaseTimer.setInterval(CXUI_SCENES_CAMERA_TIMEOUT);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    92
    mCameraReleaseTimer.setSingleShot(true);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    93
    connect(&mCameraReleaseTimer, SIGNAL(timeout()), this, SLOT(releaseCamera()), Qt::UniqueConnection);
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    94
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    95
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    96
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    97
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    98
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    99
* Load widgets from DocML.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   100
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   101
void CxuiSceneModeView::loadDefaultWidgets()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   102
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   103
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   104
    CX_DEBUG_ASSERT(mDocumentLoader);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   105
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   106
    QGraphicsWidget *widget = NULL;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   107
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   108
    widget = mDocumentLoader->findWidget(SCENE_MODE_VIEW_CONTAINER);
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   109
    mScenesContainer = qobject_cast<HbWidget *> (widget);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   110
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   111
    mScenesHeading = qobject_cast<HbLabel *>(
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   112
        mDocumentLoader->findWidget(SCENE_MODE_VIEW_HEADING_WIDGET));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   113
    CX_ASSERT_ALWAYS(mScenesHeading);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   114
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   115
    //Now let's retreive the pointer to icon widget
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   116
    widget = mDocumentLoader->findWidget(SCENE_MODE_VIEW_BG_IMAGE);
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   117
    mScenesBackground = qobject_cast<HbLabel *> (widget);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   118
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   119
    widget = mDocumentLoader->findWidget(SCENE_MODE_VIEW_BG_IMAGE2);
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   120
    mScenesBackground2 = qobject_cast<HbLabel *> (widget);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   121
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   122
    //Assuming that the automatic scene mode is always the default one
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   123
    CX_DEBUG(("CxuiSceneModeView::loadDefaultWidgets -> Now setting default image"));
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   124
    HbIcon background(CXUI_SCENES_AUTOMATIC_IMAGE);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   125
    background.setMirroringMode(HbIcon::LayoutDirection);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   126
    mScenesBackground->setIcon(background);
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   127
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   128
    widget = mDocumentLoader->findWidget(SCENE_MODE_VIEW_RADIOBUTTONS);
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   129
    mScenesList = qobject_cast<CxuiSettingRadioButtonList *> (widget);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   130
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   131
    mTransitionAnimation = new QPropertyAnimation(mScenesBackground2, "opacity");
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   132
    mTransitionAnimation->setDuration(CXUI_SCENES_TRANSITION_TIME);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   133
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   134
    createWidgetBackgroundGraphic(mScenesContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   135
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   136
    //!@todo: View flags property is missing from HbView,
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   137
    //        so can't properly hide title bar / status bar there.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   138
    hideControls();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   139
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   140
    connectSignals();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   141
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   142
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   143
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   144
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   145
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   146
* Helper function to connect signals needed in this class.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   147
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   148
void CxuiSceneModeView::connectSignals()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   149
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   150
    connect(mScenesList, SIGNAL(itemSelected(int)), this, SLOT(handleSceneRadiobuttonPress(int)));
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   151
    connect(mTransitionAnimation, SIGNAL(finished()), this, SLOT(finishScenesTransition()));
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   152
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   153
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   154
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   155
* This public method assumes that the view is already properly constructed
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   156
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   157
void CxuiSceneModeView::loadBackgroundImages()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   158
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   159
     CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   160
    RadioButtonListParams data;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   161
    if (mEngine->mode() == Cxe::ImageMode) {
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   162
        mSettingsInfo->getSettingsContent(CxeSettingIds::IMAGE_SCENE, data);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   163
    } else {
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   164
        mSettingsInfo->getSettingsContent(CxeSettingIds::VIDEO_SCENE, data);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   165
    }
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   166
    mSettingPairList = data.mSettingPairList;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   167
    mScenesList->init(&data);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   168
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   169
    if (mScenesHeading) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   170
        mScenesHeading->setPlainText(data.mHeading);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   171
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   172
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   173
    if (mScenesBackground) {
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   174
        QString sceneId;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   175
        mEngine->settings().get(data.mSettingId, sceneId);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   176
        HbIcon background(backgroundForScene(sceneId));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   177
        background.setMirroringMode(HbIcon::LayoutDirection);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   178
        mScenesBackground->setIcon(background);
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   179
    } else {
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   180
        //First time displaying a list
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   181
        //Assuming that the automatic scene mode is always the default one and is on top of the list
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   182
        mScenesList->setSelected(0);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   183
    }
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   184
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   185
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   186
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   187
/*!
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   188
 * Save view state to activity. Scene mode view doesn't have it's own activity, just save
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   189
 * correct pre-capture view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   190
 */
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   191
void CxuiSceneModeView::saveActivity()
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   192
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   193
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   194
    QVariantMap data;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   195
    QVariantHash params;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   196
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   197
    //@todo: add pre-capture icon as screenshot
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   198
    if (mEngine->mode() == Cxe::ImageMode) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   199
        mActivityManager->removeActivity(CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   200
        mActivityManager->addActivity(CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY, data, params);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   201
    } else {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   202
        mActivityManager->removeActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   203
        mActivityManager->addActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY, data, params);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   204
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   205
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   206
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   207
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   208
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   209
/*!
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   210
* Handle selecting value in scene list.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   211
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   212
void CxuiSceneModeView::handleSceneRadiobuttonPress(int index)
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   213
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   214
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   215
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   216
    CxUiSettings::SettingItem item = mSettingPairList.at(index);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   217
    QString sceneId = item.mValue.toString();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   218
    HbIcon background(backgroundForScene(sceneId));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   219
    background.setMirroringMode(HbIcon::LayoutDirection);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   220
    mScenesBackground2->setIcon(background);
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   221
    startBackgroundTransition();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   222
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   223
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   224
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   225
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   226
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   227
* Helper method for getting the background graphic name
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   228
* for each of the scenes.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   229
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   230
QString CxuiSceneModeView::backgroundForScene(const QString& sceneId)
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   231
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   232
    //!@todo: This mapping should be added to the setting xml.
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   233
    if (sceneId == Cxe::IMAGE_SCENE_AUTO) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   234
        return CXUI_SCENES_AUTOMATIC_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   235
    } else if (sceneId == Cxe::IMAGE_SCENE_PORTRAIT) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   236
        return CXUI_SCENES_PORTRAIT_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   237
    } else if (sceneId == Cxe::IMAGE_SCENE_SCENERY) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   238
        return CXUI_SCENES_LANDSCAPE_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   239
    } else if (sceneId == Cxe::IMAGE_SCENE_MACRO) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   240
        return CXUI_SCENES_CLOSEUP_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   241
    } else if (sceneId == Cxe::IMAGE_SCENE_SPORTS) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   242
        return CXUI_SCENES_SPORT_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   243
    } else if (sceneId == Cxe::IMAGE_SCENE_NIGHT) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   244
        return CXUI_SCENES_NIGHT_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   245
    } else if (sceneId == Cxe::IMAGE_SCENE_NIGHTPORTRAIT) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   246
        return CXUI_SCENES_NIGHT_PORTRAIT_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   247
    } else if (sceneId == Cxe::VIDEO_SCENE_AUTO) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   248
        return CXUI_SCENES_AUTOMATIC_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   249
    } else if (sceneId == Cxe::VIDEO_SCENE_LOWLIGHT) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   250
        return CXUI_SCENES_LOW_LIGHT_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   251
    } else if (sceneId == Cxe::VIDEO_SCENE_NIGHT) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   252
        return CXUI_SCENES_NIGHT_IMAGE;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   253
    } else {
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   254
        return "";
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   255
    }
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   256
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   257
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   258
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   259
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   260
* Start animation for changing the scene background graphic.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   261
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   262
void CxuiSceneModeView::startBackgroundTransition()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   263
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   264
    mTransitionAnimation->setStartValue(0.0);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   265
    mTransitionAnimation->setEndValue(1.0);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   266
    mTransitionAnimation->start();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   267
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   268
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   269
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   270
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   271
* Handle scene background graphic animation finishing.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   272
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   273
void CxuiSceneModeView::finishScenesTransition()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   274
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   275
    mScenesBackground->setIcon(mScenesBackground2->icon());
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   276
    mScenesBackground2->setOpacity(0);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   277
    mScenesBackground2->setIcon(HbIcon());
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   278
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   279
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   280
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   281
* Handle press of ok button.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   282
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   283
void CxuiSceneModeView::handleOkButtonPress()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   284
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   285
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   286
    mScenesList->handleSelectionAccepted();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   287
    closeView();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   288
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   289
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   290
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   291
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   292
* Handle press of cancel button.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   293
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   294
void CxuiSceneModeView::handleCancelButtonPress()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   295
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   296
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   297
    closeView();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   298
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   299
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   300
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   301
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   302
* This view is about to be shown.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   303
* Update the view to match currently selected scene.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   304
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   305
void CxuiSceneModeView::showEvent(QShowEvent *event)
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   306
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   307
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   308
    mScenesList->scrollTo(mScenesList->currentIndex(), HbAbstractItemView::PositionAtTop);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   309
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   310
    mEngine->viewfinderControl().stop();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   311
    mCameraReleaseTimer.start();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   312
    QGraphicsWidget::showEvent(event);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   313
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   314
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   315
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   316
/*!
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   317
* Allow showing UI controls?
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   318
* Title bar and other UI chrome is never shown in scene mode view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   319
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   320
bool CxuiSceneModeView::allowShowControls() const
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   321
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   322
    return false;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   323
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   324
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   325
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   326
 * Play feedback when touching view outside of any widget?
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   327
 * Feedback is not played in scene mode view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   328
 */
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   329
bool CxuiSceneModeView::isFeedbackEnabled() const
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   330
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   331
    return false;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   332
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   333
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   334
/*!
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   335
* Slot to handle capture key full press.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   336
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   337
void CxuiSceneModeView::handleCaptureKeyPressed()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   338
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   339
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   340
    closeView();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   341
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   342
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   343
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   344
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   345
* Slot to handle capture key half press / autofocus key press.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   346
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   347
void CxuiSceneModeView::handleAutofocusKeyPressed()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   348
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   349
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   350
    closeView();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   351
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   352
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   353
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   354
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   355
* Closing the view and reactivating camera hw if needed
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   356
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   357
void CxuiSceneModeView::closeView()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   358
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   359
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   360
    mScenesList->handleClose();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   361
    mScenesBackground->setIcon(HbIcon());
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   362
    mScenesHeading = NULL;
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   363
    emit viewCloseEvent();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   364
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   365
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   366
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   367
// end of file
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   368