allow configuring pos printer

This commit is contained in:
Martin Brodbeck 2018-08-15 08:03:44 +02:00
parent 98ba6db5a3
commit bfe1379e05
2 changed files with 15 additions and 11 deletions

View file

@ -16,7 +16,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
QSettings settings{}; QSettings settings{};
int cashPointNo = settings.value("global/cashPointNo").toInt(); int cashPointNo = settings.value("global/cashPointNo").toInt();
// QString posPrinterDevice = settings.value("global/posPrinterDevice").toString(); QString posPrinterDevice = settings.value("global/posPrinterDevice").toString();
int feeInPercent = settings.value("global/feeInPercent").toInt(); int feeInPercent = settings.value("global/feeInPercent").toInt();
int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt(); int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt();
@ -24,26 +24,30 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
market_ = dynamic_cast<MainWindow*>(parent)->getMarketplace(); market_ = dynamic_cast<MainWindow*>(parent)->getMarketplace();
ui_.cashPointNoSpinBox->setValue(cashPointNo); ui_.cashPointNoSpinBox->setValue(cashPointNo);
// ui_.posPrinterDeviceEdit->setText(posPrinterDevice); ui_.posPrinterDeviceEdit->setText(posPrinterDevice);
ui_.feePercentSpinBox->setValue(feeInPercent); ui_.feePercentSpinBox->setValue(feeInPercent);
ui_.maxFeeSpinBox->setValue(maxFeeInEuro); ui_.maxFeeSpinBox->setValue(maxFeeInEuro);
connect(ui_.testPosPrinterButton, &QPushButton::clicked, this, [=]() { connect(ui_.testPosPrinterButton, &QPushButton::clicked, this, [=]() {
using namespace std::string_literals; using namespace std::string_literals;
try { try {
PosPrinter printer; if (ui_.posPrinterDeviceEdit->text().isEmpty()) {
printer.printTest(); PosPrinter printer;
if (printer.isValid()) printer.printTest();
} else {
}
/* if (printer.isValid())
this->ui_.posPrinterDeviceEdit->setText("<gefunden>"); this->ui_.posPrinterDeviceEdit->setText("<gefunden>");
else else
this->ui_.posPrinterDeviceEdit->setText("<nicht gefunden>"); this->ui_.posPrinterDeviceEdit->setText("<nicht gefunden>"); */
} catch (std::runtime_error& err) { } catch (std::runtime_error& err) {
QMessageBox(QMessageBox::Icon::Warning, "Bondrucker Fehler", QMessageBox(QMessageBox::Icon::Warning, "Bondrucker Fehler",
QString("Test schlug fehl: ") + err.what(), QMessageBox::StandardButton::Ok, QString("Test schlug fehl: ") + err.what(), QMessageBox::StandardButton::Ok,
this) this)
.exec(); .exec();
this->ui_.posPrinterDeviceEdit->setText("<Fehler>"); // this->ui_.posPrinterDeviceEdit->setText("<Fehler>");
return; return;
} }
}); });
@ -56,7 +60,7 @@ void SettingsDialog::accept()
int oldCashPointNo = settings.value("global/cashPointNo").toInt(); int oldCashPointNo = settings.value("global/cashPointNo").toInt();
int newCashPointNo = ui_.cashPointNoSpinBox->value(); int newCashPointNo = ui_.cashPointNoSpinBox->value();
// settings.setValue("global/posPrinterDevice", ui_.posPrinterDeviceEdit->text()); settings.setValue("global/posPrinterDevice", ui_.posPrinterDeviceEdit->text());
settings.setValue("global/feeInPercent", ui_.feePercentSpinBox->value()); settings.setValue("global/feeInPercent", ui_.feePercentSpinBox->value());
settings.setValue("global/maxFeeInEuro", ui_.maxFeeSpinBox->value()); settings.setValue("global/maxFeeInEuro", ui_.maxFeeSpinBox->value());

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>400</width>
<height>180</height> <height>203</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -33,8 +33,8 @@
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLineEdit" name="posPrinterDeviceEdit"> <widget class="QLineEdit" name="posPrinterDeviceEdit">
<property name="enabled"> <property name="toolTip">
<bool>false</bool> <string>&lt;idVendor&gt;:&lt;idProduct&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>