diff --git a/shop/receiptsaveform.cpp b/shop/receiptsaveform.cpp index 4d7fbf1..f3dd4e8 100644 --- a/shop/receiptsaveform.cpp +++ b/shop/receiptsaveform.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -35,6 +36,14 @@ ReceiptSaveForm::ReceiptSaveForm(QWidget *parent) : ui->tabVouchers->setColumnWidth(0, 190); ui->tabVouchers->setColumnWidth(2, 200); + connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](QModelIndex, QModelIndex){ + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); + }); + + connect(ui->name, &QLineEdit::textChanged, [this](QString text){ + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty()); + }); + AddressBookService srvAdb; QList comboData; foreach (QSharedPointer adb, srvAdb.all()) { @@ -50,6 +59,8 @@ ReceiptSaveForm::ReceiptSaveForm(QWidget *parent) : m_saveAsNew = false; ui->groupBox_2->setEnabled(false); + + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); } ReceiptSaveForm::~ReceiptSaveForm() @@ -68,6 +79,7 @@ void ReceiptSaveForm::on_lineEdit_textChanged(const QString &text) if(matchingIndex.isValid()){ ui->tabVouchers->scrollTo(matchingIndex,QAbstractItemView::EnsureVisible); ui->tabVouchers->setCurrentIndex(matchingIndex); + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); } } @@ -78,11 +90,15 @@ void ReceiptSaveForm::on_radioAdd_toggled(bool checked) m_saveAsNew = false; ui->groupBox_2->setEnabled(false); ui->groupBox->setEnabled(true); + + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ui->tabVouchers->currentIndex().isValid()); } else { m_saveAsNew = true; ui->groupBox_2->setEnabled(true); ui->groupBox->setEnabled(false); + + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->name->text().isEmpty()); } }