Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F86134
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/main.cpp b/main.cpp
index b48f94e..bd2763b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,11 +1,16 @@
+/*
+ SPDX-FileCopyrightText: 2021 barcoder team <dpkg@chris-nz.com>
+
+ SPDX-License-Identifier: MIT
+*/
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
diff --git a/mainwindow.cpp b/mainwindow.cpp
index f473a3e..d4aa8f5 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -1,66 +1,70 @@
+/*
+ SPDX-FileCopyrightText: 2021 barcoder team <dpkg@chris-nz.com>
+
+ SPDX-License-Identifier: MIT
+*/
#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
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 {
DmtxEncode *im = dmtxEncodeCreate();
/* Read input data into buffer */
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(&im);
}
// DATAMATRIX STUFF END
// QRCODE STUFF START
QQREncode encoder;
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*)
{
QApplication::quit();
}
MainWindow::~MainWindow()
{
delete ui;
}
diff --git a/mainwindow.h b/mainwindow.h
index 411be55..b2d4870 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -1,24 +1,29 @@
+/*
+ SPDX-FileCopyrightText: 2021 barcoder team <dpkg@chris-nz.com>
+
+ SPDX-License-Identifier: MIT
+*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui
{
class MainWindow;
}
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
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Sep 11, 1:44 PM (17 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42672
Default Alt Text
(3 KB)
Attached To
Mode
R4 barcoder
Attached
Detach File
Event Timeline
Log In to Comment