use nicer dialog for cancelling voucher
authorKonrad Rosenbaum <konrad@silmor.de>
Fri, 22 Nov 2013 17:54:06 +0000 (18:54 +0100)
committerKonrad Rosenbaum <konrad@silmor.de>
Fri, 22 Nov 2013 17:54:06 +0000 (18:54 +0100)
src/mwin/overview.cpp

index cbd9d9b..114ef24 100644 (file)
@@ -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()