33 #include "cxestillcapturecontrol.h" |
34 #include "cxestillcapturecontrol.h" |
34 #include "cxevideocapturecontrol.h" |
35 #include "cxevideocapturecontrol.h" |
35 |
36 |
36 |
37 |
37 |
38 |
38 /* |
39 /*! |
39 * CxuiStandby::CxuiStandby |
40 * Constructor |
40 */ |
41 */ |
41 CxuiStandby::CxuiStandby(CxuiCaptureKeyHandler &keyHandler,CxuiDocumentLoader *documentLoader, CxeEngine *engine) |
42 CxuiStandby::CxuiStandby(CxuiCaptureKeyHandler &keyHandler,CxuiDocumentLoader *documentLoader, CxeEngine *engine) |
42 : mKeyHandler(keyHandler), |
43 : mKeyHandler(keyHandler), |
43 mDocumentLoader(documentLoader), |
44 mDocumentLoader(documentLoader), |
44 mEngine(engine), |
45 mEngine(engine), |
45 mStandbyPopup(NULL), |
46 mStandbyPopup(NULL), |
46 mStandbyDialogVisible(false) |
47 mStandbyDialogVisible(false), |
|
48 mAllowDismiss(true) |
47 { |
49 { |
48 CX_DEBUG_ENTER_FUNCTION(); |
50 CX_DEBUG_ENTER_FUNCTION(); |
49 CX_ASSERT_ALWAYS(engine); |
51 CX_ASSERT_ALWAYS(engine); |
50 |
52 |
51 // initialize standby timer |
53 // initialize standby timer |
53 |
55 |
54 // install event filter for application wide events |
56 // install event filter for application wide events |
55 QCoreApplication::instance()->installEventFilter(this); |
57 QCoreApplication::instance()->installEventFilter(this); |
56 |
58 |
57 CX_ASSERT_ALWAYS(mStandbyTimer); |
59 CX_ASSERT_ALWAYS(mStandbyTimer); |
58 connect(mStandbyTimer, SIGNAL(timeout()), this, SLOT(toStandby())); |
60 connect(mStandbyTimer, SIGNAL(timeout()), this, SLOT(enterStandby())); |
59 mStandbyTimer->setSingleShot(true); |
61 mStandbyTimer->setSingleShot(true); |
60 |
62 |
61 CX_DEBUG_EXIT_FUNCTION(); |
63 CX_DEBUG_EXIT_FUNCTION(); |
62 } |
64 } |
63 |
65 |
64 |
66 |
65 |
67 |
66 /* |
68 /*! |
67 * CxuiStandby::~CxuiStandby() |
69 * Destructor |
68 */ |
70 */ |
69 CxuiStandby::~CxuiStandby() |
71 CxuiStandby::~CxuiStandby() |
70 { |
72 { |
71 CX_DEBUG_IN_FUNCTION(); |
73 CX_DEBUG_IN_FUNCTION(); |
72 // remove the event filter |
74 // remove the event filter |
73 QCoreApplication::instance()->removeEventFilter(this); |
75 QCoreApplication::instance()->removeEventFilter(this); |
74 // stop standby timer |
76 // stop standby timer |
75 stopTimer(); |
77 stopTimer(); |
76 } |
78 } |
77 |
79 |
78 |
80 |
79 /* |
81 /*! |
80 * stops standby timer |
82 * Allow dismissing standby mode with AF or capture key? |
|
83 * @param allow Is dismissing allowed. |
81 */ |
84 */ |
|
85 void CxuiStandby::allowDismiss(bool allow) |
|
86 { |
|
87 CX_DEBUG_ENTER_FUNCTION(); |
|
88 mAllowDismiss = allow; |
|
89 if (allow) { |
|
90 if (mStandbyDialogVisible) { |
|
91 // Reconnect the close signals if dialog is visible |
|
92 connect(&mKeyHandler, SIGNAL(autofocusKeyPressed()), mStandbyPopup, SLOT(close()), Qt::UniqueConnection); |
|
93 connect(&mKeyHandler, SIGNAL(captureKeyPressed()), mStandbyPopup, SLOT(close()), Qt::UniqueConnection); |
|
94 } |
|
95 } else { |
|
96 disconnect(&mKeyHandler, SIGNAL(autofocusKeyPressed()), mStandbyPopup, SLOT(close())); |
|
97 disconnect(&mKeyHandler, SIGNAL(captureKeyPressed()), mStandbyPopup, SLOT(close())); |
|
98 } |
|
99 |
|
100 CX_DEBUG_EXIT_FUNCTION(); |
|
101 } |
|
102 |
|
103 |
|
104 /*! |
|
105 * Is standby mode active? |
|
106 * @return True, if standby mode is active, false if not. |
|
107 */ |
|
108 bool CxuiStandby::isActive() const |
|
109 { |
|
110 return mStandbyDialogVisible; |
|
111 } |
|
112 |
|
113 /*! |
|
114 * stops standby timer |
|
115 */ |
82 void CxuiStandby::stopTimer() |
116 void CxuiStandby::stopTimer() |
83 { |
117 { |
84 if(mStandbyTimer) { |
118 if(mStandbyTimer) { |
85 mStandbyTimer->stop(); |
119 mStandbyTimer->stop(); |
86 } |
120 } |
87 } |
121 } |
88 |
122 |
89 /* |
123 /*! |
90 * starts standby timer |
124 * starts standby timer |
91 */ |
125 */ |
92 void CxuiStandby::startTimer() |
126 void CxuiStandby::startTimer() |
93 { |
127 { |
94 if(mStandbyTimer) { |
128 if(mStandbyTimer) { |
95 mStandbyTimer->start(CXUI_STANDBY_CAMERA_TIMEOUT); |
129 mStandbyTimer->start(CXUI_STANDBY_CAMERA_TIMEOUT); |
96 } |
130 } |
97 } |
131 } |
98 |
132 |
99 |
133 /*! |
100 /* |
134 * Handles mouse press events |
101 * handles mouse press events |
135 * returns if mouse key press is consumed. |
102 * returns if mouse key press is consumed. |
136 * \param event event to be handled |
103 */ |
137 * \return boolean to indicate whether the event was handled or not |
104 bool CxuiStandby::handleMouseEvent() |
138 */ |
|
139 bool CxuiStandby::handleMouseEvent(QEvent *event) |
105 { |
140 { |
106 bool keyHandled = false; |
141 bool keyHandled = false; |
107 |
142 |
108 // close the dialog if it's visible |
143 // close the dialog if it's visible |
109 if (mStandbyDialogVisible && mStandbyPopup) { |
144 if (mStandbyDialogVisible && mStandbyPopup) { |
110 CX_DEBUG(( "closing the popup mStandbyDialogVisible = : %d", mStandbyDialogVisible )); |
145 HbInstantFeedback feedback(HbFeedback::BasicItem); |
111 mStandbyPopup->close(); |
146 switch (event->type()) { |
|
147 case QEvent::GraphicsSceneMousePress: |
|
148 feedback.play(); |
|
149 break; |
|
150 case QEvent::GraphicsSceneMouseRelease: |
|
151 if (mAllowDismiss) { |
|
152 CX_DEBUG(( "closing the popup mStandbyDialogVisible = : %d", mStandbyDialogVisible )); |
|
153 // todo: sound disabling doesn't work in orbit yet so don't do feedback on release |
|
154 // needs to be enabled when orbit support is done |
|
155 //feedback.setModalities(HbFeedback::Tactile); |
|
156 //feedback.play(); |
|
157 exitStandby(); |
|
158 } |
|
159 break; |
|
160 default: |
|
161 break; |
|
162 } |
|
163 // eat all mouse events when standby is active |
112 keyHandled = true; |
164 keyHandled = true; |
113 } else if (mStandbyTimer && mStandbyTimer->isActive()) { |
165 } else if (mStandbyTimer && mStandbyTimer->isActive()) { |
114 // restart the timer only if it's running |
166 // restart the timer only if it's running |
115 startTimer(); |
167 startTimer(); |
116 } |
168 } |
117 |
169 |
118 return keyHandled; |
170 return keyHandled; |
119 } |
171 } |
120 |
172 |
121 |
173 |
122 /* |
174 /*! |
123 * switching to standby. |
175 * switching to standby. |
124 */ |
176 */ |
125 void CxuiStandby::toStandby() |
177 void CxuiStandby::enterStandby() |
126 { |
178 { |
127 CX_DEBUG_ENTER_FUNCTION(); |
179 CX_DEBUG_ENTER_FUNCTION(); |
128 |
180 |
129 if (proceedToStandy()) { |
181 if (proceedToStandy()) { |
130 |
182 |
163 |
215 |
164 CX_ASSERT_ALWAYS(mStandbyPopup); |
216 CX_ASSERT_ALWAYS(mStandbyPopup); |
165 |
217 |
166 mStandbyPopup->show(); |
218 mStandbyPopup->show(); |
167 // connecting half press or full press key signal to dismiss standby |
219 // connecting half press or full press key signal to dismiss standby |
168 connect(&mKeyHandler, SIGNAL(autofocusKeyPressed()), mStandbyPopup, SLOT(close())); |
220 connect(&mKeyHandler, SIGNAL(autofocusKeyPressed()), mStandbyPopup, SLOT(close()), Qt::UniqueConnection); |
169 connect(&mKeyHandler, SIGNAL(captureKeyPressed()), mStandbyPopup, SLOT(close())); |
221 connect(&mKeyHandler, SIGNAL(captureKeyPressed()), mStandbyPopup, SLOT(close()), Qt::UniqueConnection); |
170 } |
222 } |
171 |
223 |
172 CX_DEBUG_EXIT_FUNCTION(); |
224 CX_DEBUG_EXIT_FUNCTION(); |
173 } |
225 } |
174 |
226 |
175 |
227 /*! |
176 /* |
228 * Close the standby dialog. |
177 * dismisses standby |
|
178 */ |
229 */ |
|
230 void CxuiStandby::exitStandby() |
|
231 { |
|
232 CX_DEBUG_ENTER_FUNCTION(); |
|
233 |
|
234 if (mAllowDismiss && mStandbyDialogVisible && mStandbyPopup) { |
|
235 mStandbyPopup->close(); |
|
236 } |
|
237 |
|
238 CX_DEBUG_EXIT_FUNCTION(); |
|
239 } |
|
240 |
|
241 |
|
242 /*! |
|
243 * dismisses standby |
|
244 */ |
179 void CxuiStandby::dismissStandby() |
245 void CxuiStandby::dismissStandby() |
180 { |
246 { |
181 CX_DEBUG_ENTER_FUNCTION(); |
247 CX_DEBUG_ENTER_FUNCTION(); |
182 |
248 |
183 if(mStandbyDialogVisible) { |
249 if(mStandbyDialogVisible) { |