camerauis/cameraxui/cxui/src/cxuiviewmanager.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:
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
     2
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
#include <QDebug>
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include <QTimer>
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <hbmainwindow.h>
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <QGraphicsSceneEvent>
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    21
#include <hbstyleloader.h>
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    22
#include <hbactivitymanager.h>
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    23
#include <hbaction.h>
45
hgs
parents: 43
diff changeset
    24
#include <xqserviceutil.h>
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    26
#include "cxuiapplication.h"
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    27
#include "cxuiapplicationstate.h"
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include "cxuiviewmanager.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include "cxuivideoprecaptureview.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include "cxuistillprecaptureview.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "cxuipostcaptureview.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include "cxuicapturekeyhandler.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include "cxeengine.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include "cxecameradevicecontrol.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
#include "cxefeaturemanager.h" //  mEngine->featureManager()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#include "cxeviewfindercontrol.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include "cxenamespace.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
#include "cxuienums.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include "cxutils.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
#include "cxuidocumentloader.h"
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    41
#include "cxesettings.h"
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    42
#include "cxememorymonitor.h"
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    43
#include "cxuiserviceprovider.h"
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    44
#include "cxuiscenemodeview.h"
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    45
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    46
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    47
#ifdef Q_OS_SYMBIAN
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
#include "OstTraceDefinitions.h"
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    49
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
#ifdef OST_TRACE_COMPILER_IN_USE
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
#include "cxuiviewmanagerTraces.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
#endif
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    54
#endif //Q_OS_SYMBIAN
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    55
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
using namespace Cxe;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
using namespace CxUiLayout;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    60
namespace
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    61
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    62
    static const int CXUI_STANDBY_CAMERA_TIMEOUT = 60000; // 60 seconds
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    63
}
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    65
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    66
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    67
* Constructor.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    68
*/
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    69
CxuiViewManager::CxuiViewManager(CxuiApplication &application, HbMainWindow &mainWindow, CxeEngine &engine) :
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    70
    mApplication(application),
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
    mMainWindow(mainWindow),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
    mEngine(engine),
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    73
    mKeyHandler(NULL),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    74
    mCameraDocumentLoader(NULL),
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    75
    mApplicationState(NULL),
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    76
    mErrorManager(NULL)
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    80
    // create mappings to map view name to correct docml file
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    81
    mDocmlFilesByView.insert(STILL_PRE_CAPTURE_VIEW, STILL_1ST_XML);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    82
    mDocmlFilesByView.insert(VIDEO_PRE_CAPTURE_VIEW, VIDEO_1ST_XML);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    83
    mDocmlFilesByView.insert(POSTCAPTURE_VIEW, POSTCAPTURE_XML);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    84
    mDocmlFilesByView.insert(SCENE_MODE_VIEW, SCENEMODE_SETTING_XML);
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    85
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    86
    // Key handler
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    87
    mKeyHandler = new CxuiCaptureKeyHandler(mEngine);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    88
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    89
    // Document loader
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    90
    OstTrace0(camerax_performance, CXUIVIEWMANAGER_CXUIVIEWMANAGER_1, "msg: e_CX_VIEWMANAGER_CREATE_DOCLOADER 1");
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    91
    mCameraDocumentLoader = new CxuiDocumentLoader(&engine);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    92
    OstTrace0(camerax_performance, CXUIVIEWMANAGER_CXUIVIEWMANAGER_2, "msg: e_CX_VIEWMANAGER_CREATE_DOCLOADER 0");
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    94
    // Application state
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    95
    mApplicationState = new CxuiApplicationState(mApplication, mEngine.settings(), mCameraDocumentLoader);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    96
    CX_ASSERT_ALWAYS(mApplicationState);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    97
    bool ok = connect(mApplicationState, SIGNAL(stateChanged(CxuiApplicationState::State, CxuiApplicationState::State)),
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    98
                      this, SLOT(handleApplicationStateChanged(CxuiApplicationState::State, CxuiApplicationState::State)));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    99
    Q_ASSERT_X(ok, "CxuiViewManager", "Application state change signal connect failed.");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   100
    connect(this, SIGNAL(standbyExitRequested()), mApplicationState, SLOT(exitStandby()), Qt::QueuedConnection);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   102
    // Standby timer
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   103
    mStandbyTimer.setInterval(CXUI_STANDBY_CAMERA_TIMEOUT);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   104
    mStandbyTimer.setSingleShot(true);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   105
    connect(&mStandbyTimer, SIGNAL(timeout()), mApplicationState, SLOT(enterStandby()));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   106
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   107
    // Filter capture and AF keys and follow user activity from mouse events.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   108
    QCoreApplication::instance()->installEventFilter(this);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   109
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   110
    // Monitor memory on normal state, not on standby, error or background.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   111
    connect(this, SIGNAL(normalStateEntered()), &mEngine.memoryMonitor(), SLOT(startMonitoring()));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   112
    connect(this, SIGNAL(normalStateExited()), &mEngine.memoryMonitor(), SLOT(stopMonitoring()));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
    //connecting initmode signals
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
    connect(&mEngine.cameraDeviceControl(), SIGNAL(initModeComplete(CxeError::Id)),
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   116
            mApplicationState, SLOT(handleApplicationError(CxeError::Id)));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   118
    connect(&mEngine.stillCaptureControl(), SIGNAL(imageCaptured(CxeError::Id, int)),
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   119
            mApplicationState, SLOT(handleApplicationError(CxeError::Id)));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   120
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   121
    // Register stylesheet. It will be automatically destroyed on application
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   122
    // exit.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   123
    HbStyleLoader::registerFilePath(":/camerax/cxui.css");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   124
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   125
    // Create the view we are starting in, or connect signals so it
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   126
    // will be created once we know the mode we are starting to.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   127
    initStartupView();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   128
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   129
    // For UI startup testing, we need to emit applicationReady signal once UI is ready to be used.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   130
    connect(mMainWindow.currentView(), SIGNAL(viewReady()), &mApplication, SIGNAL(applicationReady()));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   131
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   132
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   133
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   134
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   135
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   136
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   137
* Destructor.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   138
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   139
CxuiViewManager::~CxuiViewManager()
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   140
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   141
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   142
    QCoreApplication::instance()->removeEventFilter(this);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   143
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   144
    if (!CxuiServiceProvider::isCameraEmbedded()) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   145
        currentView()->saveActivity();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   146
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   147
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   148
    delete mApplicationState;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   149
    delete mCameraDocumentLoader;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   150
    delete mKeyHandler;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   151
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   152
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   153
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   154
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   155
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   156
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   157
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   158
* Handle change in overall state of application.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   159
* @param newState The new application state.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   160
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   161
void CxuiViewManager::handleApplicationStateChanged(CxuiApplicationState::State newState,
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   162
                                                    CxuiApplicationState::State oldState)
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   163
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   164
    Q_UNUSED(oldState);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   165
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   166
45
hgs
parents: 43
diff changeset
   167
    CxuiView *view = currentView();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   168
    CX_DEBUG(("CxuiViewManager - current view %d", view));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   169
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   170
    switch (newState) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   171
    case CxuiApplicationState::Normal:
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   172
        // Disable raising to foreground with capture key.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   173
        disconnect(mKeyHandler, SIGNAL(captureKeyPressed()), this, SLOT(toForeground()));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   174
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   175
        connectSignals(view);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   176
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   177
        CX_DEBUG(("CxuiViewManager - emitting normalStateEntered"));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   178
        emit normalStateEntered();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   179
        break;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   180
    case CxuiApplicationState::Standby:
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   181
         if (view && !view->isStandbyModeSupported()) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   182
            // If we move to Stanby, and current view does not
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   183
            // support standby mode, move to Normal mode right away.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   184
            CX_DEBUG(("CxuiViewManager - view does not support stanbdy, exiting standby right away.."));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   185
            mApplicationState->exitStandby();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   186
        } else {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   187
            handleExitingNormalState();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   188
        }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   189
        break;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   190
    case CxuiApplicationState::Error:
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   191
    case CxuiApplicationState::Background:
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   192
        handleExitingNormalState();
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   193
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   194
        if (newState == CxuiApplicationState::Background) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   195
            // Moved to background.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   196
            // Bring application back to foreground by capture key press
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   197
            connect(mKeyHandler, SIGNAL(captureKeyPressed()), this, SLOT(toForeground()));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   198
        }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   199
        break;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   200
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   201
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   202
    CX_DEBUG_EXIT_FUNCTION();
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
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   206
* Helper method to handle (possible) exiting from normal state.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   207
* @param oldState The previous state.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   208
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   209
void CxuiViewManager::handleExitingNormalState()
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   210
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   211
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   212
    // Store view that is active now.
