From d25001583946f84a8bd8abde3c171b4a1d05173e Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Sun, 5 Mar 2017 16:39:50 +0300 Subject: [PATCH] Default system printer will selected in "printer select dialog" by default --- limereport/lrpreviewreportwidget.cpp | 7 +++++++ limereport/lrreportengine.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/limereport/lrpreviewreportwidget.cpp b/limereport/lrpreviewreportwidget.cpp index 986e95d..dcddb74 100644 --- a/limereport/lrpreviewreportwidget.cpp +++ b/limereport/lrpreviewreportwidget.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -157,7 +158,13 @@ void PreviewReportWidget::lastPage() void PreviewReportWidget::print() { + + QPrinterInfo pi; QPrinter printer(QPrinter::HighResolution); + + if (!pi.defaultPrinter().isNull()) + printer.setPrinterName(pi.defaultPrinterName()); + QPrintDialog dialog(&printer,QApplication::activeWindow()); if (dialog.exec()==QDialog::Accepted){ if (!d_ptr->m_reportPages.isEmpty()) diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index d4b4fa2..6f9c6e0 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -29,6 +29,7 @@ ****************************************************************************/ #include #include +#include #include #include #include @@ -271,6 +272,9 @@ void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer, cons bool ReportEnginePrivate::printReport(QPrinter* printer) { if (!printer&&!m_printerSelected){ + QPrinterInfo pi; + if (!pi.defaultPrinter().isNull()) + m_printer.data()->setPrinterName(pi.defaultPrinterName()); QPrintDialog dialog(m_printer.data(),QApplication::activeWindow()); m_printerSelected = dialog.exec()!=QDialog::Rejected; } @@ -294,8 +298,10 @@ bool ReportEnginePrivate::printReport(QPrinter* printer) bool ReportEnginePrivate::printPages(ReportPages pages, QPrinter *printer, PrintRange printRange) { - if (!printer&&!m_printerSelected){ + QPrinterInfo pi; + if (!pi.defaultPrinter().isNull()) + m_printer.data()->setPrinterName(pi.defaultPrinterName()); QPrintDialog dialog(m_printer.data(),QApplication::activeWindow()); m_printerSelected = dialog.exec()!=QDialog::Rejected; if (m_printerSelected){