QQrDecoder example updated to Qt5

This commit is contained in:
Alexxey593 2015-06-10 14:34:32 +03:00
parent 85d82f5903
commit 13720010fc
5 changed files with 19 additions and 15 deletions

View File

@ -41,7 +41,9 @@
#include "QCameraControllerWidget.h" #include "QCameraControllerWidget.h"
//#include <QDebug> //#include <QDebug>
#include <QCameraFlashControl> #include <QCameraFlashControl>
#include <QHBoxLayout>
#include <QMessageBox>
#include <QStandardPaths>
/***************************************************************************** /*****************************************************************************
* QCameraControllerWidget * QCameraControllerWidget
@ -125,11 +127,17 @@ QCameraControllerWidget::QCameraControllerWidget(QWidget *parent) :
setLayout(hboxl); setLayout(hboxl);
QStringList list = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
if(list.isEmpty())
imagePath = qApp->applicationDirPath();
else
imagePath = list.at(0);
fileWatcher = new QFileSystemWatcher(); fileWatcher = new QFileSystemWatcher();
fileWatcher->addPath(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)); fileWatcher->addPath(imagePath);
connect(fileWatcher, SIGNAL( directoryChanged (const QString &)), this, SLOT(deleteImage(const QString &))); connect(fileWatcher, SIGNAL( directoryChanged (const QString &)), this, SLOT(deleteImage(const QString &)));
imageFolder = QDir(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)); imageFolder = QDir(imagePath);
QStringList filters; QStringList filters;
filters << "camera*"; filters << "camera*";
imageFolder.setNameFilters(filters); imageFolder.setNameFilters(filters);
@ -280,6 +288,7 @@ void QCameraControllerWidget::captureImage()
void QCameraControllerWidget::onImageCaptured(int id, const QImage &preview) void QCameraControllerWidget::onImageCaptured(int id, const QImage &preview)
{ {
Q_UNUSED(id);
// m_stillImageCapture->cancelCapture(); // m_stillImageCapture->cancelCapture();
// showViewFinder = false; // showViewFinder = false;
m_focusing = false; m_focusing = false;
@ -291,6 +300,7 @@ void QCameraControllerWidget::onImageCaptured(int id, const QImage &preview)
void QCameraControllerWidget::deleteImage(const QString & folderPath) void QCameraControllerWidget::deleteImage(const QString & folderPath)
{ {
Q_UNUSED(folderPath);
//qdebug() << "Detected change to folder: " << folderPath; //qdebug() << "Detected change to folder: " << folderPath;
QStringList files = imageFolder.entryList(imageFolder.nameFilters()); QStringList files = imageFolder.entryList(imageFolder.nameFilters());
@ -300,8 +310,7 @@ void QCameraControllerWidget::deleteImage(const QString & folderPath)
//qdebug() << "Checking file: " << image; //qdebug() << "Checking file: " << image;
if(image.startsWith("camera")) if(image.startsWith("camera"))
{ {
QString path(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)); QDir pathDir(imagePath);
QDir pathDir(path);
pathDir.remove(image); pathDir.remove(image);
//qdebug() << "file deleted: " << image; //qdebug() << "file deleted: " << image;
@ -354,6 +363,7 @@ void QCameraControllerWidget::updateVideo()
void QCameraControllerWidget::paintEvent(QPaintEvent *event) void QCameraControllerWidget::paintEvent(QPaintEvent *event)
{ {
Q_UNUSED(event);
//QMainWindow::paintEvent(event); //QMainWindow::paintEvent(event);
QPainter painter(this); QPainter painter(this);

View File

@ -58,7 +58,7 @@
#include "myvideosurface.h" #include "myvideosurface.h"
#include "button.h" #include "button.h"
#include <QStackedWidget>
class QCameraControllerWidget: public QWidget, public VideoIF class QCameraControllerWidget: public QWidget, public VideoIF
{ {
@ -117,6 +117,7 @@ private:
QCameraFocus* cameraFocus; QCameraFocus* cameraFocus;
QFileSystemWatcher* fileWatcher; QFileSystemWatcher* fileWatcher;
QDir imageFolder; QDir imageFolder;
QString imagePath;
}; };
#endif // QCAMERA_H #endif // QCAMERA_H

View File

@ -31,7 +31,7 @@
#ifndef QQRDECODER_H #ifndef QQRDECODER_H
#define QQRDECODER_H #define QQRDECODER_H
#include <QtGui/QMainWindow> #include <QMainWindow>
#include <QPixmap> #include <QPixmap>
#include "ui_QQrDecoder.h" #include "ui_QQrDecoder.h"
#include <qzxing.h> #include <qzxing.h>

View File

@ -1,15 +1,9 @@
TEMPLATE = app TEMPLATE = app
TARGET = QQrDecoder TARGET = QQrDecoder
QT += core \ QT += core gui multimedia widgets
gui \
declarative
VERSION = 2.0.0 VERSION = 2.0.0
CONFIG += mobility
MOBILITY = multimedia #\
#systeminfo
RESOURCES += resources.qrc RESOURCES += resources.qrc
include(../../source/QZXing.pri) include(../../source/QZXing.pri)

View File

@ -46,7 +46,6 @@
Button::Button(QWidget *parent, Qt::WindowFlags f) : Button::Button(QWidget *parent, Qt::WindowFlags f) :
QLabel(parent, f) QLabel(parent, f)
{ {
m_downPixmap = 0;
m_disabled = false; m_disabled = false;
m_toggled = false; m_toggled = false;
m_toggle_enabled = false; m_toggle_enabled = false;