00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#include "kpgeneralpage.h"
00021
#include "driver.h"
00022
#include "kmprinter.h"
00023
#include "kprinter.h"
00024
00025
#include <qcombobox.h>
00026
#include <qlabel.h>
00027
#include <qbuttongroup.h>
00028
#include <qlayout.h>
00029
#include <qradiobutton.h>
00030
#include <qwhatsthis.h>
00031
00032
#include <kcursor.h>
00033
#include <kdebug.h>
00034
#include <kdialog.h>
00035
#include <kiconloader.h>
00036
#include <klocale.h>
00037
00038
00039
#define ORIENT_PORTRAIT_ID 0
00040
#define ORIENT_LANDSCAPE_ID 1
00041
#define ORIENT_REVLANDSCAPE_ID 2
00042
#define ORIENT_REVPORTRAIT_ID 3
00043
00044
#define DUPLEX_NONE_ID 0
00045
#define DUPLEX_LONG_ID 1
00046
#define DUPLEX_SHORT_ID 2
00047
00048
#define NUP_1_ID 0
00049
#define NUP_2_ID 1
00050
#define NUP_4_ID 2
00051
00052
static void initCombo(
QComboBox *cb, DrListOption *opt)
00053 {
00054 cb->clear();
00055
QPtrListIterator<DrBase> it(*(opt->choices()));
00056
for (;it.current();++it)
00057 {
00058 cb->insertItem(it.current()->get(
"text"));
00059
if (it.current() == opt->currentChoice())
00060 cb->setCurrentItem(cb->count()-1);
00061 }
00062 }
00063
00064
static void setComboItem(
QComboBox *cb,
const QString& txt)
00065 {
00066
for (
int i=0;i<cb->count();i++)
00067
if (cb->text(i) == txt)
00068 {
00069 cb->setCurrentItem(i);
00070
return;
00071 }
00072 }
00073
00074
static int findOption(
const char *strs[],
int n,
const QString& txt)
00075 {
00076
for (
int i=0;i<n;i+=2)
00077
if (txt == strs[i])
return (i/2);
00078
return (-1);
00079 }
00080
00081
00082
00083
00084
static const char* default_size[] = {
00085
"A4", I18N_NOOP(
"ISO A4"),
00086
"Letter", I18N_NOOP(
"US Letter"),
00087
"Legal", I18N_NOOP(
"US Legal"),
00088
"Ledger", I18N_NOOP(
"Ledger"),
00089
"Folio", I18N_NOOP(
"Folio"),
00090
"Comm10", I18N_NOOP(
"US #10 Envelope"),
00091
"DL", I18N_NOOP(
"ISO DL Envelope"),
00092
"Tabloid", I18N_NOOP(
"Tabloid"),
00093
"A3", I18N_NOOP(
"ISO A3" ),
00094
"A2", I18N_NOOP(
"ISO A2" ),
00095
"A1", I18N_NOOP(
"ISO A1" ),
00096
"A0", I18N_NOOP(
"ISO A0" )
00097 };
00098
00099
#define SMALLSIZE_BEGIN 0
00100
#define MEDIUMSIZE_BEGIN 14
00101
#define HIGHSIZE_BEGIN 20
00102
#define DEFAULT_SIZE 24
00103
00104
#define DEFAULT_SOURCE 8
00105
static const char* default_source[] = {
00106
"Upper", I18N_NOOP(
"Upper Tray"),
00107
"Lower", I18N_NOOP(
"Lower Tray"),
00108
"MultiPurpose", I18N_NOOP(
"Multi-Purpose Tray"),
00109
"LargeCapacity", I18N_NOOP(
"Large Capacity Tray")
00110 };
00111
#define DEFAULT_TYPE 4
00112
static const char* default_type[] = {
00113
"Normal", I18N_NOOP(
"Normal"),
00114
"Transparency", I18N_NOOP(
"Transparency")
00115 };
00116
00117
00118
00119 KPGeneralPage::KPGeneralPage(KMPrinter *pr, DrMain *dr,
QWidget *parent,
const char *name)
00120 :
KPrintDialogPage(pr,dr,parent,name)
00121 {
00122
00123
QString whatsThisPrintPropertiesGeneralPage = i18n(
" <qt> "
00124
" <p><b>\"General\"</b> </p> "
00125
" <p>This dialog page contains <em>general</em> print job settings."
00126
" General settings are applicable to most printers, most jobs "
00127
" and most job file types. "
00128
" <p>To get more specific help, enable the \"WhatsThis\" cursor and click on any of the "
00129
" text labels or GUI elements of this dialog. "
00130
" </qt>" );
00131
QString whatsThisGeneralPageSizeLabel = i18n(
" <qt> "
00132
" <p><b>Page size:</b> Select paper size to be printed on from "
00133
" the drop-down menu. </p>"
00134
" <p>The exact list of choices depends on the printer driver (\"PPD\") you have installed.</p> "
00135
" <br> "
00136
" <hr> "
00137
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00138
" with the CUPS commandline job option parameter:</em> "
00139
" <pre>"
00140
" -o PageSize=... # examples: \"A4\" or \"Letter\" "
00141
" </pre>"
00142
" </p> "
00143
" </qt>" );
00144
QString whatsThisGeneralPaperTypeLabel = i18n(
" <qt> "
00145
" <p><b>Paper type:</b> Select paper type to be printed on from "
00146
" the drop-down menu. </p>"
00147
" <p>The exact list of choices depends on the printer driver (\"PPD\") you have installed. </p>"
00148
" <br> "
00149
" <hr> "
00150
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00151
" with the CUPS commandline job option parameter:</em> "
00152
" <pre>"
00153
" -o MediaType=... # example: \"Transparency\" "
00154
" </pre>"
00155
" </p> "
00156
" </qt>" );
00157
QString whatsThisGeneralPaperSourceLabel = i18n(
" <qt> "
00158
" <p><b>Paper source:</b> Select paper source tray for the paper"
00159
" to be printed on from the drop-down menu. "
00160
" <p>The exact list of choices depends on the printer driver (\"PPD\") you have installed. </p>"
00161
" <br> "
00162
" <hr> "
00163
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00164
" with the CUPS commandline job option parameter:</em> "
00165
" <pre>"
00166
" -o InputSlot=... # examples: \"Lower\" or \"LargeCapacity\" "
00167
" </pre>"
00168
" </p> "
00169
" </qt>" );
00170
QString whatsThisGeneralOrientationLabel = i18n(
" <qt> "
00171
" <p><b>Image Orientation:</b> Orientation of the printed "
00172
" page image on your paper is controlled by the radio buttons. By default, "
00173
" the orientation is <em>Portrait</em> "
00174
" <p>You can select 4 alternatives: "
00175
" <ul> "
00176
" <li> <b>Portrait.</b>.Portrait is the default setting. </li> "
00177
" <li> <b>Landscape.</b> </li> "
00178
" <li> <b>Reverse Landscape.</b> Reverse Landscape prints the images upside down. </li> "
00179
" <li> <b>Reverse Portrait.</b> Reverse Portrait prints the image upside down.</li> "
00180
" </ul> "
00181
" The icon changes according to your selection.</p>"
00182
" <br> "
00183
" <hr> "
00184
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00185
" with the CUPS commandline job option parameter:</em> "
00186
" <pre>"
00187
" -o orientation-requested=... # examples: \"landscape\" or \"reverse-portrait\" "
00188
" </pre>"
00189
" </p> "
00190
" </qt>" );
00191
QString whatsThisGeneralDuplexLabel = i18n(
" <qt> "
00192
" <p><b>Duplex Printing:</b> These controls may be grayed out if your printer "
00193
" does not support <em>duplex printing</em> (i.e. printing on both sides of the sheet). "
00194
" These controls are active if your printer supports duplex printing. "
00195
" <p> "
00196
" You can choose from 3 alternatives: </p>"
00197
" <ul> "
00198
" <li> <b>None.</b> This prints each page of the job on one side of the sheets only. </li> "
00199
" <li> <b>Long Side.</b> This prints the job on both sides of the paper sheets. "
00200
" It prints the job in a way so that the backside has the same orientation as the front "
00201
" side if you turn the paper over the long edge. (Some printer drivers name this mode "
00202
" <em>duplex-non-tumbled</em>). </li> "
00203
" <li> <b>Short Side.</b> This prints the job on both sides of the paper sheets. "
00204
" It prints the job so that the backside has the reverse orientation from the front "
00205
" side if you turn the paper over the long edge, but the same orientation, if you turn it over "
00206
" the short edge. (Some printer drivers name this mode "
00207
" <em>duplex-tumbled</em>). </li> "
00208
" </ul> "
00209
" <hr> "
00210
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00211
" with the CUPS commandline job option parameter:</em> "
00212
" <pre>"
00213
" -o duplex=... # examples: \"tumble\" or \"two-sided-short-edge\" "
00214
" </pre>"
00215
" </p> "
00216
" </qt>" );
00217
QString whatsThisGeneralBannersLabel = i18n(
" <qt> "
00218
" <p><b>Banner Page(s):</b> Select banner(s) to print one or two special sheets "
00219
" of paper just before or after your main job. </p>"
00220
" <p>Banners may contain some pieces of job information, such as user name, time of printing, job"
00221
" title and more. </p>"
00222
" <p>Banner pages are useful to separate different jobs more easily, especially in a multi-user "
00223
" environment. </p>"
00224
" <p><em><b>Hint:</em></b> You can design your own banner pages. To make use of them, just put the banner "
00225
" file into the standard CUPS <em>banners</em> directory (This is usually <em>\"/usr/share/cups/banner/\"</em> "
00226
" Your custom banner(s) must have one of the supported printable formats. "
00227
" Supported formats are ASCII text, PostScript, PDF and nearly any image format such as PNG, JPEG or "
00228
" GIF. Your added banner pages will appear in the drop down menu after a restart of CUPS. </p>"
00229
" <p>CUPS comes with a selection of banner pages. </p>"
00230
" <br> "
00231
" <hr> "
00232
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00233
" with the CUPS commandline job option parameter:</em> "
00234
" <pre>"
00235
" -o job-sheets=... # examples: \"standard\" or \"topsecret\" "
00236
" </pre>"
00237
" </p> "
00238
" </qt>" );
00239
QString whatsThisGeneralPagesPerSheetLabel = i18n(
" <qt> "
00240
" <p><b>Pages per Sheet:</b> "
00241
" You can choose to print more than one page onto each sheet of paper. "
00242
" This is sometimes useful to save paper. </p>"
00243
" <p><b>Note 1:</b> the page images get scaled down accordingly to print 2 or 4 pages per sheet. "
00244
" The page image does not get scaled if you print 1 page per sheet (the default setting.). "
00245
" <p><b>Note 2:</b> If you select multiple pages per sheet here, the scaling and re-arranging is done "
00246
" by your printing system. Be aware, that some printers can by themselves print multiple pages per sheet. "
00247
" In this case you find the option in the printer driver settings. Be careful: if you enable multiple "
00248
" pages per sheet in both places, your printout will not look as you intended. </p>"
00249
" <br> "
00250
" <hr> "
00251
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00252
" with the CUPS commandline job option parameter:</em> "
00253
" <pre>"
00254
" -o number-up=... # examples: \"2\" or \"4\" "
00255
" </pre>"
00256
" </p> "
00257
" </qt>" );
00258
00259
00260 setTitle(i18n(
"General"));
00261
00262
00263
QLabel *m_pagesizelabel =
new QLabel(i18n(
"Page s&ize:"),
this);
00264 m_pagesizelabel->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
00265 QWhatsThis::add(m_pagesizelabel, whatsThisGeneralPageSizeLabel);
00266
00267 QLabel *m_papertypelabel =
new QLabel(i18n(
"Paper t&ype:"),
this);
00268 m_papertypelabel->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
00269 QWhatsThis::add(m_papertypelabel, whatsThisGeneralPaperTypeLabel);
00270
00271 QLabel *m_inputslotlabel =
new QLabel(i18n(
"Paper so&urce:"),
this);
00272 m_inputslotlabel->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
00273 QWhatsThis::add(m_inputslotlabel, whatsThisGeneralPaperSourceLabel);
00274
00275 m_pagesize =
new QComboBox(
this);
00276 QWhatsThis::add(m_pagesize, whatsThisGeneralPageSizeLabel);
00277
00278 m_papertype =
new QComboBox(
this);
00279 QWhatsThis::add(m_papertype, whatsThisGeneralPaperTypeLabel);
00280
00281 m_inputslot =
new QComboBox(
this);
00282 QWhatsThis::add(m_inputslot, whatsThisGeneralPaperSourceLabel);
00283
00284 m_pagesizelabel->setBuddy(m_pagesize);
00285 m_papertypelabel->setBuddy(m_papertype);
00286 m_inputslotlabel->setBuddy(m_inputslot);
00287
00288 m_orientbox =
new QButtonGroup(0, Qt::Vertical, i18n(
"Orientation"),
this);
00289 QWhatsThis::add(m_orientbox, whatsThisGeneralOrientationLabel);
00290
00291 m_duplexbox =
new QButtonGroup(0, Qt::Vertical, i18n(
"Duplex Printing"),
this);
00292 QWhatsThis::add(m_duplexbox, whatsThisGeneralDuplexLabel);
00293
00294 m_nupbox =
new QButtonGroup(0, Qt::Vertical, i18n(
"Pages per Sheet"),
this);
00295 QWhatsThis::add(m_nupbox, whatsThisGeneralPagesPerSheetLabel);
00296
00297 m_bannerbox =
new QGroupBox(0, Qt::Vertical, i18n(
"Banners"),
this);
00298 QWhatsThis::add(m_bannerbox, whatsThisGeneralBannersLabel);
00299
00300
QRadioButton *m_portrait =
new QRadioButton(i18n(
"&Portrait"), m_orientbox);
00301 QRadioButton *m_landscape =
new QRadioButton(i18n(
"&Landscape"), m_orientbox);
00302 QRadioButton *m_revland =
new QRadioButton(i18n(
"&Reverse landscape"), m_orientbox);
00303 QRadioButton *m_revport =
new QRadioButton(i18n(
"R&everse portrait"), m_orientbox);
00304
00305 m_portrait->setChecked(
true);
00306 m_orientpix =
new QLabel(m_orientbox);
00307 m_orientpix->setAlignment(Qt::AlignCenter);
00308 QRadioButton *m_dupnone =
new QRadioButton(i18n(
"duplex orientation",
"&None"), m_duplexbox);
00309 QRadioButton *m_duplong =
new QRadioButton(i18n(
"duplex orientation",
"Lon&g side"), m_duplexbox);
00310 QRadioButton *m_dupshort =
new QRadioButton(i18n(
"duplex orientation",
"S&hort side"), m_duplexbox);
00311 m_dupnone->setChecked(
true);
00312 m_duplexpix =
new QLabel(m_duplexbox);
00313 m_duplexpix->setAlignment(Qt::AlignCenter);
00314 QRadioButton *m_nup1 =
new QRadioButton(
"&1", m_nupbox);
00315 QRadioButton *m_nup2 =
new QRadioButton(
"&2", m_nupbox);
00316 QRadioButton *m_nup4 =
new QRadioButton(
"&4", m_nupbox);
00317 m_nup1->setChecked(
true);
00318 m_nuppix =
new QLabel(m_nupbox);
00319 m_nuppix->setAlignment(Qt::AlignCenter);
00320 m_startbanner =
new QComboBox(m_bannerbox);
00321 m_endbanner =
new QComboBox(m_bannerbox);
00322 QLabel *m_startbannerlabel =
new QLabel(i18n(
"S&tart:"), m_bannerbox);
00323 QLabel *m_endbannerlabel =
new QLabel(i18n(
"En&d:"), m_bannerbox);
00324 m_startbannerlabel->setBuddy(m_startbanner);
00325 m_endbannerlabel->setBuddy(m_endbanner);
00326
00327
00328
QVBoxLayout *lay0 =
new QVBoxLayout(
this, 0, KDialog::spacingHint());
00329 QWhatsThis::add(
this, whatsThisPrintPropertiesGeneralPage);
00330
QGridLayout *lay1 =
new QGridLayout(0, 3, 2, 0, KDialog::spacingHint());
00331 QGridLayout *lay2 =
new QGridLayout(0, 2, 2, 0, KDialog::spacingHint());
00332 lay0->addStretch(1);
00333 lay0->addLayout(lay1);
00334 lay0->addStretch(1);
00335 lay0->addLayout(lay2);
00336 lay0->addStretch(2);
00337 lay1->addWidget(m_pagesizelabel, 0, 0);
00338 lay1->addWidget(m_papertypelabel, 1, 0);
00339 lay1->addWidget(m_inputslotlabel, 2, 0);
00340 lay1->addWidget(m_pagesize, 0, 1);
00341 lay1->addWidget(m_papertype, 1, 1);
00342 lay1->addWidget(m_inputslot, 2, 1);
00343 lay2->addWidget(m_orientbox, 0, 0);
00344 lay2->addWidget(m_bannerbox, 1, 0);
00345 lay2->addWidget(m_duplexbox, 0, 1);
00346 lay2->addWidget(m_nupbox, 1, 1);
00347 lay2->setColStretch(0, 1);
00348 lay2->setColStretch(1, 1);
00349 QGridLayout *lay3 =
new QGridLayout(m_orientbox->layout(), 4, 2,
00350 KDialog::spacingHint());
00351 lay3->addWidget(m_portrait, 0, 0);
00352 lay3->addWidget(m_landscape, 1, 0);
00353 lay3->addWidget(m_revland, 2, 0);
00354 lay3->addWidget(m_revport, 3, 0);
00355 lay3->addMultiCellWidget(m_orientpix, 0, 3, 1, 1);
00356 QGridLayout *lay4 =
new QGridLayout(m_duplexbox->layout(), 3, 2,
00357 KDialog::spacingHint());
00358 lay4->addWidget(m_dupnone, 0, 0);
00359 lay4->addWidget(m_duplong, 1, 0);
00360 lay4->addWidget(m_dupshort, 2, 0);
00361 lay4->addMultiCellWidget(m_duplexpix, 0, 2, 1, 1);
00362 lay4->setRowStretch( 0, 1 );
00363 QGridLayout *lay5 =
new QGridLayout(m_nupbox->layout(), 3, 2,
00364 KDialog::spacingHint());
00365 lay5->addWidget(m_nup1, 0, 0);
00366 lay5->addWidget(m_nup2, 1, 0);
00367 lay5->addWidget(m_nup4, 2, 0);
00368 lay5->addMultiCellWidget(m_nuppix, 0, 2, 1, 1);
00369 QGridLayout *lay6 =
new QGridLayout(m_bannerbox->layout(), 2, 2,
00370 KDialog::spacingHint());
00371 lay6->addWidget(m_startbannerlabel, 0, 0);
00372 lay6->addWidget(m_endbannerlabel, 1, 0);
00373 lay6->addWidget(m_startbanner, 0, 1);
00374 lay6->addWidget(m_endbanner, 1, 1);
00375 lay6->setColStretch(1, 1);
00376
00377
00378 connect(m_orientbox,SIGNAL(clicked(
int)),SLOT(slotOrientationChanged(
int)));
00379 connect(m_nupbox,SIGNAL(clicked(
int)),SLOT(slotNupChanged(
int)));
00380 connect(m_duplexbox,SIGNAL(clicked(
int)),SLOT(slotDuplexChanged(
int)));
00381
00382
00383 initialize();
00384 }
00385
00386 KPGeneralPage::~KPGeneralPage()
00387 {
00388 }
00389
00390
void KPGeneralPage::initialize()
00391 {
00392
if (driver())
00393 {
00394
00395 DrListOption *opt = (DrListOption*)driver()->findOption(
"PageSize");
00396
if (opt) initCombo(m_pagesize,opt);
00397
else m_pagesize->setEnabled(
false);
00398 opt = (DrListOption*)driver()->findOption(
"MediaType");
00399
if (opt) initCombo(m_papertype,opt);
00400
else m_papertype->setEnabled(
false);
00401 opt = (DrListOption*)driver()->findOption(
"InputSlot");
00402
if (opt) initCombo(m_inputslot,opt);
00403
else m_inputslot->setEnabled(
false);
00404
00405 opt = (DrListOption*)driver()->findOption(
"Duplex");
00406
if (opt)
00407 {
00408
if ( opt->choices()->count() == 2 )
00409 {
00410
00411
QButton *btn = m_duplexbox->find( DUPLEX_SHORT_ID );
00412 m_duplexbox->remove( btn );
00413 btn->hide();
00414
00415 m_duplexbox->find( DUPLEX_NONE_ID )->setText( i18n(
"Disabled" ) );
00416 m_duplexbox->find( DUPLEX_LONG_ID )->setText( i18n(
"Enabled" ) );
00417 m_duplexpix->hide();
00418 }
00419
if (opt->currentChoice())
00420 {
00421
int ID(DUPLEX_NONE_ID);
00422
if (opt->currentChoice()->name() ==
"DuplexNoTumble" || opt->currentChoice()->name() ==
"On") ID = DUPLEX_LONG_ID;
00423
else if (opt->currentChoice()->name() ==
"DuplexTumble") ID = DUPLEX_SHORT_ID;
00424 m_duplexbox->setButton(ID);
00425 slotDuplexChanged(ID);
00426 }
00427 }
00428
else m_duplexbox->setEnabled(
false);
00429 }
00430
else
00431 {
00432
00433
for (
int i=SMALLSIZE_BEGIN+1;i<MEDIUMSIZE_BEGIN;i+=2)
00434 m_pagesize->insertItem(i18n(default_size[i]));
00435
if ( printer()->printerCap() & KMPrinter::CapMedium )
00436
for (
int i=MEDIUMSIZE_BEGIN+1; i<HIGHSIZE_BEGIN; i+=2 )
00437 m_pagesize->insertItem(i18n(default_size[i]));
00438
if ( printer()->printerCap() & KMPrinter::CapLarge )
00439
for (
int i=HIGHSIZE_BEGIN+1; i<DEFAULT_SIZE; i+=2 )
00440 m_pagesize->insertItem(i18n(default_size[i]));
00441
00442
QString psname = pageSizeToPageName((KPrinter::PageSize)(KGlobal::locale()->pageSize()));
00443
int index = findOption(default_size, DEFAULT_SIZE, psname);
00444
if (index >= 0)
00445 m_pagesize->setCurrentItem(index);
00446
00447
for (
int i=1;i<DEFAULT_TYPE;i+=2)
00448 m_papertype->insertItem(i18n(default_type[i]));
00449
00450
for (
int i=1;i<DEFAULT_SOURCE;i+=2)
00451 m_inputslot->insertItem(i18n(default_source[i]));
00452
00453
00454 m_duplexbox->setEnabled( printer()->printerCap() & KMPrinter::CapDuplex );
00455 }
00456
00457
00458
QStringList values = QStringList::split(
',',printer()->option(
"kde-banners-supported"),
false);
00459
if (values.count() > 0)
00460 {
00461
for (QStringList::ConstIterator it = values.begin(); it != values.end(); ++it)
00462 {
00463 m_startbanner->insertItem(*it);
00464 m_endbanner->insertItem(*it);
00465 }
00466 values = QStringList::split(
',',printer()->option(
"kde-banners"),
false);
00467
while (values.count() < 2) values.append(
"none");
00468 setComboItem(m_startbanner, values[0]);
00469 setComboItem(m_endbanner, values[1]);
00470 }
00471
else
00472 m_bannerbox->setEnabled(
false);
00473
00474 slotOrientationChanged(ORIENT_PORTRAIT_ID);
00475 slotNupChanged(NUP_1_ID);
00476 }
00477
00478
void KPGeneralPage::setOptions(
const QMap<QString,QString>& opts)
00479 {
00480
QString value;
00481
00482
if (driver())
00483 {
00484 value = opts[
"media"];
00485
QStringList l = QStringList::split(
',',value,
false);
00486
for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it)
00487 {
00488 value = *it;
00489 DrBase *ch;
00490
if ((ch = ((DrListOption*)driver()->findOption(
"PageSize"))->findChoice(value)))
00491 {
00492
if (m_pagesize->isEnabled())
00493 setComboItem(m_pagesize, ch->get(
"text"));
00494 }
00495
else if ((ch = ((DrListOption*)driver()->findOption(
"MediaType"))->findChoice(value)))
00496 {
00497
if (m_papertype->isEnabled())
00498 setComboItem(m_papertype, ch->get(
"text"));
00499 }
00500
else if ((ch = ((DrListOption*)driver()->findOption(
"InputSlot"))->findChoice(value)))
00501 {
00502
if (m_inputslot)
00503 setComboItem(m_inputslot, ch->get(
"text"));
00504 }
00505
else
00506 {
00507 kdWarning() <<
"media option '" << value <<
"' not handled." << endl;
00508 }
00509 }
00510 value = opts[
"PageSize"];
00511
if (m_pagesize->isEnabled() && !value.isEmpty())
00512 {
00513 DrBase *ch = ((DrListOption*)driver()->findOption(
"PageSize"))->findChoice(value);
00514
if (ch) setComboItem(m_pagesize, ch->get(
"text"));
00515 }
00516 value = opts[
"MediaType"];
00517
if (m_papertype->isEnabled() && !value.isEmpty())
00518 {
00519 DrBase *ch = ((DrListOption*)driver()->findOption(
"MediaType"))->findChoice(value);
00520
if (ch) setComboItem(m_papertype, ch->get(
"text"));
00521 }
00522 value = opts[
"InputSlot"];
00523
if (m_inputslot->isEnabled() && !value.isEmpty())
00524 {
00525 DrBase *ch = ((DrListOption*)driver()->findOption(
"InputSlot"))->findChoice(value);
00526
if (ch) setComboItem(m_inputslot, ch->get(
"text"));
00527 }
00528
00529 value = opts[
"Duplex"];
00530
if (m_duplexbox->isEnabled() && !value.isEmpty())
00531 {
00532
int ID(0);
00533
if (value ==
"DuplexNoTumble" || value ==
"On") ID = 1;
00534
else if (value ==
"DuplexTumble") ID = 2;
00535 m_duplexbox->setButton(ID);
00536 slotDuplexChanged(ID);
00537 }
00538 }
00539
else
00540 {
00541
00542 value = opts[
"media"];
00543
if (!value.isEmpty())
00544 {
00545
int index(-1);
00546
QStringList l = QStringList::split(
',',value,
false);
00547
for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it)
00548 {
00549 value = *it;
00550
00551
if ((index=findOption(default_size,DEFAULT_SIZE,value)) >= 0)
00552 m_pagesize->setCurrentItem(index);
00553
else if ((index=findOption(default_type,DEFAULT_TYPE,value)) >= 0)
00554 m_papertype->setCurrentItem(index);
00555
else if ((index=findOption(default_source,DEFAULT_SOURCE,value)) >= 0)
00556 m_inputslot->setCurrentItem(index);
00557
else
00558 kdWarning() <<
"media option '" << value <<
"' not handled." << endl;
00559 }
00560 }
00561
00562
00563 value = opts[
"sides"];
00564
int ID(0);
00565
if (value ==
"two-sided-long-edge") ID = 1;
00566
else if (value ==
"two-sided-short-edge") ID = 2;
00567 m_duplexbox->setButton(ID);
00568 slotDuplexChanged(ID);
00569 }
00570
00571
00572 value = opts[
"job-sheets"];
00573
if (!value.isEmpty())
00574 {
00575
QStringList l = QStringList::split(
',',value,
false);
00576
if (l.count() > 0) setComboItem(m_startbanner,l[0]);
00577
if (l.count() > 1) setComboItem(m_endbanner,l[1]);
00578 }
00579
00580
00581 value = opts[
"orientation-requested"];
00582
if (!value.isEmpty())
00583 {
00584
bool ok;
00585
int ID = value.toInt(&ok)-3;
00586
if (ok)
00587 {
00588 m_orientbox->setButton(ID);
00589 slotOrientationChanged(ID);
00590 }
00591 }
00592
00593
00594 value = opts[
"number-up"];
00595
if (!value.isEmpty())
00596 {
00597
bool ok;
00598
int ID = QMIN(value.toInt(&ok)-1,2);
00599
if (ok)
00600 {
00601 m_nupbox->setButton(ID);
00602 slotNupChanged(ID);
00603 }
00604 }
00605
00606
if ( m_orientbox->isEnabled() )
00607 m_orientbox->setDisabled( opts[
"kde-orientation-fixed" ] ==
"1" );
00608
if ( m_pagesize->isEnabled() )
00609 m_pagesize->setDisabled( opts[
"kde-pagesize-fixed" ] ==
"1" );
00610 }
00611
00612
void KPGeneralPage::getOptions(
QMap<QString,QString>& opts,
bool incldef)
00613 {
00614
QString value;
00615
00616
if (driver())
00617 {
00618 DrListOption *opt;
00619
if ((opt=(DrListOption*)driver()->findOption(
"PageSize")) != NULL)
00620 {
00621 DrBase *ch = opt->choices()->at(m_pagesize->currentItem());
00622
if (incldef || ch->name() != opt->get(
"default")) opts[
"PageSize"] = ch->name();
00623 }
00624
if ((opt=(DrListOption*)driver()->findOption(
"MediaType")) != NULL)
00625 {
00626 DrBase *ch = opt->choices()->at(m_papertype->currentItem());
00627
if (incldef || ch->name() != opt->get(
"default")) opts[
"MediaType"] = ch->name();
00628 }
00629
if ((opt=(DrListOption*)driver()->findOption(
"InputSlot")) != NULL)
00630 {
00631 DrBase *ch = opt->choices()->at(m_inputslot->currentItem());
00632
if (incldef || ch->name() != opt->get(
"default")) opts[
"InputSlot"] = ch->name();
00633 }
00634
00635
if (m_duplexbox->isEnabled() && (opt=(DrListOption*)driver()->findOption(
"Duplex")) != NULL)
00636 {
00637
bool twoChoices = ( m_duplexbox->count() == 2 );
00638
switch (m_duplexbox->id(m_duplexbox->selected()))
00639 {
00640
case DUPLEX_NONE_ID: value = ( twoChoices ?
"Off" :
"None" );
break;
00641
case DUPLEX_LONG_ID: value = ( twoChoices ?
"On" :
"DuplexNoTumble" );
break;
00642
case DUPLEX_SHORT_ID: value =
"DuplexTumble";
break;
00643 }
00644
if (incldef || value != opt->get(
"default")) opts[
"Duplex"] = value;
00645 }
00646 }
00647
else
00648 {
00649 value =
QString(
"%1,%2,%3").arg(default_size[m_pagesize->currentItem()*2]).arg(default_type[m_papertype->currentItem()*2]).arg(default_source[m_inputslot->currentItem()*2]);
00650 opts[
"media"] = value;
00651
00652
if (m_duplexbox->isEnabled())
00653 {
00654
switch (m_duplexbox->id(m_duplexbox->selected()))
00655 {
00656
case 0: value =
"one-sided";
break;
00657
case 1: value =
"two-sided-long-edge";
break;
00658
case 2: value =
"two-sided-short-edge";
break;
00659 }
00660 opts[
"sides"] = value;
00661 }
00662 }
00663
00664 value = QString::number(m_orientbox->id(m_orientbox->selected())+3);
00665
if (value !=
"3" || incldef) opts[
"orientation-requested"] = value;
00666
00667
if (m_nupbox->isEnabled())
00668 {
00669
switch (m_nupbox->id(m_nupbox->selected()))
00670 {
00671
case 0: value =
"1";
break;
00672
case 1: value =
"2";
break;
00673
case 2: value =
"4";
break;
00674 }
00675
if (value !=
"1" || incldef) opts[
"number-up"] = value;
00676 }
00677
00678
if (m_bannerbox->isEnabled())
00679 {
00680
QStringList l = QStringList::split(
',',printer()->option(
"kde-banners"),
false);
00681
if (incldef || (l.count() == 2 && (l[0] != m_startbanner->currentText() || l[1] != m_endbanner->currentText()))
00682 || (l.count() == 0 && (m_startbanner->currentText() !=
"none" || m_endbanner->currentText() !=
"none")))
00683 {
00684 value =
QString(
"%1,%2").arg(m_startbanner->currentText()).arg(m_endbanner->currentText());
00685 opts[
"job-sheets"] = value;
00686 }
00687 }
00688 }
00689
00690
void KPGeneralPage::slotOrientationChanged(
int ID)
00691 {
00692
QString iconstr;
00693
switch (ID)
00694 {
00695
case ORIENT_PORTRAIT_ID: iconstr =
"kdeprint_portrait";
break;
00696
case ORIENT_LANDSCAPE_ID: iconstr =
"kdeprint_landscape";
break;
00697
case ORIENT_REVPORTRAIT_ID: iconstr =
"kdeprint_revportrait";
break;
00698
case ORIENT_REVLANDSCAPE_ID: iconstr =
"kdeprint_revlandscape";
break;
00699
default: iconstr =
"kdeprint_portrait";
break;
00700 }
00701 m_orientpix->setPixmap(UserIcon(iconstr));
00702 }
00703
00704
void KPGeneralPage::slotNupChanged(
int ID)
00705 {
00706
QString iconstr;
00707
switch (ID)
00708 {
00709
case NUP_1_ID: iconstr =
"kdeprint_nup1";
break;
00710
case NUP_2_ID: iconstr =
"kdeprint_nup2";
break;
00711
case NUP_4_ID: iconstr =
"kdeprint_nup4";
break;
00712
default: iconstr =
"kdeprint_nup1";
break;
00713 }
00714 m_nuppix->setPixmap(UserIcon(iconstr));
00715 }
00716
00717
void KPGeneralPage::slotDuplexChanged(
int ID)
00718 {
00719
if (m_duplexbox->isEnabled())
00720 {
00721
QString iconstr;
00722
switch (ID)
00723 {
00724
case DUPLEX_NONE_ID: iconstr =
"kdeprint_duplex_none";
break;
00725
case DUPLEX_LONG_ID: iconstr =
"kdeprint_duplex_long";
break;
00726
case DUPLEX_SHORT_ID: iconstr =
"kdeprint_duplex_short";
break;
00727
default: iconstr =
"kdeprint_duplex_none";
break;
00728 }
00729 m_duplexpix->setPixmap(UserIcon(iconstr));
00730 }
00731 }
00732
#include "kpgeneralpage.moc"