-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加二维码识别功能 细节改进
- Loading branch information
Showing
249 changed files
with
29,526 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# This file is part of JQTools | ||
# | ||
# Project introduce: https://github.com/188080501/JQTools | ||
# | ||
# Copyright: Jason | ||
# | ||
# Contact email: Jason@JasonServer.com | ||
# | ||
# GitHub: https://github.com/188080501/ | ||
# | ||
|
||
INCLUDEPATH += \ | ||
$$PWD/cpp/ | ||
|
||
HEADERS += \ | ||
$$PWD/cpp/qrcodereader.h | ||
|
||
SOURCES += \ | ||
$$PWD/cpp/qrcodereader_.cpp | ||
|
||
RESOURCES += \ | ||
$$PWD/qml/QRCodeReaderQml.qrc \ | ||
$$PWD/resources/images/QRCodeReaderImages.qrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
This file is part of JQTools | ||
|
||
Project introduce: https://github.com/188080501/JQTools | ||
|
||
Copyright: Jason | ||
|
||
Contact email: Jason@JasonServer.com | ||
|
||
GitHub: https://github.com/188080501/ | ||
*/ | ||
|
||
#include "qrcodereader.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
This file is part of JQTools | ||
Project introduce: https://github.com/188080501/JQTools | ||
Copyright: Jason | ||
Contact email: Jason@JasonServer.com | ||
GitHub: https://github.com/188080501/ | ||
*/ | ||
|
||
#ifndef __GROUP_MAKEGROUP_QRCODEREADER_CPP_QRCODEREADER_H__ | ||
#define __GROUP_MAKEGROUP_QRCODEREADER_CPP_QRCODEREADER_H__ | ||
|
||
// Qt lib import | ||
#include <QImage> | ||
#include <QQuickImageProvider> | ||
|
||
// JQToolsLibrary import | ||
#include "JQToolsLibrary.h" | ||
|
||
#define QRCODEREADER_INITIALIZA \ | ||
{ \ | ||
qmlRegisterType< QRCodeReader_::Manage >( "QRCodeReader", 1, 0, "QRCodeReaderManage" ); \ | ||
} | ||
|
||
class JQQRCodeReader; | ||
|
||
namespace QRCodeReader_ | ||
{ | ||
|
||
class Manage: public AbstractTool | ||
{ | ||
Q_OBJECT | ||
Q_DISABLE_COPY(Manage) | ||
|
||
public: | ||
Manage(); | ||
|
||
~Manage() = default; | ||
|
||
public slots: | ||
QUrl chooseImage() const; | ||
|
||
QString decodeImage(const QUrl &imageUrl); | ||
|
||
private: | ||
QSharedPointer< JQQRCodeReader > jqQRCodeReader_; | ||
}; | ||
|
||
} | ||
|
||
#endif//__GROUP_MAKEGROUP_QRCODEREADER_CPP_QRCODEREADER_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
This file is part of JQTools | ||
Project introduce: https://github.com/188080501/JQTools | ||
Copyright: Jason | ||
Contact email: Jason@JasonServer.com | ||
GitHub: https://github.com/188080501/ | ||
*/ | ||
|
||
#include "qrcodereader.h" | ||
|
||
// Qt lib import | ||
#include <QDebug> | ||
#include <QFileDialog> | ||
#include <QStandardPaths> | ||
#include <QUrl> | ||
|
||
// JQLibrary lib import | ||
#include "JQQRCodeReader.h" | ||
|
||
using namespace QRCodeReader_; | ||
|
||
Manage::Manage(): | ||
jqQRCodeReader_( new JQQRCodeReader ) | ||
{ } | ||
|
||
QUrl Manage::chooseImage() const | ||
{ | ||
return QUrl::fromLocalFile( | ||
QFileDialog::getOpenFileName( | ||
nullptr, | ||
QStringLiteral( "\u8BF7\u9009\u62E9\u56FE\u7247" ), | ||
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ), | ||
"*.png *.jpg" | ||
) | ||
); | ||
} | ||
|
||
QString Manage::decodeImage(const QUrl &imageUrl) | ||
{ | ||
if ( imageUrl.toString().startsWith( "file:" ) ) | ||
{ | ||
return jqQRCodeReader_->decodeImage( QImage( imageUrl.toLocalFile() ) ); | ||
} | ||
else if ( imageUrl.toString().startsWith( "qrc:" ) ) | ||
{ | ||
return jqQRCodeReader_->decodeImage( QImage( imageUrl.toString().mid( 3 ) ) ); | ||
} | ||
|
||
return { }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
This file is part of JQTools | ||
Project introduce: https://github.com/188080501/JQTools | ||
Copyright: Jason | ||
Contact email: Jason@JasonServer.com | ||
GitHub: https://github.com/188080501/ | ||
*/ | ||
|
||
import QtQuick 2.7 | ||
import QtQuick.Controls 1.4 | ||
import "qrc:/MaterialUI/Interface/" | ||
import QRCodeReader 1.0 | ||
|
||
Item { | ||
id: qrCodeReader | ||
width: 620 | ||
height: 540 | ||
|
||
QRCodeReaderManage { | ||
id: qrCodeReaderManage | ||
} | ||
|
||
Item { | ||
anchors.centerIn: parent | ||
width: 620 | ||
height: 540 | ||
|
||
MaterialTextField { | ||
id: textFieldForTag | ||
x: 40 | ||
y: 50 | ||
width: 540 | ||
placeholderText: "被识别的标记" | ||
|
||
Component.onCompleted: { | ||
text = qrCodeReaderManage.decodeImage( "qrc:/QRCodeReaderImages/test.png" ); | ||
} | ||
} | ||
|
||
Image { | ||
id: imageForQRCode | ||
anchors.horizontalCenter: parent.horizontalCenter | ||
anchors.horizontalCenterOffset: -100 | ||
anchors.verticalCenter: parent.verticalCenter | ||
anchors.verticalCenterOffset: 50 | ||
width: 250 | ||
height: 250 | ||
source: "qrc:/QRCodeReaderImages/test.png" | ||
|
||
MaterialButton { | ||
anchors.left: parent.right | ||
anchors.leftMargin: 50 | ||
anchors.verticalCenter: parent.verticalCenter | ||
text: "选取图片" | ||
|
||
onClicked: { | ||
imageForQRCode.source = qrCodeReaderManage.chooseImage(); | ||
|
||
if ( imageForQRCode.source.toString() !== "" ) | ||
{ | ||
textFieldForTag.text = qrCodeReaderManage.decodeImage( imageForQRCode.source ); | ||
} | ||
else | ||
{ | ||
textFieldForTag.text = ""; | ||
materialUI.showSnackbarMessage( "用户取消操作" ); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<RCC> | ||
<qresource prefix="/QRCodeReader"> | ||
<file>QRCodeReader.qml</file> | ||
</qresource> | ||
</RCC> |
5 changes: 5 additions & 0 deletions
5
components/ToolsGroup/QRCodeReader/resources/images/QRCodeReaderImages.qrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<RCC> | ||
<qresource prefix="/QRCodeReaderImages"> | ||
<file>test.png</file> | ||
</qresource> | ||
</RCC> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.