kpresenter

KPrPgConfDia.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2002, 2003 Ariya Hidayat <ariya@kde.org>
4 Copyright (C) 2004, 2005 Laurent Montel <montel@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20*/
21
22#include "KPrPgConfDia.h"
23#include "KPrDocument.h"
24#include "KPrPage.h"
25
26#include <tqbuttongroup.h>
27#include <tqhbuttongroup.h>
28#include <tqcheckbox.h>
29#include <tqcombobox.h>
30#include <tqhbox.h>
31#include <tqvbox.h>
32#include <tqvgroupbox.h>
33#include <tqheader.h>
34#include <tqlabel.h>
35#include <tqlayout.h>
36#include <tqlistview.h>
37#include <tqpen.h>
38#include <tqpushbutton.h>
39#include <tqradiobutton.h>
40#include <tqvaluelist.h>
41#include <tqvbuttongroup.h>
42#include <tqwhatsthis.h>
43
44#include <kcolorbutton.h>
45#include <tdeglobal.h>
46#include <tdelocale.h>
47#include <knuminput.h>
48#include <tqslider.h>
49
50KPrPgConfDia::KPrPgConfDia( TQWidget* parent, KPrDocument* doc )
51 : KDialogBase( KDialogBase::Tabbed, i18n("Configure Slide Show"),
52 Ok|Cancel, Ok, parent, "pgConfDia", true ),
53 m_doc( doc )
54{
55 setupPageGeneral();
56 setupPageSlides();
57
58 connect( this, TQ_SIGNAL( okClicked() ), this, TQ_SLOT( confDiaOk() ) );
59 connect( this, TQ_SIGNAL( okClicked() ), this, TQ_SLOT( accept() ) );
60}
61
62void KPrPgConfDia::setupPageGeneral()
63{
64 TQFrame* generalPage = addPage( i18n("&General") );
65 TQWhatsThis::add( generalPage, i18n("<p>This dialog allows you to configure how the slideshow "
66 "will be displayed, including whether the slides are "
67 "automatically sequenced or manually controlled, and also "
68 "allows you to configure a <em>drawing pen</em> that can "
69 "be used during the display of the presentation to add "
70 "additional information or to emphasise particular points.</p>") );
71 TQVBoxLayout *generalLayout = new TQVBoxLayout( generalPage, 0, KDialog::spacingHint() );
72
73 TQVButtonGroup *switchGroup = new TQVButtonGroup( i18n("&Transition Type"), generalPage );
74 generalLayout->addWidget( switchGroup );
75 TQWhatsThis::add( switchGroup, i18n("<li><p>If you select <b>Manual transition to next step or slide</b> "
76 "then each transition and effect on a slide, or transition from "
77 "one slide to the next, will require an action. Typically this "
78 "action will be a mouse click, or the space bar.</p></li>"
79 "<li><p>If you select <b>Automatic transition to next step or slide</b> "
80 "then the presentation will automatically sequence each transition "
81 "and effect on a slide, and will automatically transition to the "
82 "next slide when the current slide is fully displayed. The speed "
83 "of sequencing is controlled using the slider below. This also "
84 "enables the option to automatically loop back to the first "
85 "slide after the last slide has been shown.</p></li>") );
86 m_manualButton = new TQRadioButton( i18n("&Manual transition to next step or slide"), switchGroup );
87 m_manualButton->setChecked( m_doc->spManualSwitch() );
88 m_autoButton = new TQRadioButton( i18n("&Automatic transition to next step or slide"), switchGroup );
89 m_autoButton->setChecked( !m_doc->spManualSwitch() );
90
91 infiniteLoop = new TQCheckBox( i18n( "&Infinite loop" ), generalPage );
92 generalLayout->addWidget( infiniteLoop );
93 TQWhatsThis::add( infiniteLoop, i18n("<p>If this checkbox is selected, then the slideshow "
94 "will restart at the first slide after the last slide "
95 "has been displayed. It is only available if the "
96 "<b>Automatic transition to next step or slide</b> "
97 "button is selected above.</p> <p>This option may be "
98 "useful if you are running a promotional display.</p>") );
99
100 infiniteLoop->setEnabled( !m_doc->spManualSwitch() );
101 connect( m_autoButton, TQ_SIGNAL( toggled(bool) ), infiniteLoop, TQ_SLOT( setEnabled(bool) ) );
102 connect( m_autoButton, TQ_SIGNAL( toggled(bool) ), infiniteLoop, TQ_SLOT( setChecked(bool) ) );
103
104 endOfPresentationSlide = new TQCheckBox( i18n( "&Show 'End of presentation' slide" ), generalPage );
105 generalLayout->addWidget( endOfPresentationSlide );
106 TQWhatsThis::add( endOfPresentationSlide, i18n("<p>If this checkbox is selected, when the slideshow "
107 "has finished a black slideshow containing the "
108 "message 'End of presentation. Click to exit' will "
109 "be shown.") );
110 endOfPresentationSlide->setChecked( m_doc->spShowEndOfPresentationSlide() );
111 endOfPresentationSlide->setDisabled( infiniteLoop->isEnabled() && getInfiniteLoop() );
112 connect( infiniteLoop, TQ_SIGNAL( toggled(bool) ), endOfPresentationSlide, TQ_SLOT( setDisabled(bool) ) );
113
114 presentationDuration = new TQCheckBox( i18n( "Measure presentation &duration" ), generalPage );
115 generalLayout->addWidget( presentationDuration );
116 TQWhatsThis::add( presentationDuration, i18n("<p>If this checkbox is selected, the time that "
117 "each slide was displayed for, and the total time "
118 "for the presentation will be measured.</p> "
119 "<p>The times will be displayed at the end of the "
120 "presentation.</p> "
121 "<p>This can be used during rehearsal to check "
122 "coverage for each issue in the presentation, "
123 "and to verify that the presentation duration "
124 "is correct.</p>" ) );
125 presentationDuration->setChecked( m_doc->presentationDuration() );
126
127 // presentation pen (color and width)
128
129 TQGroupBox* penGroup = new TQGroupBox( 2, TQt::Horizontal, i18n("Presentation Pen") , generalPage );
130 generalLayout->addWidget( penGroup );
131 TQWhatsThis::add( penGroup, i18n("<p>This part of the dialog allows you to configure the "
132 "<em>drawing mode</em>, which allows you to add additional "
133 "information, emphasise particular content, or to correct "
134 "errors during the presentation by drawing on the slides "
135 "using the mouse.</p>"
136 "<p>You can configure the color of the drawing pen and the "
137 "width of the pen.</p>" ) );
138 penGroup->layout()->setSpacing(KDialog::marginHint());
139 penGroup->layout()->setMargin(KDialog::spacingHint());
140 //TQGridLayout *grid = new TQGridLayout(penGroup->layout(), 3, 2 );
141
142 TQLabel* label = new TQLabel( i18n( "Color:" ), penGroup );
143 //grid->addWidget( label, 0, 0 );
144 penColor = new KColorButton( m_doc->presPen().color(), m_doc->presPen().color(), penGroup );
145 //grid->addWidget( penColor, 0, 1 );
146
147 label = new TQLabel( i18n( "Width:" ), penGroup );
148 // grid->addWidget( label, 1, 0 );
149 penWidth = new TQSpinBox( 1, 10, 1, penGroup );
150 penWidth->setSuffix( i18n(" pt") );
151 penWidth->setValue( m_doc->presPen().width() );
152 //grid->addWidget( penWidth, 1, 1 );
153
154 generalLayout->addStretch();
155}
156
157void KPrPgConfDia::setupPageSlides()
158{
159 TQFrame* slidesPage = addPage( i18n("&Slides") );
160 TQWhatsThis::add( slidesPage, i18n("<p>This dialog allows you to configure which slides "
161 "are used in the presentation. Slides that are not "
162 "selected will not be displayed during the slide "
163 "show.</p>") );
164 TQGridLayout *slidesLayout = new TQGridLayout( slidesPage,7 , 2, 0, KDialog::spacingHint());
165
166
167 TQButtonGroup *group=new TQVButtonGroup( slidesPage );
168 group->setRadioButtonExclusive( true );
169
170 m_customSlide = new TQRadioButton( i18n( "Custom slide show" ), group, "customslide" );
171
172 connect( m_customSlide, TQ_SIGNAL( clicked () ), this, TQ_SLOT( radioButtonClicked() ) );
173
174 TQHBox *box = new TQHBox( group );
175
176 m_labelCustomSlide = new TQLabel( i18n( "Custom slide:" ),box );
177
178 m_customSlideCombobox = new TQComboBox( box );
179 m_customSlideCombobox->insertStringList( m_doc->presentationList() );
180
181 m_selectedSlide = new TQRadioButton( i18n( "Selected pages:" ), group, "selectedslide" );
182 slidesLayout->addMultiCellWidget( group, 0,2,0,1 );
183 connect( m_selectedSlide, TQ_SIGNAL( clicked () ), this, TQ_SLOT( radioButtonClicked() ) );
184
185 slides = new TQListView( slidesPage );
186 slidesLayout->addMultiCellWidget( slides, 3, 3, 0, 1 );
187 slidesLayout->setRowStretch( 3, 10 );
188 slides->addColumn( i18n("Slide") );
189 slides->setSorting( -1 );
190 slides->header()->hide();
191
192 for ( int i = m_doc->getPageNums() - 1; i >= 0; --i )
193 {
194 KPrPage *page=m_doc->pageList().at( i );
195 TQCheckListItem* item = new TQCheckListItem( slides,
196 page->pageTitle(),
197 TQCheckListItem::CheckBox );
198 item->setOn( page->isSlideSelected() );
199 }
200
201 TQHBox* buttonGroup = new TQHBox( slidesPage );
202 buttonGroup->setSpacing( KDialog::spacingHint() );
203
204 TQPushButton* selectAllButton = new TQPushButton( i18n( "Select &All" ), buttonGroup );
205 connect( selectAllButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( selectAllSlides() ) );
206
207 TQPushButton* deselectAllButton = new TQPushButton( i18n( "&Deselect All" ), buttonGroup );
208 connect( deselectAllButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( deselectAllSlides() ) );
209
210 TQWidget* spacer = new TQWidget( buttonGroup );
211
212 spacer->setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Expanding ) );
213 slidesLayout->addMultiCellWidget( buttonGroup, 4, 4, 0, 1 );
214
215 if ( !m_doc->presentationName().isEmpty() )
216 {
217 m_customSlide->setChecked( true );
218 m_customSlideCombobox->setCurrentText( m_doc->presentationName() );
219 }
220 else
221 m_selectedSlide->setChecked( true );
222
223 if ( m_customSlideCombobox->count()==0 )
224 {
225 m_customSlide->setEnabled( false );
226 m_labelCustomSlide->setEnabled( false );
227 m_customSlideCombobox->setEnabled( false );
228 }
229 radioButtonClicked();
230}
231
232KPrPgConfDia::~KPrPgConfDia()
233{
234}
235
236void KPrPgConfDia::radioButtonClicked()
237{
238 if ( m_customSlide->isChecked() )
239 {
240 m_labelCustomSlide->setEnabled( true );
241 m_customSlideCombobox->setEnabled( true );
242 slides->setEnabled( false );
243 }
244 else
245 {
246 m_labelCustomSlide->setEnabled( false );
247 m_customSlideCombobox->setEnabled( false );
248 slides->setEnabled( true );
249 }
250}
251
252bool KPrPgConfDia::getInfiniteLoop() const
253{
254 return infiniteLoop->isChecked();
255}
256
257bool KPrPgConfDia::getShowEndOfPresentationSlide() const
258{
259 return endOfPresentationSlide->isChecked();
260}
261
262bool KPrPgConfDia::getManualSwitch() const
263{
264 return m_manualButton->isChecked();
265}
266
267bool KPrPgConfDia::getPresentationDuration() const
268{
269 return presentationDuration->isChecked();
270}
271
272TQPen KPrPgConfDia::getPen() const
273{
274 return TQPen( penColor->color(), penWidth->value() );
275}
276
277TQValueList<bool> KPrPgConfDia::getSelectedSlides() const
278{
279 TQValueList<bool> selectedSlides;
280
281 TQListViewItem *item = slides->firstChild();
282 while( item )
283 {
284 TQCheckListItem *checkItem = dynamic_cast<TQCheckListItem*>( item );
285 bool selected = false;
286 if( checkItem ) selected = checkItem->isOn();
287 item = item->nextSibling();
288 selectedSlides.append( selected );
289 }
290 return selectedSlides;
291}
292
293void KPrPgConfDia::selectAllSlides()
294{
295 TQListViewItem *item = slides->firstChild();
296 while( item )
297 {
298 TQCheckListItem *checkItem = dynamic_cast<TQCheckListItem*>( item );
299 if( checkItem ) checkItem->setOn( true );
300 item = item->nextSibling();
301 }
302}
303
304void KPrPgConfDia::deselectAllSlides()
305{
306 TQListViewItem *item = slides->firstChild();
307 while( item )
308 {
309 TQCheckListItem *checkItem = dynamic_cast<TQCheckListItem*>( item );
310 if( checkItem ) checkItem->setOn( false );
311 item = item->nextSibling();
312 }
313}
314
315TQString KPrPgConfDia::presentationName() const
316{
317 if ( m_customSlide->isChecked() )
318 return m_customSlideCombobox->currentText();
319 else
320 return TQString();
321}
322
323#include "KPrGradient.h"
324#include "KPrPgConfDia.moc"