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>
34 #include <tdelocale.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 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>"
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. "
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>"
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> "
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> "
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> "
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> "
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: "
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> "
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> "
154 setTitle( i18n(
"Poster" ) );
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 );
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);
181 m_cutmargin->setLabel( i18n(
"C&ut margin (% of media):" ) );
182 m_cutmargin->setRange( 0, 100, 2,
true );
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" ) );
194 for (
int i=0; i<KPrinter::NPageSize-1; i++ )
196 m_postersize->insertItem( page_sizes[ i ].text );
197 m_printsize->insertItem( page_sizes[ i ].text );
199 m_postersize->setCurrentItem( findIndex( KPrinter::A3 ) );
200 slotPosterSizeChanged( m_postersize->currentItem() );
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& ) ) );
212 if ( KMFactory::self()->settings()->application != KPrinter::Dialog
213 && KMFactory::self()->settings()->application >= 0 )
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 );
243 KPPosterPage::~KPPosterPage()
247 void KPPosterPage::setOptions(
const TQMap<TQString,TQString>& opts )
249 TQString ps = opts[
"PageSize" ];
250 if ( ps.isEmpty() && !opts[
"kde-pagesize" ].isEmpty() )
254 ps = opts[
"_kde-poster-media" ];
257 m_mediasize->setText( i18n(
"Unknown" ) );
259 m_mediasize->setText( ps );
260 m_preview->setMediaSize( ps );
262 if ( opts[
"_kde-filters" ].find(
"poster" ) != -1 )
264 m_postercheck->setChecked(
true );
265 ps = opts[
"_kde-poster-size" ];
266 TQString prtsize = opts[
"kde-printsize" ];
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() );
276 if ( !opts[
"_kde-poster-cut" ].isEmpty() )
277 m_cutmargin->setValue( opts[
"_kde-poster-cut" ].toInt() );
278 m_selection->setText( opts[
"_kde-poster-select" ] );
281 m_postercheck->setChecked(
false );
284 void KPPosterPage::getOptions( TQMap<TQString,TQString>& opts,
bool )
286 TQStringList o = TQStringList::split(
",", opts[
"_kde-filters" ],
false );
287 if ( !m_postercheck->isChecked() )
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" );
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();
315 void KPPosterPage::slotPosterSizeChanged(
int value )
317 int ID = page_sizes[ m_postersize->currentItem() ].ID;
318 m_preview->setPosterSize( ID );
319 if ( m_lockbtn->isOn() )
320 m_printsize->setCurrentItem( value );
323 void KPPosterPage::slotMarginChanged(
int value )
325 m_preview->setCutMargin( value );
328 void KPPosterPage::slotLockToggled(
bool on )
330 m_lockbtn->setPixmap( SmallIcon( on ?
"encrypted" :
"decrypted" ) );
332 m_printsize->setCurrentItem( m_postersize->currentItem() );
335 #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.