2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiPrint.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
* \author Edwin Leuven
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiPrint.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
#include "ControlPrint.h"
|
2007-09-03 05:59:32 +00:00
|
|
|
#include "qt_helpers.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "PrinterParams.h"
|
|
|
|
|
2007-06-26 16:46:40 +00:00
|
|
|
#include "support/os.h"
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QSpinBox>
|
|
|
|
#include <QPushButton>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
GuiPrintDialog::GuiPrintDialog(LyXView & lv)
|
|
|
|
: GuiDialog(lv, "print")
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
setController(new ControlPrint(*this));
|
|
|
|
setViewTitle(_("Print Document"));
|
2007-08-31 22:16:11 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
connect(printPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-08-31 22:16:11 +00:00
|
|
|
|
|
|
|
connect(copiesSB, SIGNAL(valueChanged(int)), this, SLOT(copiesChanged(int)));
|
|
|
|
connect(printerED, SIGNAL(textChanged(const QString&)),
|
|
|
|
this, SLOT(printerChanged()));
|
|
|
|
connect(fileED, SIGNAL(textChanged(const QString&)),
|
|
|
|
this, SLOT(fileChanged() ));
|
|
|
|
connect(browsePB, SIGNAL(clicked()), this, SLOT(browseClicked()));
|
|
|
|
connect(allRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
|
|
|
connect(reverseCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
|
|
|
connect(collateCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
|
|
|
connect(fromED, SIGNAL(textChanged(const QString&)),
|
|
|
|
this, SLOT(pagerangeChanged()));
|
|
|
|
connect(fromED, SIGNAL(textChanged(const QString&)),
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
connect(toED, SIGNAL(textChanged(const QString&)),
|
|
|
|
this, SLOT(pagerangeChanged()));
|
|
|
|
connect(toED, SIGNAL(textChanged(const QString&)),
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
connect(fileRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
|
|
|
connect(printerRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
|
|
|
connect(rangeRB, SIGNAL(toggled(bool)), fromED, SLOT(setEnabled(bool)));
|
|
|
|
connect(rangeRB, SIGNAL(toggled(bool)), toED, SLOT(setEnabled(bool)));
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
|
|
|
|
bc().setOK(printPB);
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-11 18:33:42 +00:00
|
|
|
ControlPrint & GuiPrintDialog::controller()
|
2007-09-05 20:33:29 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
return static_cast<ControlPrint &>(GuiDialog::controller());
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPrintDialog::change_adaptor()
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPrintDialog::browseClicked()
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
QString file = toqstr(controller().browse(docstring()));
|
2007-08-31 22:16:11 +00:00
|
|
|
if (!file.isNull()) {
|
|
|
|
fileED->setText(file);
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPrintDialog::fileChanged()
|
|
|
|
{
|
|
|
|
if (!fileED->text().isEmpty())
|
|
|
|
fileRB->setChecked(true);
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPrintDialog::copiesChanged(int i)
|
|
|
|
{
|
|
|
|
collateCB->setEnabled(i != 1);
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPrintDialog::printerChanged()
|
|
|
|
{
|
|
|
|
printerRB->setChecked(true);
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPrintDialog::pagerangeChanged()
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-11 18:33:42 +00:00
|
|
|
void GuiPrintDialog::updateContents()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
PrinterParams & pp = controller().params();
|
|
|
|
|
|
|
|
// only reset params if a different buffer
|
2007-09-05 20:33:29 +00:00
|
|
|
if (!pp.file_name.empty() && pp.file_name == fromqstr(fileED->text()))
|
2006-03-05 17:24:44 +00:00
|
|
|
return;
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
printerED->setText(toqstr(pp.printer_name));
|
|
|
|
fileED->setText(toqstr(pp.file_name));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
printerRB->setChecked(true);
|
2006-03-05 17:24:44 +00:00
|
|
|
if (pp.target == PrinterParams::FILE)
|
2007-09-05 20:33:29 +00:00
|
|
|
fileRB->setChecked(true);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
reverseCB->setChecked(pp.reverse_order);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
copiesSB->setValue(pp.count_copies);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
oddCB->setChecked(pp.odd_pages);
|
|
|
|
evenCB->setChecked(pp.even_pages);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
collateCB->setChecked(pp.sorted_copies);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
if (pp.all_pages) {
|
2007-09-05 20:33:29 +00:00
|
|
|
allRB->setChecked(true);
|
|
|
|
} else {
|
|
|
|
rangeRB->setChecked(true);
|
|
|
|
fromED->setText(QString::number(pp.from_page));
|
|
|
|
toED->setText(QString::number(pp.to_page));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiPrintDialog::applyView()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
PrinterParams::Target t = PrinterParams::PRINTER;
|
2007-09-05 20:33:29 +00:00
|
|
|
if (fileRB->isChecked())
|
2006-03-05 17:24:44 +00:00
|
|
|
t = PrinterParams::FILE;
|
|
|
|
|
|
|
|
PrinterParams const pp(t,
|
2007-09-05 20:33:29 +00:00
|
|
|
fromqstr(printerED->text()),
|
|
|
|
support::os::internal_path(fromqstr(fileED->text())),
|
|
|
|
allRB->isChecked(),
|
|
|
|
fromED->text().toUInt(),
|
|
|
|
toED->text().toUInt(),
|
|
|
|
oddCB->isChecked(),
|
|
|
|
evenCB->isChecked(),
|
|
|
|
copiesSB->text().toUInt(),
|
|
|
|
collateCB->isChecked(),
|
|
|
|
reverseCB->isChecked());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
controller().params() = pp;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-08-31 22:16:11 +00:00
|
|
|
|
|
|
|
#include "GuiPrint_moc.cpp"
|