20 #include "kpposterpage.h" 21 #include "posterpreview.h" 23 #include "kmfactory.h" 26 #include <tqcheckbox.h> 27 #include <tqcombobox.h> 30 #include <tqtooltip.h> 31 #include <tqlineedit.h> 32 #include <tqwhatsthis.h> 33 #include <kpushbutton.h> 35 #include <knuminput.h> 36 #include <kiconloader.h> 38 KPPosterPage::KPPosterPage( TQWidget *parent,
const char *name )
42 TQString whatsThis5_PosterPage = i18n(
" <qt> " 46 TQString whatsThisEnablePosterPage = i18n(
" <qt> " 47 " <b>Print Poster</b> (enabled or disabled). " 48 " <p>If you enable this option, you can print posters of different sizes " 49 " The printout will happen in the form <em>'tiles'</em> printed on smaller " 50 " paper sizes, which you can stitch together later. <em>If you enable this " 51 " option here, the <em>'Poster Printing' filter</em> will be auto-loaded in " 52 " the 'Filters' tab of this dialog. </p>" 53 " <p>This tab is only visible if the external <em>'poster'</em> utility is " 54 " discovered by KDEPrint on your system. [<em>'poster'</em> is a commandline " 55 " utility that enables you to convert PostScript files into tiled printouts " 56 " which allow for oversized appearance of the stitched-together tiles.] </p>" 57 " <p><b>Note:</b> The standard version of 'poster' will not work. Your system " 58 " must use a patched version of 'poster'. Ask your operating system vendor to " 59 " provide a patched version of 'poster' if he does not already. </p>" 60 " <p><b>Additional hint for power users:</b> A patched version of 'poster' is " 61 " available from the <a href=\"http://printing.kde.org/\">KDEPrint Website</a> " 62 " at <a href=\"http://printing.kde.org/downloads/\">http://printing.kde.org/downloads/</a>. " 63 " The direct link to the patched source tarball is " 64 " <a href=\"ftp://ftp.kde.org/pub/kde/printing/poster.tar.bz2\">ftp://ftp.kde.org/pub/kde/printing/poster.tar.bz2</a> " 68 TQString whatsThisTileSelectionPosterPage = i18n(
" <qt> " 69 " <b>Tile Selection widget</b> " 70 " <p>This GUI element is <em>not only for viewing</em> your selections: it also " 71 " lets you interactively select the tile(s) you want to print. " 75 " <li>Click any tile to select it for printing.</li> " 76 " <li>To select multiple tiles to be printed " 77 " at once, <em>'shift-click'</em> on the tiles ('shift-click' means: hold down the " 78 " [SHIFT]-key on your keyboard and click with the mouse while [SHIFT]-key is held.) " 79 " <em>Be aware</em> that the order " 80 " of your clicking is also significant to the order of printing the different tiles. </li>" 82 " <b>Note 1:</b> The order of your selection (and the order for printout of the tiles) " 83 " is indicated by the contents of the text field below, " 84 " labelled as <em>'Tile pages (to be printed):'</em><p>" 85 " <b>Note 2:</b> By default no tile is selected. Before you can print (a part " 86 " of) your poster, you must select at least one tile. </p> " 89 TQString whatsThisPostersizePosterPage = i18n(
" <qt> " 90 " <b>Poster Size</b> " 91 " <p>Select the poster size you want from the dropdown list. </p> " 92 " Available sizes are all standard paper sizes up to " 93 " 'A0'. [A0 is the same size as 16 sheets of A4, or '84cm x 118.2cm'.] </p> " 94 " <p><b>Notice</b>, how the little preview window below changes with your change of poster " 95 " size. It indicates to you how many tiles need to be printed to make the poster, " 96 " given the selected paper size.</p> " 97 " <p><b>Hint:</b> The little preview window below is not just a passive icon. You can click " 98 " on its individual tiles to select them for printing. To select multiple tiles to be printed " 99 " at once, you need to <em>'shift-click'</em> on the tiles ('shift-click' means: hold down the " 100 " [SHIFT]-key on your keyboard and click with the mouse while [SHIFT]-key is held.) The order " 101 " of your clicking is significant to the order of printing the different tiles. The order of " 102 " your selection (and for the printed tiles) is indicated by the contents of the text field " 103 " labelled as <em>'Tile pages (to be printed):'</em><p>" 104 " <b>Note:</b> By default no tile is selected. Before you can print (a part " 105 " of) your poster, you must select at least one tile. </p> " 108 TQString whatsThisPrintsizePosterPage = i18n(
" <qt> " 109 " <b>Paper Size</b> " 110 " <p>This field indicates the paper size the poster tiles will be printed on. " 111 " To select a different paper size for your poster tiles, go to the 'General' tab " 112 " of this dialog and select one from the dropdown list. </p> " 113 " Available sizes are most standard paper sizes supported by your printer. Your printer's " 114 " supported paper sizes are read from the printer driver info (as laid down in the <em>'PPD'</em>, " 115 " the printer description file). <em>Be aware that the 'Paper Size' selected may not be supported " 116 " by 'poster' (example: 'HalfLetter') while it may well be supported by your printer.</em> If " 117 " you hit that obstacle, simply use another, supported Paper Size, like 'A4' or 'Letter'. " 118 " <p><b>Notice</b>, how the little preview window below changes with your change of paper " 119 " size. It indicates how many tiles need to be printed to make up the poster, " 120 " given the selected paper and poster size.</p> " 121 " <p><b>Hint:</b> The little preview window below is not just a passive icon. You can click " 122 " on its individual tiles to select them for printing. To select multiple tiles to be printed " 123 " at once, you need to <em>'shift-click'</em> on the tiles ('shift-click' means: hold down the " 124 " [SHIFT]-key on your keyboard and click with the mouse while [SHIFT]-key is held.) The order " 125 " of your clicking is significant to the order of printing the different tiles. The order of " 126 " your selection (and for the printed tiles) is indicated by the contents of the text field " 127 " labelled as <em>'Tile pages (to be printed):'</em><p>" 128 " <b>Note:</b> By default no tile is selected. Before you can print (a part " 129 " of) your poster, you must select at least one tile. </p> " 132 TQString whatsThisCutmarginPosterPage = i18n(
" <qt> " 133 " <b>Cut Margin selection</b> " 134 " <p>Slider and spinbox let you determine a <em>'cut margin'</em> which will be printed onto " 135 " each tile of your poster to help you cut the pieces as needed. </p>" 136 " <p><b>Notice</b>, how the little preview window above changes with your change of cut " 137 " margins. It indicates to you how much space the cut margins will take away from each tile. " 138 " <p><b>Be aware</b>, that your cut margins need to be equal to or greater than the margins your " 139 " printer uses. The printer's capabilities are described in the <em>'ImageableArea'</em> " 140 " keywords of its driver PPD file. </p> " 143 TQString whatsThisTileOrderSelectionPosterPage = i18n(
" <qt> " 144 " <b>Order and number of tile pages to be printed</b> " 145 " <p>This field displays and sets the individual tiles to be printed, as well as the order " 146 " for their printout. </p> " 147 " You can file the field with 2 different methods: " 149 " <li>Either use the interactive thumbnail preview above and '[SHIFT]-click' on the tiles. </li> " 150 " <li>Or edit this text field accordingly. </li> " 152 " <p>When editing the field, you can use a '3-7' syntax instead of a '3,4,5,6,7' one. </p> " 153 " <p><b>Examples:</b></p> " 160 setTitle( i18n(
"Poster" ) );
162 m_postercheck =
new TQCheckBox( i18n(
"&Print poster" ),
this );
163 TQWhatsThis::add(m_postercheck, whatsThisEnablePosterPage);
164 TQWidget *dummy =
new TQWidget(
this );
165 m_preview =
new PosterPreview( dummy );
166 TQWhatsThis::add(m_preview, whatsThisTileSelectionPosterPage);
167 m_postersize =
new TQComboBox( dummy );
168 TQWhatsThis::add(m_postersize, whatsThisPostersizePosterPage);
169 m_printsize =
new TQComboBox( dummy );
170 TQWhatsThis::add(m_printsize, whatsThisPrintsizePosterPage);
171 m_lockbtn =
new KPushButton( dummy );
173 m_mediasize =
new TQLabel( dummy );
174 TQWhatsThis::add(m_mediasize, whatsThisPrintsizePosterPage);
175 m_mediasize->setFrameStyle( TQFrame::Panel|TQFrame::Sunken );
176 TQLabel *posterlab =
new TQLabel( i18n(
"Poste&r size:" ), dummy );
177 TQWhatsThis::add(posterlab, whatsThisPostersizePosterPage);
178 TQLabel *medialab =
new TQLabel( i18n(
"Media size:" ), dummy );
179 TQWhatsThis::add(medialab, whatsThisPrintsizePosterPage);
180 TQLabel *printlab =
new TQLabel( i18n(
"Pri&nt size:" ), dummy );
181 TQWhatsThis::add(printlab, whatsThisPrintsizePosterPage);
182 posterlab->setBuddy( m_postersize );
183 printlab->setBuddy( m_printsize );
184 m_cutmargin =
new KIntNumInput( 5, dummy );
185 TQWhatsThis::add(m_cutmargin, whatsThisCutmarginPosterPage);
187 m_cutmargin->setLabel( i18n(
"C&ut margin (% of media):" ) );
188 m_cutmargin->setRange( 0, 100, 2,
true );
189 m_selection =
new TQLineEdit( dummy );
190 TQWhatsThis::add(m_selection, whatsThisTileOrderSelectionPosterPage);
191 TQLabel *selectionlab =
new TQLabel( i18n(
"&Tile pages (to be printed):" ), dummy );
192 TQWhatsThis::add(selectionlab, whatsThisTileOrderSelectionPosterPage);
193 selectionlab->setBuddy( m_selection );
194 m_lockbtn->setToggleButton(
true );
195 m_lockbtn->setPixmap( SmallIcon(
"encrypted" ) );
196 m_lockbtn->setOn(
true );
197 m_lockbtn->setFixedSize( m_lockbtn->sizeHint() );
198 TQToolTip::add( m_lockbtn, i18n(
"Link/unlink poster and print size" ) );
200 for (
int i=0; i<KPrinter::NPageSize-1; i++ )
202 m_postersize->insertItem( page_sizes[ i ].text );
203 m_printsize->insertItem( page_sizes[ i ].text );
205 m_postersize->setCurrentItem( findIndex( KPrinter::A3 ) );
206 slotPosterSizeChanged( m_postersize->currentItem() );
208 connect( m_postercheck, TQT_SIGNAL( toggled(
bool ) ), dummy, TQT_SLOT( setEnabled(
bool ) ) );
209 dummy->setEnabled(
false );
210 connect( m_postersize, TQT_SIGNAL( activated(
int ) ), TQT_SLOT( slotPosterSizeChanged(
int ) ) );
211 connect( m_cutmargin, TQT_SIGNAL( valueChanged(
int ) ), TQT_SLOT( slotMarginChanged(
int ) ) );
212 connect( m_lockbtn, TQT_SIGNAL( toggled(
bool ) ), m_printsize, TQT_SLOT( setDisabled(
bool ) ) );
213 m_printsize->setEnabled(
false );
214 connect( m_lockbtn, TQT_SIGNAL( toggled(
bool ) ), TQT_SLOT( slotLockToggled(
bool ) ) );
215 connect( m_selection, TQT_SIGNAL( textChanged(
const TQString& ) ), m_preview, TQT_SLOT( setSelectedPages(
const TQString& ) ) );
216 connect( m_preview, TQT_SIGNAL( selectionChanged(
const TQString& ) ), m_selection, TQT_SLOT( setText(
const TQString& ) ) );
218 if ( KMFactory::self()->settings()->application != KPrinter::Dialog
219 && KMFactory::self()->settings()->application >= 0 )
226 TQVBoxLayout *l0 =
new TQVBoxLayout(
this, 0, 10 );
227 l0->addWidget( m_postercheck );
228 l0->addWidget( dummy, 1 );
229 TQGridLayout *l1 =
new TQGridLayout( dummy, 8, 3, 0, 5 );
230 l1->addWidget( posterlab, 0, 0 );
231 l1->addWidget( m_postersize, 0, 1 );
232 l1->addWidget( printlab, 1, 0 );
233 l1->addWidget( m_printsize, 1, 1 );
234 l1->addWidget( medialab, 2, 0 );
235 l1->addWidget( m_mediasize, 2, 1 );
236 l1->addMultiCellWidget( m_preview, 4, 4, 0, 2 );
237 l1->addMultiCellWidget( m_cutmargin, 6, 6, 0, 2 );
238 l1->addMultiCellWidget( m_lockbtn, 0, 1, 2, 2 );
239 TQHBoxLayout *l2 =
new TQHBoxLayout( 0, 0, 5 );
240 l1->addMultiCellLayout( l2, 7, 7, 0, 2 );
241 l2->addWidget( selectionlab );
242 l2->addWidget( m_selection );
243 l1->setColStretch( 1, 1 );
244 l1->setRowStretch( 4, 1 );
245 l1->addRowSpacing( 3, 10 );
246 l1->addRowSpacing( 5, 10 );
249 KPPosterPage::~KPPosterPage()
253 void KPPosterPage::setOptions(
const TQMap<TQString,TQString>& opts )
255 TQString ps = opts[
"PageSize" ];
256 if ( ps.isEmpty() && !opts[
"kde-pagesize" ].isEmpty() )
260 ps = opts[
"_kde-poster-media" ];
263 m_mediasize->setText( i18n(
"Unknown" ) );
265 m_mediasize->setText( ps );
266 m_preview->setMediaSize( ps );
268 if ( opts[
"_kde-filters" ].find(
"poster" ) != -1 )
270 m_postercheck->setChecked(
true );
271 ps = opts[
"_kde-poster-size" ];
272 TQString prtsize = opts[
"kde-printsize" ];
275 m_postersize->setCurrentItem( findIndex( pageNameToPageSize( ps ) ) );
276 m_lockbtn->setOn( !prtsize.isEmpty() &&
277 page_sizes[ m_postersize->currentItem() ].ID == prtsize.toInt() );
278 if ( !m_lockbtn->isOn() )
279 m_printsize->setCurrentItem( findIndex( prtsize.toInt() ) );
280 slotPosterSizeChanged( m_postersize->currentItem() );
282 if ( !opts[
"_kde-poster-cut" ].isEmpty() )
283 m_cutmargin->setValue( opts[
"_kde-poster-cut" ].toInt() );
284 m_selection->setText( opts[
"_kde-poster-select" ] );
287 m_postercheck->setChecked(
false );
290 void KPPosterPage::getOptions( TQMap<TQString,TQString>& opts,
bool )
292 TQStringList o = TQStringList::split(
",", opts[
"_kde-filters" ],
false );
293 if ( !m_postercheck->isChecked() )
295 o.remove(
"poster" );
296 opts[
"_kde-filters" ] = o.join(
"," );
297 opts.remove(
"_kde-poster-media" );
298 opts.remove(
"_kde-poster-size" );
299 opts.remove(
"_kde-poster-cut" );
300 opts.remove(
"kde-printsize" );
301 opts.remove(
"_kde-poster-select" );
305 if ( !o.contains(
"poster" ) )
306 o.append(
"poster" );
307 opts[
"_kde-filters" ] = o.join(
"," );
308 opts[
"_kde-poster-media" ] = m_mediasize->text();
309 opts[
"_kde-poster-size" ] = pageSizeToPageName( (
KPrinter::PageSize )page_sizes[ m_postersize->currentItem() ].ID );
310 opts[
"kde-printsize" ] = TQString::number( page_sizes[ m_printsize->currentItem() ].ID );
311 opts[
"_kde-poster-cut" ] = TQString::number( m_cutmargin->value() );
312 opts[
"_kde-poster-select" ] = m_selection->text().stripWhiteSpace();
321 void KPPosterPage::slotPosterSizeChanged(
int value )
323 int ID = page_sizes[ m_postersize->currentItem() ].ID;
324 m_preview->setPosterSize( ID );
325 if ( m_lockbtn->isOn() )
326 m_printsize->setCurrentItem( value );
329 void KPPosterPage::slotMarginChanged(
int value )
331 m_preview->setCutMargin( value );
334 void KPPosterPage::slotLockToggled(
bool on )
336 m_lockbtn->setPixmap( SmallIcon( on ?
"encrypted" :
"decrypted" ) );
338 m_printsize->setCurrentItem( m_postersize->currentItem() );
341 #include "kpposterpage.moc" This class is intended to be used as base class for customized print dialog page. ...
virtual bool isValid(TQString &msg)
Returns true if options selected in the page are valid (no conflict), false otherwise.
PageSize
Defines the paper size to use.