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 KDE application.</p>"
57 " <p><b>Note:</b> this field is disabled if you print from"
58 " non-TDE applications like Mozilla or OpenOffice.org, since here TDEPrint has no"
59 " means to determine which document page you are currently viewing.</p></qt>" );
60 TQString whatsThisPageRangeLabel = i18n(
" <qt><b>Page Range:</b> Choose a \"Page Range\" to select a subset of the"
61 " complete document pages"
62 " to be printed. The format is <em>\"n,m,o-p,q,r,s-t, u\"</em>.</p>"
63 " <p><b>Example:</b> <em>\"4,6,10-13,17,20,23-25\"</em> will print"
64 " the pages 4, 6, 10, 11, 12, 13, 17, 20, 23, 24, 25 of your document.</p>"
67 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
68 " with the CUPS commandline job option parameter:</em> "
70 " -o page-ranges=... # example: \"4,6,10-13,17,20,23-25\" "
74 TQString whatsThisPageSetLabel = i18n(
" <qt><b>Page Set:</b>"
75 " <p>Choose <em>\"All Pages\"</em>, <em>\"Even Pages\"</em> or"
76 " <em>\"Odd Pages\"</em>"
77 " if you want to print a page selection matching one of these terms. The default"
78 " is <em>\"All Pages\"</em>.</p>"
79 " <p><b>Note:</b> If you combine a selection of a <em>\"Page Range\"</em> with a"
80 " <em>\"Page Set\"</em> of <em>\"Odd\"</em> or <em>\"Even\"</em>, you will only get the"
81 " odd or even pages from the originally selected page range. This is useful if you"
82 " odd or even pages from the originally selected page range. This is useful if you"
83 " want to print a page range in duplex on a simplex-only printer. In this case you"
84 " can feed the paper to the printer twice; in the first pass, select \"Odd\" or"
85 " \"Even\" (depending on your printer model), in second pass select the other"
86 " option. You may need to <em>\"Reverse\"</em> the output in one of the passes (depending"
87 " on your printer model).</p> "
90 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
91 " with the CUPS commandline job option parameter:</em> "
93 " -o page-set=... # example: \"odd\" or \"even\" "
97 TQString whatsThisCopiesLabel = i18n(
" <qt><b>Output Settings:</b>"
98 " Here you can determine the number of copies, the output order and the collate"
99 " mode for the pages of your printjob. (Note, that the maximum number of copies "
100 " allowed to print may be restricted by your print subsystem.)</p>"
101 " <p>The 'Copies' setting defaults to 1. </p> "
104 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
105 " with the CUPS commandline job option parameter:</em> "
107 " -o copies=... # examples: \"5\" or \"42\" "
109 " -o outputorder=... # example: \"reverse\""
111 " -o Collate=... # example: \"true\" or \"false\" "
115 TQString whatsThisNumberOfCopiesLabel = i18n(
" <qt><b>Number of Copies:</b> Determine the number of requested copies here."
116 " You can increase or decrease"
117 " the number of printed copies by clicking on the up and down arrows. You can also type the figure"
118 " directly into the box. </p>"
121 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
122 " with the CUPS commandline job option parameter:</em> "
124 " -o copies=... # examples: \"5\" or \"42\" "
128 TQString whatsThisCollateLabel = i18n(
" <qt><b>Collate Copies</b>"
129 " <p>If the <em>\"Collate\"</em> checkbox is enabled (default), the output order for"
130 " multiple copies of a multi-page document will be \"1-2-3-..., 1-2-3-..., 1-2-3-...\".</p>"
131 " <p>If the <em>\"Collate\"</em> checkbox is disabled, the output order for"
132 " multiple copies of a multi-page document will be \"1-1-1-..., 2-2-2-..., 3-3-3-...\".</p>"
135 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
136 " with the CUPS commandline job option parameter:</em> "
138 " -o Collate=... # example: \"true\" or \"false\" "
142 TQString whatsThisReverseLabel = i18n(
" <qt><b>Reverse Order</b>"
143 " <p> If the <em>\"Reverse\"</em> checkbox is enabled, the output order for"
144 " multiple copies of a multi-page document will be \"...-3-2-1, ...-3-2-1, ...-3-2-1\", if you"
145 " also have <em>en</em>abled the <em>\"Collate\"</em> checkbox at the same time"
146 " (the usual usecase).</p>"
147 " <p>If the <em>\"Reverse\"</em> checkbox is enabled, the output order for"
148 " multiple copies of a multi-page document will be \"...-3-3-3, ...-2-2-2, ...-1-1-1\", if you"
149 " have <em>dis</em>abled the <em>\"Collate\"</em> checkbox at the same time. </p>"
152 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
153 " with the CUPS commandline job option parameter:</em> "
155 " -o outputorder=... # example: \"reverse\""
163 setTitle(i18n(
"C&opies"));
164 setId(KPrinter::CopiesPage);
167 TQButtonGroup *m_pagebox =
new TQButtonGroup(0, Qt::Vertical, i18n(
"Page Selection"),
this);
168 TQWhatsThis::add(m_pagebox, whatsThisPageSelectionLabel);
169 m_all =
new TQRadioButton(i18n(
"&All"), m_pagebox);
170 TQWhatsThis::add(m_all, whatsThisAllPagesLabel);
171 m_current =
new TQRadioButton(i18n(
"Cu&rrent"), m_pagebox);
172 TQWhatsThis::add(m_current, whatsThisCurrentPagesLabel);
173 m_range =
new TQRadioButton(i18n(
"Ran&ge"), m_pagebox);
174 TQWhatsThis::add(m_range, whatsThisPageRangeLabel);
175 m_rangeedit =
new TQLineEdit(m_pagebox);
176 TQWhatsThis::add(m_rangeedit, whatsThisPageRangeLabel);
177 connect(m_range, TQT_SIGNAL(clicked()), m_rangeedit, TQT_SLOT(setFocus()));
178 TQToolTip::add(m_rangeedit, i18n(
"<p>Enter pages or group of pages to print separated by commas (1,2-5,8).</p>"));
182 TQGroupBox *m_copybox =
new TQGroupBox(0, Qt::Vertical, i18n(
"Output Settings"),
this);
183 TQWhatsThis::add(m_copybox, whatsThisCopiesLabel);
184 m_collate =
new TQCheckBox(i18n(
"Co&llate"), m_copybox);
185 TQWhatsThis::add(m_collate, whatsThisCollateLabel);
186 m_order =
new TQCheckBox(i18n(
"Re&verse"), m_copybox);
187 TQWhatsThis::add(m_order, whatsThisReverseLabel);
188 m_collatepix =
new TQLabel(m_copybox);
189 m_collatepix->setAlignment(Qt::AlignCenter);
190 m_collatepix->setMinimumHeight(70);
191 TQLabel *m_copieslabel =
new TQLabel(i18n(
"Cop&ies:"), m_copybox);
192 m_copies =
new TQSpinBox(m_copybox);
193 m_copies->setRange(1,999);
194 TQWhatsThis::add(m_copies, whatsThisNumberOfCopiesLabel);
195 m_copieslabel->setBuddy(m_copies);
196 TQWhatsThis::add(m_copieslabel, whatsThisNumberOfCopiesLabel);
197 m_pageset =
new TQComboBox(m_pagebox);
198 m_pageset->insertItem(i18n(
"All Pages"));
199 m_pageset->insertItem(i18n(
"Odd Pages"));
200 m_pageset->insertItem(i18n(
"Even Pages"));
201 TQWhatsThis::add(m_pageset, whatsThisPageSetLabel);
202 TQLabel *m_pagesetlabel =
new TQLabel(i18n(
"Page &set:"), m_pagebox);
203 m_pagesetlabel->setBuddy(m_pageset);
204 TQWhatsThis::add(m_pagesetlabel, whatsThisPageSetLabel);
205 KSeparator *sepline =
new KSeparator(Qt::Horizontal, m_pagebox);
206 sepline->setMinimumHeight(10);
208 TQWidget::setTabOrder( m_all, m_current );
209 TQWidget::setTabOrder( m_current, m_range );
210 TQWidget::setTabOrder( m_range, m_rangeedit );
211 TQWidget::setTabOrder( m_rangeedit, m_pageset );
212 TQWidget::setTabOrder( m_pageset, m_copies );
213 TQWidget::setTabOrder( m_copies, m_collate );
214 TQWidget::setTabOrder( m_collate, m_order );
217 TQGridLayout *l1 =
new TQGridLayout(
this, 2, 2, 0, 5);
218 l1->setRowStretch(1,1);
219 l1->setColStretch(0,1);
220 l1->setColStretch(1,1);
221 l1->addWidget(m_pagebox,0,0);
222 l1->addWidget(m_copybox,0,1);
223 TQVBoxLayout *l3 =
new TQVBoxLayout(TQT_TQLAYOUT(m_pagebox->layout()), 5);
224 l3->addWidget(m_all);
225 l3->addWidget(m_current);
226 TQHBoxLayout *l4 =
new TQHBoxLayout(0, 0, 5);
228 l4->addWidget(m_range,0);
229 l4->addWidget(m_rangeedit,1);
231 l3->addWidget(sepline);
232 TQHBoxLayout *l2 =
new TQHBoxLayout(0, 0, 5);
234 l2->addWidget(m_pagesetlabel,0);
235 l2->addWidget(m_pageset,1);
236 TQGridLayout *l5 =
new TQGridLayout(m_copybox->layout(), 4, 2, 10);
237 l5->setRowStretch(4,1);
238 l5->addWidget(m_copieslabel,0,0);
239 l5->addWidget(m_copies,0,1);
240 l5->addMultiCellWidget(m_collatepix,1,2,0,0);
241 l5->addWidget(m_collate,1,1);
242 l5->addWidget(m_order,2,1);
245 m_all->setChecked(
true);
246 m_copies->setValue(1);
247 initialize(m_useplugin);
248 slotCollateClicked();
251 connect(m_rangeedit,TQT_SIGNAL(textChanged(
const TQString&)),TQT_SLOT(slotRangeEntered()));
252 connect(m_collate,TQT_SIGNAL(clicked()),TQT_SLOT(slotCollateClicked()));
253 connect(m_order,TQT_SIGNAL(clicked()),TQT_SLOT(slotCollateClicked()));
255 if (!kapp->authorize(
"print/copies"))
257 setTitle(i18n(
"Pages"));
262 KPCopiesPage::~KPCopiesPage()
266 void KPCopiesPage::slotRangeEntered()
268 m_range->setChecked(
true);
271 void KPCopiesPage::slotCollateClicked()
273 TQString s(
"tdeprint_");
274 s.append((m_collate->isChecked() ?
"collate" :
"uncollate"));
275 if (m_order->isChecked()) s.append(
"_reverse");
276 m_collatepix->setPixmap(UserIcon(s));
279 void KPCopiesPage::initialize(
bool usePlugin)
281 m_useplugin = usePlugin;
282 int f = KMFactory::self()->uiManager()->copyFlags(m_printer, m_useplugin);
284 m_current->setEnabled((f & KMUiManager::Current));
285 m_range->setEnabled((f & KMUiManager::Range));
286 m_rangeedit->setEnabled((f & KMUiManager::Range));
287 m_collate->setEnabled((f & KMUiManager::Collate));
288 m_order->setEnabled((f & KMUiManager::Order));
289 m_pageset->setEnabled((f & KMUiManager::PageSet));
292 m_collate->setChecked(!(f & KMUiManager::NoAutoCollate));
293 slotCollateClicked();
296 void KPCopiesPage::setOptions(
const TQMap<TQString,TQString>& options)
300 value = options[
"kde-copies"];
301 if (!value.isEmpty()) m_copies->setValue(value.toInt());
303 value = options[
"kde-pageorder"];
304 if (m_order->isEnabled()) m_order->setChecked(value ==
"Reverse");
306 value = options[
"kde-collate"];
307 if (m_collate->isEnabled()) m_collate->setChecked(!(value ==
"Uncollate"));
309 slotCollateClicked();
311 value = options[
"kde-range"];
312 if (!value.isEmpty() && m_range->isEnabled() && value !=
"1-")
314 m_rangeedit->setText(value);
315 m_range->setChecked(
true);
317 else if (options[
"kde-current"] ==
"1")
318 m_current->setChecked(
true);
320 m_all->setChecked(
true);
322 value = options[
"kde-pageset"];
323 if (!value.isEmpty() && m_pageset->isEnabled())
324 m_pageset->setCurrentItem(value.toInt());
326 m_pageset->setCurrentItem(0);
329 void KPCopiesPage::getOptions(TQMap<TQString,TQString>& options,
bool incldef)
332 options[
"kde-copies"] = m_copies->text();
334 options[
"kde-pageorder"] = (m_order->isChecked() ?
"Reverse" :
"Forward");
336 options[
"kde-collate"] = (m_collate->isChecked() ?
"Collate" :
"Uncollate");
338 options[
"kde-current"] = (m_current->isChecked() ?
"1" :
"0");
339 options[
"kde-range"] = (m_range->isChecked() ? m_rangeedit->text() : (incldef ? TQString::fromLatin1(
"1-") : TQString::fromLatin1(
"")));
341 options[
"kde-pageset"] = TQString::number(m_pageset->currentItem());
344 void KPCopiesPage::reload()
346 initialize(m_useplugin);
349 #include "kpcopiespage.moc"