• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
kpqtpage.cpp
1/*
2 * This file is part of the KDE libraries
3 * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4 *
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License version 2 as published by the Free Software Foundation.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 **/
20
21#include "kpqtpage.h"
22#include "kprinter.h"
23#include "kxmlcommand.h"
24#include "driver.h"
25#include "util.h"
26
27#include <tqcombobox.h>
28#include <tqbuttongroup.h>
29#include <tqradiobutton.h>
30#include <tqlabel.h>
31#include <tqlayout.h>
32#include <tqwhatsthis.h>
33
34#include <kiconloader.h>
35#include <tdelocale.h>
36#include <kdebug.h>
37
38#define ORIENT_PORTRAIT_ID 0
39#define ORIENT_LANDSCAPE_ID 1
40
41#define COLORMODE_COLOR_ID 0
42#define COLORMODE_GRAYSCALE_ID 1
43
44#define NUP_1 0
45#define NUP_2 1
46#define NUP_4 2
47#define NUP_OTHER 3
48
49//*****************************************************************************************************
50
51KPQtPage::KPQtPage(TQWidget *parent, const char *name)
52: KPrintDialogPage(parent,name)
53{
54 init();
55}
56
57KPQtPage::KPQtPage(DrMain *driver, TQWidget *parent, const char *name)
58: KPrintDialogPage(0, (driver && driver->findOption("PageSize") ? driver : 0), parent, name)
59{
60 init();
61}
62
63KPQtPage::~KPQtPage()
64{
65}
66
67void KPQtPage::init()
68{
69 //WhatsThis strings.... (added by pfeifle@kde.org)
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. "
78 " </qt>" );
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. "
83 " </qt>" );
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 "
95 " pages per sheet: "
96 " <ul> "
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>"
100 " </ul>"
101 " </qt>" );
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: "
107 " <ul> "
108 " <li> <b>Portrait.</b>.Portrait is the default setting. </li> "
109 " <li> <b>Landscape.</b> </li> "
110 " </ul> "
111 " The icon changes according to your selection."
112 " </qt>" );
113 setTitle(i18n("Print Format"));
114
115 // widget creation
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(TQt::AlignVCenter|TQt::AlignRight);
120 m_pagesizelabel->setBuddy(m_pagesize);
121 m_orientbox = new TQButtonGroup(0, TQt::Vertical, i18n("Orientation"), this);
122 TQWhatsThis::add(m_orientbox, whatsThisOrientationOtPageLabel);
123 m_colorbox = new TQButtonGroup(0, TQt::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);
127
128 TQRadioButton *m_landscape = new TQRadioButton(i18n("&Landscape"), m_orientbox);
129 TQWhatsThis::add(m_landscape, whatsThisOrientationOtPageLabel);
130
131 m_orientpix = new TQLabel(m_orientbox);
132 m_orientpix->setAlignment(TQt::AlignCenter);
133 TQWhatsThis::add(m_orientpix, whatsThisOrientationOtPageLabel);
134
135 TQRadioButton *m_color = new TQRadioButton(i18n("Colo&r"), m_colorbox);
136 TQWhatsThis::add(m_color, whatsThisColorModeOtPageLabel);
137
138 TQRadioButton *m_grayscale = new TQRadioButton(i18n("&Grayscale"), m_colorbox);
139 m_colorpix = new TQLabel(m_colorbox);
140 m_colorpix->setAlignment(TQt::AlignCenter);
141 TQWhatsThis::add(m_colorpix, whatsThisColorModeOtPageLabel);
142
143 m_nupbox = new TQButtonGroup(0, TQt::Vertical, i18n("Pages per Sheet"), this);
144 // TQWhatsThis::add(m_nupbox, whatsThisPagesPerSheetOtPageLabel);
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);
153
154 m_nuppix = new TQLabel(m_nupbox);
155 m_nuppix->setAlignment(TQt::AlignCenter);
156 TQWhatsThis::add(m_nuppix, whatsThisPagesPerSheetOtPageLabel);
157
158 // layout creation
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);
181
182 // initialization
183 m_portrait->setChecked(true);
184 slotOrientationChanged(0);
185 m_color->setChecked(true);
186 slotColorModeChanged(0);
187 m_nup1->setChecked(true);
188 slotNupChanged(0);
189
190 if (!KXmlCommandManager::self()->checkCommand("psnup"))
191 m_nupbox->setEnabled(false);
192 if (KPrinter::applicationType() != KPrinter::Dialog
193 && KPrinter::applicationType() >= 0 )
194 {
195 m_orientbox->setEnabled(false);
196 m_colorbox->setEnabled(false);
197 m_pagesize->setEnabled(driver());
198 m_pagesizelabel->setEnabled(driver());
199 }
200
201 if (!driver())
202 {
203 for (int i=0; i<KPrinter::NPageSize-1; i++)
204 m_pagesize->insertItem(i18n(page_sizes[i].text));
205 // default page size to locale settings
206 m_pagesize->setCurrentItem(findIndex((KPrinter::PageSize)(TDEGlobal::locale()->pageSize())));
207 }
208 else
209 {
210 DrListOption *lopt = static_cast<DrListOption*>(driver()->findOption("PageSize"));
211 TQPtrListIterator<DrBase> it(*(lopt->choices()));
212 for (; it.current(); ++it)
213 {
214 m_pagesize->insertItem(it.current()->get("text"));
215 if (it.current() == lopt->currentChoice())
216 m_pagesize->setCurrentItem(m_pagesize->count()-1);
217 }
218 }
219
220 // connections
221 connect(m_orientbox,TQ_SIGNAL(clicked(int)),TQ_SLOT(slotOrientationChanged(int)));
222 connect(m_colorbox,TQ_SIGNAL(clicked(int)),TQ_SLOT(slotColorModeChanged(int)));
223 connect(m_nupbox,TQ_SIGNAL(clicked(int)),TQ_SLOT(slotNupChanged(int)));
224}
225
226void KPQtPage::slotOrientationChanged(int ID)
227{
228 m_orientpix->setPixmap(UserIcon((ID == ORIENT_PORTRAIT_ID ? "tdeprint_portrait" : "tdeprint_landscape")));
229}
230
231void KPQtPage::slotColorModeChanged(int ID)
232{
233 m_colorpix->setPixmap(UserIcon((ID == COLORMODE_COLOR_ID ? "tdeprint_color" : "tdeprint_grayscale")));
234}
235
236void KPQtPage::slotNupChanged(int ID)
237{
238 TQString pixstr;
239 switch (ID)
240 {
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;
245 }
246 m_nuppix->setPixmap(UserIcon(pixstr));
247}
248
249void KPQtPage::setOptions(const TQMap<TQString,TQString>& opts)
250{
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);
257 if (driver())
258 {
259 TQString val = opts["PageSize"];
260 if (!val.isEmpty())
261 {
262 DrListOption *opt = static_cast<DrListOption*>(driver()->findOption("PageSize"));
263 DrBase *ch = opt->findChoice(val);
264 if (ch)
265 m_pagesize->setCurrentItem(opt->choices()->findRef(ch));
266 }
267 }
268 else if (!opts["kde-pagesize"].isEmpty())
269 m_pagesize->setCurrentItem(findIndex(opts["kde-pagesize"].toInt()));
270 ID = NUP_1;
271 if (opts["_kde-filters"].find("psnup") != -1)
272 {
273 if (opts.contains("_kde-psnup-nup")) {
274 ID = opts["_kde-psnup-nup"].toInt();
275 if (ID == 1 || ID == 2 || ID == 4)
276 {
277 if (ID == 4) ID = 3;
278 ID--;
279 }
280 else
281 {
282 ID = NUP_OTHER;
283 }
284 }
285 else
286 {
287 ID = NUP_1;
288 }
289 }
290 m_nupbox->setButton(ID);
291 slotNupChanged(ID);
292
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" );
297}
298
299void KPQtPage::getOptions(TQMap<TQString,TQString>& opts, bool incldef)
300{
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");
303 if (driver())
304 {
305 DrListOption *opt = static_cast<DrListOption*>(driver()->findOption("PageSize"));
306 if (opt)
307 {
308 DrBase *ch = opt->choices()->at(m_pagesize->currentItem());
309 if (ch && (incldef || ch->name() != opt->get("default")))
310 {
311 opts["PageSize"] = ch->name();
312 }
313 }
314 }
315 else
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"];
319 if (ID == NUP_1)
320 {
321 opts.remove("_kde-psnup-nup");
322 }
323 else if (ID != NUP_OTHER)
324 {
325 int nup(ID == NUP_2 ? 2 : 4);
326 if (s.find("psnup") == -1)
327 {
328 TQStringList fl = TQStringList::split(',', s, false);
329 KXmlCommandManager::self()->insertCommand(fl, "psnup");
330 s = fl.join(",");
331 }
332 opts["_kde-psnup-nup"] = TQString::number(nup);
333 }
334 opts["_kde-filters"] = s;
335}
336#include "kpqtpage.moc"
KPrintDialogPage
This class is intended to be used as base class for customized print dialog page.
Definition: kprintdialogpage.h:91
KPrinter::PageSize
PageSize
Defines the paper size to use.
Definition: kprinter.h:168
KPrinter::applicationType
static ApplicationType applicationType()
Returns the application type concerning the print dialog.
Definition: kprinter.cpp:270

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.9.4
This website is maintained by Timothy Pearson.