Skip to content

Commit

Permalink
增加新功能 & 细节修改
Browse files Browse the repository at this point in the history
  • Loading branch information
188080501 committed Sep 1, 2017
1 parent f81096c commit 2d3d79d
Show file tree
Hide file tree
Showing 37 changed files with 547 additions and 72 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ https://github.com/188080501/JQNetwork
制作类|图标生成器|已完成
制作类|图标字体转PNG|已完成
制作类|二维码制作器|已完成
制作类|条形码制作器|已完成
| |
工具类|代码行数统计|已完成
工具类|PNG图片压缩|已完成
Expand Down
6 changes: 3 additions & 3 deletions components/CalculateGroup/HashCalculate/cpp/hashcalculate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -92,4 +92,4 @@ public slots:

}

#endif//__GROUP_CALCULATEGROUP_HASHCALCULATE_CPP_HASHCALCULATE_H__
#endif//GROUP_CALCULATEGROUP_HASHCALCULATE_CPP_HASHCALCULATE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -42,4 +42,4 @@ public slots:

}

#endif//__GROUP_CALCULATEGROUP_TIMESTAMPTRANSFORM_CPP_TIMESTAMPTRANSFORM_H__
#endif//GROUP_CALCULATEGROUP_TIMESTAMPTRANSFORM_CPP_TIMESTAMPTRANSFORM_H_
8 changes: 4 additions & 4 deletions components/CalculateGroup/calculategroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <HashCalculate>
#include <TimestampTransform>

#define CALCULATEGROUP__INITIALIZA \
#define CALCULATEGROUP_INITIALIZA \
HASHCALCULATE_INITIALIZA; \
TTIMESTAMPTRANSFORM_INITIALIZA;

#endif//__CALCULATEGROUP_CALCULATEGROUP_H__
#endif//CALCULATEGROUP_CALCULATEGROUP_H_
23 changes: 23 additions & 0 deletions components/MakeGroup/BarcodeMaker/BarcodeMaker.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# This file is part of JQTools
#
# Project introduce: https://github.com/188080501/JQTools
#
# Copyright: Jason
#
# Contact email: [email protected]
#
# GitHub: https://github.com/188080501/
#

INCLUDEPATH += \
$$PWD/cpp/

HEADERS += \
$$PWD/cpp/barcodemaker.h

SOURCES += \
$$PWD/cpp/barcodemaker.cpp

RESOURCES += \
$$PWD/qml/BarcodeMakerQml.qrc
13 changes: 13 additions & 0 deletions components/MakeGroup/BarcodeMaker/cpp/BarcodeMaker
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: [email protected]

GitHub: https://github.com/188080501/
*/

#include "barcodemaker.h"
88 changes: 88 additions & 0 deletions components/MakeGroup/BarcodeMaker/cpp/barcodemaker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
This file is part of JQTools
Project introduce: https://github.com/188080501/JQTools
Copyright: Jason
Contact email: [email protected]
GitHub: https://github.com/188080501/
*/

#include "barcodemaker.h"

// Qt lib import
#include <QDebug>
#include <QQmlApplicationEngine>
#include <QFileDialog>
#include <QStandardPaths>
#include <QPainter>

// 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 { };
}
}
57 changes: 57 additions & 0 deletions components/MakeGroup/BarcodeMaker/cpp/barcodemaker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
This file is part of JQTools
Project introduce: https://github.com/188080501/JQTools
Copyright: Jason
Contact email: [email protected]
GitHub: https://github.com/188080501/
*/

#ifndef GROUP_MAKEGROUP_BARCODEMAKER_CPP_BARCODEMAKER_H_
#define GROUP_MAKEGROUP_BARCODEMAKER_CPP_BARCODEMAKER_H_

// Qt lib import
#include <QImage>
#include <QQuickImageProvider>

// 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_
78 changes: 78 additions & 0 deletions components/MakeGroup/BarcodeMaker/qml/BarcodeMaker.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
This file is part of JQTools
Project introduce: https://github.com/188080501/JQTools
Copyright: Jason
Contact email: [email protected]
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;
}
}
}
}
}
}
5 changes: 5 additions & 0 deletions components/MakeGroup/BarcodeMaker/qml/BarcodeMakerQml.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/BarcodeMaker">
<file>BarcodeMaker.qml</file>
</qresource>
</RCC>
1 change: 1 addition & 0 deletions components/MakeGroup/MakeGroup.pri
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
1 change: 1 addition & 0 deletions components/MakeGroup/QRCodeMaker/qml/QRCodeMaker.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Item {
anchors.verticalCenterOffset: 50
width: 250
height: 250
fillMode: Image.PreserveAspectFit
source: "image://QRCodeMaker/" + textFieldForLower.text

MaterialButton {
Expand Down
10 changes: 6 additions & 4 deletions components/MakeGroup/makegroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <IconMaker>
#include <FontToPng>
#include <QRCodeMaker>
#include <BarcodeMaker>

#define MAKEGROUP_INITIALIZA \
ICONMAKER_INITIALIZA; \
FONTTOPNG_INITIALIZA; \
QRCODEMAKER_INITIALIZA
QRCODEMAKER_INITIALIZA; \
BARCODEMAKER_INITIALIZA;

#endif//__MAKEGROUP_MAKEGROUP_H__
#endif//MAKEGROUP_MAKEGROUP_H_
6 changes: 3 additions & 3 deletions components/QtGroup/CppFileMaker/cpp/cppfilemaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <functional>
Expand Down Expand Up @@ -56,4 +56,4 @@ public slots:

}

#endif//__GROUP_QTGROUP_CPPFILEMAKER_CPP_CPPFILEMAKER_H__
#endif//GROUP_QTGROUP_CPPFILEMAKER_CPP_CPPFILEMAKER_H_
Loading

0 comments on commit 2d3d79d

Please sign in to comment.