diff --git a/README.md b/README.md index 9fbe44a..a25b667 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ https://github.com/188080501/JQNetwork 制作类|图标生成器|已完成 制作类|图标字体转PNG|已完成 制作类|二维码制作器|已完成 +制作类|条形码制作器|已完成 | | 工具类|代码行数统计|已完成 工具类|PNG图片压缩|已完成 diff --git a/components/CalculateGroup/HashCalculate/cpp/hashcalculate.h b/components/CalculateGroup/HashCalculate/cpp/hashcalculate.h index 0ee4eb0..d871e6c 100755 --- a/components/CalculateGroup/HashCalculate/cpp/hashcalculate.h +++ b/components/CalculateGroup/HashCalculate/cpp/hashcalculate.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_CALCULATEGROUP_HASHCALCULATE_CPP_HASHCALCULATE_H__ -#define __GROUP_CALCULATEGROUP_HASHCALCULATE_CPP_HASHCALCULATE_H__ +#ifndef GROUP_CALCULATEGROUP_HASHCALCULATE_CPP_HASHCALCULATE_H_ +#define GROUP_CALCULATEGROUP_HASHCALCULATE_CPP_HASHCALCULATE_H_ // JQToolsLibrary import #include "JQToolsLibrary.h" @@ -92,4 +92,4 @@ public slots: } -#endif//__GROUP_CALCULATEGROUP_HASHCALCULATE_CPP_HASHCALCULATE_H__ +#endif//GROUP_CALCULATEGROUP_HASHCALCULATE_CPP_HASHCALCULATE_H_ diff --git a/components/CalculateGroup/TimestampTransform/cpp/timestamptransform.h b/components/CalculateGroup/TimestampTransform/cpp/timestamptransform.h index 0921cd7..22d12c5 100755 --- a/components/CalculateGroup/TimestampTransform/cpp/timestamptransform.h +++ b/components/CalculateGroup/TimestampTransform/cpp/timestamptransform.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_CALCULATEGROUP_TIMESTAMPTRANSFORM_CPP_TIMESTAMPTRANSFORM_H__ -#define __GROUP_CALCULATEGROUP_TIMESTAMPTRANSFORM_CPP_TIMESTAMPTRANSFORM_H__ +#ifndef GROUP_CALCULATEGROUP_TIMESTAMPTRANSFORM_CPP_TIMESTAMPTRANSFORM_H_ +#define GROUP_CALCULATEGROUP_TIMESTAMPTRANSFORM_CPP_TIMESTAMPTRANSFORM_H_ // JQToolsLibrary import #include "JQToolsLibrary.h" @@ -42,4 +42,4 @@ public slots: } -#endif//__GROUP_CALCULATEGROUP_TIMESTAMPTRANSFORM_CPP_TIMESTAMPTRANSFORM_H__ +#endif//GROUP_CALCULATEGROUP_TIMESTAMPTRANSFORM_CPP_TIMESTAMPTRANSFORM_H_ diff --git a/components/CalculateGroup/calculategroup.h b/components/CalculateGroup/calculategroup.h index e5d1c24..5eeb0d5 100755 --- a/components/CalculateGroup/calculategroup.h +++ b/components/CalculateGroup/calculategroup.h @@ -10,15 +10,15 @@ GitHub: https://github.com/188080501/ */ -#ifndef __CALCULATEGROUP_CALCULATEGROUP_H__ -#define __CALCULATEGROUP_CALCULATEGROUP_H__ +#ifndef CALCULATEGROUP_CALCULATEGROUP_H_ +#define CALCULATEGROUP_CALCULATEGROUP_H_ // CalculateGroup lib import #include #include -#define CALCULATEGROUP__INITIALIZA \ +#define CALCULATEGROUP_INITIALIZA \ HASHCALCULATE_INITIALIZA; \ TTIMESTAMPTRANSFORM_INITIALIZA; -#endif//__CALCULATEGROUP_CALCULATEGROUP_H__ +#endif//CALCULATEGROUP_CALCULATEGROUP_H_ diff --git a/components/MakeGroup/BarcodeMaker/BarcodeMaker.pri b/components/MakeGroup/BarcodeMaker/BarcodeMaker.pri new file mode 100755 index 0000000..a29c646 --- /dev/null +++ b/components/MakeGroup/BarcodeMaker/BarcodeMaker.pri @@ -0,0 +1,23 @@ +# +# 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/barcodemaker.h + +SOURCES += \ + $$PWD/cpp/barcodemaker.cpp + +RESOURCES += \ + $$PWD/qml/BarcodeMakerQml.qrc diff --git a/components/MakeGroup/BarcodeMaker/cpp/BarcodeMaker b/components/MakeGroup/BarcodeMaker/cpp/BarcodeMaker new file mode 100755 index 0000000..1025a92 --- /dev/null +++ b/components/MakeGroup/BarcodeMaker/cpp/BarcodeMaker @@ -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 "barcodemaker.h" diff --git a/components/MakeGroup/BarcodeMaker/cpp/barcodemaker.cpp b/components/MakeGroup/BarcodeMaker/cpp/barcodemaker.cpp new file mode 100755 index 0000000..419f21a --- /dev/null +++ b/components/MakeGroup/BarcodeMaker/cpp/barcodemaker.cpp @@ -0,0 +1,88 @@ +/* + 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 "barcodemaker.h" + +// Qt lib import +#include +#include +#include +#include +#include + +// JQLibrary lib import +#include "JQBarcode.h" + +using namespace BarcodeMaker; + +Manage::Manage() +{ + this->qmlApplicationEngine().data()->addImageProvider( "BarcodeMaker", new ImageProvider ); +} + +Manage::~Manage() +{ + this->qmlApplicationEngine().data()->removeImageProvider( "BarcodeMaker" ); +} + +QString Manage::savePng(const QString &string) +{ + auto filePath = QFileDialog::getSaveFileName( + nullptr, + QStringLiteral( "请选择保存图片的路径" ), + QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ), + "*.png" + ); + + if ( filePath.isEmpty() ) { return "cancel"; } + + if ( !filePath.toLower().endsWith( ".png" ) ) + { + filePath += ".png"; + } + + QImage targetImage( QSize( 210, 140 ), QImage::Format_RGB888 ); + targetImage.fill( QColor( "#ffffff" ) ); + + const auto &&barcodeImage = JQBarcode::makeBarcode( string.toLongLong() ); + + if ( ( string.size() == 13 ) && string.toLongLong() && ( string[ 0 ] == '6' ) ) + { + QPainter painter; + painter.begin( &targetImage ); + painter.drawImage( 10, 10, barcodeImage ); + } + + const auto &&saveSucceed = targetImage.save( filePath ); + if ( !saveSucceed ) + { + return "error"; + } + + return "OK"; +} + +ImageProvider::ImageProvider(): + QQuickImageProvider( QQuickImageProvider::Image ) +{ } + +QImage ImageProvider::requestImage(const QString &id, QSize *, const QSize &) +{ + if ( ( id.size() == 13 ) && id.toLongLong() && ( id[ 0 ] == '6' ) ) + { + return JQBarcode::makeBarcode( id.toLongLong() ); + } + else + { + return { }; + } +} diff --git a/components/MakeGroup/BarcodeMaker/cpp/barcodemaker.h b/components/MakeGroup/BarcodeMaker/cpp/barcodemaker.h new file mode 100755 index 0000000..9167c65 --- /dev/null +++ b/components/MakeGroup/BarcodeMaker/cpp/barcodemaker.h @@ -0,0 +1,57 @@ +/* + 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_BARCODEMAKER_CPP_BARCODEMAKER_H_ +#define GROUP_MAKEGROUP_BARCODEMAKER_CPP_BARCODEMAKER_H_ + +// Qt lib import +#include +#include + +// JQToolsLibrary import +#include "JQToolsLibrary.h" + +#define BARCODEMAKER_INITIALIZA \ +{ \ + qmlRegisterType< BarcodeMaker::Manage >( "BarcodeMaker", 1, 0, "BarcodeMakerManage" ); \ +} + +namespace BarcodeMaker +{ + +class Manage: public AbstractTool +{ + Q_OBJECT + Q_DISABLE_COPY(Manage) + +public: + Manage(); + + ~Manage(); + +public slots: + QString savePng(const QString &string); +}; + +class ImageProvider: public QQuickImageProvider +{ +public: + ImageProvider(); + + ~ImageProvider() = default; + + QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize); +}; + +} + +#endif//GROUP_MAKEGROUP_BARCODEMAKER_CPP_BARCODEMAKER_H_ diff --git a/components/MakeGroup/BarcodeMaker/qml/BarcodeMaker.qml b/components/MakeGroup/BarcodeMaker/qml/BarcodeMaker.qml new file mode 100755 index 0000000..407491d --- /dev/null +++ b/components/MakeGroup/BarcodeMaker/qml/BarcodeMaker.qml @@ -0,0 +1,78 @@ +/* + 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 BarcodeMaker 1.0 + +Item { + id: qrcodeMaker + width: 620 + height: 540 + + BarcodeMakerManage { + id: barcodeMakerManage + } + + Item { + anchors.centerIn: parent + width: 620 + height: 540 + + MaterialTextField { + id: textFieldForLower + x: 40 + y: 50 + width: 540 + placeholderText: "条形码ID\n目前仅支持EAN-13,并且需要6开头" + text: "6901234567892" + } + + Image { + id: imageForBarcode + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: -100 + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 50 + width: 250 + height: 250 + fillMode: Image.PreserveAspectFit + source: "image://BarcodeMaker/" + textFieldForLower.text + + MaterialButton { + anchors.left: parent.right + anchors.leftMargin: 50 + anchors.verticalCenter: parent.verticalCenter + text: "保存为PNG" + + onClicked: { + materialUI.showLoading(); + + var reply = barcodeMakerManage.savePng( + textFieldForLower.text + ); + + materialUI.hideLoading(); + + switch ( reply ) + { + case "cancel": materialUI.showSnackbarMessage( "取消保存" ); break; + case "error": materialUI.showSnackbarMessage( "保存失败" ); break; + case "OK": materialUI.showSnackbarMessage( "保存成功" ); break; + default: break; + } + } + } + } + } +} diff --git a/components/MakeGroup/BarcodeMaker/qml/BarcodeMakerQml.qrc b/components/MakeGroup/BarcodeMaker/qml/BarcodeMakerQml.qrc new file mode 100755 index 0000000..664e963 --- /dev/null +++ b/components/MakeGroup/BarcodeMaker/qml/BarcodeMakerQml.qrc @@ -0,0 +1,5 @@ + + + BarcodeMaker.qml + + diff --git a/components/MakeGroup/MakeGroup.pri b/components/MakeGroup/MakeGroup.pri index c72944f..8e92163 100755 --- a/components/MakeGroup/MakeGroup.pri +++ b/components/MakeGroup/MakeGroup.pri @@ -13,6 +13,7 @@ include( $$PWD/IconMaker/IconMaker.pri ) include( $$PWD/FontToPng/FontToPng.pri ) include( $$PWD/QRCodeMaker/QRCodeMaker.pri ) +include( $$PWD/BarcodeMaker/BarcodeMaker.pri ) INCLUDEPATH += \ $$PWD/ diff --git a/components/MakeGroup/QRCodeMaker/qml/QRCodeMaker.qml b/components/MakeGroup/QRCodeMaker/qml/QRCodeMaker.qml index 8dac6da..78062f4 100755 --- a/components/MakeGroup/QRCodeMaker/qml/QRCodeMaker.qml +++ b/components/MakeGroup/QRCodeMaker/qml/QRCodeMaker.qml @@ -46,6 +46,7 @@ Item { anchors.verticalCenterOffset: 50 width: 250 height: 250 + fillMode: Image.PreserveAspectFit source: "image://QRCodeMaker/" + textFieldForLower.text MaterialButton { diff --git a/components/MakeGroup/makegroup.h b/components/MakeGroup/makegroup.h index f79866a..f2d8a70 100755 --- a/components/MakeGroup/makegroup.h +++ b/components/MakeGroup/makegroup.h @@ -10,17 +10,19 @@ GitHub: https://github.com/188080501/ */ -#ifndef __MAKEGROUP_MAKEGROUP_H__ -#define __MAKEGROUP_MAKEGROUP_H__ +#ifndef MAKEGROUP_MAKEGROUP_H_ +#define MAKEGROUP_MAKEGROUP_H_ // MakeGroup lib import #include #include #include +#include #define MAKEGROUP_INITIALIZA \ ICONMAKER_INITIALIZA; \ FONTTOPNG_INITIALIZA; \ - QRCODEMAKER_INITIALIZA + QRCODEMAKER_INITIALIZA; \ + BARCODEMAKER_INITIALIZA; -#endif//__MAKEGROUP_MAKEGROUP_H__ +#endif//MAKEGROUP_MAKEGROUP_H_ diff --git a/components/QtGroup/CppFileMaker/cpp/cppfilemaker.h b/components/QtGroup/CppFileMaker/cpp/cppfilemaker.h index 0cb6338..be3f4f5 100755 --- a/components/QtGroup/CppFileMaker/cpp/cppfilemaker.h +++ b/components/QtGroup/CppFileMaker/cpp/cppfilemaker.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_QTGROUP_CPPFILEMAKER_CPP_CPPFILEMAKER_H__ -#define __GROUP_QTGROUP_CPPFILEMAKER_CPP_CPPFILEMAKER_H__ +#ifndef GROUP_QTGROUP_CPPFILEMAKER_CPP_CPPFILEMAKER_H_ +#define GROUP_QTGROUP_CPPFILEMAKER_CPP_CPPFILEMAKER_H_ // C++ lib import #include @@ -56,4 +56,4 @@ public slots: } -#endif//__GROUP_QTGROUP_CPPFILEMAKER_CPP_CPPFILEMAKER_H__ +#endif//GROUP_QTGROUP_CPPFILEMAKER_CPP_CPPFILEMAKER_H_ diff --git a/components/QtGroup/PngWarningRemover/cpp/pngwarningremover.h b/components/QtGroup/PngWarningRemover/cpp/pngwarningremover.h index 60ed73f..a941ca6 100755 --- a/components/QtGroup/PngWarningRemover/cpp/pngwarningremover.h +++ b/components/QtGroup/PngWarningRemover/cpp/pngwarningremover.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_QTGROUP_PNGWARNINGREMOVER_CPP_PNGWARNINGREMOVER_H__ -#define __GROUP_QTGROUP_PNGWARNINGREMOVER_CPP_PNGWARNINGREMOVER_H__ +#ifndef GROUP_QTGROUP_PNGWARNINGREMOVER_CPP_PNGWARNINGREMOVER_H_ +#define GROUP_QTGROUP_PNGWARNINGREMOVER_CPP_PNGWARNINGREMOVER_H_ // JQToolsLibrary import #include "JQToolsLibrary.h" @@ -45,4 +45,4 @@ public slots: } -#endif//__GROUP_QTGROUP_PNGWARNINGREMOVER_CPP_PNGWARNINGREMOVER_H__ +#endif//GROUP_QTGROUP_PNGWARNINGREMOVER_CPP_PNGWARNINGREMOVER_H_ diff --git a/components/QtGroup/PropertyMaker/cpp/propertymaker.h b/components/QtGroup/PropertyMaker/cpp/propertymaker.h index f277e64..7578893 100755 --- a/components/QtGroup/PropertyMaker/cpp/propertymaker.h +++ b/components/QtGroup/PropertyMaker/cpp/propertymaker.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_QTGROUP_PROPERTYMAKER_CPP_PROPERTYMAKER_H__ -#define __GROUP_QTGROUP_PROPERTYMAKER_CPP_PROPERTYMAKER_H__ +#ifndef GROUP_QTGROUP_PROPERTYMAKER_CPP_PROPERTYMAKER_H_ +#define GROUP_QTGROUP_PROPERTYMAKER_CPP_PROPERTYMAKER_H_ // C++ lib import #include @@ -49,4 +49,4 @@ public slots: } -#endif//__GROUP_QTGROUP_PROPERTYMAKER_CPP_PROPERTYMAKER_H__ +#endif//GROUP_QTGROUP_PROPERTYMAKER_CPP_PROPERTYMAKER_H_ diff --git a/components/QtGroup/qtgroup.h b/components/QtGroup/qtgroup.h index 30b811b..e8a95f7 100755 --- a/components/QtGroup/qtgroup.h +++ b/components/QtGroup/qtgroup.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __QTGROUP_QTGROUP_H__ -#define __QTGROUP_QTGROUP_H__ +#ifndef QTGROUP_QTGROUP_H_ +#define QTGROUP_QTGROUP_H_ // QtGroup lib import #include @@ -23,4 +23,4 @@ PROPERTYMAKER_INITIALIZA; \ CPPFILEMAKER_INITIALIZA; -#endif//__QTGROUP_QTGROUP_H__ +#endif//QTGROUP_QTGROUP_H_ diff --git a/components/TextGroup/CaseTransform/cpp/casetransform.h b/components/TextGroup/CaseTransform/cpp/casetransform.h index 2308286..550eba0 100755 --- a/components/TextGroup/CaseTransform/cpp/casetransform.h +++ b/components/TextGroup/CaseTransform/cpp/casetransform.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_TEXTGROUP_CASETRANSFORM_CPP_CASETRANSFORM_H__ -#define __GROUP_TEXTGROUP_CASETRANSFORM_CPP_CASETRANSFORM_H__ +#ifndef GROUP_TEXTGROUP_CASETRANSFORM_CPP_CASETRANSFORM_H_ +#define GROUP_TEXTGROUP_CASETRANSFORM_CPP_CASETRANSFORM_H_ // JQToolsLibrary import #include "JQToolsLibrary.h" @@ -42,4 +42,4 @@ public slots: } -#endif//__GROUP_TEXTGROUP_CASETRANSFORM_CPP_CASETRANSFORM_H__ +#endif//GROUP_TEXTGROUP_CASETRANSFORM_CPP_CASETRANSFORM_H_ diff --git a/components/TextGroup/JsonFormat/cpp/jsonformat.h b/components/TextGroup/JsonFormat/cpp/jsonformat.h index a102646..9a1e9fb 100755 --- a/components/TextGroup/JsonFormat/cpp/jsonformat.h +++ b/components/TextGroup/JsonFormat/cpp/jsonformat.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_TEXTGROUP_JSONFORMAT_CPP_JSONFORMAT_H__ -#define __GROUP_TEXTGROUP_JSONFORMAT_CPP_JSONFORMAT_H__ +#ifndef GROUP_TEXTGROUP_JSONFORMAT_CPP_JSONFORMAT_H_ +#define GROUP_TEXTGROUP_JSONFORMAT_CPP_JSONFORMAT_H_ // JQToolsLibrary import #include "JQToolsLibrary.h" @@ -42,4 +42,4 @@ public slots: } -#endif//__GROUP_TEXTGROUP_JSONFORMAT_CPP_JSONFORMAT_H__ +#endif//GROUP_TEXTGROUP_JSONFORMAT_CPP_JSONFORMAT_H_ diff --git a/components/TextGroup/RandomPassword/cpp/randompassword.h b/components/TextGroup/RandomPassword/cpp/randompassword.h index f55c98f..f5dd72d 100755 --- a/components/TextGroup/RandomPassword/cpp/randompassword.h +++ b/components/TextGroup/RandomPassword/cpp/randompassword.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_TEXTGROUP_RANDOMPASSWORD_CPP_RANDOMPASSWORD_H__ -#define __GROUP_TEXTGROUP_RANDOMPASSWORD_CPP_RANDOMPASSWORD_H__ +#ifndef GROUP_TEXTGROUP_RANDOMPASSWORD_CPP_RANDOMPASSWORD_H_ +#define GROUP_TEXTGROUP_RANDOMPASSWORD_CPP_RANDOMPASSWORD_H_ // JQToolsLibrary import #include "JQToolsLibrary.h" @@ -40,4 +40,4 @@ public slots: } -#endif//__GROUP_TEXTGROUP_RANDOMPASSWORD_CPP_RANDOMPASSWORD_H__ +#endif//GROUP_TEXTGROUP_RANDOMPASSWORD_CPP_RANDOMPASSWORD_H_ diff --git a/components/TextGroup/RgbStringTransform/cpp/rgbstringtransform.h b/components/TextGroup/RgbStringTransform/cpp/rgbstringtransform.h index 668846b..c5eb100 100755 --- a/components/TextGroup/RgbStringTransform/cpp/rgbstringtransform.h +++ b/components/TextGroup/RgbStringTransform/cpp/rgbstringtransform.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_TEXTGROUP_RGBSTRINGTRANSFORM_CPP_RGBSTRINGTRANSFORM_H__ -#define __GROUP_TEXTGROUP_RGBSTRINGTRANSFORM_CPP_RGBSTRINGTRANSFORM_H__ +#ifndef GROUP_TEXTGROUP_RGBSTRINGTRANSFORM_CPP_RGBSTRINGTRANSFORM_H_ +#define GROUP_TEXTGROUP_RGBSTRINGTRANSFORM_CPP_RGBSTRINGTRANSFORM_H_ // JQToolsLibrary import #include "JQToolsLibrary.h" @@ -48,4 +48,4 @@ public slots: } -#endif//__GROUP_TEXTGROUP_RGBSTRINGTRANSFORM_CPP_RGBSTRINGTRANSFORM_H__ +#endif//GROUP_TEXTGROUP_RGBSTRINGTRANSFORM_CPP_RGBSTRINGTRANSFORM_H_ diff --git a/components/TextGroup/UrlEncode/cpp/urlencode.h b/components/TextGroup/UrlEncode/cpp/urlencode.h index 7973006..be4e0dc 100755 --- a/components/TextGroup/UrlEncode/cpp/urlencode.h +++ b/components/TextGroup/UrlEncode/cpp/urlencode.h @@ -10,13 +10,13 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_TEXTGROUP_URLENCODE_CPP_URLENCODE_H__ -#define __GROUP_TEXTGROUP_URLENCODE_CPP_URLENCODE_H__ +#ifndef GROUP_TEXTGROUP_URLENCODE_CPP_URLENCODE_H_ +#define GROUP_TEXTGROUP_URLENCODE_CPP_URLENCODE_H_ // JQToolsLibrary import #include "JQToolsLibrary.h" -#define URLENCODE_INITIALIZA \ +#define URLENCODE_INITIALIZA \ { \ qmlRegisterType("UrlEncode", 1, 0, "UrlEncodeManage"); \ } @@ -42,4 +42,4 @@ public slots: } -#endif//__GROUP_TEXTGROUP_URLENCODE_CPP_URLENCODE_H__ +#endif//GROUP_TEXTGROUP_URLENCODE_CPP_URLENCODE_H_ diff --git a/components/TextGroup/Utf16Transform/cpp/utf16transform.h b/components/TextGroup/Utf16Transform/cpp/utf16transform.h index 920ad74..26f70a9 100755 --- a/components/TextGroup/Utf16Transform/cpp/utf16transform.h +++ b/components/TextGroup/Utf16Transform/cpp/utf16transform.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_TEXTGROUP_UTF16TRANSFORM_CPP_UTF16TRANSFORM_H__ -#define __GROUP_TEXTGROUP_UTF16TRANSFORM_CPP_UTF16TRANSFORM_H__ +#ifndef GROUP_TEXTGROUP_UTF16TRANSFORM_CPP_UTF16TRANSFORM_H_ +#define GROUP_TEXTGROUP_UTF16TRANSFORM_CPP_UTF16TRANSFORM_H_ // JQToolsLibrary import #include "JQToolsLibrary.h" @@ -42,4 +42,4 @@ public slots: } -#endif//__GROUP_TEXTGROUP_UTF16TRANSFORM_CPP_UTF16TRANSFORM_H__ +#endif//GROUP_TEXTGROUP_UTF16TRANSFORM_CPP_UTF16TRANSFORM_H_ diff --git a/components/TextGroup/textgroup.h b/components/TextGroup/textgroup.h index b93ce52..e99a29a 100755 --- a/components/TextGroup/textgroup.h +++ b/components/TextGroup/textgroup.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __TEXTGROUP_TEXTGROUP_H__ -#define __TEXTGROUP_TEXTGROUP_H__ +#ifndef TEXTGROUP_TEXTGROUP_H_ +#define TEXTGROUP_TEXTGROUP_H_ // TextGroup lib import #include @@ -29,4 +29,4 @@ URLENCODE_INITIALIZA; \ JSONFORMAT_INITIALIZA; -#endif//__TEXTGROUP_TEXTGROUP_H__ +#endif//TEXTGROUP_TEXTGROUP_H_ diff --git a/components/ToolsGroup/JpgOptimize/cpp/jpgoptimize.h b/components/ToolsGroup/JpgOptimize/cpp/jpgoptimize.h index 5bd9557..26717c7 100755 --- a/components/ToolsGroup/JpgOptimize/cpp/jpgoptimize.h +++ b/components/ToolsGroup/JpgOptimize/cpp/jpgoptimize.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_TOOLSGROUP_JPGOPTIMIZE_CPP_JPGOPTIMIZE_H__ -#define __GROUP_TOOLSGROUP_JPGOPTIMIZE_CPP_JPGOPTIMIZE_H__ +#ifndef GROUP_TOOLSGROUP_JPGOPTIMIZE_CPP_JPGOPTIMIZE_H_ +#define GROUP_TOOLSGROUP_JPGOPTIMIZE_CPP_JPGOPTIMIZE_H_ // C++ lib import #include @@ -71,4 +71,4 @@ public slots: } -#endif//__GROUP_TOOLSGROUP_JPGOPTIMIZE_CPP_JPGOPTIMIZE_H__ +#endif//GROUP_TOOLSGROUP_JPGOPTIMIZE_CPP_JPGOPTIMIZE_H_ diff --git a/components/ToolsGroup/LinesStatistics/cpp/linesstatistics.h b/components/ToolsGroup/LinesStatistics/cpp/linesstatistics.h index c054722..fe61648 100755 --- a/components/ToolsGroup/LinesStatistics/cpp/linesstatistics.h +++ b/components/ToolsGroup/LinesStatistics/cpp/linesstatistics.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_TOOLSGROUP_LINESSTATISTICS_CPP_LINESSTATISTICS_H__ -#define __GROUP_TOOLSGROUP_LINESSTATISTICS_CPP_LINESSTATISTICS_H__ +#ifndef GROUP_TOOLSGROUP_LINESSTATISTICS_CPP_LINESSTATISTICS_H_ +#define GROUP_TOOLSGROUP_LINESSTATISTICS_CPP_LINESSTATISTICS_H_ // Qt lib import #include @@ -43,4 +43,4 @@ public slots: } -#endif//__GROUP_TOOLSGROUP_LINESSTATISTICS_CPP_LINESSTATISTICS_H__ +#endif//GROUP_TOOLSGROUP_LINESSTATISTICS_CPP_LINESSTATISTICS_H_ diff --git a/components/ToolsGroup/PngOptimize/cpp/pngoptimize.h b/components/ToolsGroup/PngOptimize/cpp/pngoptimize.h index 8987c37..4422627 100755 --- a/components/ToolsGroup/PngOptimize/cpp/pngoptimize.h +++ b/components/ToolsGroup/PngOptimize/cpp/pngoptimize.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_TOOLSGROUP_PNGOPTIMIZE_CPP_PNGOPTIMIZE_H__ -#define __GROUP_TOOLSGROUP_PNGOPTIMIZE_CPP_PNGOPTIMIZE_H__ +#ifndef GROUP_TOOLSGROUP_PNGOPTIMIZE_CPP_PNGOPTIMIZE_H_ +#define GROUP_TOOLSGROUP_PNGOPTIMIZE_CPP_PNGOPTIMIZE_H_ // C++ lib import #include @@ -71,4 +71,4 @@ public slots: } -#endif//__GROUP_TOOLSGROUP_PNGOPTIMIZE_CPP_PNGOPTIMIZE_H__ +#endif//GROUP_TOOLSGROUP_PNGOPTIMIZE_CPP_PNGOPTIMIZE_H_ diff --git a/components/ToolsGroup/QRCodeReader/cpp/qrcodereader.h b/components/ToolsGroup/QRCodeReader/cpp/qrcodereader.h index 3bc7446..4362d51 100755 --- a/components/ToolsGroup/QRCodeReader/cpp/qrcodereader.h +++ b/components/ToolsGroup/QRCodeReader/cpp/qrcodereader.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __GROUP_MAKEGROUP_QRCODEREADER_CPP_QRCODEREADER_H__ -#define __GROUP_MAKEGROUP_QRCODEREADER_CPP_QRCODEREADER_H__ +#ifndef GROUP_MAKEGROUP_QRCODEREADER_CPP_QRCODEREADER_H_ +#define GROUP_MAKEGROUP_QRCODEREADER_CPP_QRCODEREADER_H_ // Qt lib import #include @@ -51,4 +51,4 @@ public slots: } -#endif//__GROUP_MAKEGROUP_QRCODEREADER_CPP_QRCODEREADER_H__ +#endif//GROUP_MAKEGROUP_QRCODEREADER_CPP_QRCODEREADER_H_ diff --git a/components/ToolsGroup/toolsgroup.h b/components/ToolsGroup/toolsgroup.h index d52d904..167a10b 100755 --- a/components/ToolsGroup/toolsgroup.h +++ b/components/ToolsGroup/toolsgroup.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __TOOLSGROUP_TOOLSGROUP_H__ -#define __TOOLSGROUP_TOOLSGROUP_H__ +#ifndef TOOLSGROUP_TOOLSGROUP_H_ +#define TOOLSGROUP_TOOLSGROUP_H_ // ToolsGroup lib import #include @@ -37,4 +37,4 @@ QRCODEREADER_INITIALIZA; #endif -#endif//__TOOLSGROUP_TOOLSGROUP_H__ +#endif//TOOLSGROUP_TOOLSGROUP_H_ diff --git a/components/WelcomeGroup/cpp/welcome.h b/components/WelcomeGroup/cpp/welcome.h index ed2fb52..1ded2e8 100755 --- a/components/WelcomeGroup/cpp/welcome.h +++ b/components/WelcomeGroup/cpp/welcome.h @@ -1,5 +1,5 @@ -#ifndef __GROUP_WELCOMEGROUP_CPP_WELCOME_H__ -#define __GROUP_WELCOMEGROUP_CPP_WELCOME_H__ +#ifndef GROUP_WELCOMEGROUP_CPP_WELCOME_H_ +#define GROUP_WELCOMEGROUP_CPP_WELCOME_H_ // JQToolsLibrary import #include "JQToolsLibrary.h" @@ -30,4 +30,4 @@ public slots: } -#endif//__GROUP_WELCOME_CPP_WELCOME_H__ +#endif//GROUP_WELCOMEGROUP_CPP_WELCOME_H_ diff --git a/components/WelcomeGroup/welcomegroup.h b/components/WelcomeGroup/welcomegroup.h index 624763d..d66c12a 100755 --- a/components/WelcomeGroup/welcomegroup.h +++ b/components/WelcomeGroup/welcomegroup.h @@ -10,8 +10,8 @@ GitHub: https://github.com/188080501/ */ -#ifndef __WELCOMEGROUP_WELCOMEGROUP_H__ -#define __WELCOMEGROUP_WELCOMEGROUP_H__ +#ifndef WELCOMEGROUP_WELCOMEGROUP_H_ +#define WELCOMEGROUP_WELCOMEGROUP_H_ // WelcomeGroup lib import #include "welcome.h" @@ -19,4 +19,4 @@ #define WELCOMEGROUP_INITIALIZA \ WELCOME_INITIALIZA; -#endif//__WELCOMEGROUP_WELCOMEGROUP_H__ +#endif//WELCOMEGROUP_WELCOMEGROUP_H_ diff --git a/cpp/main.cpp b/cpp/main.cpp index 689bcc8..6019be2 100755 --- a/cpp/main.cpp +++ b/cpp/main.cpp @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) // Group initializa WELCOMEGROUP_INITIALIZA; TEXTGROUP_INITIALIZA; - CALCULATEGROUP__INITIALIZA; + CALCULATEGROUP_INITIALIZA; MAKEGROUP_INITIALIZA TOOLSGROUP_INITIALIZA; QTGROUP_INITIALIZA; diff --git a/lib/JQLibrary/JQLibrary.pri b/lib/JQLibrary/JQLibrary.pri index e0e76c5..1b9bc37 100644 --- a/lib/JQLibrary/JQLibrary.pri +++ b/lib/JQLibrary/JQLibrary.pri @@ -22,6 +22,12 @@ CONFIG *= c++11 INCLUDEPATH *= \ $$PWD/include/ +exists( $$PWD/src/JQBarcode.cpp ) { + + SOURCES *= $$PWD/src/JQBarcode.cpp + HEADERS *= $$PWD/include/JQBarcode.h +} + contains( QT, bluetooth ) { exists( $$PWD/src/JQBluetooth.cpp ) { diff --git a/lib/JQLibrary/include/JQBarcode.h b/lib/JQLibrary/include/JQBarcode.h new file mode 100644 index 0000000..7c178f1 --- /dev/null +++ b/lib/JQLibrary/include/JQBarcode.h @@ -0,0 +1,43 @@ +/* + This file is part of JQLibrary + + Copyright: Jason + + Contact email: 188080501@qq.com + + GNU Lesser General Public License Usage + Alternatively, this file may be used under the terms of the GNU Lesser + General Public License version 2.1 or version 3 as published by the Free + Software Foundation and appearing in the file LICENSE.LGPLv21 and + LICENSE.LGPLv3 included in the packaging of this file. Please review the + following information to ensure the GNU Lesser General Public License + requirements will be met: https://www.gnu.org/licenses/lgpl.html and + http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +*/ + +#ifndef JQLIBRARY_JQBARCODE_H_ +#define JQLIBRARY_JQBARCODE_H_ + +// Qt lib import +#include + +class JQBarcode +{ +public: + static qint64 makeNumber(const qint64 &rawNumebr); + + static QImage makeBarcode(const qint64 &number); + +private: + static void paintByteA(QImage &image, const int &number, const int &pos); + + static void paintByteB(QImage &image, const int &number, const int &pos); + + static void paintByteC(QImage &image, const int &number, const int &pos); + + static void paintLines(QImage &image, const QString &key, const int &pos, const int &len = 100); + + static void paintLine(QImage &image, const bool &black, const int &pos, const int &len = 100); +}; + +#endif//JQLIBRARY_JQBARCODE_H_ diff --git a/lib/JQLibrary/src/JQBarcode.cpp b/lib/JQLibrary/src/JQBarcode.cpp new file mode 100644 index 0000000..4a79d4e --- /dev/null +++ b/lib/JQLibrary/src/JQBarcode.cpp @@ -0,0 +1,156 @@ +/* + This file is part of JQLibrary + + Copyright: Jason + + Contact email: 188080501@qq.com + + GNU Lesser General Public License Usage + Alternatively, this file may be used under the terms of the GNU Lesser + General Public License version 2.1 or version 3 as published by the Free + Software Foundation and appearing in the file LICENSE.LGPLv21 and + LICENSE.LGPLv3 included in the packaging of this file. Please review the + following information to ensure the GNU Lesser General Public License + requirements will be met: https://www.gnu.org/licenses/lgpl.html and + http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +*/ + +#include "JQBarcode.h" + +// Qt lib import +#include +#include + +qint64 JQBarcode::makeNumber(const qint64 &rawNumebr) +{ + const auto &n1 = rawNumebr / 100000000000 % 10; + const auto &n2 = rawNumebr / 10000000000 % 10; + const auto &n3 = rawNumebr / 1000000000 % 10; + const auto &n4 = rawNumebr / 100000000 % 10; + const auto &n5 = rawNumebr / 10000000 % 10; + const auto &n6 = rawNumebr / 1000000 % 10; + const auto &n7 = rawNumebr / 100000 % 10; + const auto &n8 = rawNumebr / 10000 % 10; + const auto &n9 = rawNumebr / 1000 % 10; + const auto &n10 = rawNumebr / 100 % 10; + const auto &n11 = rawNumebr / 10 % 10; + const auto &n12 = rawNumebr / 1 % 10; + const auto &&c1 = n1 + n3 + n5 + n7 + n9 + n11; + const auto &&c2 = ( n2 + n4 + n6 + n8 + n10 + n12 ) * 3; + const auto &&cc = c1 + c2; + const auto &&c = qAbs( 10 - ( cc % 10 ) ); + +// qDebug() << n1 << n2 << n3 << n4 << n5 << n6 << n7 << n8 << n9 << n10 << n11 << n12; +// qDebug() << cc; + + return rawNumebr * 10 + c; +} + +QImage JQBarcode::makeBarcode(const qint64 &number) +{ + QImage image( QSize( 190, 120 ), QImage::Format_ARGB32 ); + image.fill( qRgba( 0, 0, 0, 0 ) ); + + auto pos = 0; + + JQBarcode::paintLine( image, true, pos, 120 ); pos += 1; + JQBarcode::paintLine( image, false, pos, 120 ); pos += 1; + JQBarcode::paintLine( image, true, pos, 120 ); pos += 1; + + JQBarcode::paintByteA( image, number / 100000000000 % 10, pos ); pos += 7; + JQBarcode::paintByteB( image, number / 10000000000 % 10, pos ); pos += 7; + JQBarcode::paintByteB( image, number / 1000000000 % 10, pos ); pos += 7; + JQBarcode::paintByteB( image, number / 100000000 % 10, pos ); pos += 7; + JQBarcode::paintByteA( image, number / 10000000 % 10, pos ); pos += 7; + JQBarcode::paintByteA( image, number / 1000000 % 10, pos ); pos += 7; + + JQBarcode::paintLine( image, false, pos, 120 ); pos += 1; + JQBarcode::paintLine( image, true, pos, 120 ); pos += 1; + JQBarcode::paintLine( image, false, pos, 120 ); pos += 1; + JQBarcode::paintLine( image, true, pos, 120 ); pos += 1; + JQBarcode::paintLine( image, false, pos, 120 ); pos += 1; + + JQBarcode::paintByteC( image, number / 100000 % 10, pos ); pos += 7; + JQBarcode::paintByteC( image, number / 10000 % 10, pos ); pos += 7; + JQBarcode::paintByteC( image, number / 1000 % 10, pos ); pos += 7; + JQBarcode::paintByteC( image, number / 100 % 10, pos ); pos += 7; + JQBarcode::paintByteC( image, number / 10 % 10, pos ); pos += 7; + JQBarcode::paintByteC( image, number % 10, pos ); pos += 7; + + JQBarcode::paintLine( image, true, pos, 120 ); pos += 1; + JQBarcode::paintLine( image, false, pos, 120 ); pos += 1; + JQBarcode::paintLine( image, true, pos, 120 ); + + return image; +} + +void JQBarcode::paintByteA(QImage &image, const int &number, const int &pos) +{ + switch( number ) + { + case 0: JQBarcode::paintLines( image, "0001101", pos ); break; + case 1: JQBarcode::paintLines( image, "0011001", pos ); break; + case 2: JQBarcode::paintLines( image, "0010011", pos ); break; + case 3: JQBarcode::paintLines( image, "0111101", pos ); break; + case 4: JQBarcode::paintLines( image, "0100011", pos ); break; + case 5: JQBarcode::paintLines( image, "0110001", pos ); break; + case 6: JQBarcode::paintLines( image, "0101111", pos ); break; + case 7: JQBarcode::paintLines( image, "0111011", pos ); break; + case 8: JQBarcode::paintLines( image, "0110111", pos ); break; + case 9: JQBarcode::paintLines( image, "0001011", pos ); break; + default: qDebug() << "JQBarcode::paintByteA: unexpected number:" << number; break; + } +} + +void JQBarcode::paintByteB(QImage &image, const int &number, const int &pos) +{ + switch( number ) + { + case 0: JQBarcode::paintLines( image, "0100111", pos ); break; + case 1: JQBarcode::paintLines( image, "0110011", pos ); break; + case 2: JQBarcode::paintLines( image, "0011011", pos ); break; + case 3: JQBarcode::paintLines( image, "0100001", pos ); break; + case 4: JQBarcode::paintLines( image, "0011101", pos ); break; + case 5: JQBarcode::paintLines( image, "0111001", pos ); break; + case 6: JQBarcode::paintLines( image, "0000101", pos ); break; + case 7: JQBarcode::paintLines( image, "0010001", pos ); break; + case 8: JQBarcode::paintLines( image, "0001001", pos ); break; + case 9: JQBarcode::paintLines( image, "0010111", pos ); break; + default: qDebug() << "JQBarcode::paintByteB: unexpected number:" << number; break; + } +} + +void JQBarcode::paintByteC(QImage &image, const int &number, const int &pos) +{ + switch( number ) + { + case 0: JQBarcode::paintLines( image, "1110010", pos ); break; + case 1: JQBarcode::paintLines( image, "1100110", pos ); break; + case 2: JQBarcode::paintLines( image, "1101100", pos ); break; + case 3: JQBarcode::paintLines( image, "1000010", pos ); break; + case 4: JQBarcode::paintLines( image, "1011100", pos ); break; + case 5: JQBarcode::paintLines( image, "1001110", pos ); break; + case 6: JQBarcode::paintLines( image, "1010000", pos ); break; + case 7: JQBarcode::paintLines( image, "1000100", pos ); break; + case 8: JQBarcode::paintLines( image, "1001000", pos ); break; + case 9: JQBarcode::paintLines( image, "1110100", pos ); break; + default: qDebug() << "JQBarcode::paintByteC: unexpected number:" << number; break; + } +} + +void JQBarcode::paintLines(QImage &image, const QString &key, const int &pos, const int &len) +{ + for ( auto index = 0; index < 7; ++index ) + { + JQBarcode::paintLine( image, key[ index ] == '1', pos + index, len); + } +} + +void JQBarcode::paintLine(QImage &image, const bool &black, const int &pos, const int &len) +{ + for ( auto index = 0; index < len; ++index ) + { + image.setPixel( pos * 2, index, ( black ) ? ( qRgba( 0, 0, 0, 255 ) ) : ( qRgba( 0, 0, 0, 0 ) ) ); + image.setPixel( pos * 2 + 1, index, ( black ) ? ( qRgba( 0, 0, 0, 255 ) ) : ( qRgba( 0, 0, 0, 0 ) ) ); + } +} diff --git a/lib/JQToolsLibrary/include/JQToolsLibrary.h b/lib/JQToolsLibrary/include/JQToolsLibrary.h index f200131..b960609 100755 --- a/lib/JQToolsLibrary/include/JQToolsLibrary.h +++ b/lib/JQToolsLibrary/include/JQToolsLibrary.h @@ -17,7 +17,7 @@ #include #include -#define JQTOOLS_VERSIONSTRING "17.6.17" +#define JQTOOLS_VERSIONSTRING "17.9.1" class QQmlApplicationEngine; diff --git a/qml/main.qml b/qml/main.qml index 4612781..b2b02f5 100755 --- a/qml/main.qml +++ b/qml/main.qml @@ -65,7 +65,8 @@ ApplicationWindow { [ { bookmarkName: "图标生成器", titleName: "图标生成器", qrcLocation: "qrc:/IconMaker/IconMaker.qml" }, { bookmarkName: "图标字体转PNG", titleName: "图标字体转PNG", qrcLocation: "qrc:/FontToPng/FontToPng.qml" }, - { bookmarkName: "二维码生成器", titleName: "二维码生成器", qrcLocation: "qrc:/QRCodeMaker/QRCodeMaker.qml" } + { bookmarkName: "二维码生成器", titleName: "二维码生成器", qrcLocation: "qrc:/QRCodeMaker/QRCodeMaker.qml" }, + { bookmarkName: "条形码生成器", titleName: "条形码生成器", qrcLocation: "qrc:/BarcodeMaker/BarcodeMaker.qml" } ] }, {