45
hgs
parents: 43
diff changeset
   213
    CxuiView *view = currentView();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   214
    CX_DEBUG(("CxuiViewManager - current view %d", view));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   215
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   216
    // Emit signal so current view can enter standby.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   217
    emit normalStateExited();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   218
    // Disconnect signals so we don't send key event's etc.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   219
    // Using the view before normalStateExited() signal was emitted,
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   220
    // just in case it caused view switch.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   221
    disconnectSignals(view);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   222
    // Make sure standby timer is not running.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   223
    stopStandbyTimer();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   224
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   225
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   226
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   227
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   228
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   229
* Slot for starting standby timer.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   230
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   231
void CxuiViewManager::startStandbyTimer()
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   232
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   233
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   234
    mStandbyTimer.start();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   235
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   236
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   237
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   238
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   239
* Slot for stopping standby timer.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   240
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   241
void CxuiViewManager::stopStandbyTimer()
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   242
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   243
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   244
    mStandbyTimer.stop();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   245
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   246
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   247
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   248
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   249
 * Helper function to return current view cast to CxuiView.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   250
 */
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   251
CxuiView* CxuiViewManager::currentView() const
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   252
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   253
    CxuiView *view = qobject_cast<CxuiView*> (mMainWindow.currentView());
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   254
    return view;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   255
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   256
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   257
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   258
* Select and initialize the view we need to start into.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   259
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   260
void CxuiViewManager::initStartupView()
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   261
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   262
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   263
45
hgs
parents: 43
diff changeset
   264
    if (mApplication.activateReason() == Hb::ActivationReasonService ||
hgs
parents: 43
diff changeset
   265
        // @todo: There's a bug in orbit and we never get Hb::ActivationReasonService as
hgs
parents: 43
diff changeset
   266
        // activation reason. Use XQServiceUtil to determine if starting service as
hgs
parents: 43
diff changeset
   267
        // a workaround for now
hgs
parents: 43
diff changeset
   268
        XQServiceUtil::isService()) {
hgs
parents: 43
diff changeset
   269
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   270
        // For embedded mode: don't create view yet, create when engine inits to correct mode.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   271
        // Connect signals to set up the view after image/video prepare
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
        connect(&mEngine.stillCaptureControl(), SIGNAL(imagePrepareComplete(CxeError::Id)),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
                this, SLOT(changeToPrecaptureView()));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
        connect(&mEngine.videoCaptureControl(), SIGNAL(videoPrepareComplete(CxeError::Id)),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
                this, SLOT(changeToPrecaptureView()));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   277
    } else if (mApplication.activateReason() == Hb::ActivationReasonActivity) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   278
        // restoring activity, read startup view from stored activity
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   279
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   280
        // view to start in
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   281
        QString viewName = STILL_PRE_CAPTURE_VIEW;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   282
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   283
        bool preCapture = true;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   284
        QString activityId = mApplication.activateId();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   285
        if (activityId == CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   286
            viewName = STILL_PRE_CAPTURE_VIEW;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   287
        } else if (activityId == CxuiActivityIds::STILL_POSTCAPTURE_ACTIVITY) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   288
            viewName = POSTCAPTURE_VIEW;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   289
            preCapture = false;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   290
        } else if (activityId == CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   291
            viewName = VIDEO_PRE_CAPTURE_VIEW;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   292
        } else if (activityId == CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   293
            viewName = POSTCAPTURE_VIEW;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   294
            preCapture = false;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   295
        }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   296
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   297
        CxuiView *view = createView(viewName);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   298
        if (preCapture) {
45
hgs
parents: 43
diff changeset
   299
            connectPreCaptureSignals(static_cast<CxuiPrecaptureView *>(view));
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   300
        } else {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   301
            connectPostCaptureSignals();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   302
        }
