Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

在QML中如何监听拍照快捷键

From Wiki
Jump to: navigation, search

Delete instructional text in italic

This article explains how to ... Replace the abstract text with a short paragraph (or sentence) describing what the topic covers.

Enter article metadata as described below. Note that this template can be placed anywhere in the article. Do not remove parameters that you do not use

Article Metadata

代码示例
文章
liuting 在 14 Jun 2012 创建
最后由 hamishwillee 在 02 Jul 2012 编辑

Contents

介绍

本文介绍如何在QML 中监听系统拍照快捷键

代码实现

Symbian实现部分

RWindowGroup::CaptureKey() API in order to capture the key pressed event of the camera key, as in line #73 of the code snippet below. 我们需要调用Symbian API RWindowGroup::CaptureKey() 去捕获拍照快捷键,代码实现如下:

    RWsSession &wsSession = CCoeEnv::Static()->WsSession();
TUint wGroupHandle = wsSession.GetWindowGroupHandle(wGroupId);
if (wGroupHandle) {
RWindowGroup wGroup(wsSession);
wGroup.Construct(wGroupHandle);
TBool captureOK = ETrue;
captureOK = captureOK && (wGroup.CaptureKey(EKeyCamera, 0, 0, 100) > 0);
if (!captureOK)
qWarning("Unable to register for camera capture key events, SwEvent capability may be missing");
}

需要强调一点的是,在Nokia bella 系统上照相机应用程序是通过 camera key down事件启动,所以仅仅捕获 key pressed 事件是不够的,我们还要调用RWindowGroup::CaptureKeyUpAndDowns(),代码实现如下:

RWsSession &wsSession = CCoeEnv::Static()->WsSession();
TUint wGroupHandle = wsSession.GetWindowGroupHandle(wGroupId);
if (wGroupHandle) {
RWindowGroup wGroup(wsSession);
wGroup.Construct(wGroupHandle);
TBool captureOK = ETrue;
captureOK = captureOK && (wGroup.CaptureKey(EKeyCamera, 0, 0, 100) > 0);
captureOK = captureOK && (wGroup.CaptureKeyUpAndDowns(EStdKeyDevice7, 0, 0, 100) > 0);
if (!captureOK)
qWarning("Unable to register for camera capture key events")

QML 实现部分

Keys.onPressed : {
//return to capture mode if the shutter button is touched
 
if (event.key == Qt.Key_CameraFocus && !event.isAutoRepeat) {
cameraUI.state = "PhotoCapture"
event.accepted = true;
}
}

总结

以上代码均是在 Qt mobility 自带例程 的基础上进行修改

代码下载

File:Declarative-camera.zip

相关链接


Add categories below. Remove Category:Draft when the page is complete or near complete

This page was last modified on 2 July 2012, at 01:14.
287 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×