Page MenuHomePhabricator (Chris)

No OneTemporary

Size
21 KB
Referenced Files
None
Subscribers
None
diff --git a/3rdparty/qqrencode/libqtqrencode_global.h b/3rdparty/qqrencode/libqtqrencode_global.h
deleted file mode 100644
index 9ec2bc5..0000000
--- a/3rdparty/qqrencode/libqtqrencode_global.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef LIBQTQRENCODE_GLOBAL_H
-#define LIBQTQRENCODE_GLOBAL_H
-
-#include <QtCore/qglobal.h>
-
-#if defined(LIBQTQRENCODE_LIBRARY)
-# define LIBQTQRENCODESHARED_EXPORT Q_DECL_EXPORT
-#else
-# define LIBQTQRENCODESHARED_EXPORT Q_DECL_IMPORT
-#endif
-
-#endif // LIBQTQRENCODE_GLOBAL_H
diff --git a/3rdparty/qqrencode/qqrencode.cpp b/3rdparty/qqrencode/qqrencode.cpp
index 280ed0e..63650d3 100644
--- a/3rdparty/qqrencode/qqrencode.cpp
+++ b/3rdparty/qqrencode/qqrencode.cpp
@@ -1,218 +1,95 @@
-// license not clear on github. assumed lgpl due to qt licensing model
-// have asked OP for clarification
+// 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"
-#include <QDateTime>
-
-#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));
+ unsigned char *p = m_code->data;
+ for(int y=0; y<m_code->width; y++) {
+ unsigned char *row = (p+(y*m_code->width));
/* no RLE */
- for(x=0; x<m_code->width; x++) {
+ 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()
{
}
-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) {
+ 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 == NULL) {
- std::logic_error("No qr code to convert");
+ 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 4ebf668..e2e33f7 100644
--- a/3rdparty/qqrencode/qqrencode.h
+++ b/3rdparty/qqrencode/qqrencode.h
@@ -1,52 +1,49 @@
#ifndef QQRENCODE_H
#define QQRENCODE_H
#include <QtCore>
-#include "libqtqrencode_global.h"
-
class QQREncodePrivate;
-class LIBQTQRENCODESHARED_EXPORT QQREncode
+class QQREncode
{
Q_GADGET
Q_ENUMS(ErrorCorrectionLevel)
public:
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 toSVG(QString output, int size);
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.pro b/3rdparty/qqrencode/qqrencode.pro
deleted file mode 100644
index d4534ab..0000000
--- a/3rdparty/qqrencode/qqrencode.pro
+++ /dev/null
@@ -1,37 +0,0 @@
-QT += core gui svg
-
-!win32-msvc2010 {
- QMAKE_CXXFLAGS_DEBUG += -std=c++11 -Wno-write-strings
- QMAKE_CXXFLAGS_RELEASE += -std=c++11 -Wno-write-strings
-}
-
-TARGET = qtqrencode
-TEMPLATE = lib
-
-DEFINES += LIBQTQRENCODE_LIBRARY
-
-SOURCES += qqrencode.cpp
-
-HEADERS += qqrencode.h \
- libqtqrencode_global.h \
- qqrencode_p.h
-
-header_files.files = qqrencode.h \
- libqtqrencode_global.h
-header_files.path = /usr/include
-INSTALLS += header_files
-
-win32 {
- LIBS += -L$$PWD/../lib/qrencode -lqrencode
-} else {
- target.path = /usr/lib
- INSTALLS += target
- macx {
- LIBS += -L/usr/local/lib -lqrencode
- } else {
- LIBS += -lqrencode
- }
-}
-
-INCLUDEPATH += $$PWD/../lib/qrencode/include
-DEPENDPATH += $$PWD/../lib/qrencode/include
diff --git a/LICENSE b/LICENSE
index 55f0d2d..98aa069 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,21 +1,30 @@
+barcoder.png is derived from work copyright 2015 Palo Kisa.
+It is licenced under GPL2.0+.
+
+The content of 3rdparty/qqrencode is derived from
+work copyright 2013 Kentaro Fukuchi.
+That is licenced under LGPL2.1+
+
+All else, where applicable, is licensed as below:
+
MIT License
-Copyright (c) 2017-2018 SneakyWhoami
+Copyright (c) 2017-2020 barcoder team
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.
diff --git a/barcoder.pro b/barcoder.pro
index 951f456..26d0cb0 100644
--- a/barcoder.pro
+++ b/barcoder.pro
@@ -1,107 +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_BUILD = 1
DEFINES += "VERSION_MAJOR=$$VERSION_MAJOR"\
"VERSION_MINOR=$$VERSION_MINOR"\
"VERSION_BUILD=$$VERSION_BUILD"
#Target version
-VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_BUILD}
+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/256x256/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/changelog b/debian/changelog
index b932be0..43e1d44 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,36 +1,44 @@
+barcoder (1.1.0) unstable; urgency=low
+
+ * polishing to debianization, removal of lots of code, some linting
+
+
+ -- Chris <git@chris-nz.com> Sat, 05 Jul 2020 22:00:00 -0000
+
+
barcoder (1.0.1) unstable; urgency=low
* huge overhaul of build stuff to make neat deb and source packages
-- Chris <git@chris-nz.com> Sat, 04 Jul 2020 08:35:50 -0000
barcoder (1.0.0) unstable; urgency=low
* improving premake, preparing for debianization (rev.6b986e4e)
* remove some dead code (rev.f237d18a)
* Remove unused isMicro() function (rev.c84b7b9b)
* Remove a couple of unused functions (rev.c3f7bc65)
* Add some license info for 3rd part QQREncode (rev.75b3a9f7)
* Update Readme to trigger re-render (rev.f4ff13b4)
* Update licence (rev.a386fcdb)
* better clipboard handling (rev.dc59f29a)
* suppress unused warning (rev.74bfdbb6)
* patch for differing clipbaord apis, fix clipboard segfault (rev.be57d568)
* fix segfault on long datamatrix input (rev.8a964fb6)
* removed dead code in mainwindow header (rev.8309d390)
* Update README.md to reflect new situation (rev.7891b3c2)
* Complete rewrite of mainwindow. (rev.eceaf8d5)
* Update README (rev.928c1c8f)
* Update README.md (rev.8341ad83)
* Create LICENSE (rev.478e129d)
* Update README.md (rev.d8a3e710)
* first push of readme (rev.0bdfe1cd)
* shouldn't have this file in repository (rev.63e13980)
* First commit! (rev.c0938417)
-- Chris <git@chris-nz.com> Sun, 28 Jun 2020 08:21:50 -0000
diff --git a/debian/control b/debian/control
index d341f2b..668d0a0 100644
--- a/debian/control
+++ b/debian/control
@@ -1,25 +1,25 @@
Source: barcoder
Section: multiverse/utils
Priority: optional
-Maintainer: Chris <sneaky@yellow.lan>
+Maintainer: barcoder team <dpkg@chris-nz.com>
Build-Depends: libdmtx-dev, libqrencode-dev, qtbase5-dev, cdbs, debhelper
Standards-Version: 4.4.1
Package: barcoder
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Suggests: copyq | clipit | parcellite | xfce4-clipman
Description: Transfer text from clipboard using a qrcode
klipper (included in plasma-workspace) is a clipboard
manager which can show qrcodes for clipboard content.
This can be a very convenient way to transfer clipbaord content
from a desktop machine to a mobile phone.
barcoder provides this clipboard-to-barcode functionality in
a lightweight, one-shot tool. It can be invoked from a command line,
or by calling it as an action from a clipboard manager.
.
barcoder works well with applications like
(Zebra Crossing) "Barcode Scanner" on android
(com.google.zxing.client.android)
diff --git a/debian/copyright b/debian/copyright
index d3b3e22..346f176 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,65 +1,66 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: <https://scm.opengress.net/diffusion/4/>
Files: *
-Copyright: 2020 Chris <sneaky@yellow.lan>
+Copyright: 2020 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>
+Copyright: 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 d145ab4..de9072c 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -1,70 +1,65 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QProcess>
#include <QClipboard>
#include "qqrencode.h"
#include <dmtx.h>
-
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->setWindowFlags(Qt::WindowStaysOnTopHint);
// the text that I want encoded
- QString inputText;
- if (QApplication::arguments().length() > 1) {
- inputText = QApplication::arguments().last();
- } else {
- inputText = QGuiApplication::clipboard()->text();
- }
+ const QString inp = QApplication::arguments().value(-1, QGuiApplication::clipboard()->text());
// DATAMATRIX STUFF START
- DmtxEncode *enc;
int err = 0;
- int len = inputText.length();
+ int len = inp.length();
// segfault for text longer than this. so dont bother
if (len > 1595) {
// err = 1596;
} else {
- enc = dmtxEncodeCreate();
+ DmtxEncode *im = dmtxEncodeCreate();
/* Read input data into buffer */
- err = dmtxEncodeDataMatrix(enc, len, (unsigned char*)inputText.toLocal8Bit().data());
- QImage dmatrix(enc->image->pxl, enc->image->width, enc->image->height, QImage::Format_RGB888);
+ 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));
- dmtxEncodeDestroy(&enc);
+ dmtxEncodeDestroy(&im);
}
// DATAMATRIX STUFF END
// QRCODE STUFF START
QQREncode encoder;
- encoder.encode(inputText);
+ encoder.encode(inp, true);
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 )
{
Q_UNUSED(event);
QApplication::quit();
}
MainWindow::~MainWindow()
{
delete ui;
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Sep 12, 10:58 AM (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42862
Default Alt Text
(21 KB)

Event Timeline