X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt2%2FQPrintDialog.C;h=0a49773cdd68781ad1b272f4ab176b7ce2be7950;hb=1229a2712d3f4fe1392616a6973e1830cf3124ef;hp=859a8c5779a963e0307a56af2e86acfbafab74b6;hpb=03add3957a3807cdd9f7608aa9277c0177988a9e;p=lyx.git diff --git a/src/frontends/qt2/QPrintDialog.C b/src/frontends/qt2/QPrintDialog.C index 859a8c5779..0a49773cdd 100644 --- a/src/frontends/qt2/QPrintDialog.C +++ b/src/frontends/qt2/QPrintDialog.C @@ -7,6 +7,15 @@ * \author Edwin Leuven, leuven@fee.uva.nl */ +#include + +#include +#include "support/filetools.h" +#include "support/lstrings.h" + +#include "QPrint.h" +#include "QPrintDialog.h" + #include #include #include @@ -15,168 +24,62 @@ #include #include -#include "QPrintDialog.h" -#include "QPrint.h" - -#include - -#include "support/filetools.h" -#include "support/lstrings.h" -#include "lyxrc.h" -#include "PrinterParams.h" - -#include -#include - - -QPrintDialog::QPrintDialog(QPrint * f, QWidget * parent, const char * name, bool modal, WFlags fl) - : QPrintDialogBase(parent, name, modal, fl), +QPrintDialog::QPrintDialog(QPrint * f) + : QPrintDialogBase(0, 0, false, 0), form_(f) { - setCaption(name); + connect(printPB, SIGNAL(clicked()), + form_, SLOT(slotOK())); + connect(closePB, SIGNAL(clicked()), + form_, SLOT(slotClose())); } - -QPrintDialog::~QPrintDialog() +void QPrintDialog::change_adaptor() { + form_->changed(); } -const char * QPrintDialog::getFrom() { - return fromPage->text(); -} - - -const char * QPrintDialog::getTo() { - return toPage->text(); -} - - -PrinterParams::Target QPrintDialog::getTarget() { - if (toPrinter->isChecked()) - return PrinterParams::PRINTER; - else - return PrinterParams::FILE; -} - - -const char * QPrintDialog::getPrinter() { - return printerName->text(); -} - - -const char * QPrintDialog::getFile() { - return fileName->text(); -} - - -PrinterParams::WhichPages QPrintDialog::getWhichPages() { - if (oddPages->isChecked()) - return PrinterParams::ODD; - else if (evenPages->isChecked()) - return PrinterParams::EVEN; - else - return PrinterParams::ALL; -} - - -bool QPrintDialog::getReverse() { - return reverse->isChecked(); -} - - -bool QPrintDialog::getSort() { - return collate->isChecked(); -} - - -const char * QPrintDialog::getCount() { - return copies->text(); -} - - -void QPrintDialog::setTarget(PrinterParams::Target t) { - toPrinter->setChecked(t==PrinterParams::PRINTER); - toFile->setChecked(t!=PrinterParams::PRINTER); -} - - -void QPrintDialog::setPrinter(const char * name) { - printerName->setText(name); -} - - -void QPrintDialog::setFile(const char * name) { - fileName->setText(name); -} - - -void QPrintDialog::setWhichPages(PrinterParams::WhichPages wp) { - switch (wp) { - case PrinterParams::ALL: - allPages->setChecked(true); - break; - case PrinterParams::EVEN: - evenPages->setChecked(true); - break; - case PrinterParams::ODD: - oddPages->setChecked(true); - break; +void QPrintDialog::browseClicked() +{ + QString file = QFileDialog::getOpenFileName(QString::null, + _("PostScript files (*.ps)"), this, 0, _("Select a file to print to")); + if (!file.isNull()) { + fileED->setText(file); + form_->changed(); } } -void QPrintDialog::setReverse(bool on) { - reverse->setChecked(on); -} - - -void QPrintDialog::setSort(bool on) { - collate->setChecked(on); -} - - -void QPrintDialog::setCount(int num) { - copies->setValue(num); - collate->setEnabled(num > 1); +void QPrintDialog::fileChanged() +{ + if (!fileED->text().isEmpty()) + fileRB->setChecked(true); + form_->changed(); } -void QPrintDialog::setFrom(const char * text) { - fromPage->setText(text); +void QPrintDialog::copiesChanged(int i) +{ + collateCB->setEnabled(i != 1); + form_->changed(); } -void QPrintDialog::setTo(const char * text) { - toPage->setText(text); -} - - -void QPrintDialog::browse_file() +void QPrintDialog::printerChanged() { - QString d( OnlyPath(tostr(fileName->text())).c_str()); - QString s( QFileDialog::getOpenFileName(d, "PostScript Files (*.ps)", this)); - if (!s.isNull()) - fileName->setText(s); + printerRB->setChecked(true); + form_->changed(); } - -void QPrintDialog::print() -{ - form_->print(); - form_->close(); - hide(); -} - -void QPrintDialog::cancel_adaptor() +void QPrintDialog::pagerangeChanged() { - form_->close(); - hide(); -} + int from = strToUnsignedInt(fromED->text().latin1()); + int to = strToUnsignedInt(toED->text().latin1()); - -void QPrintDialog::set_collate(int copies) -{ - collate->setEnabled(copies > 1); + if (!toED->text().isEmpty() && from > to) + fromED->setText(toED->text()); + + form_->changed(); }