00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#include "kpimagepage.h"
00021
#include "imageposition.h"
00022
#include "imagepreview.h"
00023
#include "driver.h"
00024
00025
#include <qcombobox.h>
00026
#include <qbuttongroup.h>
00027
#include <qradiobutton.h>
00028
#include <qgroupbox.h>
00029
#include <qpushbutton.h>
00030
#include <qapplication.h>
00031
#include <qimage.h>
00032
#include <qlabel.h>
00033
#include <qlayout.h>
00034
#include <qwhatsthis.h>
00035
#include <klocale.h>
00036
#include <knuminput.h>
00037
#include <kseparator.h>
00038
#include <kstandarddirs.h>
00039
00040 KPImagePage::KPImagePage(DrMain *driver,
QWidget *parent,
const char *name)
00041 :
KPrintDialogPage(parent, name)
00042 {
00043
00044
QString whatsThisBrightnessImagePage = i18n(
" <qt> "
00045
" <p><b>Brightness:</b> Slider to control the brightness value of all colors used.</p>"
00046
" <p> The brightness value can range from 0 to 200. Values greater than 100 will "
00047
" lighten the print. Values less than 100 will darken the print. </p> "
00048
" <br> "
00049
" <hr> "
00050
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00051
" with the CUPS commandline job option parameter:</em> "
00052
" <pre>"
00053
" -o brightness=... # use range from \"0\" to \"200\" "
00054
" </pre> "
00055
" </p> "
00056
" </qt>" );
00057
00058
QString whatsThisHueImagePage = i18n(
" <qt> "
00059
" <p><b>Hue (Tint):</b> Slider to control the hue value for color rotation.</p>"
00060
" <p> The hue value is a number from -360 to 360 and represents the color hue rotation. "
00061
" The following table summarizes the change you will see for the base colors: "
00062
" <center> "
00063
" <table border=\"1\" width=\"70%\"> "
00064
" <tr><th><b>Original</b></th> <th><b>hue=-45</b></th> <th><b>hue=45</b></th> </tr> "
00065
" <tr><td>Red</td> <td>Purple</td> <td>Yellow-orange</td> </tr> "
00066
" <tr><td>Green</td> <td>Yellow-green</td> <td>Blue-green</td> </tr> "
00067
" <tr><td>Yellow</td> <td>Orange</td> <td>Green-yellow</td> </tr> "
00068
" <tr><td>Blue</td> <td>Sky-blue</td> <td>Purple</td> </tr> "
00069
" <tr><td>Magenta</td> <td>Indigo</td> <td>Crimson</td> </tr> "
00070
" <tr><td>Cyan</td> <td>Blue-green</td> <td>Light-navy-blue</td> </tr> "
00071
" </table> "
00072
" </center> "
00073
" <br> "
00074
" <hr> "
00075
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00076
" with the CUPS commandline job option parameter:</em> "
00077
" <pre>"
00078
" -o hue=... # use range from \"-360\" to \"360\" "
00079
" </pre>"
00080
" </p> "
00081
" </qt>" );
00082
00083
QString whatsThisSaturationImagePage = i18n(
" <qt> "
00084
" <p><b>Saturation:</b> Slider to control the saturation value for all colors used.</p>"
00085
" <p> The saturation value adjusts the saturation of the colors in an image, similar to "
00086
" the color knob on your television. The color saturation value.can range from 0 to 200."
00087
" On inkjet printers, a higher saturation value uses more ink. On laserjet printers, a "
00088
" higher saturation uses more toner. "
00089
" A color saturation of 0 produces a black-and-white print, while a value of 200 will "
00090
" make the colors extremely intense. </p>"
00091
" <br> "
00092
" <hr> "
00093
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00094
" with the CUPS commandline job option parameter:</em> "
00095
" <pre>"
00096
" -o saturation=... # use range from \"0\" to \"200\" "
00097
" </pre>"
00098
" </p> "
00099
" </qt>" );
00100
00101
QString whatsThisGammaImagePage = i18n(
" <qt> "
00102
" <p><b>Gamma:</b> Slider to control the gamma value for color correction.</p>"
00103
" <p> The gamma value can range from 1 to 3000. "
00104
" A gamma values greater than 1000 lightens the print. A gamma value less than 1000 "
00105
" darken the print. The default gamma is 1000. </p>"
00106
" <p><b>Note:</b></p> the gamma value adjustment is not visible in the thumbnail "
00107
" preview. </p> "
00108
" <br> "
00109
" <hr> "
00110
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00111
" with the CUPS commandline job option parameter:</em> "
00112
" <pre>"
00113
" -o gamma=... # use range from \"1\" to \"3000\" "
00114
" </pre>"
00115
" </p> "
00116
" </qt>" );
00117
00118
QString whatsThisImagePage = i18n(
" <qt> "
00119
" <p><b>Image Printing Options</b></p> "
00120
" <p>All options controlled on this page only apply to printing images. "
00121
" Most image file formats are supported. To name a few: JPEG, TIFF, PNG, GIF, "
00122
" PNM (PBM/PGM/PNM/PPM), Sun Raster, SGI RGB, Windows BMP."
00123
" Options to influence color output of image printouts are: "
00124
" <ul> "
00125
" <li> Brightness </li>"
00126
" <li> Hue </li>"
00127
" <li> Saturation </li>"
00128
" <li> Gamma </li>"
00129
" </ul> "
00130
" <p>For a more detailed explanation about Brightness, Hue, Saturation and Gamma settings, please "
00131
" look at the 'WhatsThis' items provided for these controls. "
00132
" </p> "
00133
" </p> "
00134
" </qt>" );
00135
00136
QString whatsThisColorationPreviewImagePage = i18n(
" <qt> "
00137
" <p><b>Coloration Preview Thumbnail</b></p> "
00138
" <p>The coloration preview thumbnail indicates change of image coloration by different settings. "
00139
" Options to influence output are: "
00140
" <ul> "
00141
" <li> Brightness </li>"
00142
" <li> Hue (Tint) </li>"
00143
" <li> Saturation </li>"
00144
" <li> Gamma </li>"
00145
" </ul> "
00146
" </p> "
00147
" <p>For a more detailed explanation about Brightness, Hue, Saturation and Gamma settings, please "
00148
" look at the 'WhatsThis' items provided for these controls. "
00149
" </p> "
00150
" </qt>" );
00151
00152
QString whatsThisSizeImagePage = i18n(
" <qt> "
00153
" <p><b>Image Size:</b> Dropdown menu to control the image size on the printed paper. Dropdown "
00154
" works in conjunction with slider below. Dropdown options are:.</p>"
00155
" <ul> "
00156
" <li> <b>Natural Image Size:</b> Image prints in its natural image size. If it does not fit onto "
00157
" one sheet, the printout will be spread across multiple sheets. Note, that the slider is disabled "
00158
" when selecting 'natural image size' in the dropdown menu. </li>"
00159
" <li> <b>Resolution (ppi):</b> The resolution value slider covers a number range from 1 to 1200. "
00160
" It specifies the resolution of the image in Pixels Per Inch (PPI). An image that is 3000x2400 pixels "
00161
" will print 10x8 inches at 300 pixels per inch, for example, but 5x4 inches at 600 pixels per inch."
00162
" If the specified resolution makes the image larger than the page, multiple pages will be printed. "
00163
" Resolution defaults to 72 ppi. "
00164
" </li>"
00165
" <li> <b>% of Page Size:</b> The percent value slider covers numbers from 1 to 800. It specifies the size "
00166
" in relation to the page (not the image). A scaling of 100 percent will fill the page as completely "
00167
" as the image aspect ratio allows (doing auto-rotation of the image as needed). "
00168
" A scaling of more than 100 will print the image across multiple "
00169
" sheets. A scaling of 200 percent will print on up to 4 pages. </li>"
00170
" Scaling in % of page size defaults to 100 %. "
00171
" <li> <b>% of Natural Image Size:</b> The percent value slider moves from 1 to 800. It specifies "
00172
" the printout size in relation "
00173
" to the natural image size. A scaling of 100 percent will print the image at its natural size, while a "
00174
" scaling of 50 percent will print the image at half its natural size. If the specified scaling makes "
00175
" the image larger than the page, multiple pages will be printed. "
00176
" Scaling in % of natural image size defaults to 100 %. "
00177
" </ul> "
00178
" <br> "
00179
" <hr> "
00180
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00181
" with the CUPS commandline job option parameter:</em> "
00182
" <pre>"
00183
" -o natural-scaling=... # range in % is 1....800 "
00184
" <br> "
00185
" -o scaling=... # range in % is 1....800 "
00186
" <br> "
00187
" -o ppi=... # range in ppi is 1...1200 "
00188
" </pre>"
00189
" </p> "
00190
" </qt>" );
00191
00192
QString whatsThisPreviewPositionImagePage = i18n(
" <qt> "
00193
" <p><b>Position Preview Thumbnail</b></p> "
00194
" <p>This position preview thumbnail indicates the position of the image on the paper sheet. "
00195
" <p>Click on horizontal and vertical radio buttons to move image alignment on paper around. Options are: "
00196
" <ul> "
00197
" <li> center </li>"
00198
" <li> top </li>"
00199
" <li> top-left </li>"
00200
" <li> left </li>"
00201
" <li> bottom-left </li>"
00202
" <li> bottom </li>"
00203
" <li> bottom-right</li>"
00204
" <li> right </li>"
00205
" <li> top-right </li>"
00206
" </ul> "
00207
" </p> "
00208
" </qt>" );
00209
00210
QString whatsThisResetButtonImagePage = i18n(
" <qt> "
00211
" <p><b>Reset to Default Values</b> </p> "
00212
" <p> Reset all coloration settings to default values. Default values are: "
00213
" <ul> "
00214
" <li> Brightness: 100 </li>"
00215
" <li> Hue (Tint). 0 </li>"
00216
" <li> Saturation: 100 </li>"
00217
" <li> Gamma: 1000 </li>"
00218
" </ul> "
00219
" </p> "
00220
" </qt>" );
00221
00222
QString whatsThisPositionImagePage = i18n(
" <qt> "
00223
" <p><b>Image Positioning:</b></p> "
00224
" <p>Select a pair of radiobuttons to "
00225
" move image to the position you want on the paper printout. Default "
00226
" is 'center'. </p> "
00227
" <br> "
00228
" <hr> "
00229
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00230
" with the CUPS commandline job option parameter:</em> "
00231
" <pre>"
00232
" -o position=... # examples: \"top-left\" or \"bottom\" "
00233
" </pre>"
00234
" </p> "
00235
" </qt>" );
00236
00237 setTitle(i18n(
"Image"));
00238
00239
QGroupBox *colorbox =
new QGroupBox(0, Qt::Vertical, i18n(
"Color Settings"),
this);
00240 QWhatsThis::add(
this, whatsThisImagePage);
00241 QGroupBox *sizebox =
new QGroupBox(0, Qt::Vertical, i18n(
"Image Size"),
this);
00242 QWhatsThis::add(sizebox, whatsThisSizeImagePage);
00243 QGroupBox *positionbox =
new QGroupBox(0, Qt::Vertical, i18n(
"Image Position"),
this);
00244 QWhatsThis::add(positionbox, whatsThisPositionImagePage);
00245
00246 m_brightness =
new KIntNumInput(100, colorbox);
00247 m_brightness->setLabel(i18n(
"&Brightness:"));
00248 m_brightness->setRange(0, 200, 20,
true);
00249 QWhatsThis::add(m_brightness, whatsThisBrightnessImagePage);
00250
00251 m_hue =
new KIntNumInput(m_brightness, 0, colorbox);
00252 m_hue->setLabel(i18n(
"&Hue (Color rotation):"));
00253 m_hue->setRange(-360, 360, 36,
true);
00254 QWhatsThis::add(m_hue, whatsThisHueImagePage);
00255
00256 m_saturation =
new KIntNumInput(m_brightness, 100, colorbox);
00257 m_saturation->setLabel(i18n(
"&Saturation:"));
00258 m_saturation->setRange(0, 200, 20,
true);
00259 QWhatsThis::add(m_saturation, whatsThisSaturationImagePage);
00260
00261 m_gamma =
new KIntNumInput(m_saturation, 1000, colorbox);
00262 m_gamma->setLabel(i18n(
"&Gamma (Color correction):"));
00263 m_gamma->setRange(1, 3000, 100,
true);
00264 QWhatsThis::add(m_gamma, whatsThisGammaImagePage);
00265
00266 connect(m_brightness, SIGNAL(valueChanged(
int)), SLOT(slotImageSettingsChanged()));
00267 connect(m_hue, SIGNAL(valueChanged(
int)), SLOT(slotImageSettingsChanged()));
00268 connect(m_saturation, SIGNAL(valueChanged(
int)), SLOT(slotImageSettingsChanged()));
00269
00270
00271 m_preview =
new ImagePreview(colorbox);
00272
bool useColor = (driver ? driver->get(
"colordevice") ==
"1" :
true);
00273 m_preview->setBlackAndWhite(!useColor);
00274 QWhatsThis::add(m_preview, whatsThisColorationPreviewImagePage);
00275
00276 m_hue->setEnabled(useColor);
00277 m_saturation->setEnabled(useColor);
00278
QImage img(locate(
"data",
"kdeprint/preview.png"));
00279 m_preview->setImage(img);
00280
00281 KSeparator *sep =
new KSeparator(Qt::Horizontal, colorbox);
00282
00283
QPushButton *defbtn =
new QPushButton(i18n(
"&Default Settings"), colorbox);
00284 QWhatsThis::add(defbtn, whatsThisResetButtonImagePage);
00285 connect(defbtn, SIGNAL(clicked()), SLOT(slotDefaultClicked()));
00286 slotDefaultClicked();
00287
00288 m_sizetype =
new QComboBox(sizebox);
00289 m_sizetype->insertItem(i18n(
"Natural Image Size"));
00290 m_sizetype->insertItem(i18n(
"Resolution (ppi)"));
00291
00292 m_sizetype->insertItem(i18n(
"% of Page"));
00293
00294 m_sizetype->insertItem(i18n(
"% of Natural Image Size"));
00295
00296 m_size =
new KIntNumInput(sizebox);
00297 m_size->setRange(1, 1200, 20,
true);
00298 m_size->setValue(72);
00299
00300 connect(m_sizetype, SIGNAL(activated(
int)), SLOT(slotSizeTypeChanged(
int)));
00301 m_sizetype->setCurrentItem(0);
00302 slotSizeTypeChanged(0);
00303
00304
QLabel *lab =
new QLabel(i18n(
"&Image size type:"), sizebox);
00305 lab->setBuddy(m_sizetype);
00306
00307 m_position =
new ImagePosition(positionbox);
00308 QWhatsThis::add(m_position, whatsThisPreviewPositionImagePage);
00309
00310
QRadioButton *bottom =
new QRadioButton(positionbox);
00311 QRadioButton *top =
new QRadioButton(positionbox);
00312 QRadioButton *vcenter =
new QRadioButton(positionbox);
00313 QRadioButton *left =
new QRadioButton(positionbox);
00314 QRadioButton *right =
new QRadioButton(positionbox);
00315 QRadioButton *hcenter =
new QRadioButton(positionbox);
00316
QSize sz = bottom->sizeHint();
00317 bottom->setFixedSize(sz);
00318 vcenter->setFixedSize(sz);
00319 top->setFixedSize(sz);
00320 left->setFixedSize(sz);
00321 hcenter->setFixedSize(sz);
00322 right->setFixedSize(sz);
00323
00324 m_vertgrp =
new QButtonGroup(positionbox);
00325 m_vertgrp->hide();
00326
00327 m_horizgrp =
new QButtonGroup(positionbox);
00328 m_horizgrp->hide();
00329
00330 m_vertgrp->insert(top, 0);
00331 m_vertgrp->insert(vcenter, 1);
00332 m_vertgrp->insert(bottom, 2);
00333
if ( QApplication::reverseLayout() )
00334 {
00335 m_horizgrp->insert(left, 2);
00336 m_horizgrp->insert(hcenter, 1);
00337 m_horizgrp->insert(right, 0);
00338 }
00339
else
00340 {
00341 m_horizgrp->insert(left, 0);
00342 m_horizgrp->insert(hcenter, 1);
00343 m_horizgrp->insert(right, 2);
00344 }
00345 connect(m_vertgrp, SIGNAL(clicked(
int)), SLOT(slotPositionChanged()));
00346 connect(m_horizgrp, SIGNAL(clicked(
int)), SLOT(slotPositionChanged()));
00347 m_vertgrp->setButton(1);
00348 m_horizgrp->setButton(1);
00349 slotPositionChanged();
00350
00351
QGridLayout *l0 =
new QGridLayout(
this, 2, 2, 0, 10);
00352 l0->addMultiCellWidget(colorbox, 0, 0, 0, 1);
00353 l0->addWidget(sizebox, 1, 0);
00354 l0->addWidget(positionbox, 1, 1);
00355 l0->setColStretch(0, 1);
00356 QGridLayout *l1 =
new QGridLayout(colorbox->layout(), 5, 2, 10);
00357 l1->addWidget(m_brightness, 0, 0);
00358 l1->addWidget(m_hue, 1, 0);
00359 l1->addWidget(m_saturation, 2, 0);
00360 l1->addWidget(sep, 3, 0);
00361 l1->addWidget(m_gamma, 4, 0);
00362 l1->addMultiCellWidget(m_preview, 0, 3, 1, 1);
00363 l1->addWidget(defbtn, 4, 1);
00364
QVBoxLayout *l2 =
new QVBoxLayout(sizebox->layout(), 3);
00365 l2->addStretch(1);
00366 l2->addWidget(lab);
00367 l2->addWidget(m_sizetype);
00368 l2->addSpacing(10);
00369 l2->addWidget(m_size);
00370 l2->addStretch(1);
00371 QGridLayout *l3 =
new QGridLayout(positionbox->layout(), 2, 2, 10);
00372
QHBoxLayout *l4 =
new QHBoxLayout(0, 0, 10);
00373 QVBoxLayout *l5 =
new QVBoxLayout(0, 0, 10);
00374 l3->addLayout(l4, 0, 1);
00375 l3->addLayout(l5, 1, 0);
00376 l3->addWidget(m_position, 1, 1);
00377 l4->addWidget(left, Qt::AlignLeft);
00378 l4->addWidget(hcenter, Qt::AlignCenter);
00379 l4->addWidget(right, Qt::AlignRight);
00380 l5->addWidget(top, Qt::AlignTop);
00381 l5->addWidget(vcenter, Qt::AlignVCenter);
00382 l5->addWidget(bottom, Qt::AlignBottom);
00383 }
00384
00385 KPImagePage::~KPImagePage()
00386 {
00387 }
00388
00389
void KPImagePage::setOptions(
const QMap<QString,QString>& opts)
00390 {
00391
QString value;
00392
if (!(value=opts[
"brightness"]).isEmpty())
00393 m_brightness->setValue(value.toInt());
00394
if (!(value=opts[
"hue"]).isEmpty())
00395 m_hue->setValue(value.toInt());
00396
if (!(value=opts[
"saturation"]).isEmpty())
00397 m_saturation->setValue(value.toInt());
00398
if (!(value=opts[
"gamma"]).isEmpty())
00399 m_gamma->setValue(value.toInt());
00400
00401
int type = 0;
00402
int ival(0);
00403
if ((ival = opts[
"ppi"].toInt()) != 0)
00404 type = 1;
00405
else if ((ival = opts[
"scaling"].toInt()) != 0)
00406 type = 2;
00407
else if (!opts[
"natural-scaling"].isEmpty() && (ival = opts[
"natural-scaling"].toInt()) != 1)
00408 type = 3;
00409 m_sizetype->setCurrentItem(type);
00410 slotSizeTypeChanged(type);
00411
if (type != 0)
00412 m_size->setValue(ival);
00413
00414
if (!(value=opts[
"position"]).isEmpty())
00415 {
00416 m_position->setPosition(value.latin1());
00417
int pos = m_position->position();
00418 m_vertgrp->setButton(pos/3);
00419 m_horizgrp->setButton(pos%3);
00420 }
00421 }
00422
00423
void KPImagePage::getOptions(
QMap<QString,QString>& opts,
bool incldef)
00424 {
00425
if (incldef || m_brightness->value() != 100)
00426 opts[
"brightness"] = QString::number(m_brightness->value());
00427
if (m_hue->isEnabled())
00428 {
00429
if (incldef || m_hue->value() != 0)
00430 opts[
"hue"] = QString::number(m_hue->value());
00431
if (incldef || m_saturation->value() != 100)
00432 opts[
"saturation"] = QString::number(m_saturation->value());
00433 }
00434
if (incldef || m_gamma->value() != 1000)
00435 opts[
"gamma"] = QString::number(m_gamma->value());
00436
00437
QString name;
00438
if (incldef)
00439 {
00440 opts[
"ppi"] =
"0";
00441 opts[
"scaling"] =
"0";
00442 opts[
"natural-scaling"] =
"1";
00443 }
00444
switch (m_sizetype->currentItem())
00445 {
00446
case 0:
break;
00447
case 1: name =
"ppi";
break;
00448
case 2: name =
"scaling";
break;
00449
case 3: name =
"natural-scaling";
break;
00450 }
00451
if (!name.isEmpty())
00452 opts[name] = QString::number(m_size->value());
00453
00454
if (incldef || m_position->position() != ImagePosition::Center)
00455 opts[
"position"] = m_position->positionString();
00456 }
00457
00458
void KPImagePage::slotSizeTypeChanged(
int t)
00459 {
00460 m_size->setEnabled(t > 0);
00461
if (t > 0)
00462 {
00463
int minval, maxval, defval;
00464
if (t == 1)
00465 {
00466 minval = 1;
00467 maxval = 1200;
00468 defval = 72;
00469 }
00470
else
00471 {
00472 minval = 1;
00473 maxval = 800;
00474 defval = 100;
00475 }
00476 m_size->setRange(minval, maxval);
00477 m_size->setValue(defval);
00478 }
00479 }
00480
00481
void KPImagePage::slotPositionChanged()
00482 {
00483
int h = m_horizgrp->id(m_horizgrp->selected()), v = m_vertgrp->id(m_vertgrp->selected());
00484 m_position->setPosition(h, v);
00485 }
00486
00487
void KPImagePage::slotImageSettingsChanged()
00488 {
00489
int b = m_brightness->value(), h = m_hue->value(), s = m_saturation->value();
00490
00491
int g = 1000;
00492 m_preview->setParameters(b, h, s, g);
00493 }
00494
00495
void KPImagePage::slotDefaultClicked()
00496 {
00497 m_brightness->setValue(100);
00498 m_hue->setValue(0);
00499 m_saturation->setValue(100);
00500 m_gamma->setValue(1000);
00501 }
00502
00503
#include "kpimagepage.moc"