kima2/src/gui/pricedialog.cpp

25 lines
686 B
C++
Raw Normal View History

2018-07-21 19:24:56 +02:00
#include "pricedialog.h"
2018-07-22 20:56:20 +02:00
#include <cmath>
#include <QMessageBox>
2018-07-21 19:24:56 +02:00
PriceDialog::PriceDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
{
ui_.setupUi(this);
ui_.priceSpinBox->setFocus();
}
2018-07-22 20:56:20 +02:00
int PriceDialog::getPrice() const { return static_cast<int>(ui_.priceSpinBox->value() * 100); }
void PriceDialog::accept()
2018-07-21 19:24:56 +02:00
{
2018-07-22 20:56:20 +02:00
if (static_cast<int>(std::round(ui_.priceSpinBox->value() * 100.0L)) % 50 != 0) {
QMessageBox(QMessageBox::Icon::Warning, "Falsche Preiseingabe",
2018-07-23 08:21:05 +02:00
"Es sind nur 0,50 Cent-Schritte erlaubt.", QMessageBox::StandardButton::Ok,
this)
2018-07-22 20:56:20 +02:00
.exec();
} else {
QDialog::accept();
}
2018-07-21 19:24:56 +02:00
}