Added a test app that is still in developement phase for testing barcode image files against QZXing library (ZXing decing result). Drag n Drop the barcode image to the application and it will be decoded.

This commit is contained in:
favoritas37 2013-07-28 23:11:37 +03:00
parent 7d4b3350b3
commit 231ef2f2f2
9 changed files with 746 additions and 0 deletions

View File

@ -0,0 +1,42 @@
# Add more folders to ship with the application, here
folder_01.source = qml/QZXingTestApp
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01
# Additional import path used to resolve QML modules in Creator's code model
QML_IMPORT_PATH =
symbian:TARGET.UID3 = 0xE0C1E62F
# Smart Installer package's UID
# This UID is from the protected range and therefore the package will
# fail to install if self-signed. By default qmake uses the unprotected
# range value if unprotected UID is defined for the application and
# 0x2002CCCF value if protected UID is given to the application
#symbian:DEPLOYMENT.installer_header = 0x2002CCCF
# Allow network access on Symbian
symbian:TARGET.CAPABILITY += NetworkServices
# If your application uses the Qt Mobility libraries, uncomment the following
# lines and add the respective components to the MOBILITY variable.
# CONFIG += mobility
# MOBILITY +=
# Speed up launching on MeeGo/Harmattan when using applauncherd daemon
# CONFIG += qdeclarative-boostable
# Add dependency to Symbian components
# CONFIG += qt-components
# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp \
droparea.cpp
# Please do not modify the following two lines. Required for deployment.
include(qzxing/QZXing.pri)
include(qmlapplicationviewer/qmlapplicationviewer.pri)
qtcAddDeployment()
HEADERS += \
droparea.h

View File

@ -0,0 +1,44 @@
#include "droparea.h"
#include <QGraphicsSceneDragDropEvent>
#include <QMimeData>
#include <QDebug>
DropArea::DropArea(QDeclarativeItem *parent)
: QDeclarativeItem(parent),
m_accepting(true)
{
setAcceptDrops(m_accepting);
}
void DropArea::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
event->acceptProposedAction();
setCursor(Qt::DragMoveCursor);
}
void DropArea::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
{
unsetCursor();
}
void DropArea::dropEvent(QGraphicsSceneDragDropEvent *event)
{
QList<QUrl> list = event->mimeData()->urls();
for(int i=0; i<list.size(); i++)
{
QString path = list.at(i).path();
emit fileDroped(path.right(path.size()-1));
}
unsetCursor();
}
void DropArea::setAcceptingDrops(bool accepting)
{
if (accepting == m_accepting)
return;
m_accepting = accepting;
setAcceptDrops(m_accepting);
emit acceptingDropsChanged();
}

View File

@ -0,0 +1,33 @@
#ifndef DROPAREA_H
#define DROPAREA_H
#include <QDeclarativeItem>
/**
An oversimplified prototype Item which accepts any drop that includes
data with mime type of text/plain, and just emits the text.
*/
class DropArea : public QDeclarativeItem
{
Q_OBJECT
Q_PROPERTY(bool acceptingDrops READ isAcceptingDrops WRITE setAcceptingDrops NOTIFY acceptingDropsChanged)
public:
DropArea(QDeclarativeItem *parent=0);
bool isAcceptingDrops() const { return m_accepting; }
void setAcceptingDrops(bool accepting);
signals:
void fileDroped(QString url);
void acceptingDropsChanged();
protected:
void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
void dropEvent(QGraphicsSceneDragDropEvent *event);
private:
bool m_accepting;
};
#endif // DROPAREA_H

View File

@ -0,0 +1,22 @@
#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
#include <qdeclarative.h>
#include "droparea.h"
#include <QZXing.h>
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
QZXing::registerQMLTypes();
QmlApplicationViewer viewer;
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
qmlRegisterType<DropArea>("DropArea", 1, 0, "DropArea");
viewer.setMainQmlFile(QLatin1String("qml/QZXingTestApp/main.qml"));
viewer.showExpanded();
return app->exec();
}