45
hgs
parents: 43
diff changeset
   303
        mMainWindow.setCurrentView(view, false);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   304
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   305
        // restore view from activity
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   306
        bool ok = mApplication.activityManager()->waitActivity();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   307
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   308
        view->restoreActivity(activityId,
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   309
                              mApplication.activityManager()->activityData(mApplication.activateId()));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   310
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   311
        clearAllActivities();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   312
    } else {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   313
        // normal start
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   314
        // no activity id, get default view from engine state
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   315
        CxuiView *view = NULL;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   316
        if (mEngine.mode() == Cxe::VideoMode) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   317
            view = createView(VIDEO_PRE_CAPTURE_VIEW);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   318
        } else {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   319
            view = createView(STILL_PRE_CAPTURE_VIEW);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   320
        }
45
hgs
parents: 43
diff changeset
   321
        connectPreCaptureSignals(static_cast<CxuiPrecaptureView *>(view));
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   322
        mMainWindow.setCurrentView(view, false);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   323
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   324
        clearAllActivities();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
    }
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   326
45
hgs
parents: 43
diff changeset
   327
    // Check the current application state, signalled to handleApplicationStateChanged.
hgs
parents: 43
diff changeset
   328
    mApplicationState->startMonitoring();
hgs
parents: 43
diff changeset
   329
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   333
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   334
* Create view and add it to main window.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   335
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   336
CxuiView* CxuiViewManager::createView(const QString &viewName)
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   340
    OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_IN, "msg: e_CX_CREATE_VIEW 1");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   341
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   342
    CX_DEBUG(("View name: %s", viewName.toAscii().data()));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   343
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   344
    CxuiView* view = mViews[viewName];
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   345
    if (view == NULL) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   346
        CX_DEBUG(("View not loaded yet, loading now"));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   347
        bool ok = false;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   348
        // Use document loader to create widgets and layouts
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   349
        // (non-sectioned parts are parsed and loaded)
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   350
        QString docmlFile = mDocmlFilesByView[viewName];
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   351
        CX_ASSERT_ALWAYS(mCameraDocumentLoader);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   352
        CX_ASSERT_ALWAYS(!docmlFile.isNull());
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   353
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   354
        OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_2, "msg: e_CX_DOCUMENTLOADER_LOAD 1");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   355
        mCameraDocumentLoader->load(docmlFile, &ok);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   356
        OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_4, "msg: e_CX_DOCUMENTLOADER_LOAD 0");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   357
        Q_ASSERT_X(ok, "createView", "error in xml file parsing");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   358
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   359
        OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_6, "msg: e_CX_DOCUMENTLOADER_FINDWIDGET 1");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   360
        QGraphicsWidget *widget = NULL;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   361
        // ask for the view widget pointer
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   362
        widget = mCameraDocumentLoader->findWidget(viewName);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   363
        view = qobject_cast<CxuiView *> (widget);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   364
        CX_ASSERT_ALWAYS(view);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   365
        OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_8, "msg: e_CX_DOCUMENTLOADER_FINDWIDGET 1");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   366
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   367
        // call for needed consturction methods
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   368
        view->construct(&mMainWindow, &mEngine, mCameraDocumentLoader, mKeyHandler, mApplication.activityManager());
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   369
        // .. and add to main window (which also takes ownership)
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   370
        OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_10, "msg: e_CX_MAINWINDOW_ADDVIEW 1");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   371
        mMainWindow.addView(view);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   372
        mViews.insert(viewName, view);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   373
        OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_12, "msg: e_CX_MAINWINDOW_ADDVIEW 0");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   374
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   375
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   376
    OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_OUT, "msg: e_CX_CREATE_VIEW 0");
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
    CX_DEBUG_EXIT_FUNCTION();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   379
    return view;
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   382
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   383
* CxuiViewManager::showScenesView
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   384
* A private method for displaying Scene Modes selection view
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   385
*/
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   386
void CxuiViewManager::showScenesView()
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   387
{
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   388
    CX_DEBUG_ENTER_FUNCTION();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   389
    // Disconnect signals from old view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   390
    disconnectSignals();
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   391
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   392
    CxuiSceneModeView *view = qobject_cast<CxuiSceneModeView*>(createView(SCENE_MODE_VIEW));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   393
    CX_ASSERT_ALWAYS(view);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   394
    view->loadBackgroundImages();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   396
    stopStandbyTimer();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   397
    connectSceneModeSignals();
45
hgs
parents: 43
diff changeset
   398
    mMainWindow.setCurrentView(view, false);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   403
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   404
* Get the precapture view appropriate for given camera mode and index.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   405
* If the view does not exist, it is created.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   406
* @param mode Which camera mode the view should match.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   407
* @param index Which camera index the view should match.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   408
*/
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
CxuiPrecaptureView*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
CxuiViewManager::getPrecaptureView(Cxe::CameraMode mode, Cxe::CameraIndex camera)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
    CX_DEBUG_ENTER_FUNCTION();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   413
    CX_DEBUG(("CxuiViewManager::getPrecaptureView - mode=%d, camera index=%d", mode, camera));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   415
    CX_DEBUG_ASSERT(camera == Cxe::PrimaryCameraIndex);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
    if (mode == ImageMode) {
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   418
        CX_DEBUG(("CxuiViewManager::getPrecaptureView - image mode"));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   419
        return qobject_cast<CxuiPrecaptureView*>(createView(STILL_PRE_CAPTURE_VIEW));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   420
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
    } else {
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   422
        CX_DEBUG(("CxuiViewManager::getPrecaptureView - video mode"));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   423
        return qobject_cast<CxuiPrecaptureView*>(createView(VIDEO_PRE_CAPTURE_VIEW));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   427
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   428
* Move to post-capture view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   429
*/
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
void CxuiViewManager::changeToPostcaptureView()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
    CX_DEBUG_ENTER_FUNCTION();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   433
    // Disconnect signals from old view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   434
    disconnectSignals();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   436
    CxuiView *postCaptureView = createView(POSTCAPTURE_VIEW);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   437
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   438
    // Connecting all necessary signals for postcapture view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   439
    // Not connected yet if not in normal state. We connect the signals
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   440
    // once we enter normal state again.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   441
    if (mApplicationState->currentState() == CxuiApplicationState::Normal) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   442
        connectPostCaptureSignals();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   443
    }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
45
hgs
parents: 43
diff changeset
   445
    // Connect signals before we set the post-capture view as current view.
hgs
parents: 43
diff changeset
   446
    // We need to have signals connected if post-capture view for example
hgs
parents: 43
diff changeset
   447
    // needs to move back to pre-capture view already in showEvent.
hgs
parents: 43
diff changeset
   448
    mMainWindow.setCurrentView(postCaptureView, false);
hgs
parents: 43
diff changeset
   449
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   453
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   454
* Move to pre-capture view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   455
*/
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
void CxuiViewManager::changeToPrecaptureView()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
    if (CxuiServiceProvider::isCameraEmbedded()) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
        // disconnect signals, we only want to call this once after the initial prepare
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
        disconnect(&mEngine.stillCaptureControl(), SIGNAL(imagePrepareComplete(CxeError::Id)),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
                this, SLOT(changeToPrecaptureView()));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
        disconnect(&mEngine.videoCaptureControl(), SIGNAL(videoPrepareComplete(CxeError::Id)),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
                this, SLOT(changeToPrecaptureView()));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   468
    // If normal mode is not active, don't switch to precapture view and reserve camera now.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   469
    if (mApplicationState->currentState() != CxuiApplicationState::Normal) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   470
        CX_DEBUG(("CxuiViewManager - Change to precapture blocked as not normal mode (error, standby, background)."));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   471
    } else {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   472
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   473
        // Disconnect signals from old view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   474
        disconnectSignals();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   475
45
hgs
parents: 43
diff changeset
   476
        CxuiPrecaptureView *view =
hgs
parents: 43
diff changeset
   477
            getPrecaptureView(mEngine.mode(), mEngine.cameraDeviceControl().cameraIndex());
hgs
parents: 43
diff changeset
   478
hgs
parents: 43
diff changeset
   479
        // Connect necessary pre-capture view signals.
hgs
parents: 43
diff changeset
   480
        connectPreCaptureSignals(view);
hgs
parents: 43
diff changeset
   481
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   482
        mMainWindow.setCurrentView(view, false);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   484
        // Release resources needed by scene view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   485
        HbView *sceneView = mViews.take(SCENE_MODE_VIEW);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   486
        if (sceneView) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   487
            // This will not delete the view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   488
            mMainWindow.removeView(sceneView);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   489
            // We can get to this slot from scene view, so don't delete the object too early.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   490
            sceneView->deleteLater();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   491
            sceneView = NULL;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   492
        }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   494
        // Make sure engine prepares for new image/video if necessary
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   495
        mEngine.initMode(mEngine.mode());
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   496
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   497
        startStandbyTimer();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   498
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   499
    }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   503
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   504
* Switch between cameras.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   505
*/
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
void CxuiViewManager::switchCamera()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
    Cxe::CameraIndex nextCamera;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
    Qt::Orientation nextViewOrientation;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
    if (mEngine.cameraDeviceControl().cameraIndex() == Cxe::PrimaryCameraIndex) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
        nextCamera = Cxe::SecondaryCameraIndex;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
        nextViewOrientation = Qt::Vertical;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
    } else {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
        nextCamera = Cxe::PrimaryCameraIndex;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
        nextViewOrientation = Qt::Horizontal;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
    CxuiPrecaptureView* view = getPrecaptureView(mEngine.mode(), nextCamera);
45
hgs
parents: 43
diff changeset
   522
    connectPreCaptureSignals(view);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
    mMainWindow.setCurrentView(view, false);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
    view->updateOrientation(nextViewOrientation);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
    mEngine.cameraDeviceControl().switchCamera(nextCamera);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   531
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   532
* Event filter function.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   533
* Used to get mouse and key events for standby and capture key handling.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   534
* @param object Target object.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   535
* @param event Event to be checked.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   536
*/
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
bool CxuiViewManager::eventFilter(QObject *object, QEvent *event)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
{
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   539
    Q_UNUSED(object)
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   540
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
    bool eventWasConsumed = false;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   542
    bool userActivity = false;
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   544
    switch (event->type()) {
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
    case QEvent::KeyPress:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
    case QEvent::KeyRelease:
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   547
        userActivity = true;
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   548
        eventWasConsumed = mKeyHandler->handleKeyEvent(event);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   549
        if (eventWasConsumed && mApplicationState->currentState() == CxuiApplicationState::Standby) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   550
            // Queued exit from standby.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   551
            emit standbyExitRequested();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   552
        }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   553
        break;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   554
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   555
    case QEvent::GraphicsSceneMouseMove:
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   556
    case QEvent::GraphicsSceneMousePress:
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   557
        userActivity = true;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   558
        break;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   559
    case QEvent::GraphicsSceneMouseRelease:
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   560
        userActivity = true;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   561
        if (mApplicationState->currentState() == CxuiApplicationState::Standby) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   562
            // Queued exit from standby.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   563
            // Standby popup in view can receive mouse event before it is dismissed.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   564
            emit standbyExitRequested();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   565
        }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
        break;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
    }
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   568
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   569
    // Restart standby timer if there is user activity.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   570
    // Only restart the timer if it is running, do not set it running here.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   571
    if (userActivity && mStandbyTimer.isActive()) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   572
        startStandbyTimer();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   573
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   574
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
    // No need to call base class implementation, because we derive from QObject directly.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
    // QObject::eventFilter() implementation always returns false.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
    return eventWasConsumed;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   580
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   581
* Connect signals specific to given view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   582
*/
45
hgs
parents: 43
diff changeset
   583
