Page MenuHomePhabricator (Chris)

No OneTemporary

Size
14 KB
Referenced Files
None
Subscribers
None
diff --git a/3rdparty/qqrencode/qqrencode.cpp b/3rdparty/qqrencode/qqrencode.cpp
index 63650d3..15a9da5 100644
--- a/3rdparty/qqrencode/qqrencode.cpp
+++ b/3rdparty/qqrencode/qqrencode.cpp
@@ -1,95 +1,95 @@
// licence isn't clear on github but many files and commits have
// the very unsurprising LGPL2.1+ so I think that's OP's intent
// https://github.com/Mistyazur/QQREncode
#include "qqrencode.h"
#include "qqrencode_p.h"
QQREncodePrivate::~QQREncodePrivate()
{
QRcode_free(m_code);
}
void QQREncodePrivate::paint(QPainter &painter)
{
int symwidth = m_code->width + m_margin * 2;
- painter.setClipRect(QRect(0,0,symwidth, symwidth));
+ 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 */
unsigned char *p = m_code->data;
- for(int y=0; y<m_code->width; y++) {
- unsigned char *row = (p+(y*m_code->width));
+ for (int y = 0; y < m_code->width; y++) {
+ unsigned char *row = (p + (y * m_code->width));
/* no RLE */
- for(int x=0; x<m_code->width; x++) {
- if(*(row+x)&0x1) {
+ for (int 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()
{
}
-
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 {
+ }
+ else {
c = QRcode_encodeString(input.toStdString().c_str(),
d->m_version,
d->m_level,
QR_MODE_8,
(caseSensitive) ? 1 : 0);
}
if (!c) {
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) {
throw 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/3rdparty/qqrencode/qqrencode.h b/3rdparty/qqrencode/qqrencode.h
index e2e33f7..4f3caf6 100644
--- a/3rdparty/qqrencode/qqrencode.h
+++ b/3rdparty/qqrencode/qqrencode.h
@@ -1,49 +1,50 @@
#ifndef QQRENCODE_H
#define QQRENCODE_H
#include <QtCore>
class QQREncodePrivate;
class QQREncode
{
Q_GADGET
Q_ENUMS(ErrorCorrectionLevel)
public:
- enum ErrorCorrectionLevel {
+ enum ErrorCorrectionLevel
+ {
LOW,
MEDIUM,
QUARTILE,
HIGH
};
QQREncode();
~QQREncode();
void setLevel(ErrorCorrectionLevel value);
ErrorCorrectionLevel getLevel() const;
void setVersion(int version);
int version() const;
void setMargin(int value);
int margin() const;
void setMicro(bool value);
bool isMicro() const;
void setBackground(QColor color);
void setForeground(QColor color);
bool encode(QByteArray input);
- bool encode(QString input, bool caseSensitive=true);
- bool encodeKanji(QByteArray input, bool caseSensitive=true);
+ bool encode(QString input, bool caseSensitive = true);
+ bool encodeKanji(QByteArray input, bool caseSensitive = true);
- QImage toQImage(int size=0);
+ QImage toQImage(int size = 0);
// ToDo: encode structured, rle
private:
Q_DISABLE_COPY(QQREncode)
QScopedPointer<QQREncodePrivate> d_ptr;
Q_DECLARE_PRIVATE(QQREncode)
};
#endif // QQRENCODE_H
diff --git a/3rdparty/qqrencode/qqrencode_p.h b/3rdparty/qqrencode/qqrencode_p.h
index 1a41e8d..cce7095 100644
--- a/3rdparty/qqrencode/qqrencode_p.h
+++ b/3rdparty/qqrencode/qqrencode_p.h
@@ -1,42 +1,42 @@
#ifndef QQRENCODE_P_H
#define QQRENCODE_P_H
#include "qqrencode.h"
#include <qrencode.h>
#include <QPainter>
class QQREncodePrivate
{
Q_DECLARE_PUBLIC(QQREncode)
public:
QQREncodePrivate(QQREncode *qqrencode)
- : q_ptr(qqrencode), m_code(NULL), m_level(QR_ECLEVEL_L),m_version(1), m_margin(4), m_micro(0),
+ : q_ptr(qqrencode), m_code(NULL), m_level(QR_ECLEVEL_L), m_version(1), m_margin(4), m_micro(0),
m_pen(Qt::black, 0.1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin), m_bg(Qt::white),
m_fg(Qt::black)
{
}
~QQREncodePrivate();
void paint(QPainter &painter);
QQREncode *q_ptr;
QRcode *m_code;
QRecLevel m_level;
int m_version;
int m_margin;
int m_micro;
QPen m_pen;
QBrush m_bg;
QBrush m_fg;
// ToDo: Corrupted SVG when setting the resolution
// int m_dpi = 72;
// ToDo: structured and rle features
// int m_structured = 0;
// int m_rle = 0;
};
#endif // QQRENCODE_P_H
diff --git a/barcoder.pro b/barcoder.pro
index de040c9..c9ae0bd 100644
--- a/barcoder.pro
+++ b/barcoder.pro
@@ -1,109 +1,109 @@
#-------------------------------------------------
#
# Project created by QtCreator 2017-02-16T22:41:52
#
#-------------------------------------------------
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_MINOR = 1
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 += VERSION_S='\\"$${VERSION}\\"'
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.path = .
# MAKE zip
zip.commands = git archive --prefix $${TARGET}_$${VERSION}/ -o $${TARGET}_$${VERSION}.orig.zip HEAD . \":(exclude)debian\" \":(exclude)data\"
zip.path = .
mangz.commands = gzip -c -9 docs/$${TARGET}.1 > docs/$${TARGET}.1.gz
mangz.files = docs/*.1
mangz.path = $$DATADIR/man/man1
man.depends = mangz
man.path = $$DATADIR/man/man1
man.files = docs/*.?.gz
# i don't provide command for icon but something like convert barcoder.xcf barcoder-256.png
icon.path = $$DATADIR/icons/hicolor/128x128/apps/
icon.files = $$PWD/$${TARGET}.png
desktop.depends = icon
desktop.path = $$DATADIR/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 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}.png
diff --git a/debian/copyright b/debian/copyright
index 60d3180..67c62cc 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,66 +1,66 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: <https://scm.opengress.net/diffusion/4/>
Files: *
-Copyright: 2020 barcoder team <dpkg@chris-nz.com>
+Copyright: 2021 barcoder team <dpkg@chris-nz.com>
License: MIT
Files: 3rdparty/qqrencode/*
Copyright: 2013 Kentaro Fukuchi <kentaro@fukuchi.org>
License: LGPL-2.1+
Files: barcoder.png
Copyright: 2015 Palo Kisa <palo.kisa@gmail.com>
2020 barcoder team <dpkg@chris-nz.com>
License: GPL-2.0+
License: GPL-2.0+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
License: MIT
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License: LGPL-2.1+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
diff --git a/mainwindow.cpp b/mainwindow.cpp
index de9072c..169749a 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -1,65 +1,67 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QProcess>
#include <QClipboard>
#include "qqrencode.h"
#include <dmtx.h>
-MainWindow::MainWindow(QWidget *parent) :
+MainWindow::MainWindow(QWidget *parent)
+ :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// tricky: don't need to use settings object because no actual settings exist
- this->setWindowTitle(this->windowTitle()+" "+VERSION_S);
+ this->setWindowTitle(this->windowTitle() + " " + VERSION_S);
this->setWindowFlags(Qt::WindowStaysOnTopHint);
// the text that I want encoded
const QString inp = QApplication::arguments().value(-1, QGuiApplication::clipboard()->text());
// DATAMATRIX STUFF START
int err = 0;
int len = inp.length();
// segfault for text longer than this. so dont bother
if (len > 1595) {
// err = 1596;
- } else {
+ }
+ else {
DmtxEncode *im = dmtxEncodeCreate();
/* Read input data into buffer */
- err = dmtxEncodeDataMatrix(im, len, (unsigned char*)inp.toLocal8Bit().data());
+ err = dmtxEncodeDataMatrix(im, len, (unsigned char *) inp.toLocal8Bit().data());
QImage dmatrix(im->image->pxl, im->image->width, im->image->height, QImage::Format_RGB888);
- ui->label->setPixmap(QPixmap::fromImage(dmatrix).scaled(240,240));
+ ui->label->setPixmap(QPixmap::fromImage(dmatrix).scaled(240, 240));
dmtxEncodeDestroy(&im);
}
// DATAMATRIX STUFF END
// QRCODE STUFF START
QQREncode encoder;
encoder.encode(inp, true);
- QImage qrcode = encoder.toQImage().scaled(240,240);
+ QImage qrcode = encoder.toQImage().scaled(240, 240);
ui->label_2->setPixmap(QPixmap::fromImage(qrcode));
// QRCODE STUFF END
// COMPENSATE FOR DMATRIX FAILURE USING INVERTED QRCODE START
if (err == 0) {
qrcode.invertPixels();
ui->label->setPixmap(QPixmap::fromImage(qrcode));
}
// COMPENSATE FOR DMATRIX FAILURE USING INVERTED QRCODE END
this->updateGeometry();
}
-void MainWindow::mousePressEvent ( QMouseEvent * event )
+void MainWindow::mousePressEvent(QMouseEvent*)
{
Q_UNUSED(event);
QApplication::quit();
}
MainWindow::~MainWindow()
{
delete ui;
}
diff --git a/mainwindow.h b/mainwindow.h
index e07018d..411be55 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -1,23 +1,24 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
-namespace Ui {
+namespace Ui
+{
class MainWindow;
}
-class MainWindow : public QMainWindow
+class MainWindow: public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
void mousePressEvent(QMouseEvent *);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

File Metadata

Mime Type
text/x-diff
Expires
Fri, Sep 12, 6:19 AM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42827
Default Alt Text
(14 KB)

Event Timeline