View File

@ -0,0 +1,38 @@
// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
Rectangle {
id: rect
property alias text: label.text
property bool isPressed: false
width: label.width + 20
height: label.height + 10
border.color: "black"
border.width: 1
radius: 5
Text{
id: label
color: "white"
anchors.centerIn: parent
}
MouseArea{
anchors.fill: parent
onClicked: rect.isPressed = !rect.isPressed
}
states: [
State{
name: "pressed"
when: isPressed
PropertyChanges {target: rect; color:"gray"}
},
State{
name: "normal"
when: !isPressed
PropertyChanges {target: rect; color:"darkgray"}
}
]
}

View File

@ -0,0 +1,175 @@
// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import DropArea 1.0
import QZXing 2.2
Rectangle {
width: 360
height: 360
Rectangle{
id:dropArea
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
height: parent.height-200
DropArea{
anchors.fill: parent
onFileDroped: decoder.decodeImageFromFile(url)
}
Text{
anchors.centerIn: parent
color: "gray"
opacity: 0.8
text: "Drag image to decode"
elide: Text.ElideMiddle
font.pixelSize: 30
}
Rectangle{
id: decSelector
width: parent.width -100
height: parent.height/2
clip:true
color: "#00ffffff"
anchors.horizontalCenter: parent.horizontalCenter
property bool isFolded: true
Rectangle{
id: label
color: "darkgray"
border.color: "black"
border.width: 1
radius: 5
width: decLabel.width + 20
height: decLabel.height + 10
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.margins: 2
Text{
id: decLabel
text: "Active Decoders"
anchors.centerIn: parent
}
MouseArea{
anchors.fill: parent
onClicked: decSelector.isFolded = !decSelector.isFolded
}
}
Rectangle{
color: "darkgray"
border.color: "black"
border.width: 1
radius: 5
clip:true
anchors.margins: 2
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: label.top
Flow{
anchors.fill: parent
spacing: 10
anchors.margins: 5
move: Transition {
NumberAnimation {
properties: "x,y"
easing.type: Easing.OutCubic
}
}
ToggleButton{ text: "Aztec" }
ToggleButton{ text: "Codabar" }
ToggleButton{ text: "Code_39" }
ToggleButton{ text: "Code_93" }
ToggleButton{ text: "Code_128" }
ToggleButton{ text: "Data Matrix" }
ToggleButton{ text: "EAN_8" }
ToggleButton{ text: "EAN_13" }
ToggleButton{ text: "ITF" }
ToggleButton{ text: "Maxicode" }
ToggleButton{ text: "PDF_417" }
ToggleButton{ text: "Qr Code" }
ToggleButton{ text: "RSS 14" }
ToggleButton{ text: "RSS expanded" }
ToggleButton{ text: "UPC A" }
ToggleButton{ text: "UPC E" }
ToggleButton{ text: "UPC EAN extension" }
}
}
states:[
State{
name: "folded"
when: decSelector.isFolded
PropertyChanges{target:decSelector; y: -decSelector.height+label.height}
},
State{
name: "unfolded"
when: !decSelector.isFolded
PropertyChanges{target:decSelector; y: 0}
}
]
Behavior on y {NumberAnimation{duration:250; easing.type: Easing.OutCubic}}
}
}
QZXing{
id: decoder
enabledDecoders: QZXing.DecoderFormat_QR_CODE
onTagFound: {
log.add("Tag found: " +tag+ ", milliseconds: " + processingTime)
}
}
Rectangle{
id: logRect
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.top: dropArea.bottom
border.color: "gray"
border.width: 1
clip: true
Flickable{
anchors.fill: parent
contentHeight: log.height
contentWidth: log.width
flickableDirection: Flickable.VerticalFlick
TextEdit{
id: log
font.pointSize: 10
width: logRect.width
wrapMode: TextEdit.WordWrap
function add(message)
{
text = "=> " + message + "\n\n" + text;
}
}
}
}
}

