Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Commit

Permalink
update setting ui and printer setting
Browse files Browse the repository at this point in the history
  • Loading branch information
apinprastya committed Mar 24, 2018
1 parent cfd573e commit c035f87
Show file tree
Hide file tree
Showing 11 changed files with 865 additions and 617 deletions.
1 change: 1 addition & 0 deletions libglobal/global_setting_const.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ namespace SETTING {
const QString PRINTER_CASHIER_LINEFEED = QStringLiteral("printer/cashier_linefeed");
const QString PRINTER_CASHIER_BARCODE_LEN = QStringLiteral("printer/cashier_barcodelen");
const QString PRINTER_CASHIER_SHOW_BARCODE = QStringLiteral("printer/cashier_show_barcode");
const QString PRINTER_CASHIER_ONLY_CPI10 = QStringLiteral("printer/cashier_only_cpi10");

const QString CAI_ENABLE = QStringLiteral("cashier/cai_enable");
const QString CAI_DEFAULT_SUPLIER = QStringLiteral("cashier/cai_default_suplier");
Expand Down
1 change: 1 addition & 0 deletions libgui/cashier/cashierreportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ void CashierReportDialog::print()
int cpi12 = Preference::getInt(SETTING::PRINTER_CASHIER_CPI12, 40);

auto escp = new Escp(Escp::SIMPLE, cpi10, cpi12);
escp->setCpi10Only(Preference::getBool(SETTING::PRINTER_CASHIER_ONLY_CPI10));
escp->cpi10()->doubleHeight(true)->centerText(tr("Cashier Report"))->newLine();
escp->cpi12()->doubleHeight(false)->centerText(Preference::getString(SETTING::MACHINE_NAME))->newLine();
escp->line();
Expand Down
3 changes: 1 addition & 2 deletions libgui/cashier/cashierwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,6 @@ void CashierWidget::printBill(const QVariantMap &data)
return;
}
int paymentType = data["payment_type"].toInt();
const QString &prName = Preference::getString(SETTING::PRINTER_CASHIER_NAME);
const QString &prDevice = Preference::getString(SETTING::PRINTER_CASHIER_DEVICE);
const QString &title = Preference::getString(SETTING::PRINTER_CASHIER_TITLE, "Sultan Minimarket");
const QString &subtitle = Preference::getString(SETTING::PRINTER_CASHIER_SUBTITLE, "Jogonalan Lor RT 2 Bantul");
const QString &footer = Preference::getString(SETTING::PRINTER_CASHIER_FOOTER, "Barang dibeli tidak dapat ditukar");
Expand All @@ -472,6 +470,7 @@ void CashierWidget::printBill(const QVariantMap &data)
int cpi12 = Preference::getInt(SETTING::PRINTER_CASHIER_CPI12, 40);

auto escp = new Escp(Escp::SIMPLE, cpi10, cpi12);
escp->setCpi10Only(Preference::getBool(SETTING::PRINTER_CASHIER_ONLY_CPI10));
escp->cpi10()->doubleHeight(true)->centerText(title)->newLine()->doubleHeight(false)->cpi12();
if(subtitle.contains("\n")) {
const QStringList &l = subtitle.split("\n");
Expand Down
3 changes: 1 addition & 2 deletions libgui/cashier/customercreditpaymentdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,12 @@ void CustomerCreditPaymentDialog::printData(const QVariantMap &d)
QMessageBox::critical(this, tr("Error"), tr("Please setting printer first"));
return;
}
const QString &prName = Preference::getString(SETTING::PRINTER_CASHIER_NAME);
const QString &prDevice = Preference::getString(SETTING::PRINTER_CASHIER_DEVICE);
const QString &title = Preference::getString(SETTING::PRINTER_CASHIER_TITLE, "Sultan Minimarket");
int cpi10 = Preference::getInt(SETTING::PRINTER_CASHIER_CPI10, 32);
int cpi12 = Preference::getInt(SETTING::PRINTER_CASHIER_CPI12, 40);

auto escp = new LibPrint::Escp(LibPrint::Escp::SIMPLE, cpi10, cpi12);
escp->setCpi10Only(Preference::getBool(SETTING::PRINTER_CASHIER_ONLY_CPI10));
escp->cpi10()->doubleHeight(true)->centerText(title)->newLine()->
centerText(tr("Debt Payment"))->
doubleHeight(false)->cpi12()->newLine(2);
Expand Down
1 change: 1 addition & 0 deletions libgui/customer/customercreditwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ void CustomerCreditWidget::print(const QVariantMap &data)
int cpi12 = Preference::getInt(SETTING::PRINTER_CASHIER_CPI12, 40);

auto escp = new LibPrint::Escp(LibPrint::Escp::SIMPLE, cpi10, cpi12);
escp->setCpi10Only(Preference::getBool(SETTING::PRINTER_CASHIER_ONLY_CPI10));
escp->cpi10()->doubleHeight(true)->centerText(title)->newLine()->
centerText(tr("Debt Payment"))->
doubleHeight(false)->cpi12()->newLine(2);
Expand Down
1 change: 1 addition & 0 deletions libgui/customer/customerrewardwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ void CustomerRewardWidget::print(const QVariantMap &data)
int cpi12 = Preference::getInt(SETTING::PRINTER_CASHIER_CPI12, 40);

