3 * Copyright 2001 LyX Team
6 * \author John Levon, moz@compsoc.man.ac.uk
11 #include "QPrintDialog.h"
17 #include "QtLyXView.h"
19 #include "PrinterParams.h"
21 #include "BufferView.h"
22 #include "support/lstrings.h"
23 #include "qmessagebox.h"
25 using Liason::printBuffer;
26 using Liason::getPrinterParams;
29 QPrint::QPrint(LyXView *v, Dialogs *d)
30 : dialog_(0), lv_(v), d_(d), h_(0), u_(0)
32 d->showPrint.connect(SigC::slot(this, &QPrint::show));
42 // we can safely ignore the parameter because we can always update
43 void QPrint::update(bool)
45 if (!lv_->view()->available())
48 PrinterParams pp(getPrinterParams(lv_->buffer()));
50 dialog_->setTarget(pp.target);
51 dialog_->setPrinter(pp.printer_name.c_str());
52 dialog_->setFile(pp.file_name.c_str());
53 dialog_->setWhichPages(pp.which_pages);
54 dialog_->setReverse(pp.reverse_order);
55 dialog_->setSort(pp.unsorted_copies);
56 dialog_->setCount(pp.count_copies);
58 if (!pp.from_page.empty()) {
59 dialog_->setFrom(pp.from_page.c_str());
61 dialog_->setTo(tostr(pp.to_page).c_str());
73 if (!lv_->view()->available())
79 if (strlen(dialog_->getFrom())) {
80 from = dialog_->getFrom();
81 if (strlen(dialog_->getTo()))
82 to = strToInt(dialog_->getTo());
85 int retval = printBuffer(lv_->buffer(), PrinterParams(dialog_->getTarget(),
86 string(dialog_->getPrinter()), string(dialog_->getFile()),
87 dialog_->getWhichPages(), from, to, dialog_->getReverse(),
88 dialog_->getSort(), max(strToInt(dialog_->getCount()),1)));
91 // FIXME: should have a utility class for this
92 string message(_("An error occured while printing.\n\n"));
93 message += _("Check the parameters are correct.\n");
94 QMessageBox msg( _("LyX: Print Error"), message.c_str(), QMessageBox::Warning, 1,0,0);
96 msg.setActiveWindow();
105 dialog_ = new QPrintDialog(this, 0, _("LyX: Print"));
107 if (!dialog_->isVisible()) {
108 h_ = d_->hideBufferDependent.connect(SigC::slot(this, &QPrint::hide));
109 u_ = d_->updateBufferDependent.connect(SigC::slot(this, &QPrint::update));
113 dialog_->setActiveWindow();