camerauis/cameraxui/cxui/src/cxuiscenemodeview.cpp
author hgs
Wed, 18 Aug 2010 14:02:45 +0300
changeset 51 ccc0e7e3344f
parent 45 24fd82631616
permissions -rw-r--r--
201031_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) {
45
hgs
parents: 43
diff changeset
   174
        QString sceneId = mEngine->settings().get<QString>(data.mSettingId);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   175
        HbIcon background(backgroundForScene(sceneId));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   176
        background.setMirroringMode(HbIcon::LayoutDirection);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   177
        mScenesBackground->setIcon(background);
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   178
    } else {
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   179
        //First time displaying a list
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   180
        //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
   181
        mScenesList->setSelected(0);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   182
    }
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   183
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   184
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   185
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   186
/*!
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   187
 * 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
   188
 * correct pre-capture view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   189
 */
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   190
void CxuiSceneModeView::saveActivity()
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   191
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   192
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   193
    QVariantMap data;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   194
    QVariantHash params;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   195
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   196
    //@todo: add pre-capture icon as screenshot
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   197
    if (mEngine->mode() == Cxe::ImageMode) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   198
        mActivityManager->removeActivity(CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   199
        mActivityManager->addActivity(CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY, data, params);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   200
    } else {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   201
        mActivityManager->removeActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   202
        mActivityManager->addActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY, data, params);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   203
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   204
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   205
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   206
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   207
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   208
/*!
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   209
* Handle selecting value in scene list.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   210
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   211
void CxuiSceneModeView::handleSceneRadiobuttonPress(int index)
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   212
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   213
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   214
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   215
    CxUiSettings::SettingItem item = mSettingPairList.at(index);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   216
    QString sceneId = item.mValue.toString();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   217
    HbIcon background(backgroundForScene(sceneId));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   218
    background.setMirroringMode(HbIcon::LayoutDirection);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   219
    mScenesBackground2->setIcon(background);
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   220
    startBackgroundTransition();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   221
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   222
}
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
* Helper method for getting the background graphic name
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   227
* for each of the scenes.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   228
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   229
QString CxuiSceneModeView::backgroundForScene(const QString& sceneId)
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   230
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   231
    //!@todo: This mapping should be added to the setting xml.
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   232
    if (sceneId == Cxe::IMAGE_SCENE_AUTO) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   233
        return CXUI_SCENES_AUTOMATIC_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   234
    } else if (sceneId == Cxe::IMAGE_SCENE_PORTRAIT) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   235
        return CXUI_SCENES_PORTRAIT_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   236
    } else if (sceneId == Cxe::IMAGE_SCENE_SCENERY) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   237
        return CXUI_SCENES_LANDSCAPE_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   238
    } else if (sceneId == Cxe::IMAGE_SCENE_MACRO) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   239
        return CXUI_SCENES_CLOSEUP_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   240
    } else if (sceneId == Cxe::IMAGE_SCENE_SPORTS) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   241
        return CXUI_SCENES_SPORT_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   242
    } else if (sceneId == Cxe::IMAGE_SCENE_NIGHT) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   243
        return CXUI_SCENES_NIGHT_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   244
    } else if (sceneId == Cxe::IMAGE_SCENE_NIGHTPORTRAIT) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   245
        return CXUI_SCENES_NIGHT_PORTRAIT_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   246
    } else if (sceneId == Cxe::VIDEO_SCENE_AUTO) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   247
        return CXUI_SCENES_AUTOMATIC_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   248
    } else if (sceneId == Cxe::VIDEO_SCENE_LOWLIGHT) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   249
        return CXUI_SCENES_LOW_LIGHT_IMAGE;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   250
    } else if (sceneId == Cxe::VIDEO_SCENE_NIGHT) {
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   251
        return CXUI_SCENES_NIGHT_IMAGE;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   252
    } else {
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   253
        return "";
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   254
    }
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
* Start animation for changing the scene background graphic.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   260
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   261
void CxuiSceneModeView::startBackgroundTransition()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   262
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   263
    mTransitionAnimation->setStartValue(0.0);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   264
    mTransitionAnimation->setEndValue(1.0);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   265
    mTransitionAnimation->start();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   266
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
* Handle scene background graphic animation finishing.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   271
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   272
void CxuiSceneModeView::finishScenesTransition()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   273
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   274
    mScenesBackground->setIcon(mScenesBackground2->icon());
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   275
    mScenesBackground2->setOpacity(0);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   276
    mScenesBackground2->setIcon(HbIcon());
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   277
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   278
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   279
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   280
* Handle press of ok button.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   281
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   282
void CxuiSceneModeView::handleOkButtonPress()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   283
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   284
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   285
    mScenesList->handleSelectionAccepted();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   286
    closeView();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   287
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   288
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   289
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   290
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   291
* Handle press of cancel button.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   292
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   293
void CxuiSceneModeView::handleCancelButtonPress()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   294
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   295
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   296
    closeView();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   297
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   298
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   299
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   300
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   301
* This view is about to be shown.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   302
* Update the view to match currently selected scene.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   303
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   304
void CxuiSceneModeView::showEvent(QShowEvent *event)
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   305
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   306
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   307
    mScenesList->scrollTo(mScenesList->currentIndex(), HbAbstractItemView::PositionAtTop);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   308
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   309
    mEngine->viewfinderControl().stop();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   310
    mCameraReleaseTimer.start();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   311
    QGraphicsWidget::showEvent(event);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   312
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   313
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   314
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   315
/*!
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   316
* Allow showing UI controls?
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   317
* Title bar and other UI chrome is never shown in scene mode view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   318
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   319
bool CxuiSceneModeView::allowShowControls() const
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   320
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   321
    return false;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   322
}
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
 * Play feedback when touching view outside of any widget?
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   326
 * Feedback is not played in scene mode view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   327
 */
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   328
bool CxuiSceneModeView::isFeedbackEnabled() const
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   329
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   330
    return false;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   331
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   332
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   333
/*!
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   334
* Slot to handle capture key full press.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   335
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   336
void CxuiSceneModeView::handleCaptureKeyPressed()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   337
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   338
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   339
    closeView();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   340
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   341
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   342
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   343
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   344
* Slot to handle capture key half press / autofocus key press.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   345
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   346
void CxuiSceneModeView::handleAutofocusKeyPressed()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   347
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   348
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   349
    closeView();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   350
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   351
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   352
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   353
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   354
* Closing the view and reactivating camera hw if needed
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   355
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   356
void CxuiSceneModeView::closeView()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   357
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   358
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   359
    mScenesList->handleClose();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   360
    mScenesBackground->setIcon(HbIcon());
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   361
    mScenesHeading = NULL;
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   362
    emit viewCloseEvent();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   363
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   364
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   365
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   366
// end of file
3075d9b614e6 201017_1
hgs
parents:
diff changeset
   367