2001-02-14 19:43:56 +00:00
|
|
|
/**
|
|
|
|
* \file printdlgimpl.C
|
|
|
|
* Copyright 2001 LyX Team
|
|
|
|
* see the file COPYING
|
|
|
|
*
|
|
|
|
* \author John Levon, moz@compsoc.man.ac.uk
|
|
|
|
* \author Edwin Leuven, leuven@fee.uva.nl
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qfiledialog.h"
|
|
|
|
#include "qcheckbox.h"
|
|
|
|
#include "qlabel.h"
|
|
|
|
#include "qlineedit.h"
|
|
|
|
#include "qpushbutton.h"
|
|
|
|
#include "qradiobutton.h"
|
|
|
|
#include "qspinbox.h"
|
|
|
|
|
|
|
|
#include "printdlgimpl.h"
|
|
|
|
#include "FormPrint.h"
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "support/filetools.h"
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "PrinterParams.h"
|
|
|
|
|
|
|
|
#include <gettext.h>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
|
|
|
|
PrintDlgImpl::PrintDlgImpl( FormPrint *f, QWidget* parent, const char* name, bool modal, WFlags fl )
|
2001-06-05 17:05:51 +00:00
|
|
|
: PrintDlg( parent, name, modal, fl ), form_(f)
|
2001-02-14 19:43:56 +00:00
|
|
|
{
|
2001-06-05 17:05:51 +00:00
|
|
|
setCaption(name);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
PrintDlgImpl::~PrintDlgImpl()
|
|
|
|
{
|
2001-06-05 17:05:51 +00:00
|
|
|
// no need to delete child widgets, Qt does it all for us
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
const char * PrintDlgImpl::getFrom() {
|
2001-06-05 17:05:51 +00:00
|
|
|
return fromPage->text();
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
const char * PrintDlgImpl::getTo() {
|
2001-06-05 17:05:51 +00:00
|
|
|
return toPage->text();
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
|
|
|
|
PrinterParams::Target PrintDlgImpl::getTarget() {
|
2001-06-05 17:05:51 +00:00
|
|
|
if (toPrinter->isChecked())
|
|
|
|
return PrinterParams::PRINTER;
|
|
|
|
else
|
|
|
|
return PrinterParams::FILE;
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char * PrintDlgImpl::getPrinter() {
|
2001-06-05 17:05:51 +00:00
|
|
|
return printerName->text();
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char * PrintDlgImpl::getFile() {
|
2001-06-05 17:05:51 +00:00
|
|
|
return fileName->text();
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PrinterParams::WhichPages PrintDlgImpl::getWhichPages() {
|
2001-06-05 17:05:51 +00:00
|
|
|
if (oddPages->isChecked())
|
|
|
|
return PrinterParams::ODD;
|
|
|
|
else if (evenPages->isChecked())
|
|
|
|
return PrinterParams::EVEN;
|
|
|
|
else
|
|
|
|
return PrinterParams::ALL;
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PrintDlgImpl::getReverse() {
|
2001-06-05 17:05:51 +00:00
|
|
|
return reverse->isChecked();
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PrintDlgImpl::getSort() {
|
2001-06-05 17:05:51 +00:00
|
|
|
return collate->isChecked();
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char * PrintDlgImpl::getCount() {
|
2001-06-05 17:05:51 +00:00
|
|
|
return copies->text();
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDlgImpl::setTarget(PrinterParams::Target t) {
|
2001-06-05 17:05:51 +00:00
|
|
|
toPrinter->setChecked(t==PrinterParams::PRINTER);
|
|
|
|
toFile->setChecked(t!=PrinterParams::PRINTER);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDlgImpl::setPrinter(const char * name) {
|
2001-06-05 17:05:51 +00:00
|
|
|
printerName->setText(name);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDlgImpl::setFile(const char * name) {
|
2001-06-05 17:05:51 +00:00
|
|
|
fileName->setText(name);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDlgImpl::setWhichPages(PrinterParams::WhichPages wp) {
|
2001-06-05 17:05:51 +00:00
|
|
|
switch (wp) {
|
|
|
|
case PrinterParams::ALL:
|
|
|
|
allPages->setChecked(true);
|
|
|
|
break;
|
|
|
|
case PrinterParams::EVEN:
|
|
|
|
evenPages->setChecked(true);
|
|
|
|
break;
|
|
|
|
case PrinterParams::ODD:
|
|
|
|
oddPages->setChecked(true);
|
|
|
|
break;
|
|
|
|
}
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
void PrintDlgImpl::setReverse(bool on) {
|
2001-06-05 17:05:51 +00:00
|
|
|
reverse->setChecked(on);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
void PrintDlgImpl::setSort(bool on) {
|
2001-06-05 17:05:51 +00:00
|
|
|
collate->setChecked(on);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
void PrintDlgImpl::setCount(int num) {
|
2001-06-05 17:05:51 +00:00
|
|
|
copies->setValue(num);
|
|
|
|
collate->setEnabled(num > 1);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
void PrintDlgImpl::setFrom(const char * text) {
|
2001-06-05 17:05:51 +00:00
|
|
|
fromPage->setText(text);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
void PrintDlgImpl::setTo(const char * text) {
|
2001-06-05 17:05:51 +00:00
|
|
|
toPage->setText(text);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
void PrintDlgImpl::browse_file()
|
|
|
|
{
|
2001-06-05 17:05:51 +00:00
|
|
|
QString d( OnlyPath(tostr(fileName->text())).c_str() );
|
|
|
|
QString s( QFileDialog::getOpenFileName( d, "PostScript Files (*.ps)", this ) );
|
|
|
|
if (!s.isNull())
|
|
|
|
fileName->setText(s);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
void PrintDlgImpl::print()
|
|
|
|
{
|
2001-06-05 17:05:51 +00:00
|
|
|
form_->print();
|
|
|
|
form_->close();
|
|
|
|
hide();
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
void PrintDlgImpl::cancel_adaptor()
|
|
|
|
{
|
2001-06-05 17:05:51 +00:00
|
|
|
form_->close();
|
|
|
|
hide();
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-02-14 19:43:56 +00:00
|
|
|
void PrintDlgImpl::set_collate(int copies)
|
|
|
|
{
|
|
|
|
collate->setEnabled(copies > 1);
|
|
|
|
}
|