Skip to content

Commit

Permalink
addition of qdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeHoarder committed Jan 17, 2013
1 parent 10074d0 commit 6a5392e
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 9 deletions.
2 changes: 2 additions & 0 deletions barcodeinvoker/assets/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Page {
title: qsTr("Barcode Invoker")
appearance: TitleBarAppearance.Branded
}
//! [0]
Container {
layout: DockLayout {
}
Expand Down Expand Up @@ -50,4 +51,5 @@ Page {
textStyle.color: Color.White
}
}
//! [0]
}
6 changes: 4 additions & 2 deletions barcodeinvoker/src/BarcodeInvoker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
#include <QtCore/QtDebug>

using namespace bb::system;

//! [0]
BarcodeInvoker::BarcodeInvoker(QObject* obj)
: QObject(obj)
{
QObject::connect(new InvokeManager(this),
SIGNAL(childCardDone(const bb::system::CardDoneMessage&)), this,
SLOT(onChildCardDone(const bb::system::CardDoneMessage&)));
}

//! [0]
//! [1]
void BarcodeInvoker::onInvokeButtonClicked() const
{
InvokeManager* imanager = qobject_cast<InvokeManager*>(sender());
Expand Down Expand Up @@ -59,3 +60,4 @@ void BarcodeInvoker::setBarcode(const QString &barcode)
m_barcode = barcode;
Q_EMIT barcodeChanged();
}
//! [1]
5 changes: 4 additions & 1 deletion barcodescanner/assets/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ NavigationPane {
Container {
layout: DockLayout {
}

//! [0]
Container {
horizontalAlignment: HorizontalAlignment.Left
verticalAlignment: VerticalAlignment.Top
Expand All @@ -37,6 +37,8 @@ NavigationPane {
}
}
}
//! [0]
//! [1]
Container {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Bottom
Expand All @@ -49,6 +51,7 @@ NavigationPane {
textStyle.color: Color.White
}
}
//! [1]
}
}
}
12 changes: 8 additions & 4 deletions barcodescanner/src/BarcodeDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using namespace bb::cascades;
using namespace bb::cascades::multimedia;
using namespace bb::community::barcode;
using namespace zxing;

//! [0]
BarcodeDecoderControl::BarcodeDecoderControl(Container *parent) :
CustomControl(parent),
m_camera(new Camera(parent)),
Expand Down Expand Up @@ -77,7 +77,8 @@ BarcodeDecoderControl::BarcodeDecoderControl(Container *parent) :
hints->addFormat(BarcodeFormat_AZTEC);
m_reader.object_->setHints(*hints);
}

//! [0]
//! [1]
void BarcodeDecoderControl::onPreviewFrameAvailable(
SharedUCharPointer previewBuffer, quint64 size, unsigned int width,
unsigned int height, unsigned int stride) {
Expand Down Expand Up @@ -110,7 +111,8 @@ void BarcodeDecoderControl::onPreviewFrameAvailable(
}
m_camera->addPreviewBuffer(previewBuffer, size);
}

