00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 <qlabel.h>
00027
#include <qcombobox.h>
00028
#include <qspinbox.h>
00029
#include <qbuttongroup.h>
00030
#include <qradiobutton.h>
00031
#include <qlineedit.h>
00032
#include <qcheckbox.h>
00033
#include <qtooltip.h>
00034
#include <qwhatsthis.h>
00035
#include <qlayout.h>
00036
00037
#include <kapplication.h>
00038
#include <klocale.h>
00039
#include <kiconloader.h>
00040
#include <kseparator.h>
00041
00042 KPCopiesPage::KPCopiesPage(
KPrinter *prt,
QWidget *parent,
const char *name)
00043 :
KPrintDialogPage(parent,name)
00044 {
00045
00046
QString 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
QString 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
QString whatsThisCurrentPagesLabel = i18n(
" <qt><b>Current Page:</b> Select <em>\"Current\"</em> if you want "
00056
" to print the page currently visible in your KDE application.</p>"
00057
" <p><b>Note:</b> this field is disabled if you print from"
00058
" non-KDE applications like Mozilla or OpenOffice.org, since here KDEPrint has no"
00059
" means to determine which document page you are currently viewing.</p></qt>" );
00060
QString whatsThisPageRangeLabel = i18n(
" <qt><b>Page Range:</b> Choose a \"Page Range\" to select a subset of the"
00061
" complete document pages"
00062
" to be printed. The format is <em>\"n,m,o-p,q,r,s-t, u\"</em>.</p>"
00063
" <p><b>Example:</b> <em>\"4,6,10-13,17,20,23-25\"</em> will print"
00064
" the pages 4, 6, 10, 11, 12, 13, 17, 20, 23, 24, 25 of your document.</p>"
00065
" <br> "
00066
" <hr> "
00067
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00068
" with the CUPS commandline job option parameter:</em> "
00069
" <pre>"
00070
" -o page-ranges=... # example: \"4,6,10-13,17,20,23-25\" "
00071
" </pre>"
00072
" </p> "
00073
"</qt>" );
00074
QString whatsThisPageSetLabel = i18n(
" <qt><b>Page Set:</b>"
00075
" <p>Choose <em>\"All Pages\"</em>, <em>\"Even Pages\"</em> or"
00076
" <em>\"Odd Pages\"</em>"
00077
" if you want to print a page selection matching one of these terms. The default"
00078
" is <em>\"All Pages\"</em>.</p>"
00079
" <p><b>Note:</b> If you combine a selection of a <em>\"Page Range\"</em> with a"
00080
" <em>\"Page Set\"</em> of <em>\"Odd\"</em> or <em>\"Even\"</em>, you will only get the"
00081
" odd or even pages from the originally selected page range. This is useful if you"
00082
" odd or even pages from the originally selected page range. This is useful if you"
00083
" want to print a page range in duplex on a simplex-only printer. In this case you"
00084
" can feed the paper to the printer twice; in the first pass, select \"Odd\" or"
00085
" \"Even\" (depending on your printer model), in second pass select the other"
00086
" option. You may need to <em>\"Reverse\"</em> the output in one of the passes (depending"
00087
" on your printer model).</p> "
00088
" <br> "
00089
" <hr> "
00090
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00091
" with the CUPS commandline job option parameter:</em> "
00092
" <pre>"
00093
" -o page-set=... # example: \"odd\" or \"even\" "
00094
" </pre>"
00095
" </p> "
00096
" </qt>" );
00097
QString whatsThisCopiesLabel = i18n(
" <qt><b>Output Settings:</b>"
00098
" Here you can determine the number of copies, the output order and the collate"
00099
" mode for the pages of your printjob. (Note, that the maximum number of copies "
00100
" allowed to print may be restricted by your print subsystem.)</p>"
00101
" <p>The 'Copies' setting defaults to 1. </p> "
00102
" <br> "
00103
" <hr> "
00104
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00105
" with the CUPS commandline job option parameter:</em> "
00106
" <pre>"
00107
" -o copies=... # examples: \"5\" or \"42\" "
00108
" <br> "
00109
" -o outputorder=... # example: \"reverse\""
00110
" <br> "
00111
" -o Collate=... # example: \"true\" or \"false\" "
00112
" </pre>"
00113
" </p> "
00114
".</qt>" );
00115
QString whatsThisNumberOfCopiesLabel = i18n(
" <qt><b>Number of Copies:</b> Determine the number of requested copies here."
00116
" You can increase or decrease"
00117
" the number of printed copies by clicking on the up and down arrows. You can also type the figure"
00118
" directly into the box. </p>"
00119
" <br> "
00120
" <hr> "
00121
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00122
" with the CUPS commandline job option parameter:</em> "
00123
" <pre>"
00124
" -o copies=... # examples: \"5\" or \"42\" "
00125
" </pre>"
00126
" </p> "
00127
" </qt>" );
00128
QString whatsThisCollateLabel = i18n(
" <qt><b>Collate Copies</b>"
00129
" <p>If the <em>\"Collate\"</em> checkbox is enabled (default), the output order for"
00130
" multiple copies of a multi-page document will be \"1-2-3-..., 1-2-3-..., 1-2-3-...\".</p>"
00131
" <p>If the <em>\"Collate\"</em> checkbox is disabled, the output order for"
00132
" multiple copies of a multi-page document will be \"1-1-1-..., 2-2-2-..., 3-3-3-...\".</p>"
00133
" <br> "
00134
" <hr> "
00135
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00136
" with the CUPS commandline job option parameter:</em> "
00137
" <pre>"
00138
" -o Collate=... # example: \"true\" or \"false\" "
00139
" </pre>"
00140
" </p> "
00141
" </qt>" );
00142
QString whatsThisReverseLabel = i18n(
" <qt><b>Reverse Order</b>"
00143
" <p> If the <em>\"Reverse\"</em> checkbox is enabled, the output order for"
00144
" multiple copies of a multi-page document will be \"...-3-2-1, ...-3-2-1, ...-3-2-1\", if you"
00145
" also have <em>en</em>abled the <em>\"Collate\"</em> checkbox at the same time"
00146
" (the usual usecase).</p>"
00147
" <p>If the <em>\"Reverse\"</em> checkbox is enabled, the output order for"
00148
" multiple copies of a multi-page document will be \"...-3-3-3, ...-2-2-2, ...-1-1-1\", if you"
00149
" have <em>dis</em>abled the <em>\"Collate\"</em> checkbox at the same time. </p>"
00150
" <br> "
00151
" <hr> "
00152
" <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches "
00153
" with the CUPS commandline job option parameter:</em> "
00154
" <pre>"
00155
" -o outputorder=... # example: \"reverse\""
00156
" "
00157
" </pre>"
00158
" </p> "
00159
" </qt>" );
00160 m_printer = prt;
00161 m_useplugin =
true;
00162
00163 setTitle(i18n(
"C&opies"));
00164 setId(KPrinter::CopiesPage);
00165
00166
00167
QButtonGroup *m_pagebox =
new QButtonGroup(0, Qt::Vertical, i18n(
"Page Selection"),
this);
00168 QWhatsThis::add(m_pagebox, whatsThisPageSelectionLabel);
00169 m_all =
new QRadioButton(i18n(
"&All"), m_pagebox);
00170 QWhatsThis::add(m_all, whatsThisAllPagesLabel);
00171 m_current =
new QRadioButton(i18n(
"Cu&rrent"), m_pagebox);
00172 QWhatsThis::add(m_current, whatsThisCurrentPagesLabel);
00173 m_range =
new QRadioButton(i18n(
"Ran&ge"), m_pagebox);
00174 QWhatsThis::add(m_range, whatsThisPageRangeLabel);
00175 m_rangeedit =
new QLineEdit(m_pagebox);
00176 QWhatsThis::add(m_rangeedit, whatsThisPageRangeLabel);
00177 connect(m_range, SIGNAL(clicked()), m_rangeedit, SLOT(setFocus()));
00178 QToolTip::add(m_rangeedit, i18n(
"<p>Enter pages or group of pages to print separated by commas (1,2-5,8).</p>"));
00179
00180
00181
00182
QGroupBox *m_copybox =
new QGroupBox(0, Qt::Vertical, i18n(
"Output Settings"),
this);
00183 QWhatsThis::add(m_copybox, whatsThisCopiesLabel);
00184 m_collate =
new QCheckBox(i18n(
"Co&llate"), m_copybox);
00185 QWhatsThis::add(m_collate, whatsThisCollateLabel);
00186 m_order =
new QCheckBox(i18n(
"Re&verse"), m_copybox);
00187 QWhatsThis::add(m_order, whatsThisReverseLabel);
00188 m_collatepix =
new QLabel(m_copybox);
00189 m_collatepix->setAlignment(Qt::AlignCenter);
00190 m_collatepix->setMinimumHeight(70);
00191 QLabel *m_copieslabel =
new QLabel(i18n(
"Cop&ies:"), m_copybox);
00192 m_copies =
new QSpinBox(m_copybox);
00193 m_copies->setRange(1,999);
00194 QWhatsThis::add(m_copies, whatsThisNumberOfCopiesLabel);
00195 m_copieslabel->setBuddy(m_copies);
00196 QWhatsThis::add(m_copieslabel, whatsThisNumberOfCopiesLabel);
00197 m_pageset =
new QComboBox(m_pagebox);
00198 m_pageset->insertItem(i18n(
"All Pages"));
00199 m_pageset->insertItem(i18n(
"Odd Pages"));
00200 m_pageset->insertItem(i18n(
"Even Pages"));
00201 QWhatsThis::add(m_pageset, whatsThisPageSetLabel);
00202 QLabel *m_pagesetlabel =
new QLabel(i18n(
"Page &set:"), m_pagebox);
00203 m_pagesetlabel->setBuddy(m_pageset);
00204 QWhatsThis::add(m_pagesetlabel, whatsThisPageSetLabel);
00205 KSeparator *sepline =
new KSeparator(Horizontal, m_pagebox);
00206 sepline->setMinimumHeight(10);
00207
00208 QWidget::setTabOrder( m_all, m_current );
00209 QWidget::setTabOrder( m_current, m_range );
00210 QWidget::setTabOrder( m_range, m_rangeedit );
00211 QWidget::setTabOrder( m_rangeedit, m_pageset );
00212 QWidget::setTabOrder( m_pageset, m_copies );
00213 QWidget::setTabOrder( m_copies, m_collate );
00214 QWidget::setTabOrder( m_collate, m_order );
00215
00216
00217
QGridLayout *l1 =
new QGridLayout(
this, 2, 2, 0, 5);
00218 l1->setRowStretch(1,1);
00219 l1->setColStretch(0,1);
00220 l1->setColStretch(1,1);
00221 l1->addWidget(m_pagebox,0,0);
00222 l1->addWidget(m_copybox,0,1);
00223
QVBoxLayout *l3 =
new QVBoxLayout(m_pagebox->layout(), 5);
00224 l3->addWidget(m_all);
00225 l3->addWidget(m_current);
00226
QHBoxLayout *l4 =
new QHBoxLayout(0, 0, 5);
00227 l3->addLayout(l4);
00228 l4->addWidget(m_range,0);
00229 l4->addWidget(m_rangeedit,1);
00230
00231 l3->addWidget(sepline);
00232 QHBoxLayout *l2 =
new QHBoxLayout(0, 0, 5);
00233 l3->addLayout(l2);
00234 l2->addWidget(m_pagesetlabel,0);
00235 l2->addWidget(m_pageset,1);
00236 QGridLayout *l5 =
new QGridLayout(m_copybox->layout(), 4, 2, 10);
00237 l5->setRowStretch(4,1);
00238 l5->addWidget(m_copieslabel,0,0);
00239 l5->addWidget(m_copies,0,1);
00240 l5->addMultiCellWidget(m_collatepix,1,2,0,0);
00241 l5->addWidget(m_collate,1,1);
00242 l5->addWidget(m_order,2,1);
00243
00244
00245 m_all->setChecked(
true);
00246 m_copies->setValue(1);
00247 initialize(m_useplugin);
00248 slotCollateClicked();
00249
00250
00251 connect(m_rangeedit,SIGNAL(textChanged(
const QString&)),SLOT(slotRangeEntered()));
00252 connect(m_collate,SIGNAL(clicked()),SLOT(slotCollateClicked()));
00253 connect(m_order,SIGNAL(clicked()),SLOT(slotCollateClicked()));
00254
00255
if (!kapp->authorize(
"print/copies"))
00256 {
00257 setTitle(i18n(
"Pages"));
00258 m_copybox->hide();
00259 }
00260 }
00261
00262 KPCopiesPage::~KPCopiesPage()
00263 {
00264 }
00265
00266
void KPCopiesPage::slotRangeEntered()
00267 {
00268 m_range->setChecked(
true);
00269 }
00270
00271
void KPCopiesPage::slotCollateClicked()
00272 {
00273
QString s(
"kdeprint_");
00274 s.append((m_collate->isChecked() ?
"collate" :
"uncollate"));
00275
if (m_order->isChecked()) s.append(
"_reverse");
00276 m_collatepix->setPixmap(UserIcon(s));
00277 }
00278
00279
void KPCopiesPage::initialize(
bool usePlugin)
00280 {
00281 m_useplugin = usePlugin;
00282
int f = KMFactory::self()->uiManager()->copyFlags(m_printer, m_useplugin);
00283
00284 m_current->setEnabled((f & KMUiManager::Current));
00285 m_range->setEnabled((f & KMUiManager::Range));
00286 m_rangeedit->setEnabled((f & KMUiManager::Range));
00287 m_collate->setEnabled((f & KMUiManager::Collate));
00288 m_order->setEnabled((f & KMUiManager::Order));
00289 m_pageset->setEnabled((f & KMUiManager::PageSet));
00290
00291
00292 m_collate->setChecked(!(f & KMUiManager::NoAutoCollate));
00293 slotCollateClicked();
00294 }
00295
00296
void KPCopiesPage::setOptions(
const QMap<QString,QString>& options)
00297 {
00298
QString value;
00299
00300 value = options[
"kde-copies"];
00301
if (!value.isEmpty()) m_copies->setValue(value.toInt());
00302
00303 value = options[
"kde-pageorder"];
00304
if (m_order->isEnabled()) m_order->setChecked(value ==
"Reverse");
00305
00306 value = options[
"kde-collate"];
00307
if (m_collate->isEnabled()) m_collate->setChecked(!(value ==
"Uncollate"));
00308
00309 slotCollateClicked();
00310
00311 value = options[
"kde-range"];
00312
if (!value.isEmpty() && m_range->isEnabled() && value !=
"1-")
00313 {
00314 m_rangeedit->setText(value);
00315 m_range->setChecked(
true);
00316 }
00317
else if (options[
"kde-current"] ==
"1")
00318 m_current->setChecked(
true);
00319
else
00320 m_all->setChecked(
true);
00321
00322 value = options[
"kde-pageset"];
00323
if (!value.isEmpty() && m_pageset->isEnabled())
00324 m_pageset->setCurrentItem(value.toInt());
00325
else
00326 m_pageset->setCurrentItem(0);
00327 }
00328
00329
void KPCopiesPage::getOptions(
QMap<QString,QString>& options,
bool incldef)
00330 {
00331
00332 options[
"kde-copies"] = m_copies->text();
00333
00334 options[
"kde-pageorder"] = (m_order->isChecked() ?
"Reverse" :
"Forward");
00335
00336 options[
"kde-collate"] = (m_collate->isChecked() ?
"Collate" :
"Uncollate");
00337
00338 options[
"kde-current"] = (m_current->isChecked() ?
"1" :
"0");
00339 options[
"kde-range"] = (m_range->isChecked() ? m_rangeedit->text() : (incldef ?
QString::fromLatin1("1-") :
QString::fromLatin1("")));
00340
00341 options[
"kde-pageset"] = QString::number(m_pageset->currentItem());
00342 }
00343
00344
void KPCopiesPage::reload()
00345 {
00346 initialize(m_useplugin);
00347 }
00348
00349
#include "kpcopiespage.moc"