View File

@ -0,0 +1,177 @@
// checksum 0xbd34 version 0x80016
/*
This file was generated by the Qt Quick Application wizard of Qt Creator.
QmlApplicationViewer is a convenience class containing mobile device specific
code such as screen orientation handling. Also QML paths and debugging are
handled here.
It is recommended not to modify this file, since newer versions of Qt Creator
may offer an updated version of it.
*/
#include "qmlapplicationviewer.h"
#include <QDir>
#include <QFileInfo>
#include <QApplication>
#include <QDeclarativeComponent>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
#include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
#ifdef HARMATTAN_BOOSTER
#include <MDeclarativeCache>
#endif
#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
#include <qt_private/qdeclarativedebughelper_p.h>
#if !defined(NO_JSDEBUGGER)
#include <jsdebuggeragent.h>
#endif
#if !defined(NO_QMLOBSERVER)
#include <qdeclarativeviewobserver.h>
#endif
// Enable debugging before any QDeclarativeEngine is created
struct QmlJsDebuggingEnabler
{
QmlJsDebuggingEnabler()
{
QDeclarativeDebugHelper::enableDebugging();
}
};
// Execute code in constructor before first QDeclarativeEngine is instantiated
static QmlJsDebuggingEnabler enableDebuggingHelper;
#endif // QMLJSDEBUGGER
class QmlApplicationViewerPrivate
{
QString mainQmlFile;
friend class QmlApplicationViewer;
static QString adjustPath(const QString &path);
};
QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
{
#ifdef Q_OS_MAC
if (!QDir::isAbsolutePath(path))
return QString::fromLatin1("%1/../Resources/%2")
.arg(QCoreApplication::applicationDirPath(), path);
#elif defined(Q_OS_QNX)
if (!QDir::isAbsolutePath(path))
return QString::fromLatin1("app/native/%1").arg(path);
#elif !defined(Q_OS_ANDROID)
QString pathInInstallDir =
QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
if (QFileInfo(pathInInstallDir).exists())
return pathInInstallDir;
pathInInstallDir =
QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path);
if (QFileInfo(pathInInstallDir).exists())
return pathInInstallDir;
#endif
return path;
}
QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
: QDeclarativeView(parent)
, d(new QmlApplicationViewerPrivate())
{
connect(engine(), SIGNAL(quit()), SLOT(close()));
setResizeMode(QDeclarativeView::SizeRootObjectToView);
// Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
#if !defined(NO_JSDEBUGGER)
new QmlJSDebugger::JSDebuggerAgent(engine());
#endif
#if !defined(NO_QMLOBSERVER)
new QmlJSDebugger::QDeclarativeViewObserver(this, this);
#endif
#endif
}
QmlApplicationViewer::~QmlApplicationViewer()
{
delete d;
}
QmlApplicationViewer *QmlApplicationViewer::create()
{
return new QmlApplicationViewer();
}
void QmlApplicationViewer::setMainQmlFile(const QString &file)
{
d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file);
#ifdef Q_OS_ANDROID
setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile));
#else
setSource(QUrl::fromLocalFile(d->mainQmlFile));
#endif
}
void QmlApplicationViewer::addImportPath(const QString &path)
{
engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path));
}
void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
{
#if QT_VERSION < 0x050000
Qt::WidgetAttribute attribute;
switch (orientation) {
#if QT_VERSION < 0x040702
// Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
case ScreenOrientationLockPortrait:
attribute = static_cast<Qt::WidgetAttribute>(128);
break;
case ScreenOrientationLockLandscape:
attribute = static_cast<Qt::WidgetAttribute>(129);
break;
default:
case ScreenOrientationAuto:
attribute = static_cast<Qt::WidgetAttribute>(130);
break;
#else // QT_VERSION < 0x040702
case ScreenOrientationLockPortrait:
attribute = Qt::WA_LockPortraitOrientation;
break;
case ScreenOrientationLockLandscape:
attribute = Qt::WA_LockLandscapeOrientation;
break;
default:
case ScreenOrientationAuto:
attribute = Qt::WA_AutoOrientation;
break;
#endif // QT_VERSION < 0x040702
};
setAttribute(attribute, true);
#else // QT_VERSION < 0x050000
Q_UNUSED(orientation)
#endif // QT_VERSION < 0x050000
}
void QmlApplicationViewer::showExpanded()
{
#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR)
showFullScreen();
#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX)
showMaximized();
#else
show();
#endif
}
QApplication *createApplication(int &argc, char **argv)
{
#ifdef HARMATTAN_BOOSTER
return MDeclarativeCache::qApplication(argc, argv);
#else
return new QApplication(argc, argv);
#endif
}

