2001-02-14 19:43:56 +00:00
|
|
|
/**
|
2001-08-19 13:25:15 +00:00
|
|
|
* \file QPrint.C
|
2001-08-29 21:11:30 +00:00
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
2001-02-14 19:43:56 +00:00
|
|
|
*
|
2001-08-29 21:11:30 +00:00
|
|
|
* \author John Levon <moz@compsoc.man.ac.uk>
|
|
|
|
* \author Edwin Leuven, leuven@fee.uva.nl
|
2001-02-14 19:43:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qradiobutton.h>
|
|
|
|
#include <qspinbox.h>
|
|
|
|
#include <qpushbutton.h>
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-19 13:25:15 +00:00
|
|
|
#include "QPrintDialog.h"
|
|
|
|
#include "QPrint.h"
|
2001-08-29 21:11:30 +00:00
|
|
|
#include "Qt2BC.h"
|
2001-02-14 19:43:56 +00:00
|
|
|
#include "gettext.h"
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
#include "QtLyXView.h"
|
|
|
|
#include "ControlPrint.h"
|
2001-02-14 19:43:56 +00:00
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
typedef Qt2CB<ControlPrint, Qt2DB<QPrintDialog> > base_class;
|
2001-02-14 19:43:56 +00:00
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
QPrint::QPrint(ControlPrint & c)
|
|
|
|
: base_class(c, _("Print"))
|
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
|
|
|
{
|
2001-08-29 21:11:30 +00:00
|
|
|
dialog_.reset(new QPrintDialog(this));
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
bc().setOK(dialog_->printPB);
|
2001-08-29 21:11:30 +00:00
|
|
|
bc().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
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
dialog_->printerED->setText(pp.printer_name.c_str());
|
|
|
|
dialog_->fileED->setText(pp.file_name.c_str());
|
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
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
QRadioButton * button;
|
|
|
|
switch (pp.which_pages) {
|
|
|
|
case PrinterParams::ALL: button = dialog_->allRB; break;
|
|
|
|
case PrinterParams::ODD: button = dialog_->oddRB; break;
|
|
|
|
case PrinterParams::EVEN: button = dialog_->evenRB; break;
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
2001-08-29 21:11:30 +00:00
|
|
|
button->setChecked(true);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
// hmmm... maybe a bit weird but maybe not
|
|
|
|
// we might just be remembering the last
|
|
|
|
// time this was printed.
|
|
|
|
if (!pp.from_page.empty()) {
|
|
|
|
dialog_->fromED->setText(pp.from_page.c_str());
|
|
|
|
|
|
|
|
dialog_->toED->setText("");
|
2002-03-21 21:21:28 +00:00
|
|
|
if (pp.to_page)
|
2001-08-29 21:11:30 +00:00
|
|
|
dialog_->toED->setText(tostr(pp.to_page).c_str());
|
|
|
|
} else {
|
|
|
|
dialog_->fromED->setText("");
|
|
|
|
dialog_->toED->setText("");
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
dialog_->copiesSB->setValue(pp.count_copies);
|
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::WhichPages wp;
|
|
|
|
|
|
|
|
if (dialog_->allRB->isChecked())
|
|
|
|
wp = PrinterParams::ALL;
|
|
|
|
else if (dialog_->oddRB->isChecked())
|
|
|
|
wp = PrinterParams::ODD;
|
|
|
|
else
|
|
|
|
wp = PrinterParams::EVEN;
|
2001-08-19 13:25:15 +00:00
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
string from;
|
|
|
|
int to(0);
|
|
|
|
if (!dialog_->fromED->text().isEmpty()) {
|
|
|
|
// we have at least one page requested
|
|
|
|
from = dialog_->fromED->text().latin1();
|
|
|
|
if (!dialog_->toED->text().isEmpty())
|
|
|
|
to = strToInt(dialog_->toED->text().latin1());
|
|
|
|
}
|
|
|
|
|
|
|
|
PrinterParams::Target t = PrinterParams::PRINTER;
|
|
|
|
if (dialog_->fileRB->isChecked())
|
|
|
|
t = PrinterParams::FILE;
|
|
|
|
|
|
|
|
PrinterParams const pp(t,
|
|
|
|
dialog_->printerED->text().latin1(),
|
|
|
|
dialog_->fileED->text().latin1(),
|
|
|
|
wp, from, to,
|
|
|
|
dialog_->reverseCB->isChecked(),
|
|
|
|
!dialog_->collateCB->isChecked(),
|
|
|
|
strToInt(dialog_->copiesSB->text().latin1()));
|
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
|
|
|
}
|