9 changed files with 284 additions and 2 deletions
@ -0,0 +1,61 @@
|
||||
#include "settingsdialog.h" |
||||
|
||||
#include <database.h> |
||||
|
||||
#include <QMessageBox> |
||||
#include <QSettings> |
||||
|
||||
SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f) |
||||
{ |
||||
ui_.setupUi(this); |
||||
|
||||
QSettings settings{}; |
||||
int cashPointNo = settings.value("global/cashPointNo").toInt(); |
||||
QString posPrinterDevice = settings.value("global/posPrinterDevice").toString(); |
||||
int feeInPercent = settings.value("global/feeInPercent").toInt(); |
||||
int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt(); |
||||
|
||||
ui_.cashPointNoSpinBox->setValue(cashPointNo); |
||||
ui_.posPrinterDeviceEdit->setText(posPrinterDevice); |
||||
ui_.feePercentSpinBox->setValue(feeInPercent); |
||||
ui_.maxFeeSpinBox->setValue(maxFeeInEuro); |
||||
} |
||||
|
||||
void SettingsDialog::accept() |
||||
{ |
||||
QSettings settings; |
||||
|
||||
int oldCashPointNo = settings.value("global/cashPointNo").toInt(); |
||||
int newCashPointNo = ui_.cashPointNoSpinBox->value(); |
||||
|
||||
settings.setValue("global/posPrinterDevice", ui_.posPrinterDeviceEdit->text()); |
||||
settings.setValue("global/feeInPercent", ui_.feePercentSpinBox->value()); |
||||
settings.setValue("global/maxFeeInEuro", ui_.maxFeeSpinBox->value()); |
||||
|
||||
if (oldCashPointNo != newCashPointNo) { |
||||
int result = |
||||
QMessageBox(QMessageBox::Icon::Question, "Sind Sie sicher?", |
||||
"Möchten Sie die Kassen-Nr wirklich ändern? Diese muss über alle " |
||||
"Installationen hinweg eindeutig sein.", |
||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this) |
||||
.exec(); |
||||
if (result == QMessageBox::Yes) { |
||||
try { |
||||
Database().updateCashPointNo(oldCashPointNo, newCashPointNo); |
||||
} 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) |
||||
.exec(); |
||||
QDialog::accept(); |
||||
return; |
||||
} |
||||
settings.setValue("global/cashPointNo", ui_.cashPointNoSpinBox->value()); |
||||
} |
||||
} |
||||
|
||||
QDialog::accept(); |
||||
} |
@ -0,0 +1,21 @@
|
||||
#ifndef SETTINGS_DIALOG_H |
||||
#define SETTINGS_DIALOG_H |
||||
|
||||
#include "ui_settingsdialog.h" |
||||
|
||||
#include <QDialog> |
||||
|
||||
class SettingsDialog : public QDialog |
||||
{ |
||||
public: |
||||
SettingsDialog(QWidget* parent = nullptr, |
||||
Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint); |
||||
|
||||
public slots: |
||||
void accept() override; |
||||
|
||||
private: |
||||
Ui::SettingsDialog ui_; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>SettingsDialog</class> |
||||
<widget class="QDialog" name="SettingsDialog"> |
||||
<property name="windowTitle"> |
||||
<string>Einstellungen</string> |
||||
</property> |
||||
<layout class="QGridLayout" name="gridLayout"> |
||||
<item row="0" column="0"> |
||||
<widget class="QLabel" name="label"> |
||||
<property name="text"> |
||||
<string>Kassen-Nr.:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="1"> |
||||
<widget class="QSpinBox" name="cashPointNoSpinBox"/> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="label_2"> |
||||
<property name="text"> |
||||
<string>Bondrucker Gerätedatei:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="1"> |
||||
<widget class="QLineEdit" name="posPrinterDeviceEdit"/> |
||||
</item> |
||||
<item row="1" column="2"> |
||||
<widget class="QPushButton" name="testPosPrinterButton"> |
||||
<property name="text"> |
||||
<string>Testen</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="label_3"> |
||||
<property name="text"> |
||||
<string>Gebühr in %:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<widget class="QSpinBox" name="feePercentSpinBox"/> |
||||
</item> |
||||
<item row="3" column="0"> |
||||
<widget class="QLabel" name="label_4"> |
||||
<property name="text"> |
||||
<string>max. Gebühr in €:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="1"> |
||||
<widget class="QSpinBox" name="maxFeeSpinBox"/> |
||||
</item> |
||||
<item row="4" column="0" colspan="3"> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>SettingsDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>248</x> |
||||
<y>254</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>SettingsDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>316</x> |
||||
<y>260</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
Loading…
Reference in new issue