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"
17 #include "PrinterParams.h"
19 #include "support/os.h"
23 #include <QRadioButton>
25 #include <QPushButton>
30 GuiPrintDialog::GuiPrintDialog(GuiPrint * f)
35 connect(printPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
36 connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
38 connect(copiesSB, SIGNAL(valueChanged(int)), this, SLOT(copiesChanged(int)));
39 connect(printerED, SIGNAL(textChanged(const QString&)),
40 this, SLOT(printerChanged()));
41 connect(fileED, SIGNAL(textChanged(const QString&)),
42 this, SLOT(fileChanged() ));
43 connect(browsePB, SIGNAL(clicked()), this, SLOT(browseClicked()));
44 connect(allRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
45 connect(reverseCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
46 connect(collateCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
47 connect(fromED, SIGNAL(textChanged(const QString&)),
48 this, SLOT(pagerangeChanged()));
49 connect(fromED, SIGNAL(textChanged(const QString&)),
50 this, SLOT(change_adaptor()));
51 connect(toED, SIGNAL(textChanged(const QString&)),
52 this, SLOT(pagerangeChanged()));
53 connect(toED, SIGNAL(textChanged(const QString&)),
54 this, SLOT(change_adaptor()));
55 connect(fileRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
56 connect(printerRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
57 connect(rangeRB, SIGNAL(toggled(bool)), fromED, SLOT(setEnabled(bool)));
58 connect(rangeRB, SIGNAL(toggled(bool)), toED, SLOT(setEnabled(bool)));
62 void GuiPrintDialog::change_adaptor()
68 void GuiPrintDialog::browseClicked()
70 QString file = toqstr(form_->controller().browse(docstring()));
72 fileED->setText(file);
78 void GuiPrintDialog::fileChanged()
80 if (!fileED->text().isEmpty())
81 fileRB->setChecked(true);
86 void GuiPrintDialog::copiesChanged(int i)
88 collateCB->setEnabled(i != 1);
93 void GuiPrintDialog::printerChanged()
95 printerRB->setChecked(true);
100 void GuiPrintDialog::pagerangeChanged()
106 GuiPrint::GuiPrint(GuiDialog & parent)
107 : GuiView<GuiPrintDialog>(parent, _("Print Document"))
112 void GuiPrint::build_dialog()
114 dialog_.reset(new GuiPrintDialog(this));
116 bc().setOK(dialog_->printPB);
117 bc().setCancel(dialog_->closePB);
121 void GuiPrint::update_contents()
123 PrinterParams & pp = controller().params();
125 // only reset params if a different buffer
126 if (!pp.file_name.empty() && pp.file_name == fromqstr(dialog_->fileED->text()))
129 dialog_->printerED->setText(toqstr(pp.printer_name));
130 dialog_->fileED->setText(toqstr(pp.file_name));
132 dialog_->printerRB->setChecked(true);
133 if (pp.target == PrinterParams::FILE)
134 dialog_->fileRB->setChecked(true);
136 dialog_->reverseCB->setChecked(pp.reverse_order);
138 dialog_->copiesSB->setValue(pp.count_copies);
140 dialog_->oddCB->setChecked(pp.odd_pages);
141 dialog_->evenCB->setChecked(pp.even_pages);
143 dialog_->collateCB->setChecked(pp.sorted_copies);
146 dialog_->allRB->setChecked(true);
150 dialog_->rangeRB->setChecked(true);
153 s.setNum(pp.from_page);
154 dialog_->fromED->setText(s);
155 s.setNum(pp.to_page);
156 dialog_->toED->setText(s);
160 void GuiPrint::applyView()
162 PrinterParams::Target t = PrinterParams::PRINTER;
163 if (dialog_->fileRB->isChecked())
164 t = PrinterParams::FILE;
166 PrinterParams const pp(t,
167 fromqstr(dialog_->printerED->text()),
168 support::os::internal_path(fromqstr(dialog_->fileED->text())),
169 dialog_->allRB->isChecked(),
170 dialog_->fromED->text().toUInt(),
171 dialog_->toED->text().toUInt(),
172 dialog_->oddCB->isChecked(),
173 dialog_->evenCB->isChecked(),
174 dialog_->copiesSB->text().toUInt(),
175 dialog_->collateCB->isChecked(),
176 dialog_->reverseCB->isChecked());
178 controller().params() = pp;
181 } // namespace frontend
184 #include "GuiPrint_moc.cpp"