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

tdeprint

  • tdeprint
kpposterpage.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001-2002 Michael Goffioul <tdeprint@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 "kpposterpage.h"
21 #include "posterpreview.h"
22 #include "kprinter.h"
23 #include "kmfactory.h"
24 #include "util.h"
25 
26 #include <tqcheckbox.h>
27 #include <tqcombobox.h>
28 #include <tqlabel.h>
29 #include <tqlayout.h>
30 #include <tqtooltip.h>
31 #include <tqlineedit.h>
32 #include <tqwhatsthis.h>
33 #include <kpushbutton.h>
34 #include <tdelocale.h>
35 #include <knuminput.h>
36 #include <kiconloader.h>
37 
38 KPPosterPage::KPPosterPage( TQWidget *parent, const char *name )
39  : KPrintDialogPage( parent, name )
40 {
41  //WhatsThis strings.... (added by pfeifle@kde.org)
42  TQString whatsThis5_PosterPage = i18n( " <qt> "
43  " 5. "
44  " </qt>" );
45 
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 TDEPrint 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  " </qt>" );
61 
62  TQString whatsThisTileSelectionPosterPage = i18n( " <qt> "
63  " <b>Tile Selection widget</b> "
64  " <p>This GUI element is <em>not only for viewing</em> your selections: it also "
65  " lets you interactively select the tile(s) you want to print. "
66  " </p>"
67  " <p><b>Hints</b> "
68  " <ul> "
69  " <li>Click any tile to select it for printing.</li> "
70  " <li>To select multiple tiles to be printed "
71  " at once, <em>'shift-click'</em> on the tiles ('shift-click' means: hold down the "
72  " [SHIFT]-key on your keyboard and click with the mouse while [SHIFT]-key is held.) "
73  " <em>Be aware</em> that the order "
74  " of your clicking is also significant to the order of printing the different tiles. </li>"
75  " </ul> "
76  " <b>Note 1:</b> The order of your selection (and the order for printout of the tiles) "
77  " is indicated by the contents of the text field below, "
78  " labelled as <em>'Tile pages (to be printed):'</em><p>"
79  " <b>Note 2:</b> By default no tile is selected. Before you can print (a part "
80  " of) your poster, you must select at least one tile. </p> "
81  " </qt>" );
82 
83  TQString whatsThisPostersizePosterPage = i18n( " <qt> "
84  " <b>Poster Size</b> "
85  " <p>Select the poster size you want from the dropdown list. </p> "
86  " Available sizes are all standard paper sizes up to "
87  " 'A0'. [A0 is the same size as 16 sheets of A4, or '84cm x 118.2cm'.] </p> "
88  " <p><b>Notice</b>, how the little preview window below changes with your change of poster "
89  " size. It indicates to you how many tiles need to be printed to make the poster, "
90  " given the selected paper size.</p> "
91  " <p><b>Hint:</b> The little preview window below is not just a passive icon. You can click "
92  " on its individual tiles to select them for printing. To select multiple tiles to be printed "
93  " at once, you need to <em>'shift-click'</em> on the tiles ('shift-click' means: hold down the "
94  " [SHIFT]-key on your keyboard and click with the mouse while [SHIFT]-key is held.) The order "
95  " of your clicking is significant to the order of printing the different tiles. The order of "
96  " your selection (and for the printed tiles) is indicated by the contents of the text field "
97  " labelled as <em>'Tile pages (to be printed):'</em><p>"
98  " <b>Note:</b> By default no tile is selected. Before you can print (a part "
99  " of) your poster, you must select at least one tile. </p> "
100  " </qt>" );
101 
102  TQString whatsThisPrintsizePosterPage = i18n( " <qt> "
103  " <b>Paper Size</b> "
104  " <p>This field indicates the paper size the poster tiles will be printed on. "
105  " To select a different paper size for your poster tiles, go to the 'General' tab "
106  " of this dialog and select one from the dropdown list. </p> "
107  " Available sizes are most standard paper sizes supported by your printer. Your printer's "
108  " supported paper sizes are read from the printer driver info (as laid down in the <em>'PPD'</em>, "
109  " the printer description file). <em>Be aware that the 'Paper Size' selected may not be supported "
110  " by 'poster' (example: 'HalfLetter') while it may well be supported by your printer.</em> If "
111  " you hit that obstacle, simply use another, supported Paper Size, like 'A4' or 'Letter'. "
112  " <p><b>Notice</b>, how the little preview window below changes with your change of paper "
113  " size. It indicates how many tiles need to be printed to make up the poster, "
114  " given the selected paper and poster size.</p> "
115  " <p><b>Hint:</b> The little preview window below is not just a passive icon. You can click "
116  " on its individual tiles to select them for printing. To select multiple tiles to be printed "
117  " at once, you need to <em>'shift-click'</em> on the tiles ('shift-click' means: hold down the "
118  " [SHIFT]-key on your keyboard and click with the mouse while [SHIFT]-key is held.) The order "
119  " of your clicking is significant to the order of printing the different tiles. The order of "
120  " your selection (and for the printed tiles) is indicated by the contents of the text field "
121  " labelled as <em>'Tile pages (to be printed):'</em><p>"
122  " <b>Note:</b> By default no tile is selected. Before you can print (a part "
123  " of) your poster, you must select at least one tile. </p> "
124  " </qt>" );
125 
126  TQString whatsThisCutmarginPosterPage = i18n( " <qt> "
127  " <b>Cut Margin selection</b> "
128  " <p>Slider and spinbox let you determine a <em>'cut margin'</em> which will be printed onto "
129  " each tile of your poster to help you cut the pieces as needed. </p>"
130  " <p><b>Notice</b>, how the little preview window above changes with your change of cut "
131  " margins. It indicates to you how much space the cut margins will take away from each tile. "
132  " <p><b>Be aware</b>, that your cut margins need to be equal to or greater than the margins your "
133  " printer uses. The printer's capabilities are described in the <em>'ImageableArea'</em> "
134  " keywords of its driver PPD file. </p> "
135  " </qt>" );
136 
137  TQString whatsThisTileOrderSelectionPosterPage = i18n( " <qt> "
138  " <b>Order and number of tile pages to be printed</b> "
139  " <p>This field displays and sets the individual tiles to be printed, as well as the order "
140  " for their printout. </p> "
141  " You can file the field with 2 different methods: "
142  " <ul> "
143  " <li>Either use the interactive thumbnail preview above and '[SHIFT]-click' on the tiles. </li> "
144  " <li>Or edit this text field accordingly. </li> "
145  " </ul> "
146  " <p>When editing the field, you can use a '3-7' syntax instead of a '3,4,5,6,7' one. </p> "
147  " <p><b>Examples:</b></p> "
148  " <pre> "
149  " \"2,3,7,9,3\" "
150  " <br> "
151  " \"1-3,6,8-11\" "
152  " </qt>" );
153 
154  setTitle( i18n( "Poster" ) );
155 
156  m_postercheck = new TQCheckBox( i18n( "&Print poster" ), this );
157  TQWhatsThis::add(m_postercheck, whatsThisEnablePosterPage);
158  TQWidget *dummy = new TQWidget( this );
159  m_preview = new PosterPreview( dummy );
160  TQWhatsThis::add(m_preview, whatsThisTileSelectionPosterPage);
161  m_postersize = new TQComboBox( dummy );
162  TQWhatsThis::add(m_postersize, whatsThisPostersizePosterPage);
163  m_printsize = new TQComboBox( dummy );
164  TQWhatsThis::add(m_printsize, whatsThisPrintsizePosterPage);
165  m_lockbtn = new KPushButton( dummy );
166  //TQWhatsThis::add(m_lockbtn, whatsThis5_PosterPage); //FIXME ASK_MICHAEL: which pushbutton would that be?
167  m_mediasize = new TQLabel( dummy );
168  TQWhatsThis::add(m_mediasize, whatsThisPrintsizePosterPage);
169  m_mediasize->setFrameStyle( TQFrame::Panel|TQFrame::Sunken );
170  TQLabel *posterlab = new TQLabel( i18n( "Poste&r size:" ), dummy );
171  TQWhatsThis::add(posterlab, whatsThisPostersizePosterPage);
172  TQLabel *medialab = new TQLabel( i18n( "Media size:" ), dummy );
173  TQWhatsThis::add(medialab, whatsThisPrintsizePosterPage);
174  TQLabel *printlab = new TQLabel( i18n( "Pri&nt size:" ), dummy );
175  TQWhatsThis::add(printlab, whatsThisPrintsizePosterPage);
176  posterlab->setBuddy( m_postersize );
177  printlab->setBuddy( m_printsize );
178  m_cutmargin = new KIntNumInput( 5, dummy );
179  TQWhatsThis::add(m_cutmargin, whatsThisCutmarginPosterPage);
180  // xgettext:no-c-format
181  m_cutmargin->setLabel( i18n( "C&ut margin (% of media):" ) );
182  m_cutmargin->setRange( 0, 100, 2, true ); // step width was too big, changed from 10 to 2 (-kp-)
183  m_selection = new TQLineEdit( dummy );
184  TQWhatsThis::add(m_selection, whatsThisTileOrderSelectionPosterPage);
185  TQLabel *selectionlab = new TQLabel( i18n( "&Tile pages (to be printed):" ), dummy );
186  TQWhatsThis::add(selectionlab, whatsThisTileOrderSelectionPosterPage);
187  selectionlab->setBuddy( m_selection );
188  m_lockbtn->setToggleButton( true );
189  m_lockbtn->setPixmap( SmallIcon( "encrypted" ) );
190  m_lockbtn->setOn( true );
191  m_lockbtn->setFixedSize( m_lockbtn->sizeHint() );
192  TQToolTip::add( m_lockbtn, i18n( "Link/unlink poster and print size" ) );
193 
194  for ( int i=0; i<KPrinter::NPageSize-1; i++ )
195  {
196  m_postersize->insertItem( page_sizes[ i ].text );
197  m_printsize->insertItem( page_sizes[ i ].text );
198  }
199  m_postersize->setCurrentItem( findIndex( KPrinter::A3 ) );
200  slotPosterSizeChanged( m_postersize->currentItem() );
201 
202  connect( m_postercheck, TQ_SIGNAL( toggled( bool ) ), dummy, TQ_SLOT( setEnabled( bool ) ) );
203  dummy->setEnabled( false );
204  connect( m_postersize, TQ_SIGNAL( activated( int ) ), TQ_SLOT( slotPosterSizeChanged( int ) ) );
205  connect( m_cutmargin, TQ_SIGNAL( valueChanged( int ) ), TQ_SLOT( slotMarginChanged( int ) ) );
206  connect( m_lockbtn, TQ_SIGNAL( toggled( bool ) ), m_printsize, TQ_SLOT( setDisabled( bool ) ) );
207  m_printsize->setEnabled( false );
208  connect( m_lockbtn, TQ_SIGNAL( toggled( bool ) ), TQ_SLOT( slotLockToggled( bool ) ) );
209  connect( m_selection, TQ_SIGNAL( textChanged( const TQString& ) ), m_preview, TQ_SLOT( setSelectedPages( const TQString& ) ) );
210  connect( m_preview, TQ_SIGNAL( selectionChanged( const TQString& ) ), m_selection, TQ_SLOT( setText( const TQString& ) ) );
211 
212  if ( KMFactory::self()->settings()->application != KPrinter::Dialog
213  && KMFactory::self()->settings()->application >= 0 )
214  {
215  m_printsize->hide();
216  m_lockbtn->hide();
217  printlab->hide();
218  }
219 
220  TQVBoxLayout *l0 = new TQVBoxLayout( this, 0, 10 );
221  l0->addWidget( m_postercheck );
222  l0->addWidget( dummy, 1 );
223  TQGridLayout *l1 = new TQGridLayout( dummy, 8, 3, 0, 5 );
224  l1->addWidget( posterlab, 0, 0 );
225  l1->addWidget( m_postersize, 0, 1 );
226  l1->addWidget( printlab, 1, 0 );
227  l1->addWidget( m_printsize, 1, 1 );
228  l1->addWidget( medialab, 2, 0 );
229  l1->addWidget( m_mediasize, 2, 1 );
230  l1->addMultiCellWidget( m_preview, 4, 4, 0, 2 );
231  l1->addMultiCellWidget( m_cutmargin, 6, 6, 0, 2 );
232  l1->addMultiCellWidget( m_lockbtn, 0, 1, 2, 2 );
233  TQHBoxLayout *l2 = new TQHBoxLayout( 0, 0, 5 );
234  l1->addMultiCellLayout( l2, 7, 7, 0, 2 );
235  l2->addWidget( selectionlab );
236  l2->addWidget( m_selection );
237  l1->setColStretch( 1, 1 );
238  l1->setRowStretch( 4, 1 );
239  l1->addRowSpacing( 3, 10 );
240  l1->addRowSpacing( 5, 10 );
241 }
242 
243 KPPosterPage::~KPPosterPage()
244 {
245 }
246 
247 void KPPosterPage::setOptions( const TQMap<TQString,TQString>& opts )
248 {
249  TQString ps = opts[ "PageSize" ];
250  if ( ps.isEmpty() && !opts[ "kde-pagesize" ].isEmpty() )
251  {
252  ps = pageSizeToPageName( ( KPrinter::PageSize )opts[ "kde-pagesize" ].toInt() );
253  if ( ps.isEmpty() )
254  ps = opts[ "_kde-poster-media" ];
255  }
256  if ( ps.isEmpty() )
257  m_mediasize->setText( i18n( "Unknown" ) );
258  else
259  m_mediasize->setText( ps );
260  m_preview->setMediaSize( ps );
261 
262  if ( opts[ "_kde-filters" ].find( "poster" ) != -1 )
263  {
264  m_postercheck->setChecked( true );
265  ps = opts[ "_kde-poster-size" ];
266  TQString prtsize = opts[ "kde-printsize" ];
267  if ( !ps.isEmpty() )
268  {
269  m_postersize->setCurrentItem( findIndex( pageNameToPageSize( ps ) ) );
270  m_lockbtn->setOn( !prtsize.isEmpty() &&
271  page_sizes[ m_postersize->currentItem() ].ID == prtsize.toInt() );
272  if ( !m_lockbtn->isOn() )
273  m_printsize->setCurrentItem( findIndex( prtsize.toInt() ) );
274  slotPosterSizeChanged( m_postersize->currentItem() );
275  }
276  if ( !opts[ "_kde-poster-cut" ].isEmpty() )
277  m_cutmargin->setValue( opts[ "_kde-poster-cut" ].toInt() );
278  m_selection->setText( opts[ "_kde-poster-select" ] );
279  }
280  else
281  m_postercheck->setChecked( false );
282 }
283 
284 void KPPosterPage::getOptions( TQMap<TQString,TQString>& opts, bool )
285 {
286  TQStringList o = TQStringList::split( ",", opts[ "_kde-filters" ], false );
287  if ( !m_postercheck->isChecked() )
288  {
289  o.remove( "poster" );
290  opts[ "_kde-filters" ] = o.join( "," );
291  opts.remove( "_kde-poster-media" );
292  opts.remove( "_kde-poster-size" );
293  opts.remove( "_kde-poster-cut" );
294  opts.remove( "kde-printsize" );
295  opts.remove( "_kde-poster-select" );
296  }
297  else
298  {
299  if ( !o.contains( "poster" ) )
300  o.append( "poster" );
301  opts[ "_kde-filters" ] = o.join( "," );
302  opts[ "_kde-poster-media" ] = m_mediasize->text();
303  opts[ "_kde-poster-size" ] = pageSizeToPageName( ( KPrinter::PageSize )page_sizes[ m_postersize->currentItem() ].ID );
304  opts[ "kde-printsize" ] = TQString::number( page_sizes[ m_printsize->currentItem() ].ID );
305  opts[ "_kde-poster-cut" ] = TQString::number( m_cutmargin->value() );
306  opts[ "_kde-poster-select" ] = m_selection->text().stripWhiteSpace();
307  }
308 }
309 
310 bool KPPosterPage::isValid()
311 {
312  return true;
313 }
314 
315 void KPPosterPage::slotPosterSizeChanged( int value )
316 {
317  int ID = page_sizes[ m_postersize->currentItem() ].ID;
318  m_preview->setPosterSize( ID );
319  if ( m_lockbtn->isOn() )
320  m_printsize->setCurrentItem( value );
321 }
322 
323 void KPPosterPage::slotMarginChanged( int value )
324 {
325  m_preview->setCutMargin( value );
326 }
327 
328 void KPPosterPage::slotLockToggled( bool on )
329 {
330  m_lockbtn->setPixmap( SmallIcon( on ? "encrypted" : "decrypted" ) );
331  if ( on )
332  m_printsize->setCurrentItem( m_postersize->currentItem() );
333 }
334 
335 #include "kpposterpage.moc"
KPrintDialogPage
This class is intended to be used as base class for customized print dialog page.
Definition: kprintdialogpage.h:91
KPrintDialogPage::isValid
virtual bool isValid(TQString &msg)
Returns true if options selected in the page are valid (no conflict), false otherwise.
Definition: kprintdialogpage.cpp:45
KPrinter::PageSize
PageSize
Defines the paper size to use.
Definition: kprinter.h:168

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