Read ticket templates from config:

- config group is [TICKET_TEMPLATES]
 - reads list of printer templates for each TICKET_VARIANT
This commit is contained in:
Siegfried Siegert 2025-03-12 13:57:36 +01:00
parent e8b3bb1aa0
commit 03b192fb60
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 51 additions and 0 deletions

View File

@ -45,6 +45,7 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
QString printerLocaleString = settings.value("ATBDeviceControllerPlugin/printerLocale", "de_DE").toString().toLatin1();
this->printerLocale = QLocale(printerLocaleString);
this->initTicketTemplateList(&settings);
this->init_sc_dbus();
@ -140,6 +141,53 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
}
void ATBDeviceControllerPlugin::initTicketTemplateList(const QSettings * settings)
{
QList<quint8> templateList;
QString templateListString;
QMetaEnum metaTicketVariants = QMetaEnum::fromType<nsDeviceControllerInterface::TICKET_VARIANT>();
for (int i = 0; i < metaTicketVariants.keyCount(); i++) {
const char* ticketVariant_char = metaTicketVariants.key(i);
quint8 intValue = metaTicketVariants.value(i);
// DEBUG
//qCritical() << " processing TICKET_VARIANT::" << ticketVariant_char;
QString configKey = QString("TICKET_TEMPLATES/") + ticketVariant_char;
templateListString = settings->value(configKey, "1,2,3").toString();
// DEBUG
//qCritical() << " configKey: " << configKey;
//qCritical() << " templateListString: " << templateListString;
QStringList templateListStringList = templateListString.split(",", QString::SplitBehavior::SkipEmptyParts);
quint8 templateEntry;
bool ok;
for (const auto & ListEntry : templateListStringList) {
templateEntry = ListEntry.toInt(&ok);
if (ok) {
templateList.append(templateEntry);
}
}
// DEBUG
/*
QStringList elements;
for (const auto &item : templateList) {
elements << QString::number(item);
}
qCritical() << " template list: " << elements.join(',');
*/
this->ticketTemplateList.insert(static_cast<nsDeviceControllerInterface::TICKET_VARIANT>(intValue), templateList);
templateList.clear();
}
}
void ATBDeviceControllerPlugin::sendDeviceParameter(const QJsonObject &jsonObject)
{

View File

@ -140,6 +140,9 @@ private:
Ticket * currentTicket;
QLocale printerLocale;
QHash<TICKET_VARIANT, QList<quint8>> ticketTemplateList;
void initTicketTemplateList(const QSettings * settings);
void prepareDynTemplateData();
void private_setupDynTemplateData_START_RECEIPT(struct T_dynDat *dynTicketData, Ticket *ticket);