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-09-24 13:57:09 +00:00
|
|
|
* \author John Levon
|
|
|
|
* \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
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
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"
|
|
|
|
#include "gettext.h"
|
|
|
|
|
|
|
|
#include "QPrint.h"
|
|
|
|
#include "QPrintDialog.h"
|
|
|
|
#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-06-19 03:38:44 +00:00
|
|
|
// FIXME FIXME QPrintDialog is getting destructed twice !!!!
|
|
|
|
|
2001-08-29 21:11:30 +00:00
|
|
|
typedef Qt2CB<ControlPrint, Qt2DB<QPrintDialog> > base_class;
|
2001-02-14 19:43:56 +00:00
|
|
|
|
2002-08-12 14:28:43 +00:00
|
|
|
QPrint::QPrint()
|
|
|
|
: base_class(_("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
|
|
|
|
2002-09-12 13:59:41 +00:00
|
|
|
// only reset params if a different buffer
|
|
|
|
if (!pp.file_name.empty() && pp.file_name == dialog_->fileED->text().latin1())
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
|
2002-09-11 19:57:49 +00:00
|
|
|
dialog_->copiesSB->setValue(pp.count_copies);
|
|
|
|
|
|
|
|
dialog_->oddCB->setChecked(pp.odd_pages);
|
|
|
|
dialog_->evenCB->setChecked(pp.even_pages);
|
|
|
|
|
2002-09-12 02:50:47 +00:00
|
|
|
dialog_->collateCB->setChecked(pp.sorted_copies);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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,
|
|
|
|
dialog_->printerED->text().latin1(),
|
|
|
|
dialog_->fileED->text().latin1(),
|
2002-09-11 19:57:49 +00:00
|
|
|
dialog_->allRB->isChecked(),
|
|
|
|
dialog_->fromED->text().toUInt(),
|
|
|
|
dialog_->toED->text().toUInt(),
|
|
|
|
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
|
|
|
}
|