Read ticket templates from config:
- config group is [TICKET_TEMPLATES] - reads list of printer templates for each TICKET_VARIANT
This commit is contained in:
parent
e8b3bb1aa0
commit
03b192fb60
@ -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)
|
||||
{
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user