auto escp = new LibPrint::Escp(LibPrint::Escp::SIMPLE, cpi10, cpi12);
escp->setCpi10Only(Preference::getBool(SETTING::PRINTER_CASHIER_ONLY_CPI10));
escp->cpi10()->doubleHeight(true)->centerText(title)->newLine()->
centerText(tr("Reward Exchange"))->
doubleHeight(false)->cpi12()->newLine(2);
Expand Down
1 change: 1 addition & 0 deletions libgui/item/itemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ void ItemWidget::printPrice(TableItem *item)
int cpi12 = Preference::getInt(SETTING::PRINTER_CASHIER_CPI12, 40);

auto escp = new LibPrint::Escp(LibPrint::Escp::SIMPLE, cpi10, cpi12);
escp->setCpi10Only(Preference::getBool(SETTING::PRINTER_CASHIER_ONLY_CPI10));
escp->cpi10()->line(QChar('='))->newLine()->
centerText(item->data("name").toString())->newLine()->
centerText(Preference::formatMoney(item->data("sell_price").toDouble()))->newLine()->
Expand Down
40 changes: 38 additions & 2 deletions libgui/setting/settingwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#include "printtestdialog.h"
#include "message.h"
#include "guiutil.h"
#include "escp.h"
#include <QMetaEnum>
#include <QMessageBox>
#include <QDebug>

#define TAB_APPLICATION 0
Expand Down Expand Up @@ -158,6 +160,7 @@ void SettingWidget::setupPrinter()
ui->spinCashierPriceLinefeed->setValue(Preference::getInt(SETTING::PRINTER_CASHIER_PRICE_LINEFEED, 2));
ui->spinBarcodeLength->setValue(Preference::getInt(SETTING::PRINTER_CASHIER_BARCODE_LEN, 15));
ui->checkShowBarcode->setChecked(Preference::getBool(SETTING::PRINTER_CASHIER_SHOW_BARCODE));
ui->checkOnly10->setChecked(Preference::getBool(SETTING::PRINTER_CASHIER_ONLY_CPI10));
}

void SettingWidget::setupCashier()
Expand Down Expand Up @@ -258,6 +261,7 @@ void SettingWidget::saveClicked()
Preference::setValue(SETTING::PRINTER_CASHIER_PRICE_LINEFEED, ui->spinCashierPriceLinefeed->value());
Preference::setValue(SETTING::PRINTER_CASHIER_BARCODE_LEN, ui->spinBarcodeLength->value());
Preference::setValue(SETTING::PRINTER_CASHIER_SHOW_BARCODE, ui->checkShowBarcode->isChecked());
Preference::setValue(SETTING::PRINTER_CASHIER_ONLY_CPI10, ui->checkOnly10->isChecked());
#ifdef USE_LIBUSB
int cur = ui->comboUsb->currentIndex();
if(ui->comboUsb->isEnabled() && mUsbDevices.size() > 0) {
Expand Down Expand Up @@ -287,8 +291,40 @@ void SettingWidget::tabChanged()

void SettingWidget::printTestClicked()
{
LibPrint::PrintTestDialog dialog(this);
dialog.exec();
int type = ui->comboPrintCashierType->currentData().toInt();
Escp e(type, 20, 20);
QString str;
QString str2;
int counter = 1;
while(counter <= 100) {
str.append(QString::number(counter % 10));
counter++;
}
counter = 1;
while(counter <= 100) {
str2.append(QString::number(counter % 10));
counter++;
}
e.cpi10()->leftText("SULTAN TEST PAGE", true)->newLine()->line();
e.leftText("CPI 10 :", true)->newLine();
e.leftText(str, true)->newLine()->line();
e.cpi12()->leftText("CPI 12 :")->newLine();
e.leftText(str2, true)->newLine();
e.line()->newLine(ui->spinCashierLinefeed->value());
QString printName = type == PRINT_TYPE::DEVICE ? ui->linePrintCashierDevice->text() : PRINT_TYPE::SPOOL ? ui->comboPrintCashier->currentText() : ui->comboUsb->currentText();
if(printName.isEmpty()) {
QMessageBox::critical(this, tr("Error"), tr("Please specify the printer"));
return;
}
uint16_t vendorId = 0;
uint16_t productId = 0;
if(mUsbDevices.size() > 0) {
vendorId = mUsbDevices[ui->comboUsb->currentIndex()].vendorId;
productId = mUsbDevices[ui->comboUsb->currentIndex()].productId;
}
if(ui->checkPrintCashierDrawer->isChecked()) Printer::instance()->print(printName, Escp::openDrawerCommand(), type, vendorId, productId);
Printer::instance()->print(printName, e.data(), type);
if(ui->checkPrintCashierCut->isChecked()) Printer::instance()->print(printName, Escp::cutPaperCommand(), type, vendorId, productId);
}

void SettingWidget::localeLanguageChanged()
Expand Down
Loading

0 comments on commit c035f87

Please sign in to comment.