void CxuiViewManager::connectSignals(CxuiView *view)
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   584
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   585
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   586
    OstTrace0(camerax_performance, CXUIVIEWMANAGER_CONNECTSIGNALS_1, "msg: e_CX_VIEWMANAGER_CONNECT_SIGNALS 1");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   587
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   588
    if (view) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   589
        if (view == mViews[POSTCAPTURE_VIEW]) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   590
            connectPostCaptureSignals();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   591
        } else if (view == mViews[SCENE_MODE_VIEW]) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   592
            connectSceneModeSignals();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   593
        } else {
45
hgs
parents: 43
diff changeset
   594
            connectPreCaptureSignals(static_cast<CxuiPrecaptureView *>(view));
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   595
        }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   596
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   597
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   598
    OstTrace0(camerax_performance, CXUIVIEWMANAGER_CONNECTSIGNALS_2, "msg: e_CX_VIEWMANAGER_CONNECT_SIGNALS 0");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   599
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   600
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   601
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   602
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   603
* Disconnect signals.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   604
* We don't want to send or receive signals with inactive views, so this is done every time changing a view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   605
* @param view View object from which signals are disconnected. If NULL is given, current view is used.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   606
*/
45
hgs
parents: 43
diff changeset
   607
void CxuiViewManager::disconnectSignals(CxuiView *view)
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   608
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   609
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   610
    OstTrace0(camerax_performance, CXUIVIEWMANAGER_DISCONNECT_1, "msg: e_CX_VIEWMANAGER_DISCONNECT_SIGNALS 1");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   611
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   612
    // Disconnect all existing capture key signals
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   613
    mKeyHandler->disconnect();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   614
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   615
    if (!view) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   616
        // If view is not given, take current view.
