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

tdeprint

kpcopiespage.cpp
00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "kpcopiespage.h"
00021 #include "kmfactory.h"
00022 #include "kmuimanager.h"
00023 #include "kprinter.h"
00024 #include "kxmlcommand.h"
00025 
00026 #include <tqlabel.h>
00027 #include <tqcombobox.h>
00028 #include <tqspinbox.h>
00029 #include <tqbuttongroup.h>
00030 #include <tqradiobutton.h>
00031 #include <tqlineedit.h>
00032 #include <tqcheckbox.h>
00033 #include <tqtooltip.h>
00034 #include <tqwhatsthis.h>
00035 #include <tqlayout.h>
00036 
00037 #include <tdeapplication.h>
00038 #include <tdelocale.h>
00039 #include <kiconloader.h>
00040 #include <kseparator.h>
00041 
00042 KPCopiesPage::KPCopiesPage(KPrinter *prt, TQWidget *parent, const char *name)
00043 : KPrintDialogPage(parent,name)
00044 {
00045     //WhatsThis strings.... (added by pfeifle@kde.org)
00046     TQString whatsThisPageSelectionLabel = i18n(  " <qt><p><b>Page Selection</b></p> "
00047                         " <p>Here you can control if you print a certain selection only out of all"
00048                         " the pages from the complete document."
00049                         " </p>"
00050                         " </qt>" );
00051     TQString whatsThisAllPagesLabel = i18n(  " <qt><b>All Pages:</b> Select \"All\" to print the complete document."
00052                         " Since this is the default, it is pre-selected."
00053                         " </p>"
00054                         " </qt>" );
00055     TQString whatsThisCurrentPagesLabel = i18n(  " <qt><b>Current Page:</b> Select <em>\"Current\"</em> if you want "
00056                         " to print the page currently visible in your TDE application.</p>"
00057                         " <p><b>Note:</b> this field is disabled if you print from"
00058                         " non-TDE applications like Firefox, PaleMoon, SeaMonkey or OpenOffice and"
00059                         " LibreOffice, since here TDEPrint has no means to determine which document page"
00060                         " you are currently viewing.</p></qt>" );
00061     TQString whatsThisPageRangeLabel = i18n(  " <qt><b>Page Range:</b> Choose a \"Page Range\" to select a subset of the"
00062                         " complete document pages"
00063                         " to be printed. The format is <em>\"n,m,o-p,q,r,s-t, u\"</em>.</p>"
00064                         " <p><b>Example:</b> <em>\"4,6,10-13,17,20,23-25\"</em> will print"
00065                         " the pages 4, 6, 10, 11, 12, 13, 17, 20, 23, 24, 25 of your document.</p>"
00066                         " <br> "
00067                         " <hr> "
00068                         " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
00069                         " with the CUPS commandline job option parameter:</em> "
00070                         " <pre>"
00071                         "    -o page-ranges=...     # example: \"4,6,10-13,17,20,23-25\" "
00072                         " </pre>"
00073                         " </p> "
00074                         "</qt>" );
00075     TQString whatsThisPageSetLabel = i18n(  " <qt><b>Page Set:</b>"
00076                         " <p>Choose <em>\"All Pages\"</em>, <em>\"Even Pages\"</em> or"
00077                         " <em>\"Odd Pages\"</em>"
00078                         " if you want to print a page selection matching one of these terms. The default"
00079                         " is <em>\"All Pages\"</em>.</p>"
00080                         " <p><b>Note:</b> If you combine a selection of a <em>\"Page Range\"</em> with a"
00081                         " <em>\"Page Set\"</em> of <em>\"Odd\"</em> or <em>\"Even\"</em>, you will only get the"
00082                         " odd or even pages from the originally selected page range. This is useful if you"
00083                         " odd or even pages from the originally selected page range. This is useful if you"
00084                         " want to print a page range in duplex on a simplex-only printer. In this case you"
00085                         " can feed the paper to the printer twice; in the first pass, select \"Odd\" or"
00086                         " \"Even\" (depending on your printer model), in second pass select the other"
00087                         " option. You may need to <em>\"Reverse\"</em> the output in one of the passes (depending"
00088                         " on your printer model).</p> "
00089                         " <br> "
00090                         " <hr> "
00091                         " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
00092                         " with the CUPS commandline job option parameter:</em> "
00093                         " <pre>"
00094                         "    -o page-set=...        # example: \"odd\" or \"even\" "
00095                         " </pre>"
00096                         " </p> "
00097                         " </qt>" );
00098     TQString whatsThisCopiesLabel = i18n(  " <qt><b>Output Settings:</b>"
00099                         " Here you can determine the number of copies, the output order and the collate"
00100                         " mode for the pages of your printjob. (Note, that the maximum number of copies "
00101                         " allowed to print may be restricted by your print subsystem.)</p>"
00102                         " <p>The 'Copies' setting defaults to 1. </p> "
00103                         " <br> "
00104                         " <hr> "
00105                         " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
00106                         " with the CUPS commandline job option parameter:</em> "
00107                         " <pre>"
00108                         "     -o copies=...            # examples: \"5\" or \"42\" "
00109                         " <br> "
00110                         "    -o outputorder=...       # example:  \"reverse\""
00111                         " <br> "
00112                         "    -o Collate=...           # example:  \"true\" or \"false\" "
00113                         " </pre>"
00114                         " </p> "
00115                         ".</qt>" );
00116     TQString whatsThisNumberOfCopiesLabel = i18n(  " <qt><b>Number of Copies:</b> Determine the number of requested copies here."
00117                         " You can increase or decrease"
00118                         " the number of printed copies by clicking on the up and down arrows. You can also type the figure"
00119                         " directly into the box. </p>"
00120                         " <br> "
00121                         " <hr> "
00122                         " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
00123                         " with the CUPS commandline job option parameter:</em> "
00124                         " <pre>"
00125                         "     -o copies=...            # examples: \"5\" or \"42\" "
00126                         " </pre>"
00127                         " </p> "
00128                         " </qt>" );
00129     TQString whatsThisCollateLabel = i18n(  " <qt><b>Collate Copies</b>"
00130                         " <p>If the <em>\"Collate\"</em> checkbox is enabled (default), the output order for"
00131                         " multiple copies of a multi-page document will be \"1-2-3-..., 1-2-3-..., 1-2-3-...\".</p>"
00132                         " <p>If the <em>\"Collate\"</em> checkbox is disabled, the output order for"
00133                         " multiple copies of a multi-page document will be \"1-1-1-..., 2-2-2-..., 3-3-3-...\".</p>"
00134                         " <br> "
00135                         " <hr> "
00136                         " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
00137                         " with the CUPS commandline job option parameter:</em> "
00138                         " <pre>"
00139                         "    -o Collate=...           # example:  \"true\" or \"false\" "
00140                         " </pre>"
00141                         " </p> "
00142                         " </qt>" );
00143     TQString whatsThisReverseLabel = i18n(  " <qt><b>Reverse Order</b>"
00144                         " <p> If the <em>\"Reverse\"</em> checkbox is enabled, the output order for"
00145                         " multiple copies of a multi-page document will be \"...-3-2-1, ...-3-2-1, ...-3-2-1\", if you"
00146                         " also have <em>en</em>abled the <em>\"Collate\"</em> checkbox at the same time"
00147                         " (the usual usecase).</p>"
00148                         " <p>If the <em>\"Reverse\"</em> checkbox is enabled, the output order for"
00149                         " multiple copies of a multi-page document will be \"...-3-3-3, ...-2-2-2, ...-1-1-1\", if you"
00150                         " have <em>dis</em>abled the <em>\"Collate\"</em> checkbox at the same time. </p>"
00151                         " <br> "
00152                         " <hr> "
00153                         " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
00154                         " with the CUPS commandline job option parameter:</em> "
00155                         " <pre>"
00156                         "    -o outputorder=...       # example:  \"reverse\""
00157                         " "
00158                         " </pre>"
00159                         " </p> "
00160                         " </qt>" );
00161     m_printer = prt;
00162     m_useplugin = true;
00163 
00164     setTitle(i18n("C&opies"));
00165     setId(KPrinter::CopiesPage);
00166 
00167     // widget creation
00168     TQButtonGroup   *m_pagebox = new TQButtonGroup(0, Qt::Vertical, i18n("Page Selection"), this);
00169     TQWhatsThis::add(m_pagebox, whatsThisPageSelectionLabel);
00170     m_all = new TQRadioButton(i18n("&All"), m_pagebox);
00171     TQWhatsThis::add(m_all, whatsThisAllPagesLabel);
00172     m_current = new TQRadioButton(i18n("Cu&rrent"), m_pagebox);
00173     TQWhatsThis::add(m_current, whatsThisCurrentPagesLabel);
00174     m_range = new TQRadioButton(i18n("Ran&ge"), m_pagebox);
00175     TQWhatsThis::add(m_range, whatsThisPageRangeLabel);
00176     m_rangeedit = new TQLineEdit(m_pagebox);
00177     TQWhatsThis::add(m_rangeedit, whatsThisPageRangeLabel);
00178     connect(m_range, TQT_SIGNAL(clicked()), m_rangeedit, TQT_SLOT(setFocus()));
00179     TQToolTip::add(m_rangeedit, i18n("<p>Enter pages or group of pages to print separated by commas (1,2-5,8).</p>"));
00180 //  TQWhatsThis::add(m_rangeedit, i18n("<p>Enter pages or group of pages to print separated by commas (1,2-5,8).</p>"));
00181     //TQLabel   *m_rangeexpl = new TQLabel(m_pagebox);
00182     //m_rangeexpl->setText(i18n("<p>Enter pages or group of pages to print separated by commas (1,2-5,8).</p>"));
00183     TQGroupBox  *m_copybox = new TQGroupBox(0, Qt::Vertical, i18n("Output Settings"), this);
00184     TQWhatsThis::add(m_copybox, whatsThisCopiesLabel);
00185     m_collate = new TQCheckBox(i18n("Co&llate"), m_copybox);
00186     TQWhatsThis::add(m_collate, whatsThisCollateLabel);
00187     m_order = new TQCheckBox(i18n("Re&verse"), m_copybox);
00188     TQWhatsThis::add(m_order, whatsThisReverseLabel);
00189     m_collatepix = new TQLabel(m_copybox);
00190     m_collatepix->setAlignment(Qt::AlignCenter);
00191     m_collatepix->setMinimumHeight(70);
00192     TQLabel *m_copieslabel = new TQLabel(i18n("Cop&ies:"), m_copybox);
00193     m_copies = new TQSpinBox(m_copybox);
00194     m_copies->setRange(1,999);
00195     TQWhatsThis::add(m_copies, whatsThisNumberOfCopiesLabel);
00196     m_copieslabel->setBuddy(m_copies);
00197     TQWhatsThis::add(m_copieslabel, whatsThisNumberOfCopiesLabel);
00198     m_pageset = new TQComboBox(m_pagebox);
00199     m_pageset->insertItem(i18n("All Pages"));
00200     m_pageset->insertItem(i18n("Odd Pages"));
00201     m_pageset->insertItem(i18n("Even Pages"));
00202     TQWhatsThis::add(m_pageset, whatsThisPageSetLabel);
00203     TQLabel *m_pagesetlabel = new TQLabel(i18n("Page &set:"), m_pagebox);
00204     m_pagesetlabel->setBuddy(m_pageset);
00205     TQWhatsThis::add(m_pagesetlabel, whatsThisPageSetLabel);
00206     KSeparator  *sepline = new KSeparator(Qt::Horizontal, m_pagebox);
00207     sepline->setMinimumHeight(10);
00208 
00209     TQWidget::setTabOrder( m_all, m_current );
00210     TQWidget::setTabOrder( m_current, m_range );
00211     TQWidget::setTabOrder( m_range, m_rangeedit );
00212     TQWidget::setTabOrder( m_rangeedit, m_pageset );
00213     TQWidget::setTabOrder( m_pageset, m_copies );
00214     TQWidget::setTabOrder( m_copies, m_collate );
00215     TQWidget::setTabOrder( m_collate, m_order );
00216 
00217     // layout creation
00218     TQGridLayout    *l1 = new TQGridLayout(this, 2, 2, 0, 5);
00219     l1->setRowStretch(1,1);
00220     l1->setColStretch(0,1);
00221     l1->setColStretch(1,1);
00222     l1->addWidget(m_pagebox,0,0);
00223     l1->addWidget(m_copybox,0,1);
00224     TQVBoxLayout    *l3 = new TQVBoxLayout(TQT_TQLAYOUT(m_pagebox->layout()), 5);
00225     l3->addWidget(m_all);
00226     l3->addWidget(m_current);
00227     TQHBoxLayout    *l4 = new TQHBoxLayout(0, 0, 5);
00228     l3->addLayout(l4);
00229     l4->addWidget(m_range,0);
00230     l4->addWidget(m_rangeedit,1);
00231     //l3->addWidget(m_rangeexpl);
00232     l3->addWidget(sepline);
00233     TQHBoxLayout    *l2 = new TQHBoxLayout(0, 0, 5);
00234     l3->addLayout(l2);
00235     l2->addWidget(m_pagesetlabel,0);
00236     l2->addWidget(m_pageset,1);
00237     TQGridLayout    *l5 = new TQGridLayout(m_copybox->layout(), 4, 2, 10);
00238     l5->setRowStretch(4,1);
00239     l5->addWidget(m_copieslabel,0,0);
00240     l5->addWidget(m_copies,0,1);
00241     l5->addMultiCellWidget(m_collatepix,1,2,0,0);
00242     l5->addWidget(m_collate,1,1);
00243     l5->addWidget(m_order,2,1);
00244 
00245     // some initialization
00246     m_all->setChecked(true);
00247     m_copies->setValue(1);
00248     initialize(m_useplugin);
00249     slotCollateClicked();
00250 
00251     // connections
00252     connect(m_rangeedit,TQT_SIGNAL(textChanged(const TQString&)),TQT_SLOT(slotRangeEntered()));
00253     connect(m_collate,TQT_SIGNAL(clicked()),TQT_SLOT(slotCollateClicked()));
00254     connect(m_order,TQT_SIGNAL(clicked()),TQT_SLOT(slotCollateClicked()));
00255 
00256     if (!kapp->authorize("print/copies"))
00257     {
00258         setTitle(i18n("Pages"));
00259         m_copybox->hide();
00260     }
00261 }
00262 
00263 KPCopiesPage::~KPCopiesPage()
00264 {
00265 }
00266 
00267 void KPCopiesPage::slotRangeEntered()
00268 {
00269     m_range->setChecked(true);
00270 }
00271 
00272 void KPCopiesPage::slotCollateClicked()
00273 {
00274     TQString    s("tdeprint_");
00275     s.append((m_collate->isChecked() ? "collate" : "uncollate"));
00276     if (m_order->isChecked()) s.append("_reverse");
00277     m_collatepix->setPixmap(UserIcon(s));
00278 }
00279 
00280 void KPCopiesPage::initialize(bool usePlugin)
00281 {
00282     m_useplugin = usePlugin;
00283     int f = KMFactory::self()->uiManager()->copyFlags(m_printer, m_useplugin);
00284 
00285     m_current->setEnabled((f & KMUiManager::Current));
00286     m_range->setEnabled((f & KMUiManager::Range));
00287     m_rangeedit->setEnabled((f & KMUiManager::Range));
00288     m_collate->setEnabled((f & KMUiManager::Collate));
00289     m_order->setEnabled((f & KMUiManager::Order));
00290     m_pageset->setEnabled((f & KMUiManager::PageSet));
00291 
00292     // by default, if collate disabled, set it to true
00293     m_collate->setChecked(!(f & KMUiManager::NoAutoCollate));
00294     slotCollateClicked();
00295 }
00296 
00297 void KPCopiesPage::setOptions(const TQMap<TQString,TQString>& options)
00298 {
00299     TQString    value;
00300     // copies
00301     value = options["kde-copies"];
00302     if (!value.isEmpty()) m_copies->setValue(value.toInt());
00303     // output order
00304     value = options["kde-pageorder"];
00305     if (m_order->isEnabled()) m_order->setChecked(value == "Reverse");
00306     // collate
00307     value = options["kde-collate"];
00308     if (m_collate->isEnabled()) m_collate->setChecked(!(value == "Uncollate"));
00309     // update pixmap
00310     slotCollateClicked();
00311     // page ranges
00312     value = options["kde-range"];
00313     if (!value.isEmpty() && m_range->isEnabled() && value != "1-")
00314     {
00315         m_rangeedit->setText(value);
00316         m_range->setChecked(true);
00317     }
00318     else if (options["kde-current"] == "1")
00319         m_current->setChecked(true);
00320     else
00321         m_all->setChecked(true);
00322     // page set
00323     value = options["kde-pageset"];
00324     if (!value.isEmpty() && m_pageset->isEnabled())
00325         m_pageset->setCurrentItem(value.toInt());
00326     else
00327         m_pageset->setCurrentItem(0);
00328 }
00329 
00330 void KPCopiesPage::getOptions(TQMap<TQString,TQString>& options, bool incldef)
00331 {
00332     // copies
00333     options["kde-copies"] = m_copies->text();
00334     // output order
00335     options["kde-pageorder"] = (m_order->isChecked() ? "Reverse" : "Forward");
00336     // collate
00337     options["kde-collate"] = (m_collate->isChecked() ? "Collate" : "Uncollate");
00338     // ranges
00339     options["kde-current"] = (m_current->isChecked() ? "1" : "0");
00340     options["kde-range"] = (m_range->isChecked() ? m_rangeedit->text() : (incldef ? TQString::fromLatin1("1-") : TQString::fromLatin1("")));
00341     // page set
00342     options["kde-pageset"] = TQString::number(m_pageset->currentItem());
00343 }
00344 
00345 void KPCopiesPage::reload()
00346 {
00347     initialize(m_useplugin);
00348 }
00349 
00350 #include "kpcopiespage.moc"

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.7.6.1
This website is maintained by Timothy Pearson.