From: Konrad Rosenbaum Date: Fri, 22 Nov 2013 17:54:06 +0000 (+0100) Subject: use nicer dialog for cancelling voucher X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=9ed491d017582094fc1a0a607599f0d62139f302;p=web%2Fkonrad%2Fsmoke.git use nicer dialog for cancelling voucher --- diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index cbd9d9b..114ef24 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -327,17 +327,36 @@ void MOverview::deductVoucher() void MOverview::emptyVoucher() { //get voucher ID - const QString vid=QInputDialog::getText(this,tr("Invalidate Voucher"),tr("Please enter/scan the barcode of the voucher to invalidate/empty - the voucher will no longer be usable afterwards, but still has to be paid for.")); - if(vid=="")return; - const QString comment=QInputDialog::getText(this,tr("Invalidate Voucher"),tr("Please enter a comment why this voucher was emptied:")); + QDialog d(this); + d.setWindowTitle(tr("Invalidate Voucher")); + QGridLayout*gl; + d.setLayout(gl=new QGridLayout); + gl->addWidget(new QLabel(tr("This will invalidate/empty the voucher. It will no longer be usable afterwards, but will still have to be paid for.")),0,0,1,2); + gl->addWidget(new QLabel(tr("Comment:")),1,0); + QLineEdit*vid,*comment; + gl->addWidget(comment=new QLineEdit,1,1); + comment->setPlaceholderText(tr("Please enter a reason for invalidating the voucher.")); + gl->addWidget(new QLabel(tr("Voucher ID/Barcode:")),2,0); + gl->addWidget(vid=new QLineEdit,2,1); + vid->setPlaceholderText(tr("Please scan the barcode.")); + gl->setRowMinimumHeight(3,15); + QHBoxLayout*hl; + gl->addLayout(hl=new QHBoxLayout,4,0,1,2); + hl->addStretch(1); + QPushButton*p; + hl->addWidget(p=new QPushButton(tr("&OK"))); + connect(p,SIGNAL(clicked(bool)),&d,SLOT(accept())); + hl->addWidget(p=new QPushButton(tr("&Cancel"))); + connect(p,SIGNAL(clicked(bool)),&d,SLOT(reject())); + if(d.exec()!=QDialog::Accepted)return; //query server - MTEmptyVoucher dv=req->queryEmptyVoucher(vid,comment); + MTEmptyVoucher dv=req->queryEmptyVoucher(vid->text(),comment->text()); if(dv.hasError()){ QMessageBox::warning(this,tr("Warning"),tr("Unable to invalidate voucher: %1").arg(dv.errorString())); return; } QMessageBox::information(this,tr("Invalidated Voucher"), - tr("The voucher '%1'has been invalidated.").arg(vid)); + tr("The voucher '%1'has been invalidated.").arg(vid->text())); } void MOverview::refreshData()