45
hgs
parents: 43
diff changeset
   617
        view = currentView();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   618
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   619
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   620
    CX_DEBUG(("CxuiViewManager - disconnecting from view %d", view));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   621
    if (view) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   622
        // Disconnect all signals from current view to us.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   623
        disconnect(view, 0, this, 0);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   624
        // Disconnect all signals from us to current view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   625
        disconnect(this, 0, view, 0);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   626
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   627
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   628
    OstTrace0(camerax_performance, CXUIVIEWMANAGER_DISCONNECT_2, "msg: e_CX_VIEWMANAGER_DISCONNECT_SIGNALS 0");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   629
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   630
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   631
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   632
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   633
* Connect signals to pre-capture view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   634
*/
45
hgs
parents: 43
diff changeset
   635
void CxuiViewManager::connectPreCaptureSignals(CxuiPrecaptureView *view)
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   636
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   637
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   638
45
hgs
parents: 43
diff changeset
   639
    // Disconnect from the current, "old" view
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   640
    disconnectSignals();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   641
45
hgs
parents: 43
diff changeset
   642
    // connecting pre-capture view signals to standby timer.
hgs
parents: 43
diff changeset
   643
    connect(view, SIGNAL(startStandbyTimer()),       this, SLOT(startStandbyTimer()), Qt::UniqueConnection);
