20 #include "kpimagepage.h"
21 #include "imageposition.h"
22 #include "imagepreview.h"
25 #include <tqcombobox.h>
26 #include <tqbuttongroup.h>
27 #include <tqradiobutton.h>
28 #include <tqgroupbox.h>
29 #include <tqpushbutton.h>
30 #include <tqapplication.h>
34 #include <tqwhatsthis.h>
35 #include <tdelocale.h>
36 #include <knuminput.h>
37 #include <kseparator.h>
38 #include <kstandarddirs.h>
40 KPImagePage::KPImagePage(DrMain *driver, TQWidget *parent,
const char *name)
44 TQString whatsThisBrightnessImagePage = i18n(
" <qt> "
45 " <p><b>Brightness:</b> Slider to control the brightness value of all colors used.</p>"
46 " <p> The brightness value can range from 0 to 200. Values greater than 100 will "
47 " lighten the print. Values less than 100 will darken the print. </p> "
50 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
51 " with the CUPS commandline job option parameter:</em> "
53 " -o brightness=... # use range from \"0\" to \"200\" "
58 TQString whatsThisHueImagePage = i18n(
" <qt> "
59 " <p><b>Hue (Tint):</b> Slider to control the hue value for color rotation.</p>"
60 " <p> The hue value is a number from -360 to 360 and represents the color hue rotation. "
61 " The following table summarizes the change you will see for the base colors: "
63 " <table border=\"1\" width=\"70%\"> "
64 " <tr><th><b>Original</b></th> <th><b>hue=-45</b></th> <th><b>hue=45</b></th> </tr> "
65 " <tr><td>Red</td> <td>Purple</td> <td>Yellow-orange</td> </tr> "
66 " <tr><td>Green</td> <td>Yellow-green</td> <td>Blue-green</td> </tr> "
67 " <tr><td>Yellow</td> <td>Orange</td> <td>Green-yellow</td> </tr> "
68 " <tr><td>Blue</td> <td>Sky-blue</td> <td>Purple</td> </tr> "
69 " <tr><td>Magenta</td> <td>Indigo</td> <td>Crimson</td> </tr> "
70 " <tr><td>Cyan</td> <td>Blue-green</td> <td>Light-navy-blue</td> </tr> "
75 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
76 " with the CUPS commandline job option parameter:</em> "
78 " -o hue=... # use range from \"-360\" to \"360\" "
83 TQString whatsThisSaturationImagePage = i18n(
" <qt> "
84 " <p><b>Saturation:</b> Slider to control the saturation value for all colors used.</p>"
85 " <p> The saturation value adjusts the saturation of the colors in an image, similar to "
86 " the color knob on your television. The color saturation value.can range from 0 to 200."
87 " On inkjet printers, a higher saturation value uses more ink. On laserjet printers, a "
88 " higher saturation uses more toner. "
89 " A color saturation of 0 produces a black-and-white print, while a value of 200 will "
90 " make the colors extremely intense. </p>"
93 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
94 " with the CUPS commandline job option parameter:</em> "
96 " -o saturation=... # use range from \"0\" to \"200\" "
101 TQString whatsThisGammaImagePage = i18n(
" <qt> "
102 " <p><b>Gamma:</b> Slider to control the gamma value for color correction.</p>"
103 " <p> The gamma value can range from 1 to 3000. "
104 " A gamma values greater than 1000 lightens the print. A gamma value less than 1000 "
105 " darken the print. The default gamma is 1000. </p>"
106 " <p><b>Note:</b></p> the gamma value adjustment is not visible in the thumbnail "
110 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
111 " with the CUPS commandline job option parameter:</em> "
113 " -o gamma=... # use range from \"1\" to \"3000\" "
118 TQString whatsThisImagePage = i18n(
" <qt> "
119 " <p><b>Image Printing Options</b></p> "
120 " <p>All options controlled on this page only apply to printing images. "
121 " Most image file formats are supported. To name a few: JPEG, TIFF, PNG, GIF, "
122 " PNM (PBM/PGM/PNM/PPM), Sun Raster, SGI RGB, Windows BMP."
123 " Options to influence color output of image printouts are: "
125 " <li> Brightness </li>"
127 " <li> Saturation </li>"
130 " <p>For a more detailed explanation about Brightness, Hue, Saturation and Gamma settings, please "
131 " look at the 'WhatsThis' items provided for these controls. "
136 TQString whatsThisColorationPreviewImagePage = i18n(
" <qt> "
137 " <p><b>Coloration Preview Thumbnail</b></p> "
138 " <p>The coloration preview thumbnail indicates change of image coloration by different settings. "
139 " Options to influence output are: "
141 " <li> Brightness </li>"
142 " <li> Hue (Tint) </li>"
143 " <li> Saturation </li>"
147 " <p>For a more detailed explanation about Brightness, Hue, Saturation and Gamma settings, please "
148 " look at the 'WhatsThis' items provided for these controls. "
152 TQString whatsThisSizeImagePage = i18n(
" <qt> "
153 " <p><b>Image Size:</b> Dropdown menu to control the image size on the printed paper. Dropdown "
154 " works in conjunction with slider below. Dropdown options are:.</p>"
156 " <li> <b>Natural Image Size:</b> Image prints in its natural image size. If it does not fit onto "
157 " one sheet, the printout will be spread across multiple sheets. Note, that the slider is disabled "
158 " when selecting 'natural image size' in the dropdown menu. </li>"
159 " <li> <b>Resolution (ppi):</b> The resolution value slider covers a number range from 1 to 1200. "
160 " It specifies the resolution of the image in Pixels Per Inch (PPI). An image that is 3000x2400 pixels "
161 " will print 10x8 inches at 300 pixels per inch, for example, but 5x4 inches at 600 pixels per inch."
162 " If the specified resolution makes the image larger than the page, multiple pages will be printed. "
163 " Resolution defaults to 72 ppi. "
165 " <li> <b>% of Page Size:</b> The percent value slider covers numbers from 1 to 800. It specifies the size "
166 " in relation to the page (not the image). A scaling of 100 percent will fill the page as completely "
167 " as the image aspect ratio allows (doing auto-rotation of the image as needed). "
168 " A scaling of more than 100 will print the image across multiple "
169 " sheets. A scaling of 200 percent will print on up to 4 pages. </li>"
170 " Scaling in % of page size defaults to 100 %. "
171 " <li> <b>% of Natural Image Size:</b> The percent value slider moves from 1 to 800. It specifies "
172 " the printout size in relation "
173 " to the natural image size. A scaling of 100 percent will print the image at its natural size, while a "
174 " scaling of 50 percent will print the image at half its natural size. If the specified scaling makes "
175 " the image larger than the page, multiple pages will be printed. "
176 " Scaling in % of natural image size defaults to 100 %. "
180 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
181 " with the CUPS commandline job option parameter:</em> "
183 " -o natural-scaling=... # range in % is 1....800 "
185 " -o scaling=... # range in % is 1....800 "
187 " -o ppi=... # range in ppi is 1...1200 "
192 TQString whatsThisPreviewPositionImagePage = i18n(
" <qt> "
193 " <p><b>Position Preview Thumbnail</b></p> "
194 " <p>This position preview thumbnail indicates the position of the image on the paper sheet. "
195 " <p>Click on horizontal and vertical radio buttons to move image alignment on paper around. Options are: "
199 " <li> top-left </li>"
201 " <li> bottom-left </li>"
203 " <li> bottom-right</li>"
205 " <li> top-right </li>"
210 TQString whatsThisResetButtonImagePage = i18n(
" <qt> "
211 " <p><b>Reset to Default Values</b> </p> "
212 " <p> Reset all coloration settings to default values. Default values are: "
214 " <li> Brightness: 100 </li>"
215 " <li> Hue (Tint). 0 </li>"
216 " <li> Saturation: 100 </li>"
217 " <li> Gamma: 1000 </li>"
222 TQString whatsThisPositionImagePage = i18n(
" <qt> "
223 " <p><b>Image Positioning:</b></p> "
224 " <p>Select a pair of radiobuttons to "
225 " move image to the position you want on the paper printout. Default "
226 " is 'center'. </p> "
229 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
230 " with the CUPS commandline job option parameter:</em> "
232 " -o position=... # examples: \"top-left\" or \"bottom\" "
237 setTitle(i18n(
"Image"));
239 TQGroupBox *colorbox =
new TQGroupBox(0, TQt::Vertical, i18n(
"Color Settings"),
this);
240 TQWhatsThis::add(
this, whatsThisImagePage);
241 TQGroupBox *sizebox =
new TQGroupBox(0, TQt::Vertical, i18n(
"Image Size"),
this);
242 TQWhatsThis::add(sizebox, whatsThisSizeImagePage);
243 TQGroupBox *positionbox =
new TQGroupBox(0, TQt::Vertical, i18n(
"Image Position"),
this);
244 TQWhatsThis::add(positionbox, whatsThisPositionImagePage);
246 m_brightness =
new KIntNumInput(100, colorbox);
247 m_brightness->setLabel(i18n(
"&Brightness:"));
248 m_brightness->setRange(0, 200, 20,
true);
249 TQWhatsThis::add(m_brightness, whatsThisBrightnessImagePage);
251 m_hue =
new KIntNumInput(m_brightness, 0, colorbox);
252 m_hue->setLabel(i18n(
"&Hue (Color rotation):"));
253 m_hue->setRange(-360, 360, 36,
true);
254 TQWhatsThis::add(m_hue, whatsThisHueImagePage);
256 m_saturation =
new KIntNumInput(m_brightness, 100, colorbox);
257 m_saturation->setLabel(i18n(
"&Saturation:"));
258 m_saturation->setRange(0, 200, 20,
true);
259 TQWhatsThis::add(m_saturation, whatsThisSaturationImagePage);
261 m_gamma =
new KIntNumInput(m_saturation, 1000, colorbox);
262 m_gamma->setLabel(i18n(
"&Gamma (Color correction):"));
263 m_gamma->setRange(1, 3000, 100,
true);
264 TQWhatsThis::add(m_gamma, whatsThisGammaImagePage);
266 connect(m_brightness, TQ_SIGNAL(valueChanged(
int)), TQ_SLOT(slotImageSettingsChanged()));
267 connect(m_hue, TQ_SIGNAL(valueChanged(
int)), TQ_SLOT(slotImageSettingsChanged()));
268 connect(m_saturation, TQ_SIGNAL(valueChanged(
int)), TQ_SLOT(slotImageSettingsChanged()));
271 m_preview =
new ImagePreview(colorbox);
272 bool useColor = (driver ? driver->get(
"colordevice") ==
"1" :
true);
273 m_preview->setBlackAndWhite(!useColor);
274 TQWhatsThis::add(m_preview, whatsThisColorationPreviewImagePage);
276 m_hue->setEnabled(useColor);
277 m_saturation->setEnabled(useColor);
278 TQImage img(locate(
"data",
"tdeprint/preview.png"));
279 m_preview->setImage(img);
281 KSeparator *sep =
new KSeparator(TQt::Horizontal, colorbox);
283 TQPushButton *defbtn =
new TQPushButton(i18n(
"&Default Settings"), colorbox);
284 TQWhatsThis::add(defbtn, whatsThisResetButtonImagePage);
285 connect(defbtn, TQ_SIGNAL(clicked()), TQ_SLOT(slotDefaultClicked()));
286 slotDefaultClicked();
288 m_sizetype =
new TQComboBox(sizebox);
289 m_sizetype->insertItem(i18n(
"Natural Image Size"));
290 m_sizetype->insertItem(i18n(
"Resolution (ppi)"));
292 m_sizetype->insertItem(i18n(
"% of Page"));
294 m_sizetype->insertItem(i18n(
"% of Natural Image Size"));
296 m_size =
new KIntNumInput(sizebox);
297 m_size->setRange(1, 1200, 20,
true);
298 m_size->setValue(72);
300 connect(m_sizetype, TQ_SIGNAL(activated(
int)), TQ_SLOT(slotSizeTypeChanged(
int)));
301 m_sizetype->setCurrentItem(0);
302 slotSizeTypeChanged(0);
304 TQLabel *lab =
new TQLabel(i18n(
"&Image size type:"), sizebox);
305 lab->setBuddy(m_sizetype);
307 m_position =
new ImagePosition(positionbox);
308 TQWhatsThis::add(m_position, whatsThisPreviewPositionImagePage);
310 TQRadioButton *bottom =
new TQRadioButton(positionbox);
311 TQRadioButton *top =
new TQRadioButton(positionbox);
312 TQRadioButton *vcenter =
new TQRadioButton(positionbox);
313 TQRadioButton *left =
new TQRadioButton(positionbox);
314 TQRadioButton *right =
new TQRadioButton(positionbox);
315 TQRadioButton *hcenter =
new TQRadioButton(positionbox);
316 TQSize sz = bottom->sizeHint();
317 bottom->setFixedSize(sz);
318 vcenter->setFixedSize(sz);
319 top->setFixedSize(sz);
320 left->setFixedSize(sz);
321 hcenter->setFixedSize(sz);
322 right->setFixedSize(sz);
324 m_vertgrp =
new TQButtonGroup(positionbox);
327 m_horizgrp =
new TQButtonGroup(positionbox);
330 m_vertgrp->insert(top, 0);
331 m_vertgrp->insert(vcenter, 1);
332 m_vertgrp->insert(bottom, 2);
333 if ( TQApplication::reverseLayout() )
335 m_horizgrp->insert(left, 2);
336 m_horizgrp->insert(hcenter, 1);
337 m_horizgrp->insert(right, 0);
341 m_horizgrp->insert(left, 0);
342 m_horizgrp->insert(hcenter, 1);
343 m_horizgrp->insert(right, 2);
345 connect(m_vertgrp, TQ_SIGNAL(clicked(
int)), TQ_SLOT(slotPositionChanged()));
346 connect(m_horizgrp, TQ_SIGNAL(clicked(
int)), TQ_SLOT(slotPositionChanged()));
347 m_vertgrp->setButton(1);
348 m_horizgrp->setButton(1);
349 slotPositionChanged();
351 TQGridLayout *l0 =
new TQGridLayout(
this, 2, 2, 0, 10);
352 l0->addMultiCellWidget(colorbox, 0, 0, 0, 1);
353 l0->addWidget(sizebox, 1, 0);
354 l0->addWidget(positionbox, 1, 1);
355 l0->setColStretch(0, 1);
356 TQGridLayout *l1 =
new TQGridLayout(colorbox->layout(), 5, 2, 10);
357 l1->addWidget(m_brightness, 0, 0);
358 l1->addWidget(m_hue, 1, 0);
359 l1->addWidget(m_saturation, 2, 0);
360 l1->addWidget(sep, 3, 0);
361 l1->addWidget(m_gamma, 4, 0);
362 l1->addMultiCellWidget(m_preview, 0, 3, 1, 1);
363 l1->addWidget(defbtn, 4, 1);
364 TQVBoxLayout *l2 =
new TQVBoxLayout(sizebox->layout(), 3);
367 l2->addWidget(m_sizetype);
369 l2->addWidget(m_size);
371 TQGridLayout *l3 =
new TQGridLayout(positionbox->layout(), 2, 2, 10);
372 TQHBoxLayout *l4 =
new TQHBoxLayout(0, 0, 10);
373 TQVBoxLayout *l5 =
new TQVBoxLayout(0, 0, 10);
374 l3->addLayout(l4, 0, 1);
375 l3->addLayout(l5, 1, 0);
376 l3->addWidget(m_position, 1, 1);
377 l4->addWidget(left, TQt::AlignLeft);
378 l4->addWidget(hcenter, TQt::AlignCenter);
379 l4->addWidget(right, TQt::AlignRight);
380 l5->addWidget(top, TQt::AlignTop);
381 l5->addWidget(vcenter, TQt::AlignVCenter);
382 l5->addWidget(bottom, TQt::AlignBottom);
385 KPImagePage::~KPImagePage()
389 void KPImagePage::setOptions(
const TQMap<TQString,TQString>& opts)
392 if (!(value=opts[
"brightness"]).isEmpty())
393 m_brightness->setValue(value.toInt());
394 if (!(value=opts[
"hue"]).isEmpty())
395 m_hue->setValue(value.toInt());
396 if (!(value=opts[
"saturation"]).isEmpty())
397 m_saturation->setValue(value.toInt());
398 if (!(value=opts[
"gamma"]).isEmpty())
399 m_gamma->setValue(value.toInt());
403 if ((ival = opts[
"ppi"].toInt()) != 0)
405 else if ((ival = opts[
"scaling"].toInt()) != 0)
407 else if (!opts[
"natural-scaling"].isEmpty() && (ival = opts[
"natural-scaling"].toInt()) != 1)
409 m_sizetype->setCurrentItem(type);
410 slotSizeTypeChanged(type);
412 m_size->setValue(ival);
414 if (!(value=opts[
"position"]).isEmpty())
416 m_position->setPosition(value.latin1());
417 int pos = m_position->position();
418 m_vertgrp->setButton(pos/3);
419 m_horizgrp->setButton(pos%3);
423 void KPImagePage::getOptions(TQMap<TQString,TQString>& opts,
bool incldef)
425 if (incldef || m_brightness->value() != 100)
426 opts[
"brightness"] = TQString::number(m_brightness->value());
427 if (m_hue->isEnabled())
429 if (incldef || m_hue->value() != 0)
430 opts[
"hue"] = TQString::number(m_hue->value());
431 if (incldef || m_saturation->value() != 100)
432 opts[
"saturation"] = TQString::number(m_saturation->value());
434 if (incldef || m_gamma->value() != 1000)
435 opts[
"gamma"] = TQString::number(m_gamma->value());
441 opts[
"scaling"] =
"0";
442 opts[
"natural-scaling"] =
"1";
444 switch (m_sizetype->currentItem())
447 case 1: name =
"ppi";
break;
448 case 2: name =
"scaling";
break;
449 case 3: name =
"natural-scaling";
break;
452 opts[name] = TQString::number(m_size->value());
454 if (incldef || m_position->position() != ImagePosition::Center)
455 opts[
"position"] = m_position->positionString();
458 void KPImagePage::slotSizeTypeChanged(
int t)
460 m_size->setEnabled(t > 0);
463 int minval, maxval, defval;
476 m_size->setRange(minval, maxval);
477 m_size->setValue(defval);
481 void KPImagePage::slotPositionChanged()
483 int h = m_horizgrp->id(m_horizgrp->selected()), v = m_vertgrp->id(m_vertgrp->selected());
484 m_position->setPosition(h, v);
487 void KPImagePage::slotImageSettingsChanged()
489 int b = m_brightness->value(), h = m_hue->value(), s = m_saturation->value();
492 m_preview->setParameters(b, h, s, g);
495 void KPImagePage::slotDefaultClicked()
497 m_brightness->setValue(100);
499 m_saturation->setValue(100);
500 m_gamma->setValue(1000);
503 #include "kpimagepage.moc"
This class is intended to be used as base class for customized print dialog page.