45
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <HbMainWindow>
|
|
19 |
#include <HbView>
|
|
20 |
#include <HbLabel>
|
|
21 |
#include <QGraphicsLinearLayout>
|
|
22 |
#include "cxeviewfindercontroldesktop.h"
|
|
23 |
#include "cxecameradevicedesktop.h"
|
|
24 |
#include "cxeviewfinderwidgetdesktop.h"
|
|
25 |
#include "cxutils.h"
|
|
26 |
|
|
27 |
const int KResWidth = 640;
|
|
28 |
const int KResHeight = 360;
|
|
29 |
|
|
30 |
CxeViewfinderControlDesktop::CxeViewfinderControlDesktop(CxeCameraDeviceDesktop &cameraDevice) :
|
|
31 |
mState(Uninitialized),
|
|
32 |
mResolution(KResWidth, KResHeight),
|
|
33 |
mCameraDevice(cameraDevice),
|
|
34 |
mViewfinderWidget(0)
|
|
35 |
{
|
|
36 |
CX_DEBUG_IN_FUNCTION();
|
|
37 |
}
|
|
38 |
|
|
39 |
CxeViewfinderControlDesktop::~CxeViewfinderControlDesktop()
|
|
40 |
{
|
|
41 |
CX_DEBUG_IN_FUNCTION();
|
|
42 |
}
|
|
43 |
|
|
44 |
/*!
|
|
45 |
* Set Window ID
|
|
46 |
*/
|
|
47 |
void CxeViewfinderControlDesktop::setWindow(WId windowId)
|
|
48 |
{
|
|
49 |
CX_DEBUG_ENTER_FUNCTION();
|
|
50 |
mWindowId = windowId;
|
|
51 |
|
|
52 |
if (state() != Running) {
|
|
53 |
mState = Ready;
|
|
54 |
emit stateChanged(mState, CxeError::None);
|
|
55 |
CX_DEBUG_EXIT_FUNCTION();
|
|
56 |
}
|
|
57 |
|
|
58 |
|
|
59 |
HbMainWindow* mainWindow = qobject_cast<HbMainWindow*>(QWidget::find(mWindowId));
|
|
60 |
|
|
61 |
if (mainWindow) {
|
|
62 |
if( !mViewfinderWidget) {
|
|
63 |
mViewfinderWidget = new CxeViewfinderWidgetDesktop();
|
|
64 |
connect(&mCameraDevice, SIGNAL(imageChanged(QPixmap)), mViewfinderWidget, SLOT(handleImageChange(QPixmap)));
|
|
65 |
}
|
|
66 |
HbView* view = mainWindow->currentView();
|
|
67 |
view->scene()->addItem(mViewfinderWidget);
|
|
68 |
mViewfinderWidget->setZValue(-1.0);
|
|
69 |
}
|
|
70 |
}
|
|
71 |
|
|
72 |
/*!
|
|
73 |
* Start viewfinder
|
|
74 |
* @return CxeEngine specific error code
|
|
75 |
*/
|
|
76 |
CxeError::Id CxeViewfinderControlDesktop::start()
|
|
77 |
{
|
|
78 |
CX_DEBUG_ENTER_FUNCTION();
|
|
79 |
if (mState != Running) {
|
|
80 |
mState = Running;
|
|
81 |
emit stateChanged(mState, CxeError::None);
|
|
82 |
mCameraDevice.start();
|
|
83 |
}
|
|
84 |
CX_DEBUG_EXIT_FUNCTION();
|
|
85 |
return CxeError::None;
|
|
86 |
}
|
|
87 |
|
|
88 |
/*!
|
|
89 |
* Stop viewfinder
|
|
90 |
*/
|
|
91 |
void CxeViewfinderControlDesktop::stop()
|
|
92 |
{
|
|
93 |
CX_DEBUG_ENTER_FUNCTION();
|
|
94 |
mState = Ready;
|
|
95 |
emit stateChanged(mState, CxeError::None);
|
|
96 |
mCameraDevice.stop();
|
|
97 |
CX_DEBUG_EXIT_FUNCTION();
|
|
98 |
}
|
|
99 |
|
|
100 |
/*!
|
|
101 |
* Current viewfinder state
|
|
102 |
*/
|
|
103 |
CxeViewfinderControl::State CxeViewfinderControlDesktop::state() const
|
|
104 |
{
|
|
105 |
return mState;
|
|
106 |
}
|
|
107 |
|
|
108 |
/*!
|
|
109 |
* Returns Device's Display resolution
|
|
110 |
*/
|
|
111 |
QSize CxeViewfinderControlDesktop::deviceDisplayResolution() const
|
|
112 |
{
|
|
113 |
return mResolution;
|
|
114 |
}
|
|
115 |
|
|
116 |
// end of file
|