00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "KPrPgConfDia.h"
00023 #include "KPrDocument.h"
00024 #include "KPrPage.h"
00025
00026 #include <qbuttongroup.h>
00027 #include <qhbuttongroup.h>
00028 #include <qcheckbox.h>
00029 #include <qcombobox.h>
00030 #include <qhbox.h>
00031 #include <qvbox.h>
00032 #include <qvgroupbox.h>
00033 #include <qheader.h>
00034 #include <qlabel.h>
00035 #include <qlayout.h>
00036 #include <qlistview.h>
00037 #include <qpen.h>
00038 #include <qpushbutton.h>
00039 #include <qradiobutton.h>
00040 #include <qvaluelist.h>
00041 #include <qvbuttongroup.h>
00042 #include <qwhatsthis.h>
00043
00044 #include <kcolorbutton.h>
00045 #include <kglobal.h>
00046 #include <klocale.h>
00047 #include <knuminput.h>
00048 #include <qslider.h>
00049
00050 KPrPgConfDia::KPrPgConfDia( QWidget* parent, KPrDocument* doc )
00051 : KDialogBase( KDialogBase::Tabbed, i18n("Configure Slide Show"),
00052 Ok|Cancel, Ok, parent, "pgConfDia", true ),
00053 m_doc( doc )
00054 {
00055 setupPageGeneral();
00056 setupPageSlides();
00057
00058 connect( this, SIGNAL( okClicked() ), this, SLOT( confDiaOk() ) );
00059 connect( this, SIGNAL( okClicked() ), this, SLOT( accept() ) );
00060 }
00061
00062 void KPrPgConfDia::setupPageGeneral()
00063 {
00064 QFrame* generalPage = addPage( i18n("&General") );
00065 QWhatsThis::add( generalPage, i18n("<p>This dialog allows you to configure how the slideshow "
00066 "will be displayed, including whether the slides are "
00067 "automatically sequenced or manually controlled, and also "
00068 "allows you to configure a <em>drawing pen</em> that can "
00069 "be used during the display of the presentation to add "
00070 "additional information or to emphasise particular points.</p>") );
00071 QVBoxLayout *generalLayout = new QVBoxLayout( generalPage, 0, KDialog::spacingHint() );
00072
00073 QVButtonGroup *switchGroup = new QVButtonGroup( i18n("&Transition Type"), generalPage );
00074 generalLayout->addWidget( switchGroup );
00075 QWhatsThis::add( switchGroup, i18n("<li><p>If you select <b>Manual transition to next step or slide</b> "
00076 "then each transition and effect on a slide, or transition from "
00077 "one slide to the next, will require an action. Typically this "
00078 "action will be a mouse click, or the space bar.</p></li>"
00079 "<li><p>If you select <b>Automatic transition to next step or slide</b> "
00080 "then the presentation will automatically sequence each transition "
00081 "and effect on a slide, and will automatically transition to the "
00082 "next slide when the current slide is fully displayed. The speed "
00083 "of sequencing is controlled using the slider below. This also "
00084 "enables the option to automatically loop back to the first "
00085 "slide after the last slide has been shown.</p></li>") );
00086 m_manualButton = new QRadioButton( i18n("&Manual transition to next step or slide"), switchGroup );
00087 m_manualButton->setChecked( m_doc->spManualSwitch() );
00088 m_autoButton = new QRadioButton( i18n("&Automatic transition to next step or slide"), switchGroup );
00089 m_autoButton->setChecked( !m_doc->spManualSwitch() );
00090
00091 infiniteLoop = new QCheckBox( i18n( "&Infinite loop" ), generalPage );
00092 generalLayout->addWidget( infiniteLoop );
00093 QWhatsThis::add( infiniteLoop, i18n("<p>If this checkbox is selected, then the slideshow "
00094 "will restart at the first slide after the last slide "
00095 "has been displayed. It is only available if the "
00096 "<b>Automatic transition to next step or slide</b> "
00097 "button is selected above.</p> <p>This option may be "
00098 "useful if you are running a promotional display.</p>") );
00099
00100 infiniteLoop->setEnabled( !m_doc->spManualSwitch() );
00101 connect( m_autoButton, SIGNAL( toggled(bool) ), infiniteLoop, SLOT( setEnabled(bool) ) );
00102 connect( m_autoButton, SIGNAL( toggled(bool) ), infiniteLoop, SLOT( setChecked(bool) ) );
00103
00104 endOfPresentationSlide = new QCheckBox( i18n( "&Show 'End of presentation' slide" ), generalPage );
00105 generalLayout->addWidget( endOfPresentationSlide );
00106 QWhatsThis::add( endOfPresentationSlide, i18n("<p>If this checkbox is selected, when the slideshow "
00107 "has finished a black slideshow containing the "
00108 "message 'End of presentation. Click to exit' will "
00109 "be shown.") );
00110 endOfPresentationSlide->setChecked( m_doc->spShowEndOfPresentationSlide() );
00111 endOfPresentationSlide->setDisabled( infiniteLoop->isEnabled() && getInfiniteLoop() );
00112 connect( infiniteLoop, SIGNAL( toggled(bool) ), endOfPresentationSlide, SLOT( setDisabled(bool) ) );
00113
00114 presentationDuration = new QCheckBox( i18n( "Measure presentation &duration" ), generalPage );
00115 generalLayout->addWidget( presentationDuration );
00116 QWhatsThis::add( presentationDuration, i18n("<p>If this checkbox is selected, the time that "
00117 "each slide was displayed for, and the total time "
00118 "for the presentation will be measured.</p> "
00119 "<p>The times will be displayed at the end of the "
00120 "presentation.</p> "
00121 "<p>This can be used during rehearsal to check "
00122 "coverage for each issue in the presentation, "
00123 "and to verify that the presentation duration "
00124 "is correct.</p>" ) );
00125 presentationDuration->setChecked( m_doc->presentationDuration() );
00126
00127
00128
00129 QGroupBox* penGroup = new QGroupBox( 2, Qt::Horizontal, i18n("Presentation Pen") , generalPage );
00130 generalLayout->addWidget( penGroup );
00131 QWhatsThis::add( penGroup, i18n("<p>This part of the dialog allows you to configure the "
00132 "<em>drawing mode</em>, which allows you to add additional "
00133 "information, emphasise particular content, or to correct "
00134 "errors during the presentation by drawing on the slides "
00135 "using the mouse.</p>"
00136 "<p>You can configure the color of the drawing pen and the "
00137 "width of the pen.</p>" ) );
00138 penGroup->layout()->setSpacing(KDialog::marginHint());
00139 penGroup->layout()->setMargin(KDialog::spacingHint());
00140
00141
00142 QLabel* label = new QLabel( i18n( "Color:" ), penGroup );
00143
00144 penColor = new KColorButton( m_doc->presPen().color(), m_doc->presPen().color(), penGroup );
00145
00146
00147 label = new QLabel( i18n( "Width:" ), penGroup );
00148
00149 penWidth = new QSpinBox( 1, 10, 1, penGroup );
00150 penWidth->setSuffix( i18n(" pt") );
00151 penWidth->setValue( m_doc->presPen().width() );
00152
00153
00154 generalLayout->addStretch();
00155 }
00156
00157 void KPrPgConfDia::setupPageSlides()
00158 {
00159 QFrame* slidesPage = addPage( i18n("&Slides") );
00160 QWhatsThis::add( slidesPage, i18n("<p>This dialog allows you to configure which slides "
00161 "are used in the presentation. Slides that are not "
00162 "selected will not be displayed during the slide "
00163 "show.</p>") );
00164 QGridLayout *slidesLayout = new QGridLayout( slidesPage,7 , 2, 0, KDialog::spacingHint());
00165
00166
00167 QButtonGroup *group=new QVButtonGroup( slidesPage );
00168 group->setRadioButtonExclusive( true );
00169
00170 m_customSlide = new QRadioButton( i18n( "Custom slide show" ), group, "customslide" );
00171
00172 connect( m_customSlide, SIGNAL( clicked () ), this, SLOT( radioButtonClicked() ) );
00173
00174 QHBox *box = new QHBox( group );
00175
00176 m_labelCustomSlide = new QLabel( i18n( "Custom slide:" ),box );
00177
00178 m_customSlideCombobox = new QComboBox( box );
00179 m_customSlideCombobox->insertStringList( m_doc->presentationList() );
00180
00181 m_selectedSlide = new QRadioButton( i18n( "Selected pages:" ), group, "selectedslide" );
00182 slidesLayout->addMultiCellWidget( group, 0,2,0,1 );
00183 connect( m_selectedSlide, SIGNAL( clicked () ), this, SLOT( radioButtonClicked() ) );
00184
00185 slides = new QListView( slidesPage );
00186 slidesLayout->addMultiCellWidget( slides, 3, 3, 0, 1 );
00187 slidesLayout->setRowStretch( 3, 10 );
00188 slides->addColumn( i18n("Slide") );
00189 slides->setSorting( -1 );
00190 slides->header()->hide();
00191
00192 for ( int i = m_doc->getPageNums() - 1; i >= 0; --i )
00193 {
00194 KPrPage *page=m_doc->pageList().at( i );
00195 QCheckListItem* item = new QCheckListItem( slides,
00196 page->pageTitle(),
00197 QCheckListItem::CheckBox );
00198 item->setOn( page->isSlideSelected() );
00199 }
00200
00201 QHBox* buttonGroup = new QHBox( slidesPage );
00202 buttonGroup->setSpacing( KDialog::spacingHint() );
00203
00204 QPushButton* selectAllButton = new QPushButton( i18n( "Select &All" ), buttonGroup );
00205 connect( selectAllButton, SIGNAL( clicked() ), this, SLOT( selectAllSlides() ) );
00206
00207 QPushButton* deselectAllButton = new QPushButton( i18n( "&Deselect All" ), buttonGroup );
00208 connect( deselectAllButton, SIGNAL( clicked() ), this, SLOT( deselectAllSlides() ) );
00209
00210 QWidget* spacer = new QWidget( buttonGroup );
00211
00212 spacer->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
00213 slidesLayout->addMultiCellWidget( buttonGroup, 4, 4, 0, 1 );
00214
00215 if ( !m_doc->presentationName().isEmpty() )
00216 {
00217 m_customSlide->setChecked( true );
00218 m_customSlideCombobox->setCurrentText( m_doc->presentationName() );
00219 }
00220 else
00221 m_selectedSlide->setChecked( true );
00222
00223 if ( m_customSlideCombobox->count()==0 )
00224 {
00225 m_customSlide->setEnabled( false );
00226 m_labelCustomSlide->setEnabled( false );
00227 m_customSlideCombobox->setEnabled( false );
00228 }
00229 radioButtonClicked();
00230 }
00231
00232 KPrPgConfDia::~KPrPgConfDia()
00233 {
00234 }
00235
00236 void KPrPgConfDia::radioButtonClicked()
00237 {
00238 if ( m_customSlide->isChecked() )
00239 {
00240 m_labelCustomSlide->setEnabled( true );
00241 m_customSlideCombobox->setEnabled( true );
00242 slides->setEnabled( false );
00243 }
00244 else
00245 {
00246 m_labelCustomSlide->setEnabled( false );
00247 m_customSlideCombobox->setEnabled( false );
00248 slides->setEnabled( true );
00249 }
00250 }
00251
00252 bool KPrPgConfDia::getInfiniteLoop() const
00253 {
00254 return infiniteLoop->isChecked();
00255 }
00256
00257 bool KPrPgConfDia::getShowEndOfPresentationSlide() const
00258 {
00259 return endOfPresentationSlide->isChecked();
00260 }
00261
00262 bool KPrPgConfDia::getManualSwitch() const
00263 {
00264 return m_manualButton->isChecked();
00265 }
00266
00267 bool KPrPgConfDia::getPresentationDuration() const
00268 {
00269 return presentationDuration->isChecked();
00270 }
00271
00272 QPen KPrPgConfDia::getPen() const
00273 {
00274 return QPen( penColor->color(), penWidth->value() );
00275 }
00276
00277 QValueList<bool> KPrPgConfDia::getSelectedSlides() const
00278 {
00279 QValueList<bool> selectedSlides;
00280
00281 QListViewItem *item = slides->firstChild();
00282 while( item )
00283 {
00284 QCheckListItem *checkItem = dynamic_cast<QCheckListItem*>( item );
00285 bool selected = false;
00286 if( checkItem ) selected = checkItem->isOn();
00287 item = item->nextSibling();
00288 selectedSlides.append( selected );
00289 }
00290 return selectedSlides;
00291 }
00292
00293 void KPrPgConfDia::selectAllSlides()
00294 {
00295 QListViewItem *item = slides->firstChild();
00296 while( item )
00297 {
00298 QCheckListItem *checkItem = dynamic_cast<QCheckListItem*>( item );
00299 if( checkItem ) checkItem->setOn( true );
00300 item = item->nextSibling();
00301 }
00302 }
00303
00304 void KPrPgConfDia::deselectAllSlides()
00305 {
00306 QListViewItem *item = slides->firstChild();
00307 while( item )
00308 {
00309 QCheckListItem *checkItem = dynamic_cast<QCheckListItem*>( item );
00310 if( checkItem ) checkItem->setOn( false );
00311 item = item->nextSibling();
00312 }
00313 }
00314
00315 QString KPrPgConfDia::presentationName() const
00316 {
00317 if ( m_customSlide->isChecked() )
00318 return m_customSlideCombobox->currentText();
00319 else
00320 return QString::null;
00321 }
00322
00323 #include "KPrGradient.h"
00324 #include "KPrPgConfDia.moc"