hgs
parents: 43
diff changeset
   644
    connect(view, SIGNAL(stopStandbyTimer()),        this, SLOT(stopStandbyTimer()),  Qt::UniqueConnection);
hgs
parents: 43
diff changeset
   645
    connect(view, SIGNAL(changeToPrecaptureView()),  this, SLOT(startStandbyTimer()), Qt::UniqueConnection);
hgs
parents: 43
diff changeset
   646
    connect(view, SIGNAL(changeToPostcaptureView()), this, SLOT(stopStandbyTimer()),  Qt::UniqueConnection);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   647
45
hgs
parents: 43
diff changeset
   648
    // connecting pre-capture view signals to viewmanager slots
hgs
parents: 43
diff changeset
   649
    connect(view, SIGNAL(changeToPostcaptureView()), this, SLOT(changeToPostcaptureView()), Qt::UniqueConnection);
hgs
parents: 43
diff changeset
   650
    connect(view, SIGNAL(changeToPrecaptureView()),  this, SLOT(changeToPrecaptureView()),  Qt::UniqueConnection);
hgs
parents: 43
diff changeset
   651
hgs
parents: 43
diff changeset
   652
    //connecting scene modes signal
hgs
parents: 43
diff changeset
   653
    connect(view, SIGNAL(showScenesView()), this, SLOT(showScenesView()), Qt::UniqueConnection);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   654
