#include <QPrintDialog>
#include <QPrinter>
#include <QPushButton>
+#include <QSettings>
#include <QStandardItemModel>
#include <QTableView>
#include <QTextEdit>
}
//get printer settings
QPrinter printer;
+ restorePrinter(printer,"ticket");
QPrintDialog pd(&printer,this);
if(pd.exec()!=QDialog::Accepted)return;
+ storePrinter(printer,"ticket");
//label arrangement
MTicketRenderer render(tf);
MLabelDialog ld(this,&printer,tickets.size(),render.labelSize(printer));
}
//get printer settings
QPrinter printer;
+ restorePrinter(printer,"voucher");
QPrintDialog pd(&printer,this);
if(pd.exec()!=QDialog::Accepted)return;
+ storePrinter(printer,"voucher");
//label arrangement
MVoucherRenderer render(tf);
MLabelDialog ld(this,&printer,vouchers.size(),render.labelSize(printer));
}
}
+void MOrderWindow::restorePrinter(QPrinter&prn,QString key)
+{
+ QSettings set;
+ set.beginGroup(req->settingsGroup()+"/"+key);
+ if(!set.contains("name"))return;
+ prn.setPrinterName(set.value("name").toString());
+#if !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE)
+ prn.setPrinterSelectionOption(set.value("soption","").toString());
+#endif
+ prn.setPaperSize(QPrinter::PageSize(set.value("paper",QPrinter::Custom).toInt()));
+ prn.setPaperSize(set.value("papersize").toSizeF(),QPrinter::Point);
+ qreal ml,mr,mt,mb;
+ ml=set.value("marginLeft").toDouble();
+ mr=set.value("marginRight").toDouble();
+ mb=set.value("marginBottom").toDouble();
+ mt=set.value("marginTop").toDouble();
+ prn.setPageMargins(ml,mr,mb,mt,QPrinter::Point);
+ prn.setDuplex(QPrinter::DuplexMode(set.value("duplex",QPrinter::DuplexAuto).toInt()));
+ prn.setOrientation((set.value("orientation","portrait").toString()=="portrait")?QPrinter::Portrait:QPrinter::Landscape);
+ prn.setResolution(set.value("resolution").toInt());
+}
+
+void MOrderWindow::storePrinter(QPrinter&prn,QString key)
+{
+ QSettings set;
+ set.beginGroup(req->settingsGroup()+"/"+key);
+ set.setValue("name",prn.printerName());
+#if !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE)
+ set.setValue("soption",prn.printerSelectionOption());
+#endif
+ qreal ml,mr,mt,mb;
+ prn.getPageMargins(&ml,&mr,&mb,&mt,QPrinter::Point);
+ set.setValue("marginLeft",ml);
+ set.setValue("marginRight",mr);
+ set.setValue("marginBottom",mb);
+ set.setValue("marginTop",mt);
+ set.setValue("duplex",(int)prn.duplex());
+ set.setValue("orientation",prn.orientation()==QPrinter::Portrait?"portrait":"landscape");
+ set.setValue("paper",(int)prn.paperSize());
+ set.setValue("papersize",prn.paperSize(QPrinter::Point));
+ set.setValue("resolution",prn.resolution());
+}
+
void MOrderWindow::printBill()
{
//get template