Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F86186
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/3rdparty/qqrencode/qqrencode.cpp b/3rdparty/qqrencode/qqrencode.cpp
index b9ed94e..280ed0e 100644
--- a/3rdparty/qqrencode/qqrencode.cpp
+++ b/3rdparty/qqrencode/qqrencode.cpp
@@ -1,219 +1,218 @@
// license not clear on github. assumed lgpl due to qt licensing model
// have asked OP for clarification
// https://github.com/Mistyazur/QQREncode
#include "qqrencode.h"
#include "qqrencode_p.h"
#include <QDateTime>
-#include <QSvgGenerator>
#define INCHES_PER_METER (100.0/2.54)
QQREncodePrivate::~QQREncodePrivate()
{
QRcode_free(m_code);
}
void QQREncodePrivate::paint(QPainter &painter)
{
unsigned char *row, *p;
int x, y;
int symwidth = m_code->width + m_margin * 2;
painter.setClipRect(QRect(0,0,symwidth, symwidth));
painter.setPen(m_pen);
painter.setBrush(m_fg);
/* Make solid background */
painter.fillRect(QRect(0, 0, symwidth, symwidth), m_bg);
/* Write data */
p = m_code->data;
for(y=0; y<m_code->width; y++) {
row = (p+(y*m_code->width));
/* no RLE */
for(x=0; x<m_code->width; x++) {
if(*(row+x)&0x1) {
painter.drawRect(m_margin + x, m_margin + y, 1, 1);
}
}
}
}
QQREncode::QQREncode()
: d_ptr(new QQREncodePrivate(this))
{
}
QQREncode::~QQREncode()
{
}
void QQREncode::setLevel(QQREncode::ErrorCorrectionLevel value)
{
Q_D(QQREncode);
switch (value) {
case LOW:
d->m_level = QR_ECLEVEL_L;
break;
case MEDIUM:
d->m_level = QR_ECLEVEL_M;
break;
case QUARTILE:
d->m_level = QR_ECLEVEL_Q;
break;
case HIGH:
d->m_level = QR_ECLEVEL_H;
break;
}
}
QQREncode::ErrorCorrectionLevel QQREncode::getLevel() const
{
Q_D(const QQREncode);
switch (d->m_level) {
case QR_ECLEVEL_L:
return LOW;
case QR_ECLEVEL_M:
return MEDIUM;
case QR_ECLEVEL_Q:
return QUARTILE;
case QR_ECLEVEL_H:
return HIGH;
}
return LOW;
}
//bool QQREncode::encode(QString code, QString output)
//{
// if (code.isEmpty() || output.isEmpty()) {
// return false;
// }
// QString program = "./qrencode.exe";
// QStringList arguments;
// arguments << "-t" << "PNG";
// arguments << "-o" << output;
// arguments << code;
// QProcess *myProcess = new QProcess(this);
// myProcess->start(program, arguments);
// return myProcess->waitForFinished();
//}
void QQREncode::setVersion(int version)
{
Q_D(QQREncode);
// 1 - 40
if (version > 0 && version <= 40)
d->m_version = version;
}
int QQREncode::version() const
{
Q_D(const QQREncode);
return d->m_version;
}
void QQREncode::setMargin(int value)
{
Q_D(QQREncode);
if (value > -1)
d->m_margin = value;
}
int QQREncode::margin() const
{
Q_D(const QQREncode);
return d->m_margin;
}
void QQREncode::setMicro(bool value)
{
Q_D(QQREncode);
d->m_micro = (value) ? 1 : 0;
}
void QQREncode::setBackground(QColor color)
{
Q_D(QQREncode);
d->m_bg.setColor(color);
}
void QQREncode::setForeground(QColor color)
{
Q_D(QQREncode);
d->m_fg.setColor(color);
d->m_pen.setColor(color);
}
bool QQREncode::encode(QByteArray input)
{
Q_D(QQREncode);
QRcode *c = NULL;
if (input.isEmpty()) return false;
if (d->m_micro) {
c = QRcode_encodeDataMQR(input.size(), (const unsigned char*)input.constData(),
d->m_version, d->m_level);
} else {
c = QRcode_encodeData(input.size(), (const unsigned char*)input.constData(),
d->m_version, d->m_level);
}
if (c == NULL) {
return false;
}
if (d->m_code) QRcode_free(d->m_code);
d->m_code = c;
return true;
}
bool QQREncode::encode(QString input, bool caseSensitive)
{
Q_D(QQREncode);
if (input.isEmpty()) return false;
QRcode *c = NULL;
if (d->m_micro) {
c = QRcode_encodeStringMQR(input.toStdString().c_str(),
d->m_version,
d->m_level,
QR_MODE_8,
(caseSensitive) ? 1 : 0);
} else {
c = QRcode_encodeString(input.toStdString().c_str(),
d->m_version,
d->m_level,
QR_MODE_8,
(caseSensitive) ? 1 : 0);
}
if (c == NULL) {
return false;
}
if (d->m_code) QRcode_free(d->m_code);
d->m_code = c;
return true;
}
QImage QQREncode::toQImage(int size)
{
Q_D(QQREncode);
if (size < 0) throw std::invalid_argument("Invalid size");
if (d->m_code == NULL) {
std::logic_error("No qr code to convert");
}
int symwidth = d->m_code->width + d->m_margin * 2;
QImage result(QSize(symwidth, symwidth), QImage::Format_Mono);
result.fill(Qt::white);
QPainter painter;
painter.begin(&result);
d->paint(painter);
painter.end();
if (size > 0)
return result.scaled(size, size);
return result;
}
diff --git a/barcoder.pro b/barcoder.pro
index a69150c..bc75967 100644
--- a/barcoder.pro
+++ b/barcoder.pro
@@ -1,111 +1,112 @@
#-------------------------------------------------
#
# Project created by QtCreator 2017-02-16T22:41:52
#
#-------------------------------------------------
-# svg?
+
QT += core gui
+# this kind of conflicts with a later option
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = barcoder
TEMPLATE = app
VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_BUILD = 1
DEFINES += "VERSION_MAJOR=$$VERSION_MAJOR"\
"VERSION_MINOR=$$VERSION_MINOR"\
"VERSION_BUILD=$$VERSION_BUILD"
#Target version
VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_BUILD}
DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050000
INCLUDEPATH += 3rdparty/qqrencode
LIBS += -lqrencode -ldmtx
SOURCES += main.cpp\
mainwindow.cpp\
3rdparty/qqrencode/qqrencode.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
unix {
#VARIABLES
isEmpty(PREFIX) {
PREFIX = /usr #QT_INSTALL_PREFIX
}
BINDIR = $$PREFIX/bin
DATADIR =$$PREFIX/share
DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\"
# MAKE tarball
tarball.commands = git archive --prefix $${TARGET}_$${VERSION}/ -o $${TARGET}_$${VERSION}.orig.tar.gz HEAD . \":(exclude)debian\" \":(exclude)data\"
tarball.depends = .git
tarball.path = .
# MAKE zip
zip.commands = git archive --prefix $${TARGET}_$${VERSION}/ -o $${TARGET}_$${VERSION}.orig.zip HEAD . \":(exclude)debian\" \":(exclude)data\"
zip.depends = .git
zip.path = .
mangz.depends = .git
mangz.commands = gzip -c -9 docs/$${TARGET}.1 > docs/$${TARGET}.1.gz
mangz.files = docs/*.1
mangz.path = /usr/share/man/man1
man.depends = mangz
man.path = /usr/share/man/man1
man.files = docs/*.?.gz
# i don't provide command for icon but something like convert barcoder.xcf barcoder-256.png
icon.path = /usr/share/$$TARGET
icon.files = $$PWD/$${TARGET}-256.png
desktop.depends = icon
desktop.path = /usr/share/applications/
desktop.files = $$PWD/$${TARGET}.desktop
QMAKE_CLEAN += $$PWD/*zip $$PWD/*.tar.gz $$PWD/*.deb
QMAKE_EXTRA_TARGETS += tarball zip deb man mangz desktop icon
#MAKE INSTALL
INSTALLS += target
target += mangz man desktop icon
target.path = $$BINDIR
deb.target = deb
deb.path = .
deb.depends = debian/control
deb.commands = dpkg-buildpackage -uc -us
}
DISTFILES += docs/*gz \
$${TARGET}.desktop \
$${TARGET}-256.png
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Sep 11, 8:20 PM (23 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42721
Default Alt Text
(7 KB)
Attached To
Mode
R4 barcoder
Attached
Detach File
Event Timeline
Log In to Comment