View File

@ -0,0 +1,46 @@
// checksum 0xc67a version 0x80016
/*
This file was generated by the Qt Quick Application wizard of Qt Creator.
QmlApplicationViewer is a convenience class containing mobile device specific
code such as screen orientation handling. Also QML paths and debugging are
handled here.
It is recommended not to modify this file, since newer versions of Qt Creator
may offer an updated version of it.
*/
#ifndef QMLAPPLICATIONVIEWER_H
#define QMLAPPLICATIONVIEWER_H
#include <QDeclarativeView>
class QmlApplicationViewer : public QDeclarativeView
{
Q_OBJECT
public:
enum ScreenOrientation {
ScreenOrientationLockPortrait,
ScreenOrientationLockLandscape,
ScreenOrientationAuto
};
explicit QmlApplicationViewer(QWidget *parent = 0);
virtual ~QmlApplicationViewer();
static QmlApplicationViewer *create();
void setMainQmlFile(const QString &file);
void addImportPath(const QString &path);
// Note that this will only have an effect on Fremantle.
void setOrientation(ScreenOrientation orientation);
void showExpanded();
private:
class QmlApplicationViewerPrivate *d;
};
QApplication *createApplication(int &argc, char **argv);
#endif // QMLAPPLICATIONVIEWER_H

View File

