2001-02-14 19:43:56 +00:00
|
|
|
/**
|
2001-08-19 13:25:15 +00:00
|
|
|
* \file QPrint.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-02-14 19:43:56 +00:00
|
|
|
*
|
2002-10-20 01:48:28 +00:00
|
|
|
* \author John Levon
|
2002-09-24 13:57:09 +00:00
|
|
|
* \author Edwin Leuven
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-02-14 19:43:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "LyXView.h"
|
2002-09-24 13:57:09 +00:00
|
|
|
#include "PrinterParams.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "ControlPrint.h"
|
|
|
|
#include "support/lstrings.h"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
|
|
#include "QPrint.h"
|
2002-10-30 19:47:15 +00:00
|
|
|
#include "QLPrintDialog.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "Qt2BC.h"
|
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qradiobutton.h>
|
|
|
|
#include <qspinbox.h>
|
|
|
|
#include <qpushbutton.h>
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-10-30 19:47:15 +00:00
|
|
|
typedef Qt2CB<ControlPrint, Qt2DB<QLPrintDialog> > base_class;
|
2001-02-14 19:43:56 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-08-12 14:28:43 +00:00
|
|
|
QPrint::QPrint()
|
2003-05-22 18:14:36 +00:00
|
|
|
: base_class(_("LyX: Print Document"))
|
2001-02-14 19:43:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-08-19 13:25:15 +00:00
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
void QPrint::build_dialog()
|
2001-02-14 19:43:56 +00:00
|
|
|
{
|
2002-10-30 19:47:15 +00:00
|
|
|
dialog_.reset(new QLPrintDialog(this));
|
2001-08-29 21:11:30 +00:00
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().setOK(dialog_->printPB);
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-08-19 13:25:15 +00:00
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
void QPrint::update_contents()
|
2001-02-14 19:43:56 +00:00
|
|
|
{
|
2001-08-29 21:11:30 +00:00
|
|
|
PrinterParams & pp = controller().params();
|
2001-08-19 13:25:15 +00:00
|
|
|
|
2002-09-12 13:59:41 +00:00
|
|
|
// only reset params if a different buffer
|
2002-12-17 20:37:13 +00:00
|
|
|
if (!pp.file_name.empty() && pp.file_name == fromqstr(dialog_->fileED->text()))
|
2002-09-12 13:59:41 +00:00
|
|
|
return;
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->printerED->setText(toqstr(pp.printer_name));
|
|
|
|
dialog_->fileED->setText(toqstr(pp.file_name));
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
dialog_->printerRB->setChecked(true);
|
|
|
|
if (pp.target == PrinterParams::FILE)
|
|
|
|
dialog_->fileRB->setChecked(true);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
dialog_->reverseCB->setChecked(pp.reverse_order);
|
2001-02-14 19:43:56 +00:00
|
|
|
|
2002-09-11 19:57:49 +00:00
|
|
|
dialog_->copiesSB->setValue(pp.count_copies);
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-11 19:57:49 +00:00
|
|
|
dialog_->oddCB->setChecked(pp.odd_pages);
|
|
|
|
dialog_->evenCB->setChecked(pp.even_pages);
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-12 02:50:47 +00:00
|
|
|
dialog_->collateCB->setChecked(pp.sorted_copies);
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-11 19:57:49 +00:00
|
|
|
if (pp.all_pages) {
|
|
|
|
dialog_->allRB->setChecked(true);
|
|
|
|
return;
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2002-09-11 19:57:49 +00:00
|
|
|
dialog_->rangeRB->setChecked(true);
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-11 19:57:49 +00:00
|
|
|
QString s;
|
|
|
|
s.setNum(pp.from_page);
|
|
|
|
dialog_->fromED->setText(s);
|
|
|
|
s.setNum(pp.to_page);
|
|
|
|
dialog_->toED->setText(s);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-08-19 13:25:15 +00:00
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
void QPrint::apply()
|
2001-02-14 19:43:56 +00:00
|
|
|
{
|
2001-08-29 21:11:30 +00:00
|
|
|
PrinterParams::Target t = PrinterParams::PRINTER;
|
|
|
|
if (dialog_->fileRB->isChecked())
|
|
|
|
t = PrinterParams::FILE;
|
|
|
|
|
|
|
|
PrinterParams const pp(t,
|
2002-12-17 20:37:13 +00:00
|
|
|
fromqstr(dialog_->printerED->text()),
|
|
|
|
fromqstr(dialog_->fileED->text()),
|
2002-10-20 01:48:28 +00:00
|
|
|
dialog_->allRB->isChecked(),
|
2002-09-11 19:57:49 +00:00
|
|
|
dialog_->fromED->text().toUInt(),
|
2002-10-20 01:48:28 +00:00
|
|
|
dialog_->toED->text().toUInt(),
|
2002-09-11 19:57:49 +00:00
|
|
|
dialog_->oddCB->isChecked(),
|
|
|
|
dialog_->evenCB->isChecked(),
|
|
|
|
dialog_->copiesSB->text().toUInt(),
|
|
|
|
dialog_->collateCB->isChecked(),
|
|
|
|
dialog_->reverseCB->isChecked());
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
controller().params() = pp;
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|