45
hgs
parents: 43
diff changeset
   655
    connect(view, SIGNAL(switchCamera()), this, SLOT(switchCamera()), Qt::UniqueConnection);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   656
45
hgs
parents: 43
diff changeset
   657
    // connecting error signals from precapture view to application state.
hgs
parents: 43
diff changeset
   658
    connect(view, SIGNAL(errorEncountered(CxeError::Id)),
hgs
parents: 43
diff changeset
   659
            mApplicationState, SLOT(handleApplicationError(CxeError::Id)),
hgs
parents: 43
diff changeset
   660
            Qt::UniqueConnection);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   661
45
hgs
parents: 43
diff changeset
   662
    // Standby signals
hgs
parents: 43
diff changeset
   663
    connect(this, SIGNAL(normalStateEntered()), view, SLOT(exitStandby()), Qt::UniqueConnection);
hgs
parents: 43
diff changeset
   664
    connect(this, SIGNAL(normalStateExited()), view, SLOT(enterStandby()), Qt::UniqueConnection);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   665
45
hgs
parents: 43
diff changeset
   666
    // connects all capture key signals.
hgs
parents: 43
diff changeset
   667
    connectCaptureKeySignals(view);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   668
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   669
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   670
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   671
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   672
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   673
* Connect signals to post-capture view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   674
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   675
void CxuiViewManager::connectPostCaptureSignals()
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   676
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   677
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   678
45
hgs
parents: 43
diff changeset
   679
    // Disconnect from the current, "old" view
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   680
    disconnectSignals();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   681
45
hgs
parents: 43
diff changeset
   682
    CxuiView *view = mViews[POSTCAPTURE_VIEW];