@ -0,0 +1,169 @@
# checksum 0x77b version 0x80016
# This file was generated by the Qt Quick Application wizard of Qt Creator.
# The code below adds the QmlApplicationViewer to the project and handles the
# activation of QML debugging.
# It is recommended not to modify this file, since newer versions of Qt Creator
# may offer an updated version of it.
QT += declarative
SOURCES += $$PWD/qmlapplicationviewer.cpp
HEADERS += $$PWD/qmlapplicationviewer.h
INCLUDEPATH += $$PWD
# Include JS debugger library if QMLJSDEBUGGER_PATH is set
!isEmpty(QMLJSDEBUGGER_PATH) {
include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri)
} else {
DEFINES -= QMLJSDEBUGGER
}
contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) {
DEFINES += HARMATTAN_BOOSTER
}
# This file was generated by an application wizard of Qt Creator.
# The code below handles deployment to Android and Maemo, aswell as copying
# of the application data to shadow build directories on desktop.
# It is recommended not to modify this file, since newer versions of Qt Creator
# may offer an updated version of it.
defineTest(qtcAddDeployment) {
for(deploymentfolder, DEPLOYMENTFOLDERS) {
item = item$${deploymentfolder}
greaterThan(QT_MAJOR_VERSION, 4) {
itemsources = $${item}.files
} else {
itemsources = $${item}.sources
}
$$itemsources = $$eval($${deploymentfolder}.source)
itempath = $${item}.path
$$itempath= $$eval($${deploymentfolder}.target)
export($$itemsources)
export($$itempath)
DEPLOYMENT += $$item
}
MAINPROFILEPWD = $$PWD
android {
for(deploymentfolder, DEPLOYMENTFOLDERS) {
item = item$${deploymentfolder}
itemfiles = $${item}.files
$$itemfiles = $$eval($${deploymentfolder}.source)
itempath = $${item}.path
$$itempath = /assets/$$eval($${deploymentfolder}.target)
export($$itemfiles)
export($$itempath)
INSTALLS += $$item
}
x86 {
target.path = /libs/x86
} else: armeabi-v7a {
target.path = /libs/armeabi-v7a
} else {
target.path = /libs/armeabi
}
export(target.path)
INSTALLS += target
} else:win32 {
copyCommand =
for(deploymentfolder, DEPLOYMENTFOLDERS) {
source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
source = $$replace(source, /, \\)
sourcePathSegments = $$split(source, \\)
target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments)
target = $$replace(target, /, \\)
target ~= s,\\\\\\.?\\\\,\\,
!isEqual(source,$$target) {
!isEmpty(copyCommand):copyCommand += &&
isEqual(QMAKE_DIR_SEP, \\) {
copyCommand += $(COPY_DIR) \"$$source\" \"$$target\"
} else {
source = $$replace(source, \\\\, /)
target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
target = $$replace(target, \\\\, /)
copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\"
}
}
}
!isEmpty(copyCommand) {
copyCommand = @echo Copying application data... && $$copyCommand
copydeploymentfolders.commands = $$copyCommand
first.depends = $(first) copydeploymentfolders
export(first.depends)
export(copydeploymentfolders.commands)
QMAKE_EXTRA_TARGETS += first copydeploymentfolders
}
} else:unix {
maemo5 {
desktopfile.files = $${TARGET}.desktop
desktopfile.path = /usr/share/applications/hildon
icon.files = $${TARGET}64.png
icon.path = /usr/share/icons/hicolor/64x64/apps
} else:!isEmpty(MEEGO_VERSION_MAJOR) {
desktopfile.files = $${TARGET}_harmattan.desktop
desktopfile.path = /usr/share/applications
icon.files = $${TARGET}80.png
icon.path = /usr/share/icons/hicolor/80x80/apps
} else { # Assumed to be a Desktop Unix
copyCommand =
for(deploymentfolder, DEPLOYMENTFOLDERS) {
source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
source = $$replace(source, \\\\, /)
macx {
target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target)
} else {
target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
}
target = $$replace(target, \\\\, /)
sourcePathSegments = $$split(source, /)
targetFullPath = $$target/$$last(sourcePathSegments)
targetFullPath ~= s,/\\.?/,/,
!isEqual(source,$$targetFullPath) {
!isEmpty(copyCommand):copyCommand += &&
copyCommand += $(MKDIR) \"$$target\"
copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\"
}
}
!isEmpty(copyCommand) {
copyCommand = @echo Copying application data... && $$copyCommand
copydeploymentfolders.commands = $$copyCommand
first.depends = $(first) copydeploymentfolders
export(first.depends)
export(copydeploymentfolders.commands)
QMAKE_EXTRA_TARGETS += first copydeploymentfolders
}
}
installPrefix = /opt/$${TARGET}
for(deploymentfolder, DEPLOYMENTFOLDERS) {
item = item$${deploymentfolder}
itemfiles = $${item}.files
$$itemfiles = $$eval($${deploymentfolder}.source)
itempath = $${item}.path
$$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target)
export($$itemfiles)
export($$itempath)
INSTALLS += $$item
}
!isEmpty(desktopfile.path) {
export(icon.files)
export(icon.path)
export(desktopfile.files)
export(desktopfile.path)
INSTALLS += icon desktopfile
}
target.path = $${installPrefix}/bin
export(target.path)
INSTALLS += target
}
export (ICON)
export (INSTALLS)
export (DEPLOYMENT)
export (LIBS)
export (QMAKE_EXTRA_TARGETS)
}