Hugely improove the poster template

This commit is contained in:
Dorian Zedler 2021-07-08 00:28:32 +02:00
parent 800796fb06
commit 74403dd990
Signed by: dorian
GPG key ID: 989DE36109AFA354
8 changed files with 30 additions and 8 deletions

View file

@ -7,3 +7,14 @@ App to view ranking and calendar data from https://www.digitalrock.de/
git submodule init git submodule init
git submodule update git submodule update
´´´ ´´´
# Poster
The poster offsets are (always top left of the element):
- Width: 1654
- Height: 2339
### QR-Code
- Cooridnates: 276, 276
- Size: 1100x1100
### Comp name
- Cooridnates: x: 216, y: 1670
- Size: 44

View file

@ -32,6 +32,7 @@
#include <QTextCursor> #include <QTextCursor>
#include <QPageSize> #include <QPageSize>
#include <QPdfWriter> #include <QPdfWriter>
#include <QSizeF>
#include "QZXing.h" #include "QZXing.h"
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Binary file not shown.

View file

@ -21,5 +21,6 @@
<file>fonts/fa5regular.otf</file> <file>fonts/fa5regular.otf</file>
<file>fonts/fa5solid.otf</file> <file>fonts/fa5solid.otf</file>
<file>PosterTemplate.png</file> <file>PosterTemplate.png</file>
<file>fonts/OpenSans-Light.ttf</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -112,8 +112,9 @@ void BlueRockBackend::shareResultsAsPoster(QString url, QString compName) {
} }
} }
compName = compName.replace("/", ""); QString rawCompName = compName;
path += "/" + compName + ".pdf"; QString escapedCompName = compName.replace("/", " ");
path += "/" + escapedCompName + ".pdf";
QFile file(path); QFile file(path);
file.remove(); file.remove();
@ -123,7 +124,7 @@ void BlueRockBackend::shareResultsAsPoster(QString url, QString compName) {
} }
QPdfWriter writer(&file); QPdfWriter writer(&file);
writer.setPageSize(QPageSize(QPageSize::A4)); writer.setPageSize(QPageSize(QSizeF(70.02, 99.02), QPageSize::Millimeter));
writer.setPageMargins(QMargins(0, 0, 0, 0)); writer.setPageMargins(QMargins(0, 0, 0, 0));
writer.setResolution(600); writer.setResolution(600);
@ -132,17 +133,22 @@ void BlueRockBackend::shareResultsAsPoster(QString url, QString compName) {
painter.drawPixmap(0,0, writer.width(), writer.height(), background); painter.drawPixmap(0,0, writer.width(), writer.height(), background);
QPixmap barcode; QPixmap barcode;
int size = writer.width() * 0.5; int size = 1100;
QZXingEncoderConfig encoderConfig(QZXing::EncoderFormat_QR_CODE, QSize(size, size), QZXing::EncodeErrorCorrectionLevel_H, false, false);
QZXingEncoderConfig encoderConfig(QZXing::EncoderFormat_QR_CODE, QSize(size, size), QZXing::EncodeErrorCorrectionLevel_M, false, false);
barcode.convertFromImage(QZXing::encodeData(url, encoderConfig)); barcode.convertFromImage(QZXing::encodeData(url, encoderConfig));
painter.drawPixmap(276, 276, size, size, barcode);
painter.drawPixmap((writer.width() - size) / 2, size * 0.5, size, size, barcode); QFont font("OpenSans-Light");
font.setPixelSize(44);
painter.setFont(font);
painter.setPen(Qt::black);
// QFontMetrics(painter.font()).size(Qt::TextSingleLine, "One ").width()
painter.drawText(QRect(216, 1670, 1100, 100), Qt::AlignLeft|Qt::AlignTop|Qt::TextWordWrap, rawCompName);
painter.end(); painter.end();
file.close(); file.close();
this->_shareUtils->sendFile(path, compName, "application/pdf", 1); this->_shareUtils->sendFile(path, escapedCompName, "application/pdf", 1);
} }
bool BlueRockBackend::isCameraPermissionGranted() { bool BlueRockBackend::isCameraPermissionGranted() {

View file

@ -21,6 +21,7 @@
#include <QtQml/QQmlContext> #include <QtQml/QQmlContext>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QUrl> #include <QUrl>
#include <QFontDatabase>
#include "QZXing.h" #include "QZXing.h"
#include "headers/bluerockbackend.h" #include "headers/bluerockbackend.h"
@ -41,6 +42,8 @@ int main(int argc, char *argv[])
if(!translator->load(":/" + localeName + ".qm")) if(!translator->load(":/" + localeName + ".qm"))
translator->load(":/en.qm"); translator->load(":/en.qm");
QFontDatabase::addApplicationFont(":/fonts/OpenSans-Light.ttf");
QGuiApplication::installTranslator(translator); QGuiApplication::installTranslator(translator);
QQuickStyle::setStyle("Material"); QQuickStyle::setStyle("Material");