From e8d839eccbfca7d95b17352bb8c1787e49e45979 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Mon, 6 Aug 2018 13:39:12 +0200 Subject: [PATCH] more on printer --- src/gui/settingsdialog.cpp | 22 ++++++++++++++-------- src/printer/posprinter.cpp | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index 398a22a..bb63e4a 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -3,6 +3,8 @@ #include #include +#include + #include #include @@ -21,10 +23,16 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par ui_.feePercentSpinBox->setValue(feeInPercent); ui_.maxFeeSpinBox->setValue(maxFeeInEuro); - connect(ui_.testPosPrinterButton, &QPushButton::clicked, this, [](){ - //PosPrinter::initialize({0, 0}); - PosPrinter printer; - printer.printTest(); + connect(ui_.testPosPrinterButton, &QPushButton::clicked, this, [=]() { + using namespace std::string_literals; + try { + PosPrinter printer; + printer.printTest(); + } catch (std::runtime_error& err) { + QMessageBox(QMessageBox::Icon::Warning, "Bondrucker Fehler", + QString("Test schlug fehl: ") + err.what(), QMessageBox::StandardButton::Ok, this) + .exec(); + } }); } @@ -52,10 +60,8 @@ void SettingsDialog::accept() } catch (std::exception& ex) { std::string errMsg("Das Ändern der Kassen-Nr. ist fehlgeschlagen: "); errMsg.append(ex.what()); - QMessageBox(QMessageBox::Icon::Critical, "Fehler", - errMsg.c_str(), - QMessageBox::StandardButton::Ok, - this) + QMessageBox(QMessageBox::Icon::Critical, "Fehler", errMsg.c_str(), + QMessageBox::StandardButton::Ok, this) .exec(); QDialog::accept(); return; diff --git a/src/printer/posprinter.cpp b/src/printer/posprinter.cpp index c174806..93b9e0b 100644 --- a/src/printer/posprinter.cpp +++ b/src/printer/posprinter.cpp @@ -112,7 +112,7 @@ void PosPrinter::printTest() std::stringstream commandStream; commandStream << Command::ENCODING; commandStream << "Der Drucker kann von KIMA2\nangesprochen werden.\n\n" - << "Beachten Sie, dass nicht\nalle Modelle Strichcodes\nausdrucken können."; + << u8"Beachten Sie, dass nicht\nalle Modelle Strichcodes\nausdrucken können."; commandStream << Command::FEED; printHeader(); write(commandStream.str());