20 #include "kpcopiespage.h"
21 #include "kmfactory.h"
22 #include "kmuimanager.h"
24 #include "kxmlcommand.h"
27 #include <tqcombobox.h>
28 #include <tqspinbox.h>
29 #include <tqbuttongroup.h>
30 #include <tqradiobutton.h>
31 #include <tqlineedit.h>
32 #include <tqcheckbox.h>
33 #include <tqtooltip.h>
34 #include <tqwhatsthis.h>
37 #include <tdeapplication.h>
38 #include <tdelocale.h>
39 #include <kiconloader.h>
40 #include <kseparator.h>
42 KPCopiesPage::KPCopiesPage(
KPrinter *prt, TQWidget *parent,
const char *name)
46 TQString whatsThisPageSelectionLabel = i18n(
" <qt><p><b>Page Selection</b></p> "
47 " <p>Here you can control if you print a certain selection only out of all"
48 " the pages from the complete document."
51 TQString whatsThisAllPagesLabel = i18n(
" <qt><b>All Pages:</b> Select \"All\" to print the complete document."
52 " Since this is the default, it is pre-selected."
55 TQString whatsThisCurrentPagesLabel = i18n(
" <qt><b>Current Page:</b> Select <em>\"Current\"</em> if you want "
56 " to print the page currently visible in your TDE application.</p>"
57 " <p><b>Note:</b> this field is disabled if you print from"
58 " non-TDE applications like Firefox, PaleMoon, SeaMonkey or OpenOffice and"
59 " LibreOffice, since here TDEPrint has no means to determine which document page"
60 " you are currently viewing.</p></qt>" );
61 TQString whatsThisPageRangeLabel = i18n(
" <qt><b>Page Range:</b> Choose a \"Page Range\" to select a subset of the"
62 " complete document pages"
63 " to be printed. The format is <em>\"n,m,o-p,q,r,s-t, u\"</em>.</p>"
64 " <p><b>Example:</b> <em>\"4,6,10-13,17,20,23-25\"</em> will print"
65 " the pages 4, 6, 10, 11, 12, 13, 17, 20, 23, 24, 25 of your document.</p>"
68 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
69 " with the CUPS commandline job option parameter:</em> "
71 " -o page-ranges=... # example: \"4,6,10-13,17,20,23-25\" "
75 TQString whatsThisPageSetLabel = i18n(
" <qt><b>Page Set:</b>"
76 " <p>Choose <em>\"All Pages\"</em>, <em>\"Even Pages\"</em> or"
77 " <em>\"Odd Pages\"</em>"
78 " if you want to print a page selection matching one of these terms. The default"
79 " is <em>\"All Pages\"</em>.</p>"
80 " <p><b>Note:</b> If you combine a selection of a <em>\"Page Range\"</em> with a"
81 " <em>\"Page Set\"</em> of <em>\"Odd\"</em> or <em>\"Even\"</em>, you will only get the"
82 " odd or even pages from the originally selected page range. This is useful if you"
83 " odd or even pages from the originally selected page range. This is useful if you"
84 " want to print a page range in duplex on a simplex-only printer. In this case you"
85 " can feed the paper to the printer twice; in the first pass, select \"Odd\" or"
86 " \"Even\" (depending on your printer model), in second pass select the other"
87 " option. You may need to <em>\"Reverse\"</em> the output in one of the passes (depending"
88 " on your printer model).</p> "
91 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
92 " with the CUPS commandline job option parameter:</em> "
94 " -o page-set=... # example: \"odd\" or \"even\" "
98 TQString whatsThisCopiesLabel = i18n(
" <qt><b>Output Settings:</b>"
99 " Here you can determine the number of copies, the output order and the collate"
100 " mode for the pages of your printjob. (Note, that the maximum number of copies "
101 " allowed to print may be restricted by your print subsystem.)</p>"
102 " <p>The 'Copies' setting defaults to 1. </p> "
105 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
106 " with the CUPS commandline job option parameter:</em> "
108 " -o copies=... # examples: \"5\" or \"42\" "
110 " -o outputorder=... # example: \"reverse\""
112 " -o Collate=... # example: \"true\" or \"false\" "
116 TQString whatsThisNumberOfCopiesLabel = i18n(
" <qt><b>Number of Copies:</b> Determine the number of requested copies here."
117 " You can increase or decrease"
118 " the number of printed copies by clicking on the up and down arrows. You can also type the figure"
119 " directly into the box. </p>"
122 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
123 " with the CUPS commandline job option parameter:</em> "
125 " -o copies=... # examples: \"5\" or \"42\" "
129 TQString whatsThisCollateLabel = i18n(
" <qt><b>Collate Copies</b>"
130 " <p>If the <em>\"Collate\"</em> checkbox is enabled (default), the output order for"
131 " multiple copies of a multi-page document will be \"1-2-3-..., 1-2-3-..., 1-2-3-...\".</p>"
132 " <p>If the <em>\"Collate\"</em> checkbox is disabled, the output order for"
133 " multiple copies of a multi-page document will be \"1-1-1-..., 2-2-2-..., 3-3-3-...\".</p>"
136 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
137 " with the CUPS commandline job option parameter:</em> "
139 " -o Collate=... # example: \"true\" or \"false\" "
143 TQString whatsThisReverseLabel = i18n(
" <qt><b>Reverse Order</b>"
144 " <p> If the <em>\"Reverse\"</em> checkbox is enabled, the output order for"
145 " multiple copies of a multi-page document will be \"...-3-2-1, ...-3-2-1, ...-3-2-1\", if you"
146 " also have <em>en</em>abled the <em>\"Collate\"</em> checkbox at the same time"
147 " (the usual usecase).</p>"
148 " <p>If the <em>\"Reverse\"</em> checkbox is enabled, the output order for"
149 " multiple copies of a multi-page document will be \"...-3-3-3, ...-2-2-2, ...-1-1-1\", if you"
150 " have <em>dis</em>abled the <em>\"Collate\"</em> checkbox at the same time. </p>"
153 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
154 " with the CUPS commandline job option parameter:</em> "
156 " -o outputorder=... # example: \"reverse\""
164 setTitle(i18n(
"C&opies"));
165 setId(KPrinter::CopiesPage);
168 TQButtonGroup *m_pagebox =
new TQButtonGroup(0, TQt::Vertical, i18n(
"Page Selection"),
this);
169 TQWhatsThis::add(m_pagebox, whatsThisPageSelectionLabel);
170 m_all =
new TQRadioButton(i18n(
"&All"), m_pagebox);
171 TQWhatsThis::add(m_all, whatsThisAllPagesLabel);
172 m_current =
new TQRadioButton(i18n(
"Cu&rrent"), m_pagebox);
173 TQWhatsThis::add(m_current, whatsThisCurrentPagesLabel);
174 m_range =
new TQRadioButton(i18n(
"Ran&ge"), m_pagebox);
175 TQWhatsThis::add(m_range, whatsThisPageRangeLabel);
176 m_rangeedit =
new TQLineEdit(m_pagebox);
177 TQWhatsThis::add(m_rangeedit, whatsThisPageRangeLabel);
178 connect(m_range, TQ_SIGNAL(clicked()), m_rangeedit, TQ_SLOT(setFocus()));
179 TQToolTip::add(m_rangeedit, i18n(
"<p>Enter pages or group of pages to print separated by commas (1,2-5,8).</p>"));
183 TQGroupBox *m_copybox =
new TQGroupBox(0, TQt::Vertical, i18n(
"Output Settings"),
this);
184 TQWhatsThis::add(m_copybox, whatsThisCopiesLabel);
185 m_collate =
new TQCheckBox(i18n(
"Co&llate"), m_copybox);
186 TQWhatsThis::add(m_collate, whatsThisCollateLabel);
187 m_order =
new TQCheckBox(i18n(
"Re&verse"), m_copybox);
188 TQWhatsThis::add(m_order, whatsThisReverseLabel);
189 m_collatepix =
new TQLabel(m_copybox);
190 m_collatepix->setAlignment(TQt::AlignCenter);
191 m_collatepix->setMinimumHeight(70);
192 TQLabel *m_copieslabel =
new TQLabel(i18n(
"Cop&ies:"), m_copybox);
193 m_copies =
new TQSpinBox(m_copybox);
194 m_copies->setRange(1,999);
195 TQWhatsThis::add(m_copies, whatsThisNumberOfCopiesLabel);
196 m_copieslabel->setBuddy(m_copies);
197 TQWhatsThis::add(m_copieslabel, whatsThisNumberOfCopiesLabel);
198 m_pageset =
new TQComboBox(m_pagebox);
199 m_pageset->insertItem(i18n(
"All Pages"));
200 m_pageset->insertItem(i18n(
"Odd Pages"));
201 m_pageset->insertItem(i18n(
"Even Pages"));
202 TQWhatsThis::add(m_pageset, whatsThisPageSetLabel);
203 TQLabel *m_pagesetlabel =
new TQLabel(i18n(
"Page &set:"), m_pagebox);
204 m_pagesetlabel->setBuddy(m_pageset);
205 TQWhatsThis::add(m_pagesetlabel, whatsThisPageSetLabel);
206 KSeparator *sepline =
new KSeparator(TQt::Horizontal, m_pagebox);
207 sepline->setMinimumHeight(10);
209 TQWidget::setTabOrder( m_all, m_current );
210 TQWidget::setTabOrder( m_current, m_range );
211 TQWidget::setTabOrder( m_range, m_rangeedit );
212 TQWidget::setTabOrder( m_rangeedit, m_pageset );
213 TQWidget::setTabOrder( m_pageset, m_copies );
214 TQWidget::setTabOrder( m_copies, m_collate );
215 TQWidget::setTabOrder( m_collate, m_order );
218 TQGridLayout *l1 =
new TQGridLayout(
this, 2, 2, 0, 5);
219 l1->setRowStretch(1,1);
220 l1->setColStretch(0,1);
221 l1->setColStretch(1,1);
222 l1->addWidget(m_pagebox,0,0);
223 l1->addWidget(m_copybox,0,1);
224 TQVBoxLayout *l3 =
new TQVBoxLayout(m_pagebox->layout(), 5);
225 l3->addWidget(m_all);
226 l3->addWidget(m_current);
227 TQHBoxLayout *l4 =
new TQHBoxLayout(0, 0, 5);
229 l4->addWidget(m_range,0);
230 l4->addWidget(m_rangeedit,1);
232 l3->addWidget(sepline);
233 TQHBoxLayout *l2 =
new TQHBoxLayout(0, 0, 5);
235 l2->addWidget(m_pagesetlabel,0);
236 l2->addWidget(m_pageset,1);
237 TQGridLayout *l5 =
new TQGridLayout(m_copybox->layout(), 4, 2, 10);
238 l5->setRowStretch(4,1);
239 l5->addWidget(m_copieslabel,0,0);
240 l5->addWidget(m_copies,0,1);
241 l5->addMultiCellWidget(m_collatepix,1,2,0,0);
242 l5->addWidget(m_collate,1,1);
243 l5->addWidget(m_order,2,1);
246 m_all->setChecked(
true);
247 m_copies->setValue(1);
248 initialize(m_useplugin);
249 slotCollateClicked();
252 connect(m_rangeedit,TQ_SIGNAL(textChanged(
const TQString&)),TQ_SLOT(slotRangeEntered()));
253 connect(m_collate,TQ_SIGNAL(clicked()),TQ_SLOT(slotCollateClicked()));
254 connect(m_order,TQ_SIGNAL(clicked()),TQ_SLOT(slotCollateClicked()));
256 if (!kapp->authorize(
"print/copies"))
258 setTitle(i18n(
"Pages"));
263 KPCopiesPage::~KPCopiesPage()
267 void KPCopiesPage::slotRangeEntered()
269 m_range->setChecked(
true);
272 void KPCopiesPage::slotCollateClicked()
274 TQString s(
"tdeprint_");
275 s.append((m_collate->isChecked() ?
"collate" :
"uncollate"));
276 if (m_order->isChecked()) s.append(
"_reverse");
277 m_collatepix->setPixmap(UserIcon(s));
280 void KPCopiesPage::initialize(
bool usePlugin)
282 m_useplugin = usePlugin;
283 int f = KMFactory::self()->uiManager()->copyFlags(m_printer, m_useplugin);
285 m_current->setEnabled((f & KMUiManager::Current));
286 m_range->setEnabled((f & KMUiManager::Range));
287 m_rangeedit->setEnabled((f & KMUiManager::Range));
288 m_collate->setEnabled((f & KMUiManager::Collate));
289 m_order->setEnabled((f & KMUiManager::Order));
290 m_pageset->setEnabled((f & KMUiManager::PageSet));
293 m_collate->setChecked(!(f & KMUiManager::NoAutoCollate));
294 slotCollateClicked();
297 void KPCopiesPage::setOptions(
const TQMap<TQString,TQString>& options)
301 value = options[
"kde-copies"];
302 if (!value.isEmpty()) m_copies->setValue(value.toInt());
304 value = options[
"kde-pageorder"];
305 if (m_order->isEnabled()) m_order->setChecked(value ==
"Reverse");
307 value = options[
"kde-collate"];
308 if (m_collate->isEnabled()) m_collate->setChecked(!(value ==
"Uncollate"));
310 slotCollateClicked();
312 value = options[
"kde-range"];
313 if (!value.isEmpty() && m_range->isEnabled() && value !=
"1-")
315 m_rangeedit->setText(value);
316 m_range->setChecked(
true);
318 else if (options[
"kde-current"] ==
"1")
319 m_current->setChecked(
true);
321 m_all->setChecked(
true);
323 value = options[
"kde-pageset"];
324 if (!value.isEmpty() && m_pageset->isEnabled())
325 m_pageset->setCurrentItem(value.toInt());
327 m_pageset->setCurrentItem(0);
330 void KPCopiesPage::getOptions(TQMap<TQString,TQString>& options,
bool incldef)
333 options[
"kde-copies"] = m_copies->text();
335 options[
"kde-pageorder"] = (m_order->isChecked() ?
"Reverse" :
"Forward");
337 options[
"kde-collate"] = (m_collate->isChecked() ?
"Collate" :
"Uncollate");
339 options[
"kde-current"] = (m_current->isChecked() ?
"1" :
"0");
340 options[
"kde-range"] = (m_range->isChecked() ? m_rangeedit->text() : (incldef ? TQString::fromLatin1(
"1-") : TQString::fromLatin1(
"")));
342 options[
"kde-pageset"] = TQString::number(m_pageset->currentItem());
345 void KPCopiesPage::reload()
347 initialize(m_useplugin);
350 #include "kpcopiespage.moc"
This class is intended to be used as base class for customized print dialog page.
This class is the main interface to access the TDE print framework.