23 #include "kxmlcommand.h"
27 #include <tqcombobox.h>
28 #include <tqbuttongroup.h>
29 #include <tqradiobutton.h>
32 #include <tqwhatsthis.h>
34 #include <kiconloader.h>
35 #include <tdelocale.h>
38 #define ORIENT_PORTRAIT_ID 0
39 #define ORIENT_LANDSCAPE_ID 1
41 #define COLORMODE_COLOR_ID 0
42 #define COLORMODE_GRAYSCALE_ID 1
51 KPQtPage::KPQtPage(TQWidget *parent,
const char *name)
57 KPQtPage::KPQtPage(DrMain *driver, TQWidget *parent,
const char *name)
58 :
KPrintDialogPage(0, (driver && driver->findOption(
"PageSize") ? driver : 0), parent, name)
70 TQString whatsThisColorModeOtPageLabel = i18n(
" <qt> "
71 " <b>Selection of color mode:</b> You can choose between 2 options: "
72 " <ul><li><b>Color</b> and</li> "
73 " <li><b>Grayscale</b></li></ul> "
74 " <b>Note:</b> This selection field may be grayed out and made inactive. "
75 " This happens if TDEPrint can not retrieve "
76 " enough information about your print file. In this case the embedded color- or grayscale information "
77 " of your printfile, and the default handling of the printer take precedence. "
79 TQString whatsThisPageSizeOtPageLabel = i18n(
" <qt> "
80 " <b>Selection of page size:</b> Select paper size to be printed on from "
81 " the drop-down menu. "
82 " <p>The exact list of choices depends on the printer driver (\"PPD\") you have installed. "
84 TQString whatsThisPagesPerSheetOtPageLabel = i18n(
" <qt> "
85 " <b>Selection of pages per sheet:</b> "
86 " You can choose to print more than one page onto each sheet of paper. "
87 " This is sometimes useful to save paper. "
88 " <p><b>Note 1:</b> the page images get scaled down accordingly to print 2 or 4 pages per sheet. "
89 " The page image does not get scaled if you print 1 page per sheet (the default setting.). "
90 " <p><b>Note 2:</b> If you select multiple pages per sheet here, the scaling and re-arranging is done "
91 " by your printing system. "
92 " <p><b>Note 3, regarding \"Other\":</b> You cannot really select <em>Other</em> as the number of "
93 " pages to print on one sheet.\"Other\" is checkmarked here for information purposes only. "
94 " <p>To select 8, 9, 16 or other numbers of "
97 " <li> go to the tab headlined \"Filter\"</li>"
98 " <li> enable the <em>Multiple Pages per Sheet</em> filter </li>"
99 " <li> and configure it (bottom-most button on the right of the \"Filters\" tab). </li>"
102 TQString whatsThisOrientationOtPageLabel = i18n(
" <qt> "
103 " <b>Selection of image orientation:</b> Orientation of the printed "
104 " pageimage on your paper is controlled by the radio buttons. By default, "
105 " the orientation is <em>Portrait</em> "
106 " <p>You can select 2 alternatives: "
108 " <li> <b>Portrait.</b>.Portrait is the default setting. </li> "
109 " <li> <b>Landscape.</b> </li> "
111 " The icon changes according to your selection."
113 setTitle(i18n(
"Print Format"));
116 m_pagesize =
new TQComboBox(
this);
117 TQWhatsThis::add(m_pagesize, whatsThisPageSizeOtPageLabel);
118 TQLabel *m_pagesizelabel =
new TQLabel(i18n(
"Page s&ize:"),
this);
119 m_pagesizelabel->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
120 m_pagesizelabel->setBuddy(m_pagesize);
121 m_orientbox =
new TQButtonGroup(0, Qt::Vertical, i18n(
"Orientation"),
this);
122 TQWhatsThis::add(m_orientbox, whatsThisOrientationOtPageLabel);
123 m_colorbox =
new TQButtonGroup(0, Qt::Vertical, i18n(
"Color Mode"),
this);
124 TQWhatsThis::add(m_colorbox, whatsThisColorModeOtPageLabel);
125 TQRadioButton *m_portrait =
new TQRadioButton(i18n(
"&Portrait"), m_orientbox);
126 TQWhatsThis::add(m_portrait, whatsThisOrientationOtPageLabel);
128 TQRadioButton *m_landscape =
new TQRadioButton(i18n(
"&Landscape"), m_orientbox);
129 TQWhatsThis::add(m_landscape, whatsThisOrientationOtPageLabel);
131 m_orientpix =
new TQLabel(m_orientbox);
132 m_orientpix->setAlignment(Qt::AlignCenter);
133 TQWhatsThis::add(m_orientpix, whatsThisOrientationOtPageLabel);
135 TQRadioButton *m_color =
new TQRadioButton(i18n(
"Colo&r"), m_colorbox);
136 TQWhatsThis::add(m_color, whatsThisColorModeOtPageLabel);
138 TQRadioButton *m_grayscale =
new TQRadioButton(i18n(
"&Grayscale"), m_colorbox);
139 m_colorpix =
new TQLabel(m_colorbox);
140 m_colorpix->setAlignment(Qt::AlignCenter);
141 TQWhatsThis::add(m_colorpix, whatsThisColorModeOtPageLabel);
143 m_nupbox =
new TQButtonGroup(0, Qt::Vertical, i18n(
"Pages per Sheet"),
this);
145 TQRadioButton *m_nup1 =
new TQRadioButton(
"&1", m_nupbox);
146 TQWhatsThis::add(m_nup1, whatsThisPagesPerSheetOtPageLabel);
147 TQRadioButton *m_nup2 =
new TQRadioButton(
"&2", m_nupbox);
148 TQWhatsThis::add(m_nup2, whatsThisPagesPerSheetOtPageLabel);
149 TQRadioButton *m_nup4 =
new TQRadioButton(
"&4", m_nupbox);
150 TQWhatsThis::add(m_nup4, whatsThisPagesPerSheetOtPageLabel);
151 TQRadioButton *m_nupother =
new TQRadioButton(i18n(
"Ot&her"), m_nupbox);
152 TQWhatsThis::add(m_nupother, whatsThisPagesPerSheetOtPageLabel);
154 m_nuppix =
new TQLabel(m_nupbox);
155 m_nuppix->setAlignment(Qt::AlignCenter);
156 TQWhatsThis::add(m_nuppix, whatsThisPagesPerSheetOtPageLabel);
159 TQGridLayout *lay0 =
new TQGridLayout(
this, 3, 2, 0, 10);
160 lay0->setRowStretch(1,1);
161 lay0->setRowStretch(2,1);
162 lay0->addWidget(m_pagesizelabel,0,0);
163 lay0->addWidget(m_pagesize,0,1);
164 lay0->addWidget(m_orientbox,1,0);
165 lay0->addWidget(m_colorbox,1,1);
166 lay0->addWidget(m_nupbox,2,0);
167 TQGridLayout *lay1 =
new TQGridLayout(m_orientbox->layout(), 2, 2, 10);
168 lay1->addWidget(m_portrait,0,0);
169 lay1->addWidget(m_landscape,1,0);
170 lay1->addMultiCellWidget(m_orientpix,0,1,1,1);
171 TQGridLayout *lay2 =
new TQGridLayout(m_colorbox->layout(), 2, 2, 10);
172 lay2->addWidget(m_color,0,0);
173 lay2->addWidget(m_grayscale,1,0);
174 lay2->addMultiCellWidget(m_colorpix,0,1,1,1);
175 TQGridLayout *lay3 =
new TQGridLayout(m_nupbox->layout(), 4, 2, 5);
176 lay3->addWidget(m_nup1,0,0);
177 lay3->addWidget(m_nup2,1,0);
178 lay3->addWidget(m_nup4,2,0);
179 lay3->addWidget(m_nupother,3,0);
180 lay3->addMultiCellWidget(m_nuppix,0,3,1,1);
183 m_portrait->setChecked(
true);
184 slotOrientationChanged(0);
185 m_color->setChecked(
true);
186 slotColorModeChanged(0);
187 m_nup1->setChecked(
true);
190 if (!KXmlCommandManager::self()->checkCommand(
"psnup"))
191 m_nupbox->setEnabled(
false);
195 m_orientbox->setEnabled(
false);
196 m_colorbox->setEnabled(
false);
197 m_pagesize->setEnabled(driver());
198 m_pagesizelabel->setEnabled(driver());
203 for (
int i=0; i<KPrinter::NPageSize-1; i++)
204 m_pagesize->insertItem(i18n(page_sizes[i].text));
206 m_pagesize->setCurrentItem(findIndex((
KPrinter::PageSize)(TDEGlobal::locale()->pageSize())));
210 DrListOption *lopt =
static_cast<DrListOption*
>(driver()->findOption(
"PageSize"));
211 TQPtrListIterator<DrBase> it(*(lopt->choices()));
212 for (; it.current(); ++it)
214 m_pagesize->insertItem(it.current()->get(
"text"));
215 if (it.current() == lopt->currentChoice())
216 m_pagesize->setCurrentItem(m_pagesize->count()-1);
221 connect(m_orientbox,TQT_SIGNAL(clicked(
int)),TQT_SLOT(slotOrientationChanged(
int)));
222 connect(m_colorbox,TQT_SIGNAL(clicked(
int)),TQT_SLOT(slotColorModeChanged(
int)));
223 connect(m_nupbox,TQT_SIGNAL(clicked(
int)),TQT_SLOT(slotNupChanged(
int)));
226 void KPQtPage::slotOrientationChanged(
int ID)
228 m_orientpix->setPixmap(UserIcon((ID == ORIENT_PORTRAIT_ID ?
"tdeprint_portrait" :
"tdeprint_landscape")));
231 void KPQtPage::slotColorModeChanged(
int ID)
233 m_colorpix->setPixmap(UserIcon((ID == COLORMODE_COLOR_ID ?
"tdeprint_color" :
"tdeprint_grayscale")));
236 void KPQtPage::slotNupChanged(
int ID)
241 case NUP_1: pixstr =
"tdeprint_nup1";
break;
242 case NUP_2: pixstr =
"tdeprint_nup2";
break;
243 case NUP_4: pixstr =
"tdeprint_nup4";
break;
244 case NUP_OTHER: pixstr =
"tdeprint_nupother";
break;
246 m_nuppix->setPixmap(UserIcon(pixstr));
249 void KPQtPage::setOptions(
const TQMap<TQString,TQString>& opts)
251 int ID = (opts[
"kde-orientation"] ==
"Landscape" ? ORIENT_LANDSCAPE_ID : ORIENT_PORTRAIT_ID);
252 m_orientbox->setButton(ID);
253 slotOrientationChanged(ID);
254 ID = (opts[
"kde-colormode"] ==
"GrayScale" ? COLORMODE_GRAYSCALE_ID : COLORMODE_COLOR_ID);
255 m_colorbox->setButton(ID);
256 slotColorModeChanged(ID);
259 QString val = opts[
"PageSize"];
262 DrListOption *opt =
static_cast<DrListOption*
>(driver()->findOption(
"PageSize"));
263 DrBase *ch = opt->findChoice(val);
265 m_pagesize->setCurrentItem(opt->choices()->findRef(ch));
268 else if (!opts[
"kde-pagesize"].isEmpty())
269 m_pagesize->setCurrentItem(findIndex(opts[
"kde-pagesize"].toInt()));
271 if (opts[
"_kde-filters"].find(
"psnup") != -1)
273 if (opts.contains(
"_kde-psnup-nup")) {
274 ID = opts[
"_kde-psnup-nup"].toInt();
275 if (ID == 1 || ID == 2 || ID == 4)
290 m_nupbox->setButton(ID);
293 if ( m_orientbox->isEnabled() )
294 m_orientbox->setDisabled( opts[
"kde-orientation-fixed" ] ==
"1" );
295 if ( m_pagesize->isEnabled() )
296 m_pagesize->setDisabled( opts[
"kde-pagesize-fixed" ] ==
"1" );
299 void KPQtPage::getOptions(TQMap<TQString,TQString>& opts,
bool incldef)
301 opts[
"kde-orientation"] = (m_orientbox->id(m_orientbox->selected()) == ORIENT_LANDSCAPE_ID ?
"Landscape" :
"Portrait");
302 opts[
"kde-colormode"] = (m_colorbox->id(m_colorbox->selected()) == COLORMODE_GRAYSCALE_ID ?
"GrayScale" :
"Color");
305 DrListOption *opt =
static_cast<DrListOption*
>(driver()->findOption(
"PageSize"));
308 DrBase *ch = opt->choices()->at(m_pagesize->currentItem());
309 if (ch && (incldef || ch->name() != opt->get(
"default")))
311 opts[
"PageSize"] = ch->name();
316 opts[
"kde-pagesize"] = TQString::number(page_sizes[m_pagesize->currentItem()].ID);
317 int ID = m_nupbox->id(m_nupbox->selected());
318 TQString s = opts[
"_kde-filters"];
321 opts.remove(
"_kde-psnup-nup");
323 else if (ID != NUP_OTHER)
325 int nup(ID == NUP_2 ? 2 : 4);
326 if (s.find(
"psnup") == -1)
328 TQStringList fl = TQStringList::split(
',', s,
false);
329 KXmlCommandManager::self()->insertCommand(fl,
"psnup");
332 opts[
"_kde-psnup-nup"] = TQString::number(nup);
334 opts[
"_kde-filters"] = s;
336 #include "kpqtpage.moc"