Set 'printerLocale' from settings

This commit is contained in:
Siegfried Siegert 2023-12-01 15:07:29 +01:00
parent d2a0491bba
commit 60c4d5896a
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 10 additions and 4 deletions

View File

@ -80,6 +80,9 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
// read variables from setting
this->serialPortName = settings.value("ATBDeviceControllerPlugin/serialPort", "ttymxc2").toString();
QByteArray printerEncoding = settings.value("ATBDeviceControllerPlugin/printerEncoding", "ISO 8859-2").toString().toLatin1();
QString printerLocaleString = settings.value("ATBDeviceControllerPlugin/printerLocale", "de_DE").toString().toLatin1();
this->printerLocale = QLocale(printerLocaleString);
if (this->isMaster) {
// open serial port
@ -509,8 +512,8 @@ void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface::
QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate);
QString parkingEndDateString = QLocale().toString(parkingEndDateTime.date(), QLocale::ShortFormat);
QString currentDateString = QLocale().toString(currentDateTime.date(), QLocale::ShortFormat);
QString parkingEndDateString = this->printerLocale.toString(parkingEndDateTime.date(), QLocale::ShortFormat);
QString currentDateString = this->printerLocale.toString(currentDateTime.date(), QLocale::ShortFormat);
// set dynamic printer data:
@ -680,8 +683,8 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate);
QString parkingEndDateString = QLocale().toString(parkingEndDateTime.date(), QLocale::ShortFormat);
QString currentDateString = QLocale().toString(currentDateTime.date(), QLocale::ShortFormat);
QString parkingEndDateString = this->printerLocale.toString(parkingEndDateTime.date(), QLocale::ShortFormat);
QString currentDateString = this->printerLocale.toString(currentDateTime.date(), QLocale::ShortFormat);
/* -----------------------------------------------------------------------------------------
* note: the following highly depends on printer template files!

View File

@ -2,6 +2,7 @@
#define ATBDEVICECONTROLLERPLUGIN_H
#include <QObject>
#include <QLocale>
#include "src/ATBAPP/DeviceControllerInterface.h"
#include "src/ATBAPP/ATBAPPplugin.h"
@ -128,6 +129,8 @@ private:
// dbus
int init_sc_dbus();
QLocale printerLocale;
private slots:
// printer