3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
16 #include "qt_helpers.h"
18 #include "PrinterParams.h"
20 #include "support/os.h"
24 #include <QRadioButton>
26 #include <QPushButton>
31 GuiPrintDialog::GuiPrintDialog(GuiPrint * f)
36 connect(printPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
37 connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
39 connect(copiesSB, SIGNAL(valueChanged(int)), this, SLOT(copiesChanged(int)));
40 connect(printerED, SIGNAL(textChanged(const QString&)),
41 this, SLOT(printerChanged()));
42 connect(fileED, SIGNAL(textChanged(const QString&)),
43 this, SLOT(fileChanged() ));
44 connect(browsePB, SIGNAL(clicked()), this, SLOT(browseClicked()));
45 connect(allRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
46 connect(reverseCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
47 connect(collateCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
48 connect(fromED, SIGNAL(textChanged(const QString&)),
49 this, SLOT(pagerangeChanged()));
50 connect(fromED, SIGNAL(textChanged(const QString&)),
51 this, SLOT(change_adaptor()));
52 connect(toED, SIGNAL(textChanged(const QString&)),
53 this, SLOT(pagerangeChanged()));
54 connect(toED, SIGNAL(textChanged(const QString&)),
55 this, SLOT(change_adaptor()));
56 connect(fileRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
57 connect(printerRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
58 connect(rangeRB, SIGNAL(toggled(bool)), fromED, SLOT(setEnabled(bool)));
59 connect(rangeRB, SIGNAL(toggled(bool)), toED, SLOT(setEnabled(bool)));
63 void GuiPrintDialog::change_adaptor()
69 void GuiPrintDialog::browseClicked()
71 QString file = toqstr(form_->controller().browse(docstring()));
73 fileED->setText(file);
79 void GuiPrintDialog::fileChanged()
81 if (!fileED->text().isEmpty())
82 fileRB->setChecked(true);
87 void GuiPrintDialog::copiesChanged(int i)
89 collateCB->setEnabled(i != 1);
94 void GuiPrintDialog::printerChanged()
96 printerRB->setChecked(true);
101 void GuiPrintDialog::pagerangeChanged()
107 GuiPrint::GuiPrint(Dialog & parent)
108 : GuiView<GuiPrintDialog>(parent, _("Print Document"))
113 void GuiPrint::build_dialog()
115 dialog_.reset(new GuiPrintDialog(this));
117 bcview().setOK(dialog_->printPB);
118 bcview().setCancel(dialog_->closePB);
122 void GuiPrint::update_contents()
124 PrinterParams & pp = controller().params();
126 // only reset params if a different buffer
127 if (!pp.file_name.empty() && pp.file_name == fromqstr(dialog_->fileED->text()))
130 dialog_->printerED->setText(toqstr(pp.printer_name));
131 dialog_->fileED->setText(toqstr(pp.file_name));
133 dialog_->printerRB->setChecked(true);
134 if (pp.target == PrinterParams::FILE)
135 dialog_->fileRB->setChecked(true);
137 dialog_->reverseCB->setChecked(pp.reverse_order);
139 dialog_->copiesSB->setValue(pp.count_copies);
141 dialog_->oddCB->setChecked(pp.odd_pages);
142 dialog_->evenCB->setChecked(pp.even_pages);
144 dialog_->collateCB->setChecked(pp.sorted_copies);
147 dialog_->allRB->setChecked(true);
151 dialog_->rangeRB->setChecked(true);
154 s.setNum(pp.from_page);
155 dialog_->fromED->setText(s);
156 s.setNum(pp.to_page);
157 dialog_->toED->setText(s);
161 void GuiPrint::apply()
163 PrinterParams::Target t = PrinterParams::PRINTER;
164 if (dialog_->fileRB->isChecked())
165 t = PrinterParams::FILE;
167 PrinterParams const pp(t,
168 fromqstr(dialog_->printerED->text()),
169 support::os::internal_path(fromqstr(dialog_->fileED->text())),
170 dialog_->allRB->isChecked(),
171 dialog_->fromED->text().toUInt(),
172 dialog_->toED->text().toUInt(),
173 dialog_->oddCB->isChecked(),
174 dialog_->evenCB->isChecked(),
175 dialog_->copiesSB->text().toUInt(),
176 dialog_->collateCB->isChecked(),
177 dialog_->reverseCB->isChecked());
179 controller().params() = pp;
182 } // namespace frontend
185 #include "GuiPrint_moc.cpp"