| # kdeprint Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kpposterpage.cpp

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (c) 2001-2002 Michael Goffioul <kdeprint@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., 59 Temple Place - Suite 330,
    00017  *  Boston, MA 02111-1307, USA.
    00018  **/
    00019
    00020 #include "kpposterpage.h"
    00021 #include "posterpreview.h"
    00022 #include "kprinter.h"
    00023 #include "kmfactory.h"
    00024 #include "util.h"
    00025
    00026 #include <qcheckbox.h>
    00027 #include <qcombobox.h>
    00028 #include <qlabel.h>
    00029 #include <qlayout.h>
    00030 #include <qtooltip.h>
    00031 #include <qlineedit.h>
    00032 #include <qwhatsthis.h>
    00033 #include <kpushbutton.h>
    00034 #include <klocale.h>
    00035 #include <knuminput.h>
    00036 #include <kiconloader.h>
    00037
    00038 KPPosterPage::KPPosterPage( QWidget *parent, const char *name )
    00039     : KPrintDialogPage( parent, name )
    00040 {
    00041         //WhatsThis strings.... (added by pfeifle@kde.org)
    00042     QString whatsThis5_PosterPage = i18n( " <qt> "
    00043             " 5. "
    00044             " </qt>" );
    00045
    00046     QString whatsThisEnablePosterPage = i18n( " <qt> "
    00047                         " <b>Print Poster</b> (enabled or disabled). "
    00048             " <p>If you enable this option, you can print posters of different sizes "
    00049             " The printout will happen in the form <em>'tiles'</em> printed on smaller "
    00050             " paper sizes, which you can stitch together later. <em>If you enable this "
    00051             " option here, the <em>'Poster Printing' filter</em> will be auto-loaded in "
    00052             " the 'Filters' tab of this dialog. </p>"
    00053             " <p>This tab is only visible if the external <em>'poster'</em> utility is "
    00054             " discovered by KDEPrint on your system. [<em>'poster'</em> is a commandline "
    00055             " utility that enables you to convert PostScript files into tiled printouts "
    00056             " which allow for oversized appearance of the stitched-together tiles.] </p>"
    00057             " <p><b>Note:</b> The standard version of 'poster' will not work. Your system "
    00058             " must use a patched version of 'poster'. Ask your operating system vendor to "
    00059             " provide a patched version of 'poster' if he does not already. </p>"
    00060             " <p><b>Additional hint for power users:</b> A patched version of 'poster' is "
    00061             " available from the <a href=\"http://printing.kde.org/\">KDEPrint Website</a> "
    00062             " at <a href=\"http://printing.kde.org/downloads/\">http://printing.kde.org/downloads/</a>. "
    00063             " The direct link to the patched source tarball is "
    00064             " <a href=\"ftp://ftp.kde.org/pub/kde/printing/poster.tar.bz2\">ftp://ftp.kde.org/pub/kde/printing/poster.tar.bz2</a> "
    00065             " </p> "
    00066             " </qt>" );
    00067
    00068     QString whatsThisTileSelectionPosterPage = i18n( " <qt> "
    00069                         " <b>Tile Selection widget</b> "
    00070             " <p>This GUI element is <em>not only for viewing</em> your selections: it also "
    00071             " lets you interactively select the tile(s) you want to print. "
    00072             " </p>"
    00073             " <p><b>Hints</b> "
    00074             " <ul> "
    00075             " <li>Click any tile to select it for printing.</li> "
    00076             " <li>To select multiple tiles to be printed "
    00077             " at once, <em>'shift-click'</em> on the tiles ('shift-click' means: hold down the "
    00078             " [SHIFT]-key on your keyboard and click with the mouse while [SHIFT]-key is held.)  "
    00079             " <em>Be aware</em> that the order "
    00080             " of your clicking is also significant to the order of printing the different tiles. </li>"
    00081             " </ul> "
    00082             " <b>Note 1:</b> The order of your selection (and the order for printout of the tiles) "
    00083             " is indicated by the contents of the text field below, "
    00084             " labelled as <em>'Tile pages (to be printed):'</em><p>"
    00085             " <b>Note 2:</b> By default no tile is selected. Before you can print (a part "
    00086             " of) your poster, you must select at least one tile. </p> "
    00087             " </qt>" );
    00088
    00089     QString whatsThisPostersizePosterPage = i18n( " <qt> "
    00090                         " <b>Poster Size</b> "
    00091             " <p>Select the poster size you want from the dropdown list. </p> "
    00092             " Available sizes are all standard paper sizes up to "
    00093             " 'A0'. [A0 is the same size as 16 sheets of A4, or '84cm x 118.2cm'.] </p> "
    00094             " <p><b>Notice</b>, how the little preview window below changes with your change of poster "
    00095             " size. It indicates to you how many tiles need to be printed to make the poster, "
    00096             " given the selected paper size.</p>  "
    00097             " <p><b>Hint:</b> The little preview window below is not just a passive icon. You can click "
    00098             " on its individual tiles to select them for printing. To select multiple tiles to be printed "
    00099             " at once, you need to <em>'shift-click'</em> on the tiles ('shift-click' means: hold down the "
    00100             " [SHIFT]-key on your keyboard and click with the mouse while [SHIFT]-key is held.) The order "
    00101             " of your clicking is significant to the order of printing the different tiles. The order of "
    00102             " your selection (and for the printed tiles) is indicated by the contents of the text field "
    00103             " labelled as <em>'Tile pages (to be printed):'</em><p>"
    00104             " <b>Note:</b> By default no tile is selected. Before you can print (a part "
    00105             " of) your poster, you must select at least one tile. </p> "
    00106             " </qt>" );
    00107
    00108     QString whatsThisPrintsizePosterPage = i18n( " <qt> "
    00109                         " <b>Paper Size</b> "
    00110             " <p>This field indicates the paper size the poster tiles will be printed on. "
    00111             " To select a different paper size for your poster tiles, go to the 'General' tab "
    00112             " of this dialog and select one from the dropdown list. </p> "
    00113             " Available sizes are most standard paper sizes supported by your printer. Your printer's "
    00114             " supported paper sizes are read from the printer driver info (as laid down in the <em>'PPD'</em>, "
    00115             " the printer description file). <em>Be aware that the 'Paper Size' selected may not be supported "
    00116             " by 'poster' (example: 'HalfLetter') while it may well be supported by your printer.</em>  If "
    00117             " you hit that obstacle, simply use another, supported Paper Size, like 'A4' or 'Letter'. "
    00118             " <p><b>Notice</b>, how the little preview window below changes with your change of paper "
    00119             " size. It indicates how many tiles need to be printed to make up the poster, "
    00120             " given the selected paper and poster size.</p>  "
    00121             " <p><b>Hint:</b> The little preview window below is not just a passive icon. You can click "
    00122             " on its individual tiles to select them for printing. To select multiple tiles to be printed "
    00123             " at once, you need to <em>'shift-click'</em> on the tiles ('shift-click' means: hold down the "
    00124             " [SHIFT]-key on your keyboard and click with the mouse while [SHIFT]-key is held.) The order "
    00125             " of your clicking is significant to the order of printing the different tiles. The order of "
    00126             " your selection (and for the printed tiles) is indicated by the contents of the text field "
    00127             " labelled as <em>'Tile pages (to be printed):'</em><p>"
    00128             " <b>Note:</b> By default no tile is selected. Before you can print (a part "
    00129             " of) your poster, you must select at least one tile. </p> "
    00130             " </qt>" );
    00131
    00132     QString whatsThisCutmarginPosterPage = i18n( " <qt> "
    00133                         " <b>Cut Margin selection</b> "
    00134             " <p>Slider and spinbox let you determine a <em>'cut margin'</em> which will be printed onto "
    00135             " each tile of your poster to help you cut the pieces as needed. </p>"
    00136             " <p><b>Notice</b>, how the little preview window above changes with your change of cut "
    00137             " margins. It indicates to you how much space the cut margins will take away from each tile. "
    00138             " <p><b>Be aware</b>, that your cut margins need to be equal to or greater than the margins your "
    00139             " printer uses. The printer's capabilities are described in the <em>'ImageableArea'</em> "
    00140             " keywords of its driver PPD file. </p> "
    00141             " </qt>" );
    00142
    00143     QString whatsThisTileOrderSelectionPosterPage = i18n( " <qt> "
    00144                         " <b>Order and number of tile pages to be printed</b> "
    00145             " <p>This field displays and sets the individual tiles to be printed, as well as the order "
    00146             " for their printout. </p> "
    00147             " You can file the field with 2 different methods: "
    00148             " <ul> "
    00149             " <li>Either use the interactive thumbnail preview above and '[SHIFT]-click' on the tiles. </li> "
    00150             " <li>Or edit this text field accordingly. </li> "
    00151             " </ul> "
    00152             " <p>When editing the field, you can use a '3-7' syntax instead of a '3,4,5,6,7' one. </p> "
    00153             " <p><b>Examples:</b></p> "
    00154             " <pre> "
    00155             "   \"2,3,7,9,3\" "
    00156             " <br> "
    00157             "   \"1-3,6,8-11\" "
    00158             " </qt>" );
    00159
    00160     setTitle( i18n( "Poster" ) );
    00161
    00162     m_postercheck = new QCheckBox( i18n( "&Print poster" ), this );
    00163           QWhatsThis::add(m_postercheck, whatsThisEnablePosterPage);
    00164     QWidget *dummy = new QWidget( this );
    00165     m_preview = new PosterPreview( dummy );
    00166           QWhatsThis::add(m_preview, whatsThisTileSelectionPosterPage);
    00167     m_postersize = new QComboBox( dummy );
    00168           QWhatsThis::add(m_postersize, whatsThisPostersizePosterPage);
    00169     m_printsize = new QComboBox( dummy );
    00170           QWhatsThis::add(m_printsize, whatsThisPrintsizePosterPage);
    00171     m_lockbtn = new KPushButton( dummy );
    00172           //QWhatsThis::add(m_lockbtn, whatsThis5_PosterPage);           //FIXME ASK_MICHAEL: which pushbutton would that be?
    00173     m_mediasize = new QLabel( dummy );
    00174           QWhatsThis::add(m_mediasize, whatsThisPrintsizePosterPage);
    00175     m_mediasize->setFrameStyle( QFrame::Panel|QFrame::Sunken );
    00176     QLabel *posterlab = new QLabel( i18n( "Poste&r size:" ), dummy );
    00177           QWhatsThis::add(posterlab, whatsThisPostersizePosterPage);
    00178     QLabel *medialab = new QLabel( i18n( "Media size:" ), dummy );
    00179           QWhatsThis::add(medialab, whatsThisPrintsizePosterPage);
    00180     QLabel *printlab = new QLabel( i18n( "Pri&nt size:" ), dummy );
    00181           QWhatsThis::add(printlab, whatsThisPrintsizePosterPage);
    00182     posterlab->setBuddy( m_postersize );
    00183     printlab->setBuddy( m_printsize );
    00184     m_cutmargin = new KIntNumInput( 5, dummy );
    00185           QWhatsThis::add(m_cutmargin, whatsThisCutmarginPosterPage);
    00186     // xgettext:no-c-format
    00187     m_cutmargin->setLabel( i18n( "C&ut margin (% of media):" ) );
    00188     m_cutmargin->setRange( 0, 100, 2, true );                     // step width was too big, changed from 10 to 2 (-kp-)
    00189     m_selection = new QLineEdit( dummy );
    00190           QWhatsThis::add(m_selection, whatsThisTileOrderSelectionPosterPage);
    00191     QLabel *selectionlab = new QLabel( i18n( "&Tile pages (to be printed):" ), dummy );
    00192           QWhatsThis::add(selectionlab, whatsThisTileOrderSelectionPosterPage);
    00193     selectionlab->setBuddy( m_selection );
    00194     m_lockbtn->setToggleButton( true );
    00195     m_lockbtn->setPixmap( SmallIcon( "encrypted" ) );
    00196     m_lockbtn->setOn( true );
    00197     m_lockbtn->setFixedSize( m_lockbtn->sizeHint() );
    00198     QToolTip::add( m_lockbtn, i18n( "Link/unlink poster and print size" ) );
    00199
    00200     for ( int i=0; i<KPrinter::NPageSize-1; i++ )
    00201     {
    00202         m_postersize->insertItem( page_sizes[ i ].text );
    00203         m_printsize->insertItem( page_sizes[ i ].text );
    00204     }
    00205     m_postersize->setCurrentItem( findIndex( KPrinter::A3 ) );
    00206     slotPosterSizeChanged( m_postersize->currentItem() );
    00207
    00208     connect( m_postercheck, SIGNAL( toggled( bool ) ), dummy, SLOT( setEnabled( bool ) ) );
    00209     dummy->setEnabled( false );
    00210     connect( m_postersize, SIGNAL( activated( int ) ), SLOT( slotPosterSizeChanged( int ) ) );
    00211     connect( m_cutmargin, SIGNAL( valueChanged( int ) ), SLOT( slotMarginChanged( int ) ) );
    00212     connect( m_lockbtn, SIGNAL( toggled( bool ) ), m_printsize, SLOT( setDisabled( bool ) ) );
    00213     m_printsize->setEnabled( false );
    00214     connect( m_lockbtn, SIGNAL( toggled( bool ) ), SLOT( slotLockToggled( bool ) ) );
    00215     connect( m_selection, SIGNAL( textChanged( const QString& ) ), m_preview, SLOT( setSelectedPages( const QString& ) ) );
    00216     connect( m_preview, SIGNAL( selectionChanged( const QString& ) ), m_selection, SLOT( setText( const QString& ) ) );
    00217
    00218     if ( KMFactory::self()->settings()->application != KPrinter::Dialog
    00219             && KMFactory::self()->settings()->application >= 0 )
    00220     {
    00221         m_printsize->hide();
    00222         m_lockbtn->hide();
    00223         printlab->hide();
    00224     }
    00225
    00226     QVBoxLayout *l0 = new QVBoxLayout( this, 0, 10 );
    00227     l0->addWidget( m_postercheck );
    00228     l0->addWidget( dummy, 1 );
    00229     QGridLayout *l1 = new QGridLayout( dummy, 8, 3, 0, 5 );
    00230     l1->addWidget( posterlab, 0, 0 );
    00231     l1->addWidget( m_postersize, 0, 1 );
    00232     l1->addWidget( printlab, 1, 0 );
    00233     l1->addWidget( m_printsize, 1, 1 );
    00234     l1->addWidget( medialab, 2, 0 );
    00235     l1->addWidget( m_mediasize, 2, 1 );
    00236     l1->addMultiCellWidget( m_preview, 4, 4, 0, 2 );
    00237     l1->addMultiCellWidget( m_cutmargin, 6, 6, 0, 2 );
    00238     l1->addMultiCellWidget( m_lockbtn, 0, 1, 2, 2 );
    00239     QHBoxLayout *l2 = new QHBoxLayout( 0, 0, 5 );
    00240     l1->addMultiCellLayout( l2, 7, 7, 0, 2 );
    00241     l2->addWidget( selectionlab );
    00242     l2->addWidget( m_selection );
    00243     l1->setColStretch( 1, 1 );
    00244     l1->setRowStretch( 4, 1 );
    00245     l1->addRowSpacing( 3, 10 );
    00246     l1->addRowSpacing( 5, 10 );
    00247 }
    00248
    00249 KPPosterPage::~KPPosterPage()
    00250 {
    00251 }
    00252
    00253 void KPPosterPage::setOptions( const QMap<QString,QString>& opts )
    00254 {
    00255     QString ps = opts[ "PageSize" ];
    00256     if ( ps.isEmpty() && !opts[ "kde-pagesize" ].isEmpty() )
    00257     {
    00258         ps = pageSizeToPageName( ( KPrinter::PageSize )opts[ "kde-pagesize" ].toInt() );
    00259         if ( ps.isEmpty() )
    00260             ps = opts[ "_kde-poster-media" ];
    00261     }
    00262     if ( ps.isEmpty() )
    00263         m_mediasize->setText( i18n( "Unknown" ) );
    00264     else
    00265         m_mediasize->setText( ps );
    00266     m_preview->setMediaSize( ps );
    00267
    00268     if ( opts[ "_kde-filters" ].find( "poster" ) != -1 )
    00269     {
    00270         m_postercheck->setChecked( true );
    00271         ps = opts[ "_kde-poster-size" ];
    00272         QString prtsize = opts[ "kde-printsize" ];
    00273         if ( !ps.isEmpty() )
    00274         {
    00275             m_postersize->setCurrentItem( findIndex( pageNameToPageSize( ps ) ) );
    00276             m_lockbtn->setOn( !prtsize.isEmpty() &&
    00277                     page_sizes[ m_postersize->currentItem() ].ID == prtsize.toInt() );
    00278             if ( !m_lockbtn->isOn() )
    00279                 m_printsize->setCurrentItem( findIndex( prtsize.toInt() ) );
    00280             slotPosterSizeChanged( m_postersize->currentItem() );
    00281         }
    00282         if ( !opts[ "_kde-poster-cut" ].isEmpty() )
    00283             m_cutmargin->setValue( opts[ "_kde-poster-cut" ].toInt() );
    00284         m_selection->setText( opts[ "_kde-poster-select" ] );
    00285     }
    00286     else
    00287         m_postercheck->setChecked( false );
    00288 }
    00289
    00290 void KPPosterPage::getOptions( QMap<QString,QString>& opts, bool )
    00291 {
    00292     QStringList o = QStringList::split( ",", opts[ "_kde-filters" ], false );
    00293     if ( !m_postercheck->isChecked() )
    00294     {
    00295         o.remove( "poster" );
    00296         opts[ "_kde-filters" ] = o.join( "," );
    00297         opts.remove( "_kde-poster-media" );
    00298         opts.remove( "_kde-poster-size" );
    00299         opts.remove( "_kde-poster-cut" );
    00300         opts.remove( "kde-printsize" );
    00301         opts.remove( "_kde-poster-select" );
    00302     }
    00303     else
    00304     {
    00305         if ( !o.contains( "poster" ) )
    00306             o.append( "poster" );
    00307         opts[ "_kde-filters" ] = o.join( "," );
    00308         opts[ "_kde-poster-media" ] = m_mediasize->text();
    00309         opts[ "_kde-poster-size" ] = pageSizeToPageName( ( KPrinter::PageSize )page_sizes[ m_postersize->currentItem() ].ID );
    00310         opts[ "kde-printsize" ] = QString::number( page_sizes[ m_printsize->currentItem() ].ID );
    00311         opts[ "_kde-poster-cut" ] = QString::number( m_cutmargin->value() );
    00312         opts[ "_kde-poster-select" ] = m_selection->text().stripWhiteSpace();
    00313     }
    00314 }
    00315
    00316 bool KPPosterPage::isValid()
    00317 {
    00318     return true;
    00319 }
    00320
    00321 void KPPosterPage::slotPosterSizeChanged( int value )
    00322 {
    00323     int ID = page_sizes[ m_postersize->currentItem() ].ID;
    00324     m_preview->setPosterSize( ID );
    00325     if ( m_lockbtn->isOn() )
    00326         m_printsize->setCurrentItem( value );
    00327 }
    00328
    00329 void KPPosterPage::slotMarginChanged( int value )
    00330 {
    00331     m_preview->setCutMargin( value );
    00332 }
    00333
    00334 void KPPosterPage::slotLockToggled( bool on )
    00335 {
    00336     m_lockbtn->setPixmap( SmallIcon( on ? "encrypted" : "decrypted" ) );
    00337     if ( on )
    00338         m_printsize->setCurrentItem( m_postersize->currentItem() );
    00339 }
    00340
    00341 #include "kpposterpage.moc"

This file is part of the documentation for kdeprint Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:31:04 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003