hgs
parents: 43
diff changeset
   683
    if (view) {
hgs
parents: 43
diff changeset
   684
        connect(view, SIGNAL(changeToPrecaptureView()), this, SLOT(changeToPrecaptureView()), Qt::UniqueConnection);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   685
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   686
        // Standby signals
45
hgs
parents: 43
diff changeset
   687
        connect(this, SIGNAL(normalStateEntered()), view, SLOT(exitStandby()), Qt::UniqueConnection);
hgs
parents: 43
diff changeset
   688
        connect(this, SIGNAL(normalStateExited()), view, SLOT(enterStandby()), Qt::UniqueConnection);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   689
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   690
        // connect necessary capturekey signals
45
hgs
parents: 43
diff changeset
   691
        connectCaptureKeySignals(view);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   692
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   693
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   694
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   695
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   696
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   697
* Connect signals to scene mode view.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   698
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   699
void CxuiViewManager::connectSceneModeSignals()
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   700
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   701
    CX_DEBUG_ENTER_FUNCTION();
45
hgs
parents: 43
diff changeset
   702
hgs
parents: 43
diff changeset
   703
    // Disconnect from the current, "old" view
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   704
    disconnectSignals();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   705
45
hgs
parents: 43
diff changeset
   706
    CxuiView *view = mViews[SCENE_MODE_VIEW];
hgs
parents: 43
diff changeset
   707
    if (view) {
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   708
        // Standby signals for releasing camera
45
hgs
parents: 43
diff changeset
   709
        connect(this, SIGNAL(normalStateEntered()), view, SLOT(exitStandby()));
hgs
parents: 43
diff changeset
   710
        connect(this, SIGNAL(normalStateExited()), view, SLOT(enterStandby()));
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   711
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   712
        // Moving back to pre-capture view
45
hgs
parents: 43
diff changeset
   713
        connect(view, SIGNAL(viewCloseEvent()), this, SLOT(changeToPrecaptureView()));
hgs
parents: 43
diff changeset
   714
hgs
parents: 43
diff changeset
   715
        connectCaptureKeySignals(view);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   716
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   717
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   718
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   719
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   720
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   721
* Connect key handler capture key signals.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   722
*/
45
hgs
parents: 43
diff changeset
   723
void CxuiViewManager::connectCaptureKeySignals(CxuiView *view)
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   725
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   726
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
    // Disconnect all existing capture key signals
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   728
    mKeyHandler->disconnect();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
45
hgs
parents: 43
diff changeset
   730
    if (view) {
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
        // If the view class does not implement the named slot, the connect will fail
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   732
        // and output some warnings as debug prints. This is by design.
45
hgs
parents: 43
diff changeset
   733
        connect(mKeyHandler, SIGNAL(autofocusKeyPressed()),  view, SLOT(handleAutofocusKeyPressed()));
hgs
parents: 43
diff changeset
   734
        connect(mKeyHandler, SIGNAL(autofocusKeyReleased()), view, SLOT(handleAutofocusKeyReleased()));
hgs
parents: 43
diff changeset
   735
        connect(mKeyHandler, SIGNAL(captureKeyPressed()),    view, SLOT(handleCaptureKeyPressed()));
hgs
parents: 43
diff changeset
   736
        connect(mKeyHandler, SIGNAL(captureKeyReleased()),   view, SLOT(handleCaptureKeyReleased()));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   740
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   741
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   742
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   743
 * Clears all camera activities from activity manager.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   744
 */
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   745
void CxuiViewManager::clearAllActivities()
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
{
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   747
    HbActivityManager *activityManager = mApplication.activityManager();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   748
    activityManager->removeActivity(CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   749
    activityManager->removeActivity(CxuiActivityIds::STILL_POSTCAPTURE_ACTIVITY);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   750
    activityManager->removeActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   751
    activityManager->removeActivity(CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   752
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   754
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   755
* Raise application to foreground if it's currently (fully) in background.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   756
*/
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   757
void CxuiViewManager::toForeground()
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   758
{
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   759
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   760
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   761
    if (mApplicationState->currentState() == CxuiApplicationState::Background) {
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   762
        // Bring to foreground and gain focus.
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   763
        CX_DEBUG(("CxuiViewManager - in background, bringing to foreground now."));
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   764
        mMainWindow.raise();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   765
        mMainWindow.activateWindow();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   766
    }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   767
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   768
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   769
}
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   770
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
// end of file