configuring pos printer now works
This commit is contained in:
parent
bfe1379e05
commit
dccf260431
3 changed files with 31 additions and 14 deletions
|
@ -6,6 +6,7 @@
|
|||
#include <posprinter.h>
|
||||
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
|
@ -35,19 +36,33 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
|||
PosPrinter printer;
|
||||
printer.printTest();
|
||||
} else {
|
||||
|
||||
}
|
||||
/* if (printer.isValid())
|
||||
this->ui_.posPrinterDeviceEdit->setText("<gefunden>");
|
||||
else
|
||||
this->ui_.posPrinterDeviceEdit->setText("<nicht gefunden>"); */
|
||||
std::string posPrinterDeviceString = ui_.posPrinterDeviceEdit->text().toStdString();
|
||||
std::string delimiter = ":";
|
||||
PrinterDevice printerDevice;
|
||||
try {
|
||||
printerDevice.idVendor = std::stoi(
|
||||
posPrinterDeviceString.substr(0, posPrinterDeviceString.find(delimiter)), 0,
|
||||
16);
|
||||
printerDevice.idProduct = std::stoi(
|
||||
posPrinterDeviceString.substr(posPrinterDeviceString.find(delimiter) + 1),
|
||||
0, 16);
|
||||
} catch (std::exception&) {
|
||||
QMessageBox(QMessageBox::Icon::Warning, "Falsche Eingabe",
|
||||
QString("Eingabeformat für den Bondrucker (hexadezimale IDs): "
|
||||
"<VendorID>:<ProductID>\nBeispiel: 0416:5011"),
|
||||
QMessageBox::StandardButton::Ok, this)
|
||||
.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
PosPrinter printer(printerDevice);
|
||||
printer.printTest();
|
||||
}
|
||||
} catch (std::runtime_error& err) {
|
||||
QMessageBox(QMessageBox::Icon::Warning, "Bondrucker Fehler",
|
||||
QString("Test schlug fehl: ") + err.what(), QMessageBox::StandardButton::Ok,
|
||||
this)
|
||||
.exec();
|
||||
// this->ui_.posPrinterDeviceEdit->setText("<Fehler>");
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue