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

kdeprint

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

kdeprint

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

kdeprint

Skip menu "kdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdeprint by doxygen 1.9.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |