20 #include "kpgeneralpage.h"
22 #include "kmprinter.h"
25 #include <tqcombobox.h>
28 #include <tqbuttongroup.h>
30 #include <tqradiobutton.h>
31 #include <tqwhatsthis.h>
36 #include <kiconloader.h>
37 #include <tdelocale.h>
40 #define ORIENT_PORTRAIT_ID 0
41 #define ORIENT_LANDSCAPE_ID 1
42 #define ORIENT_REVLANDSCAPE_ID 2
43 #define ORIENT_REVPORTRAIT_ID 3
45 #define DUPLEX_NONE_ID 0
46 #define DUPLEX_LONG_ID 1
47 #define DUPLEX_SHORT_ID 2
53 static void initCombo(TQComboBox *cb, DrListOption *opt)
56 TQPtrListIterator<DrBase> it(*(opt->choices()));
57 for (;it.current();++it)
59 cb->insertItem(it.current()->get(
"text"));
60 if (it.current() == opt->currentChoice())
61 cb->setCurrentItem(cb->count()-1);
65 static void setComboItem(TQComboBox *cb,
const TQString& txt)
67 for (
int i=0;i<cb->count();i++)
68 if (cb->text(i) == txt)
70 cb->setCurrentItem(i);
75 static int findOption(
const char *strs[],
int n,
const TQString& txt)
77 for (
int i=0;i<n;i+=2)
78 if (txt == strs[i])
return (i/2);
85 static const char* default_size[] = {
86 "A4", I18N_NOOP(
"ISO A4"),
87 "Letter", I18N_NOOP(
"US Letter"),
88 "Legal", I18N_NOOP(
"US Legal"),
89 "Ledger", I18N_NOOP(
"Ledger"),
90 "Folio", I18N_NOOP(
"Folio"),
91 "Comm10", I18N_NOOP(
"US #10 Envelope"),
92 "DL", I18N_NOOP(
"ISO DL Envelope"),
93 "Tabloid", I18N_NOOP(
"Tabloid"),
94 "A3", I18N_NOOP(
"ISO A3" ),
95 "A2", I18N_NOOP(
"ISO A2" ),
96 "A1", I18N_NOOP(
"ISO A1" ),
97 "A0", I18N_NOOP(
"ISO A0" )
100 #define SMALLSIZE_BEGIN 0
101 #define MEDIUMSIZE_BEGIN 14
102 #define HIGHSIZE_BEGIN 20
103 #define DEFAULT_SIZE 24
105 #define DEFAULT_SOURCE 8
106 static const char* default_source[] = {
107 "Upper", I18N_NOOP(
"Upper Tray"),
108 "Lower", I18N_NOOP(
"Lower Tray"),
109 "MultiPurpose", I18N_NOOP(
"Multi-Purpose Tray"),
110 "LargeCapacity", I18N_NOOP(
"Large Capacity Tray")
112 #define DEFAULT_TYPE 4
113 static const char* default_type[] = {
114 "Normal", I18N_NOOP(
"Normal"),
115 "Transparency", I18N_NOOP(
"Transparency")
120 KPGeneralPage::KPGeneralPage(KMPrinter *pr, DrMain *dr, TQWidget *parent,
const char *name)
124 TQString whatsThisPrintPropertiesGeneralPage = i18n(
" <qt> "
125 " <p><b>\"General\"</b> </p> "
126 " <p>This dialog page contains <em>general</em> print job settings."
127 " General settings are applicable to most printers, most jobs "
128 " and most job file types. "
129 " <p>To get more specific help, enable the \"WhatsThis\" cursor and click on any of the "
130 " text labels or GUI elements of this dialog. "
132 TQString whatsThisGeneralPageSizeLabel = i18n(
" <qt> "
133 " <p><b>Page size:</b> Select paper size to be printed on from "
134 " the drop-down menu. </p>"
135 " <p>The exact list of choices depends on the printer driver (\"PPD\") you have installed.</p> "
138 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
139 " with the CUPS commandline job option parameter:</em> "
141 " -o PageSize=... # examples: \"A4\" or \"Letter\" "
145 TQString whatsThisGeneralPaperTypeLabel = i18n(
" <qt> "
146 " <p><b>Paper type:</b> Select paper type to be printed on from "
147 " the drop-down menu. </p>"
148 " <p>The exact list of choices depends on the printer driver (\"PPD\") you have installed. </p>"
151 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
152 " with the CUPS commandline job option parameter:</em> "
154 " -o MediaType=... # example: \"Transparency\" "
158 TQString whatsThisGeneralPaperSourceLabel = i18n(
" <qt> "
159 " <p><b>Paper source:</b> Select paper source tray for the paper"
160 " to be printed on from the drop-down menu. "
161 " <p>The exact list of choices depends on the printer driver (\"PPD\") you have installed. </p>"
164 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
165 " with the CUPS commandline job option parameter:</em> "
167 " -o InputSlot=... # examples: \"Lower\" or \"LargeCapacity\" "
171 TQString whatsThisGeneralOrientationLabel = i18n(
" <qt> "
172 " <p><b>Image Orientation:</b> Orientation of the printed "
173 " page image on your paper is controlled by the radio buttons. By default, "
174 " the orientation is <em>Portrait</em> "
175 " <p>You can select 4 alternatives: "
177 " <li> <b>Portrait.</b>.Portrait is the default setting. </li> "
178 " <li> <b>Landscape.</b> </li> "
179 " <li> <b>Reverse Landscape.</b> Reverse Landscape prints the images upside down. </li> "
180 " <li> <b>Reverse Portrait.</b> Reverse Portrait prints the image upside down.</li> "
182 " The icon changes according to your selection.</p>"
185 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
186 " with the CUPS commandline job option parameter:</em> "
188 " -o orientation-requested=... # examples: \"landscape\" or \"reverse-portrait\" "
192 TQString whatsThisGeneralDuplexLabel = i18n(
" <qt> "
193 " <p><b>Duplex Printing:</b> These controls may be grayed out if your printer "
194 " does not support <em>duplex printing</em> (i.e. printing on both sides of the sheet). "
195 " These controls are active if your printer supports duplex printing. "
197 " You can choose from 3 alternatives: </p>"
199 " <li> <b>None.</b> This prints each page of the job on one side of the sheets only. </li> "
200 " <li> <b>Long Side.</b> This prints the job on both sides of the paper sheets. "
201 " It prints the job in a way so that the backside has the same orientation as the front "
202 " side if you turn the paper over the long edge. (Some printer drivers name this mode "
203 " <em>duplex-non-tumbled</em>). </li> "
204 " <li> <b>Short Side.</b> This prints the job on both sides of the paper sheets. "
205 " It prints the job so that the backside has the reverse orientation from the front "
206 " side if you turn the paper over the long edge, but the same orientation, if you turn it over "
207 " the short edge. (Some printer drivers name this mode "
208 " <em>duplex-tumbled</em>). </li> "
211 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
212 " with the CUPS commandline job option parameter:</em> "
214 " -o duplex=... # examples: \"tumble\" or \"two-sided-short-edge\" "
218 TQString whatsThisGeneralBannersLabel = i18n(
" <qt> "
219 " <p><b>Banner Page(s):</b> Select banner(s) to print one or two special sheets "
220 " of paper just before or after your main job. </p>"
221 " <p>Banners may contain some pieces of job information, such as user name, time of printing, job"
222 " title and more. </p>"
223 " <p>Banner pages are useful to separate different jobs more easily, especially in a multi-user "
225 " <p><em><b>Hint:</em></b> You can design your own banner pages. To make use of them, just put the banner "
226 " file into the standard CUPS <em>banners</em> directory (This is usually <em>\"/usr/share/cups/banner/\"</em> "
227 " Your custom banner(s) must have one of the supported printable formats. "
228 " Supported formats are ASCII text, PostScript, PDF and nearly any image format such as PNG, JPEG or "
229 " GIF. Your added banner pages will appear in the drop down menu after a restart of CUPS. </p>"
230 " <p>CUPS comes with a selection of banner pages. </p>"
233 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
234 " with the CUPS commandline job option parameter:</em> "
236 " -o job-sheets=... # examples: \"standard\" or \"topsecret\" "
240 TQString whatsThisGeneralPagesPerSheetLabel = i18n(
" <qt> "
241 " <p><b>Pages per Sheet:</b> "
242 " You can choose to print more than one page onto each sheet of paper. "
243 " This is sometimes useful to save paper. </p>"
244 " <p><b>Note 1:</b> the page images get scaled down accordingly to print 2 or 4 pages per sheet. "
245 " The page image does not get scaled if you print 1 page per sheet (the default setting.). "
246 " <p><b>Note 2:</b> If you select multiple pages per sheet here, the scaling and re-arranging is done "
247 " by your printing system. Be aware, that some printers can by themselves print multiple pages per sheet. "
248 " In this case you find the option in the printer driver settings. Be careful: if you enable multiple "
249 " pages per sheet in both places, your printout will not look as you intended. </p>"
252 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
253 " with the CUPS commandline job option parameter:</em> "
255 " -o number-up=... # examples: \"2\" or \"4\" "
261 setTitle(i18n(
"General"));
264 TQLabel *m_pagesizelabel =
new TQLabel(i18n(
"Page s&ize:"),
this);
265 m_pagesizelabel->setAlignment(TQt::AlignVCenter|TQt::AlignRight);
266 TQWhatsThis::add(m_pagesizelabel, whatsThisGeneralPageSizeLabel);
268 TQLabel *m_papertypelabel =
new TQLabel(i18n(
"Paper t&ype:"),
this);
269 m_papertypelabel->setAlignment(TQt::AlignVCenter|TQt::AlignRight);
270 TQWhatsThis::add(m_papertypelabel, whatsThisGeneralPaperTypeLabel);
272 TQLabel *m_inputslotlabel =
new TQLabel(i18n(
"Paper so&urce:"),
this);
273 m_inputslotlabel->setAlignment(TQt::AlignVCenter|TQt::AlignRight);
274 TQWhatsThis::add(m_inputslotlabel, whatsThisGeneralPaperSourceLabel);
276 m_pagesize =
new TQComboBox(
this);
277 TQWhatsThis::add(m_pagesize, whatsThisGeneralPageSizeLabel);
279 m_papertype =
new TQComboBox(
this);
280 TQWhatsThis::add(m_papertype, whatsThisGeneralPaperTypeLabel);
282 m_inputslot =
new TQComboBox(
this);
283 TQWhatsThis::add(m_inputslot, whatsThisGeneralPaperSourceLabel);
285 m_pagesizelabel->setBuddy(m_pagesize);
286 m_papertypelabel->setBuddy(m_papertype);
287 m_inputslotlabel->setBuddy(m_inputslot);
289 m_orientbox =
new TQButtonGroup(0, TQt::Vertical, i18n(
"Orientation"),
this);
290 TQWhatsThis::add(m_orientbox, whatsThisGeneralOrientationLabel);
292 m_duplexbox =
new TQButtonGroup(0, TQt::Vertical, i18n(
"Duplex Printing"),
this);
293 TQWhatsThis::add(m_duplexbox, whatsThisGeneralDuplexLabel);
295 m_nupbox =
new TQButtonGroup(0, TQt::Vertical, i18n(
"Pages per Sheet"),
this);
296 TQWhatsThis::add(m_nupbox, whatsThisGeneralPagesPerSheetLabel);
298 m_bannerbox =
new TQGroupBox(0, TQt::Vertical, i18n(
"Banners"),
this);
299 TQWhatsThis::add(m_bannerbox, whatsThisGeneralBannersLabel);
301 TQRadioButton *m_portrait =
new TQRadioButton(i18n(
"&Portrait"), m_orientbox);
302 TQRadioButton *m_landscape =
new TQRadioButton(i18n(
"&Landscape"), m_orientbox);
303 TQRadioButton *m_revland =
new TQRadioButton(i18n(
"&Reverse landscape"), m_orientbox);
304 TQRadioButton *m_revport =
new TQRadioButton(i18n(
"R&everse portrait"), m_orientbox);
306 m_portrait->setChecked(
true);
307 m_orientpix =
new TQLabel(m_orientbox);
308 m_orientpix->setAlignment(TQt::AlignCenter);
309 TQRadioButton *m_dupnone =
new TQRadioButton(i18n(
"duplex orientation",
"&None"), m_duplexbox);
310 TQRadioButton *m_duplong =
new TQRadioButton(i18n(
"duplex orientation",
"Lon&g side"), m_duplexbox);
311 TQRadioButton *m_dupshort =
new TQRadioButton(i18n(
"duplex orientation",
"S&hort side"), m_duplexbox);
312 m_dupnone->setChecked(
true);
313 m_duplexpix =
new TQLabel(m_duplexbox);
314 m_duplexpix->setAlignment(TQt::AlignCenter);
315 TQRadioButton *m_nup1 =
new TQRadioButton(
"&1", m_nupbox);
316 TQRadioButton *m_nup2 =
new TQRadioButton(
"&2", m_nupbox);
317 TQRadioButton *m_nup4 =
new TQRadioButton(
"&4", m_nupbox);
318 m_nup1->setChecked(
true);
319 m_nuppix =
new TQLabel(m_nupbox);
320 m_nuppix->setAlignment(TQt::AlignCenter);
321 m_startbanner =
new TQComboBox(m_bannerbox);
322 m_endbanner =
new TQComboBox(m_bannerbox);
323 TQLabel *m_startbannerlabel =
new TQLabel(i18n(
"S&tart:"), m_bannerbox);
324 TQLabel *m_endbannerlabel =
new TQLabel(i18n(
"En&d:"), m_bannerbox);
325 m_startbannerlabel->setBuddy(m_startbanner);
326 m_endbannerlabel->setBuddy(m_endbanner);
329 TQVBoxLayout *lay0 =
new TQVBoxLayout(
this, 0, KDialog::spacingHint());
330 TQWhatsThis::add(
this, whatsThisPrintPropertiesGeneralPage);
331 TQGridLayout *lay1 =
new TQGridLayout(0, 3, 2, 0, KDialog::spacingHint());
332 TQGridLayout *lay2 =
new TQGridLayout(0, 2, 2, 0, KDialog::spacingHint());
334 lay0->addLayout(lay1);
336 lay0->addLayout(lay2);
338 lay1->addWidget(m_pagesizelabel, 0, 0);
339 lay1->addWidget(m_papertypelabel, 1, 0);
340 lay1->addWidget(m_inputslotlabel, 2, 0);
341 lay1->addWidget(m_pagesize, 0, 1);
342 lay1->addWidget(m_papertype, 1, 1);
343 lay1->addWidget(m_inputslot, 2, 1);
344 lay2->addWidget(m_orientbox, 0, 0);
345 lay2->addWidget(m_bannerbox, 1, 0);
346 lay2->addWidget(m_duplexbox, 0, 1);
347 lay2->addWidget(m_nupbox, 1, 1);
348 lay2->setColStretch(0, 1);
349 lay2->setColStretch(1, 1);
350 TQGridLayout *lay3 =
new TQGridLayout(m_orientbox->layout(), 4, 2,
351 KDialog::spacingHint());
352 lay3->addWidget(m_portrait, 0, 0);
353 lay3->addWidget(m_landscape, 1, 0);
354 lay3->addWidget(m_revland, 2, 0);
355 lay3->addWidget(m_revport, 3, 0);
356 lay3->addMultiCellWidget(m_orientpix, 0, 3, 1, 1);
357 TQGridLayout *lay4 =
new TQGridLayout(m_duplexbox->layout(), 3, 2,
358 KDialog::spacingHint());
359 lay4->addWidget(m_dupnone, 0, 0);
360 lay4->addWidget(m_duplong, 1, 0);
361 lay4->addWidget(m_dupshort, 2, 0);
362 lay4->addMultiCellWidget(m_duplexpix, 0, 2, 1, 1);
363 lay4->setRowStretch( 0, 1 );
364 TQGridLayout *lay5 =
new TQGridLayout(m_nupbox->layout(), 3, 2,
365 KDialog::spacingHint());
366 lay5->addWidget(m_nup1, 0, 0);
367 lay5->addWidget(m_nup2, 1, 0);
368 lay5->addWidget(m_nup4, 2, 0);
369 lay5->addMultiCellWidget(m_nuppix, 0, 2, 1, 1);
370 TQGridLayout *lay6 =
new TQGridLayout(m_bannerbox->layout(), 2, 2,
371 KDialog::spacingHint());
372 lay6->addWidget(m_startbannerlabel, 0, 0);
373 lay6->addWidget(m_endbannerlabel, 1, 0);
374 lay6->addWidget(m_startbanner, 0, 1);
375 lay6->addWidget(m_endbanner, 1, 1);
376 lay6->setColStretch(1, 1);
379 connect(m_orientbox,TQ_SIGNAL(clicked(
int)),TQ_SLOT(slotOrientationChanged(
int)));
380 connect(m_nupbox,TQ_SIGNAL(clicked(
int)),TQ_SLOT(slotNupChanged(
int)));
381 connect(m_duplexbox,TQ_SIGNAL(clicked(
int)),TQ_SLOT(slotDuplexChanged(
int)));
387 KPGeneralPage::~KPGeneralPage()
391 void KPGeneralPage::initialize()
396 DrListOption *opt = (DrListOption*)driver()->findOption(
"PageSize");
397 if (opt) initCombo(m_pagesize,opt);
398 else m_pagesize->setEnabled(
false);
399 opt = (DrListOption*)driver()->findOption(
"MediaType");
400 if (opt) initCombo(m_papertype,opt);
401 else m_papertype->setEnabled(
false);
402 opt = (DrListOption*)driver()->findOption(
"InputSlot");
403 if (opt) initCombo(m_inputslot,opt);
404 else m_inputslot->setEnabled(
false);
406 opt = (DrListOption*)driver()->findOption(
"Duplex");
409 if ( opt->choices()->count() == 2 )
412 TQButton *btn =
static_cast<TQButton*
>(m_duplexbox->find( DUPLEX_SHORT_ID ));
413 m_duplexbox->remove( btn );
416 static_cast<TQButton*
>(m_duplexbox->find( DUPLEX_NONE_ID ))->setText( i18n(
"Disabled" ) );
417 static_cast<TQButton*
>(m_duplexbox->find( DUPLEX_LONG_ID ))->setText( i18n(
"Enabled" ) );
420 if (opt->currentChoice())
422 int ID(DUPLEX_NONE_ID);
423 if (opt->currentChoice()->name() ==
"DuplexNoTumble" || opt->currentChoice()->name() ==
"On") ID = DUPLEX_LONG_ID;
424 else if (opt->currentChoice()->name() ==
"DuplexTumble") ID = DUPLEX_SHORT_ID;
425 m_duplexbox->setButton(ID);
426 slotDuplexChanged(ID);
429 else m_duplexbox->setEnabled(
false);
434 for (
int i=SMALLSIZE_BEGIN+1;i<MEDIUMSIZE_BEGIN;i+=2)
435 m_pagesize->insertItem(i18n(default_size[i]));
436 if ( printer()->printerCap() & KMPrinter::CapMedium )
437 for (
int i=MEDIUMSIZE_BEGIN+1; i<HIGHSIZE_BEGIN; i+=2 )
438 m_pagesize->insertItem(i18n(default_size[i]));
439 if ( printer()->printerCap() & KMPrinter::CapLarge )
440 for (
int i=HIGHSIZE_BEGIN+1; i<DEFAULT_SIZE; i+=2 )
441 m_pagesize->insertItem(i18n(default_size[i]));
443 TQString psname = pageSizeToPageName((
KPrinter::PageSize)(TDEGlobal::locale()->pageSize()));
444 int index = findOption(default_size, DEFAULT_SIZE, psname);
446 m_pagesize->setCurrentItem(index);
448 for (
int i=1;i<DEFAULT_TYPE;i+=2)
449 m_papertype->insertItem(i18n(default_type[i]));
451 for (
int i=1;i<DEFAULT_SOURCE;i+=2)
452 m_inputslot->insertItem(i18n(default_source[i]));
455 m_duplexbox->setEnabled( printer()->printerCap() & KMPrinter::CapDuplex );
459 TQStringList values = TQStringList::split(
',',printer()->option(
"kde-banners-supported"),
false);
460 if (values.count() > 0)
462 for (TQStringList::ConstIterator it = values.begin(); it != values.end(); ++it)
464 m_startbanner->insertItem(*it);
465 m_endbanner->insertItem(*it);
467 values = TQStringList::split(
',',printer()->option(
"kde-banners"),
false);
468 while (values.count() < 2) values.append(
"none");
469 setComboItem(m_startbanner, values[0]);
470 setComboItem(m_endbanner, values[1]);
473 m_bannerbox->setEnabled(
false);
475 slotOrientationChanged(ORIENT_PORTRAIT_ID);
476 slotNupChanged(NUP_1_ID);
479 void KPGeneralPage::setOptions(
const TQMap<TQString,TQString>& opts)
485 value = opts[
"media"];
486 TQStringList l = TQStringList::split(
',',value,
false);
487 for(TQStringList::ConstIterator it = l.begin(); it != l.end(); ++it)
491 if ((ch = (driver()->findOption(
"PageSize"))) &&
492 (ch = (
static_cast<DrListOption*
>(ch))->findChoice(value)))
494 if (m_pagesize->isEnabled())
495 setComboItem(m_pagesize, ch->get(
"text"));
497 else if ((ch = (driver()->findOption(
"MediaType"))) &&
498 (ch = (
static_cast<DrListOption*
>(ch))->findChoice(value)))
500 if (m_papertype->isEnabled())
501 setComboItem(m_papertype, ch->get(
"text"));
503 else if ((ch = (driver()->findOption(
"InputSlot"))) &&
504 (ch =
static_cast<DrListOption*
>(ch)->findChoice(value)))
507 setComboItem(m_inputslot, ch->get(
"text"));
511 kdWarning() <<
"media option '" << value <<
"' not handled." << endl;
514 value = opts[
"PageSize"];
515 if (m_pagesize->isEnabled() && !value.isEmpty())
517 DrBase *ch = ((DrListOption*)driver()->findOption(
"PageSize"))->findChoice(value);
518 if (ch) setComboItem(m_pagesize, ch->get(
"text"));
520 value = opts[
"MediaType"];
521 if (m_papertype->isEnabled() && !value.isEmpty())
523 DrBase *ch = ((DrListOption*)driver()->findOption(
"MediaType"))->findChoice(value);
524 if (ch) setComboItem(m_papertype, ch->get(
"text"));
526 value = opts[
"InputSlot"];
527 if (m_inputslot && m_inputslot->isEnabled() && !value.isEmpty())
529 DrBase *ch = ((DrListOption*)driver()->findOption(
"InputSlot"))->findChoice(value);
530 if (ch) setComboItem(m_inputslot, ch->get(
"text"));
533 value = opts[
"Duplex"];
534 if (m_duplexbox->isEnabled() && !value.isEmpty())
537 if (value ==
"DuplexNoTumble" || value ==
"On") ID = 1;
538 else if (value ==
"DuplexTumble") ID = 2;
539 m_duplexbox->setButton(ID);
540 slotDuplexChanged(ID);
546 value = opts[
"media"];
547 if (!value.isEmpty())
550 TQStringList l = TQStringList::split(
',',value,
false);
551 for(TQStringList::ConstIterator it = l.begin(); it != l.end(); ++it)
555 if ((index=findOption(default_size,DEFAULT_SIZE,value)) >= 0)
556 m_pagesize->setCurrentItem(index);
557 else if ((index=findOption(default_type,DEFAULT_TYPE,value)) >= 0)
558 m_papertype->setCurrentItem(index);
559 else if ((index=findOption(default_source,DEFAULT_SOURCE,value)) >= 0)
560 m_inputslot->setCurrentItem(index);
562 kdWarning() <<
"media option '" << value <<
"' not handled." << endl;
567 value = opts[
"sides"];
569 if (value ==
"two-sided-long-edge") ID = 1;
570 else if (value ==
"two-sided-short-edge") ID = 2;
571 m_duplexbox->setButton(ID);
572 slotDuplexChanged(ID);
576 value = opts[
"job-sheets"];
577 if (!value.isEmpty())
579 TQStringList l = TQStringList::split(
',',value,
false);
580 if (l.count() > 0) setComboItem(m_startbanner,l[0]);
581 if (l.count() > 1) setComboItem(m_endbanner,l[1]);
585 value = opts[
"orientation-requested"];
586 if (!value.isEmpty())
589 int ID = value.toInt(&ok)-3;
592 m_orientbox->setButton(ID);
593 slotOrientationChanged(ID);
598 value = opts[
"number-up"];
599 if (!value.isEmpty())
602 int ID = TQMIN(value.toInt(&ok)-1,2);
605 m_nupbox->setButton(ID);
610 if ( m_orientbox->isEnabled() )
611 m_orientbox->setDisabled( opts[
"kde-orientation-fixed" ] ==
"1" );
612 if ( m_pagesize->isEnabled() )
613 m_pagesize->setDisabled( opts[
"kde-pagesize-fixed" ] ==
"1" );
616 void KPGeneralPage::getOptions(TQMap<TQString,TQString>& opts,
bool incldef)
623 if ((opt=(DrListOption*)driver()->findOption(
"PageSize")) != NULL)
625 DrBase *ch = opt->choices()->at(m_pagesize->currentItem());
626 if (incldef || ch->name() != opt->get(
"default")) opts[
"PageSize"] = ch->name();
628 if ((opt=(DrListOption*)driver()->findOption(
"MediaType")) != NULL)
630 DrBase *ch = opt->choices()->at(m_papertype->currentItem());
631 if (incldef || ch->name() != opt->get(
"default")) opts[
"MediaType"] = ch->name();
633 if ((opt=(DrListOption*)driver()->findOption(
"InputSlot")) != NULL)
635 DrBase *ch = opt->choices()->at(m_inputslot->currentItem());
636 if (incldef || ch->name() != opt->get(
"default")) opts[
"InputSlot"] = ch->name();
639 if (m_duplexbox->isEnabled() && (opt=(DrListOption*)driver()->findOption(
"Duplex")) != NULL)
641 bool twoChoices = ( m_duplexbox->count() == 2 );
642 switch (m_duplexbox->id(m_duplexbox->selected()))
644 case DUPLEX_NONE_ID: value = ( twoChoices ?
"Off" :
"None" );
break;
645 case DUPLEX_LONG_ID: value = ( twoChoices ?
"On" :
"DuplexNoTumble" );
break;
646 case DUPLEX_SHORT_ID: value =
"DuplexTumble";
break;
648 if (incldef || value != opt->get(
"default")) opts[
"Duplex"] = value;
653 value = TQString(
"%1,%2,%3").arg(default_size[m_pagesize->currentItem()*2]).arg(default_type[m_papertype->currentItem()*2]).arg(default_source[m_inputslot->currentItem()*2]);
654 opts[
"media"] = value;
656 if (m_duplexbox->isEnabled())
658 switch (m_duplexbox->id(m_duplexbox->selected()))
660 case 0: value =
"one-sided";
break;
661 case 1: value =
"two-sided-long-edge";
break;
662 case 2: value =
"two-sided-short-edge";
break;
664 opts[
"sides"] = value;
668 value = TQString::number(m_orientbox->id(m_orientbox->selected())+3);
669 if (value !=
"3" || incldef) opts[
"orientation-requested"] = value;
671 if (m_nupbox->isEnabled())
673 switch (m_nupbox->id(m_nupbox->selected()))
675 case 0: value =
"1";
break;
676 case 1: value =
"2";
break;
677 case 2: value =
"4";
break;
679 if (value !=
"1" || incldef) opts[
"number-up"] = value;
682 if (m_bannerbox->isEnabled())
684 TQStringList l = TQStringList::split(
',',printer()->option(
"kde-banners"),
false);
685 if (incldef || (l.count() == 2 && (l[0] != m_startbanner->currentText() || l[1] != m_endbanner->currentText()))
686 || (l.count() == 0 && (m_startbanner->currentText() !=
"none" || m_endbanner->currentText() !=
"none")))
688 value = TQString(
"%1,%2").arg(m_startbanner->currentText()).arg(m_endbanner->currentText());
689 opts[
"job-sheets"] = value;
694 void KPGeneralPage::slotOrientationChanged(
int ID)
699 case ORIENT_PORTRAIT_ID: iconstr =
"tdeprint_portrait";
break;
700 case ORIENT_LANDSCAPE_ID: iconstr =
"tdeprint_landscape";
break;
701 case ORIENT_REVPORTRAIT_ID: iconstr =
"tdeprint_revportrait";
break;
702 case ORIENT_REVLANDSCAPE_ID: iconstr =
"tdeprint_revlandscape";
break;
703 default: iconstr =
"tdeprint_portrait";
break;
705 m_orientpix->setPixmap(UserIcon(iconstr));
708 void KPGeneralPage::slotNupChanged(
int ID)
713 case NUP_1_ID: iconstr =
"tdeprint_nup1";
break;
714 case NUP_2_ID: iconstr =
"tdeprint_nup2";
break;
715 case NUP_4_ID: iconstr =
"tdeprint_nup4";
break;
716 default: iconstr =
"tdeprint_nup1";
break;
718 m_nuppix->setPixmap(UserIcon(iconstr));
721 void KPGeneralPage::slotDuplexChanged(
int ID)
723 if (m_duplexbox->isEnabled())
728 case DUPLEX_NONE_ID: iconstr =
"tdeprint_duplex_none";
break;
729 case DUPLEX_LONG_ID: iconstr =
"tdeprint_duplex_long";
break;
730 case DUPLEX_SHORT_ID: iconstr =
"tdeprint_duplex_short";
break;
731 default: iconstr =
"tdeprint_duplex_none";
break;
733 m_duplexpix->setPixmap(UserIcon(iconstr));
736 #include "kpgeneralpage.moc"
This class is intended to be used as base class for customized print dialog page.
PageSize
Defines the paper size to use.