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

tdeprint

  • tdeprint
kpcopiespage.cpp
1/*
2 * This file is part of the KDE libraries
3 * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License version 2 as published by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 **/
19
20#include "kpcopiespage.h"
21#include "kmfactory.h"
22#include "kmuimanager.h"
23#include "kprinter.h"
24#include "kxmlcommand.h"
25
26#include <tqlabel.h>
27#include <tqcombobox.h>
28#include <tqspinbox.h>
29#include <tqbuttongroup.h>
30#include <tqradiobutton.h>
31#include <tqlineedit.h>
32#include <tqcheckbox.h>
33#include <tqtooltip.h>
34#include <tqwhatsthis.h>
35#include <tqlayout.h>
36
37#include <tdeapplication.h>
38#include <tdelocale.h>
39#include <kiconloader.h>
40#include <kseparator.h>
41
42KPCopiesPage::KPCopiesPage(KPrinter *prt, TQWidget *parent, const char *name)
43: KPrintDialogPage(parent,name)
44{
45 //WhatsThis strings.... (added by pfeifle@kde.org)
46 TQString whatsThisPageSelectionLabel = i18n( " <qt><p><b>Page Selection</b></p> "
47 " <p>Here you can control if you print a certain selection only out of all"
48 " the pages from the complete document."
49 " </p>"
50 " </qt>" );
51 TQString whatsThisAllPagesLabel = i18n( " <qt><b>All Pages:</b> Select \"All\" to print the complete document."
52 " Since this is the default, it is pre-selected."
53 " </p>"
54 " </qt>" );
55 TQString whatsThisCurrentPagesLabel = i18n( " <qt><b>Current Page:</b> Select <em>\"Current\"</em> if you want "
56 " to print the page currently visible in your TDE application.</p>"
57 " <p><b>Note:</b> this field is disabled if you print from"
58 " non-TDE applications like Firefox, PaleMoon, SeaMonkey or OpenOffice and"
59 " LibreOffice, since here TDEPrint has no means to determine which document page"
60 " you are currently viewing.</p></qt>" );
61 TQString whatsThisPageRangeLabel = i18n( " <qt><b>Page Range:</b> Choose a \"Page Range\" to select a subset of the"
62 " complete document pages"
63 " to be printed. The format is <em>\"n,m,o-p,q,r,s-t, u\"</em>.</p>"
64 " <p><b>Example:</b> <em>\"4,6,10-13,17,20,23-25\"</em> will print"
65 " the pages 4, 6, 10, 11, 12, 13, 17, 20, 23, 24, 25 of your document.</p>"
66 " <br> "
67 " <hr> "
68 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
69 " with the CUPS commandline job option parameter:</em> "
70 " <pre>"
71 " -o page-ranges=... # example: \"4,6,10-13,17,20,23-25\" "
72 " </pre>"
73 " </p> "
74 "</qt>" );
75 TQString whatsThisPageSetLabel = i18n( " <qt><b>Page Set:</b>"
76 " <p>Choose <em>\"All Pages\"</em>, <em>\"Even Pages\"</em> or"
77 " <em>\"Odd Pages\"</em>"
78 " if you want to print a page selection matching one of these terms. The default"
79 " is <em>\"All Pages\"</em>.</p>"
80 " <p><b>Note:</b> If you combine a selection of a <em>\"Page Range\"</em> with a"
81 " <em>\"Page Set\"</em> of <em>\"Odd\"</em> or <em>\"Even\"</em>, you will only get the"
82 " odd or even pages from the originally selected page range. This is useful if you"
83 " odd or even pages from the originally selected page range. This is useful if you"
84 " want to print a page range in duplex on a simplex-only printer. In this case you"
85 " can feed the paper to the printer twice; in the first pass, select \"Odd\" or"
86 " \"Even\" (depending on your printer model), in second pass select the other"
87 " option. You may need to <em>\"Reverse\"</em> the output in one of the passes (depending"
88 " on your printer model).</p> "
89 " <br> "
90 " <hr> "
91 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
92 " with the CUPS commandline job option parameter:</em> "
93 " <pre>"
94 " -o page-set=... # example: \"odd\" or \"even\" "
95 " </pre>"
96 " </p> "
97 " </qt>" );
98 TQString whatsThisCopiesLabel = i18n( " <qt><b>Output Settings:</b>"
99 " Here you can determine the number of copies, the output order and the collate"
100 " mode for the pages of your printjob. (Note, that the maximum number of copies "
101 " allowed to print may be restricted by your print subsystem.)</p>"
102 " <p>The 'Copies' setting defaults to 1. </p> "
103 " <br> "
104 " <hr> "
105 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
106 " with the CUPS commandline job option parameter:</em> "
107 " <pre>"
108 " -o copies=... # examples: \"5\" or \"42\" "
109 " <br> "
110 " -o outputorder=... # example: \"reverse\""
111 " <br> "
112 " -o Collate=... # example: \"true\" or \"false\" "
113 " </pre>"
114 " </p> "
115 ".</qt>" );
116 TQString whatsThisNumberOfCopiesLabel = i18n( " <qt><b>Number of Copies:</b> Determine the number of requested copies here."
117 " You can increase or decrease"
118 " the number of printed copies by clicking on the up and down arrows. You can also type the figure"
119 " directly into the box. </p>"
120 " <br> "
121 " <hr> "
122 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
123 " with the CUPS commandline job option parameter:</em> "
124 " <pre>"
125 " -o copies=... # examples: \"5\" or \"42\" "
126 " </pre>"
127 " </p> "
128 " </qt>" );
129 TQString whatsThisCollateLabel = i18n( " <qt><b>Collate Copies</b>"
130 " <p>If the <em>\"Collate\"</em> checkbox is enabled (default), the output order for"
131 " multiple copies of a multi-page document will be \"1-2-3-..., 1-2-3-..., 1-2-3-...\".</p>"
132 " <p>If the <em>\"Collate\"</em> checkbox is disabled, the output order for"
133 " multiple copies of a multi-page document will be \"1-1-1-..., 2-2-2-..., 3-3-3-...\".</p>"
134 " <br> "
135 " <hr> "
136 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
137 " with the CUPS commandline job option parameter:</em> "
138 " <pre>"
139 " -o Collate=... # example: \"true\" or \"false\" "
140 " </pre>"
141 " </p> "
142 " </qt>" );
143 TQString whatsThisReverseLabel = i18n( " <qt><b>Reverse Order</b>"
144 " <p> If the <em>\"Reverse\"</em> checkbox is enabled, the output order for"
145 " multiple copies of a multi-page document will be \"...-3-2-1, ...-3-2-1, ...-3-2-1\", if you"
146 " also have <em>en</em>abled the <em>\"Collate\"</em> checkbox at the same time"
147 " (the usual usecase).</p>"
148 " <p>If the <em>\"Reverse\"</em> checkbox is enabled, the output order for"
149 " multiple copies of a multi-page document will be \"...-3-3-3, ...-2-2-2, ...-1-1-1\", if you"
150 " have <em>dis</em>abled the <em>\"Collate\"</em> checkbox at the same time. </p>"
151 " <br> "
152 " <hr> "
153 " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
154 " with the CUPS commandline job option parameter:</em> "
155 " <pre>"
156 " -o outputorder=... # example: \"reverse\""
157 " "
158 " </pre>"
159 " </p> "
160 " </qt>" );
161 m_printer = prt;
162 m_useplugin = true;
163
164 setTitle(i18n("C&opies"));
165 setId(KPrinter::CopiesPage);
166
167 // widget creation
168 TQButtonGroup *m_pagebox = new TQButtonGroup(0, TQt::Vertical, i18n("Page Selection"), this);
169 TQWhatsThis::add(m_pagebox, whatsThisPageSelectionLabel);
170 m_all = new TQRadioButton(i18n("&All"), m_pagebox);
171 TQWhatsThis::add(m_all, whatsThisAllPagesLabel);
172 m_current = new TQRadioButton(i18n("Cu&rrent"), m_pagebox);
173 TQWhatsThis::add(m_current, whatsThisCurrentPagesLabel);
174 m_range = new TQRadioButton(i18n("Ran&ge"), m_pagebox);
175 TQWhatsThis::add(m_range, whatsThisPageRangeLabel);
176 m_rangeedit = new TQLineEdit(m_pagebox);
177 TQWhatsThis::add(m_rangeedit, whatsThisPageRangeLabel);
178 connect(m_range, TQ_SIGNAL(clicked()), m_rangeedit, TQ_SLOT(setFocus()));
179 TQToolTip::add(m_rangeedit, i18n("<p>Enter pages or group of pages to print separated by commas (1,2-5,8).</p>"));
180// TQWhatsThis::add(m_rangeedit, i18n("<p>Enter pages or group of pages to print separated by commas (1,2-5,8).</p>"));
181 //TQLabel *m_rangeexpl = new TQLabel(m_pagebox);
182 //m_rangeexpl->setText(i18n("<p>Enter pages or group of pages to print separated by commas (1,2-5,8).</p>"));
183 TQGroupBox *m_copybox = new TQGroupBox(0, TQt::Vertical, i18n("Output Settings"), this);
184 TQWhatsThis::add(m_copybox, whatsThisCopiesLabel);
185 m_collate = new TQCheckBox(i18n("Co&llate"), m_copybox);
186 TQWhatsThis::add(m_collate, whatsThisCollateLabel);
187 m_order = new TQCheckBox(i18n("Re&verse"), m_copybox);
188 TQWhatsThis::add(m_order, whatsThisReverseLabel);
189 m_collatepix = new TQLabel(m_copybox);
190 m_collatepix->setAlignment(TQt::AlignCenter);
191 m_collatepix->setMinimumHeight(70);
192 TQLabel *m_copieslabel = new TQLabel(i18n("Cop&ies:"), m_copybox);
193 m_copies = new TQSpinBox(m_copybox);
194 m_copies->setRange(1,999);
195 TQWhatsThis::add(m_copies, whatsThisNumberOfCopiesLabel);
196 m_copieslabel->setBuddy(m_copies);
197 TQWhatsThis::add(m_copieslabel, whatsThisNumberOfCopiesLabel);
198 m_pageset = new TQComboBox(m_pagebox);
199 m_pageset->insertItem(i18n("All Pages"));
200 m_pageset->insertItem(i18n("Odd Pages"));
201 m_pageset->insertItem(i18n("Even Pages"));
202 TQWhatsThis::add(m_pageset, whatsThisPageSetLabel);
203 TQLabel *m_pagesetlabel = new TQLabel(i18n("Page &set:"), m_pagebox);
204 m_pagesetlabel->setBuddy(m_pageset);
205 TQWhatsThis::add(m_pagesetlabel, whatsThisPageSetLabel);
206 KSeparator *sepline = new KSeparator(TQt::Horizontal, m_pagebox);
207 sepline->setMinimumHeight(10);
208
209 TQWidget::setTabOrder( m_all, m_current );
210 TQWidget::setTabOrder( m_current, m_range );
211 TQWidget::setTabOrder( m_range, m_rangeedit );
212 TQWidget::setTabOrder( m_rangeedit, m_pageset );
213 TQWidget::setTabOrder( m_pageset, m_copies );
214 TQWidget::setTabOrder( m_copies, m_collate );
215 TQWidget::setTabOrder( m_collate, m_order );
216
217 // layout creation
218 TQGridLayout *l1 = new TQGridLayout(this, 2, 2, 0, 5);
219 l1->setRowStretch(1,1);
220 l1->setColStretch(0,1);
221 l1->setColStretch(1,1);
222 l1->addWidget(m_pagebox,0,0);
223 l1->addWidget(m_copybox,0,1);
224 TQVBoxLayout *l3 = new TQVBoxLayout(m_pagebox->layout(), 5);
225 l3->addWidget(m_all);
226 l3->addWidget(m_current);
227 TQHBoxLayout *l4 = new TQHBoxLayout(0, 0, 5);
228 l3->addLayout(l4);
229 l4->addWidget(m_range,0);
230 l4->addWidget(m_rangeedit,1);
231 //l3->addWidget(m_rangeexpl);
232 l3->addWidget(sepline);
233 TQHBoxLayout *l2 = new TQHBoxLayout(0, 0, 5);
234 l3->addLayout(l2);
235 l2->addWidget(m_pagesetlabel,0);
236 l2->addWidget(m_pageset,1);
237 TQGridLayout *l5 = new TQGridLayout(m_copybox->layout(), 4, 2, 10);
238 l5->setRowStretch(4,1);
239 l5->addWidget(m_copieslabel,0,0);
240 l5->addWidget(m_copies,0,1);
241 l5->addMultiCellWidget(m_collatepix,1,2,0,0);
242 l5->addWidget(m_collate,1,1);
243 l5->addWidget(m_order,2,1);
244
245 // some initialization
246 m_all->setChecked(true);
247 m_copies->setValue(1);
248 initialize(m_useplugin);
249 slotCollateClicked();
250
251 // connections
252 connect(m_rangeedit,TQ_SIGNAL(textChanged(const TQString&)),TQ_SLOT(slotRangeEntered()));
253 connect(m_collate,TQ_SIGNAL(clicked()),TQ_SLOT(slotCollateClicked()));
254 connect(m_order,TQ_SIGNAL(clicked()),TQ_SLOT(slotCollateClicked()));
255
256 if (!tdeApp->authorize("print/copies"))
257 {
258 setTitle(i18n("Pages"));
259 m_copybox->hide();
260 }
261}
262
263KPCopiesPage::~KPCopiesPage()
264{
265}
266
267void KPCopiesPage::slotRangeEntered()
268{
269 m_range->setChecked(true);
270}
271
272void KPCopiesPage::slotCollateClicked()
273{
274 TQString s("tdeprint_");
275 s.append((m_collate->isChecked() ? "collate" : "uncollate"));
276 if (m_order->isChecked()) s.append("_reverse");
277 m_collatepix->setPixmap(UserIcon(s));
278}
279
280void KPCopiesPage::initialize(bool usePlugin)
281{
282 m_useplugin = usePlugin;
283 int f = KMFactory::self()->uiManager()->copyFlags(m_printer, m_useplugin);
284
285 m_current->setEnabled((f & KMUiManager::Current));
286 m_range->setEnabled((f & KMUiManager::Range));
287 m_rangeedit->setEnabled((f & KMUiManager::Range));
288 m_collate->setEnabled((f & KMUiManager::Collate));
289 m_order->setEnabled((f & KMUiManager::Order));
290 m_pageset->setEnabled((f & KMUiManager::PageSet));
291
292 // by default, if collate disabled, set it to true
293 m_collate->setChecked(!(f & KMUiManager::NoAutoCollate));
294 slotCollateClicked();
295}
296
297void KPCopiesPage::setOptions(const TQMap<TQString,TQString>& options)
298{
299 TQString value;
300 // copies
301 value = options["kde-copies"];
302 if (!value.isEmpty()) m_copies->setValue(value.toInt());
303 // output order
304 value = options["kde-pageorder"];
305 if (m_order->isEnabled()) m_order->setChecked(value == "Reverse");
306 // collate
307 value = options["kde-collate"];
308 if (m_collate->isEnabled()) m_collate->setChecked(!(value == "Uncollate"));
309 // update pixmap
310 slotCollateClicked();
311 // page ranges
312 value = options["kde-range"];
313 if (!value.isEmpty() && m_range->isEnabled() && value != "1-")
314 {
315 m_rangeedit->setText(value);
316 m_range->setChecked(true);
317 }
318 else if (options["kde-current"] == "1")
319 m_current->setChecked(true);
320 else
321 m_all->setChecked(true);
322 // page set
323 value = options["kde-pageset"];
324 if (!value.isEmpty() && m_pageset->isEnabled())
325 m_pageset->setCurrentItem(value.toInt());
326 else
327 m_pageset->setCurrentItem(0);
328}
329
330void KPCopiesPage::getOptions(TQMap<TQString,TQString>& options, bool incldef)
331{
332 // copies
333 options["kde-copies"] = m_copies->text();
334 // output order
335 options["kde-pageorder"] = (m_order->isChecked() ? "Reverse" : "Forward");
336 // collate
337 options["kde-collate"] = (m_collate->isChecked() ? "Collate" : "Uncollate");
338 // ranges
339 options["kde-current"] = (m_current->isChecked() ? "1" : "0");
340 options["kde-range"] = (m_range->isChecked() ? m_rangeedit->text() : (incldef ? TQString::fromLatin1("1-") : TQString::fromLatin1("")));
341 // page set
342 options["kde-pageset"] = TQString::number(m_pageset->currentItem());
343}
344
345void KPCopiesPage::reload()
346{
347 initialize(m_useplugin);
348}
349
350#include "kpcopiespage.moc"
KPrintDialogPage
This class is intended to be used as base class for customized print dialog page.
Definition: kprintdialogpage.h:91
KPrinter
This class is the main interface to access the TDE print framework.
Definition: kprinter.h:89

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.