//! [1]
//! [2]
void BarcodeDecoderControl::onCameraOpened() {
quint64 bufferSize = m_camera->previewBufferSize();
//Use two buffers for double buffering goodness.
Expand All @@ -131,7 +133,8 @@ void BarcodeDecoderControl::onCameraOpened() {

m_camera->startViewfinder();
}

//! [2]
//! [3]
void BarcodeDecoderControl::startScanning() const {
m_camera->startViewfinder();
}
Expand All @@ -143,3 +146,4 @@ void BarcodeDecoderControl::stopScanning() const {
void BarcodeDecoderControl::onViewfinderStopped() {
m_barcodeData.clear();
}
//! [3]
6 changes: 4 additions & 2 deletions barcodescanner/src/BarcodeScannerApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

using namespace bb::multimedia;
using namespace bb::system;

//! [0]
BarcodeScannerApp::BarcodeScannerApp(QObject* parent)
: QObject(parent),
m_player(new MediaPlayer(this))
Expand Down Expand Up @@ -60,7 +60,8 @@ BarcodeScannerApp::BarcodeScannerApp(QObject* parent)

qDebug() << "+++++++++ Application invoked: " << m_invoked << endl;
}

//! [0]
//! [1]
void BarcodeScannerApp::newBarcodeDetected(const QString &barcode) {
m_player->play();

Expand All @@ -83,3 +84,4 @@ void BarcodeScannerApp::onInvoked(const bb::system::InvokeRequest&) {
Q_EMIT startScan();
}
}
//! [1]
61 changes: 61 additions & 0 deletions docs/barcodeinvoker.qdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion Limited.
** All rights reserved.
** Contact: Research In Motion Ltd. (http://www.rim.com/company/contact/)
**
** This file is part of the examples of the BB10 Platform.
**
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Research In Motion Limited.
**
****************************************************************************/

/*!
\page barcodeinvoker
\example barcodeinvoker
\title Barcode Invoker Example

\section1 Description

The Barcode Invoker example allows the user to scan barcodes via a Card through the
\c InvokeManager by issuing scan requests.

\image barcodeinvoker-example.png
\image barcodeinvoker-example1.png

\section1 Overview
In this example we'll learn how to use the \c InvokeManager class to issue barcode scanning requests
to the BarcodeScanner Card and retrieve the decoded barcode data from the Card.

\section1 The UI
The simplistic UI of this sample application consists of a \c Button to issue requests, and a \c Label
to display the request results.

\snippet barcodeinvoker/assets/main.qml 0

When the \c Button is clicked, the request is sent and the barcodescanner card is invoked and transitions over
the parent to begin barcode scanning. Once the barcode is read and decoded, the card sends a cardDone() signal to
the requesting parent, transitions off screen and is pooled to await subsequent invokation requests. The Label's
text property is bound to the BarcodeInvoker barcode property, which gets updated when barcodeChanged() signal
is emited.

\snippet barcodeinvoker/src/BarcodeInvoker.cpp 0

Constructor initializes \c InvokeManager and hooks into the signal/slot mechanism to receive childCardDone() signals
from the invoked Card.

\snippet barcodeinvoker/src/BarcodeInvoker.cpp 1

The onInvokeButtonClicked() method creates \c InvokeRequest and invokes the request via \c InvokeManager. Once the card
finishes processing the onChildCardDone() is invoked and sets the barcode textual data from the result, which than emits
a barcodeChanged() signal via the setBarcode() method for the QML to update the \c Label's text property.
*/
90 changes: 90 additions & 0 deletions docs/barcodescanner.qdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion Limited.
** All rights reserved.
** Contact: Research In Motion Ltd. (http://www.rim.com/company/contact/)
**
** This file is part of the examples of the BB10 Platform.
**
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Research In Motion Limited.
**
****************************************************************************/

/*!
\page barcodescanner
\example barcodescanner
\title Barcode Scanner Example

\section1 Description

The Barcode Scanner example allows the user to scan a QR Code with the camera and
view the decoded textual representation.

\image barcodescanner-example.png
\image barcodescanner-example1.png

\section1 Overview
In this example we'll learn how to use the \c Camera and the build in ZXing barcode decoding
library to scan a QR code and decode it.

\section1 The UI
The UI of this sample application consists of the custom \c Camera control and a \c Label, which shows
a preview of the current camera viewport and uses the \c Label to display decoded barcode data.

\snippet barcodescanner/assets/main.qml 0

The BarcodeDecoder custom control shows the video stream that is currently provided by the camera viewport.
It configures and opens the \c Camera upon its creation.

\snippet barcodescanner/assets/main.qml 1

This \c Label is used to display the required action and the resulting decoded barcode data after a successful
barcode scan has been performed.

\snippet barcodescanner/src/BarcodeDecoder.cpp 0

The constructor initializes the member variables. It creates and configures the \c Camera using \c CameraSettings and connects
its methods to the signals/slots mechanism. It initializes the reader for decoding barcodes from an image, and invokes
open() on the \c Camera.

If the open() call was successful, the cameraOpened() signal is emitted, which we react to in the cameraOpened()
signal handler.

\snippet barcodescanner/src/BarcodeDecoder.cpp 1

This method is invoked when a preview frame buffer is available with data. Using ZXing classes to convert the buffer into
a BinaryBitmap, which in turn is used with the reader to decode the barcode and save the results. After barcode decoding is
successful, it emits the newBarcodeDetected() signal with the textual data as parameter.

\snippet barcodescanner/src/BarcodeDecoder.cpp 2

This method is invoked when the \c Camera is opened. It adds unsigned char buffers to store the data from the preview frame
and connects to the signal/slots mechanism to recieve previewFrameAvailable() signals. Before the method returns it starts
the view finder, which begins streaming preview frames upon its success and emits previewFrameAvailable() signals.

\snippet barcodescanner/src/BarcodeDecoder.cpp 3

These are control methods to start/stop view finder streaming and clearing of the barcode data variable.

\snippet barcodescanner/src/BarcodeScannerApp.cpp 0

The constructor initializes various member variables. It creates a \c MediaPlayer for playing sounds upon barcode detection and
intializes a \c InvokeManager to deal with invoke requests when the sample is launched as a card by the "barcodeinvoker" sample.
Here it distinguishes how it was launched and sets the appropriate member variables to dictate its behaviour as an application
or as a card.

\snippet barcodescanner/src/BarcodeScannerApp.cpp 1

This method is invoked when a newBarcodeDetected() signal is received from the BarcodeDecoder class. It plays a sound upon receiving
the data. If the sample was launched as a Card, a \c CardDoneMessage is generated and sent as response to the parent of this Card.
Once the card is done, it transitions off screen and is pooled (ready to be invoked again) at which time it fires a cardPooled() signal.
*/
Binary file added docs/images/barcodeinvoker-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/barcodeinvoker-example1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/barcodescanner-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/barcodescanner-example1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6a5392e

Please sign in to comment.