summaryrefslogtreecommitdiffstats
path: root/kpresenter/KPrPgConfDia.cpp
blob: 1a7b3079d41a084e14d8c61cbc1cec5d7fd8fb03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/* This file is part of the KDE project
   Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
   Copyright (C) 2002, 2003 Ariya Hidayat <ariya@kde.org>
   Copyright (C) 2004, 2005 Laurent Montel <montel@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#include "KPrPgConfDia.h"
#include "KPrDocument.h"
#include "KPrPage.h"

#include <tqbuttongroup.h>
#include <tqhbuttongroup.h>
#include <tqcheckbox.h>
#include <tqcombobox.h>
#include <tqhbox.h>
#include <tqvbox.h>
#include <tqvgroupbox.h>
#include <tqheader.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqlistview.h>
#include <tqpen.h>
#include <tqpushbutton.h>
#include <tqradiobutton.h>
#include <tqvaluelist.h>
#include <tqvbuttongroup.h>
#include <tqwhatsthis.h>

#include <kcolorbutton.h>
#include <tdeglobal.h>
#include <tdelocale.h>
#include <knuminput.h>
#include <tqslider.h>

KPrPgConfDia::KPrPgConfDia( TQWidget* parent, KPrDocument* doc )
    : KDialogBase( KDialogBase::Tabbed, i18n("Configure Slide Show"),
                   Ok|Cancel, Ok, parent, "pgConfDia", true ),
      m_doc( doc )
{
    setupPageGeneral();
    setupPageSlides();

    connect( this, TQT_SIGNAL( okClicked() ), this, TQT_SLOT( confDiaOk() ) );
    connect( this, TQT_SIGNAL( okClicked() ), this, TQT_SLOT( accept() ) );
}

void KPrPgConfDia::setupPageGeneral()
{
    TQFrame* generalPage = addPage( i18n("&General") );
    TQWhatsThis::add( generalPage, i18n("<p>This dialog allows you to configure how the slideshow "
				       "will be displayed, including whether the slides are "
				       "automatically sequenced or manually controlled, and also "
				       "allows you to configure a <em>drawing pen</em> that can "
				       "be used during the display of the presentation to add "
				       "additional information or to emphasise particular points.</p>") );
    TQVBoxLayout *generalLayout = new TQVBoxLayout( generalPage, 0, KDialog::spacingHint() );

    TQVButtonGroup *switchGroup = new TQVButtonGroup( i18n("&Transition Type"), generalPage );
    generalLayout->addWidget( switchGroup );
    TQWhatsThis::add( switchGroup, i18n("<li><p>If you select <b>Manual transition to next step or slide</b> "
					  "then each transition and effect on a slide, or transition from "
					  "one slide to the next, will require an action. Typically this "
					  "action will be a mouse click, or the space bar.</p></li>"
					  "<li><p>If you select <b>Automatic transition to next step or slide</b> "
					  "then the presentation will automatically sequence each transition "
					  "and effect on a slide, and will automatically transition to the "
					  "next slide when the current slide is fully displayed. The speed "
					  "of sequencing is controlled using the slider below. This also "
					  "enables the option to automatically loop back to the first "
					  "slide after the last slide has been shown.</p></li>") );
    m_manualButton = new TQRadioButton( i18n("&Manual transition to next step or slide"), switchGroup );
    m_manualButton->setChecked( m_doc->spManualSwitch() );
    m_autoButton = new TQRadioButton( i18n("&Automatic transition to next step or slide"), switchGroup );
    m_autoButton->setChecked( !m_doc->spManualSwitch() );

    infiniteLoop = new TQCheckBox( i18n( "&Infinite loop" ), generalPage );
    generalLayout->addWidget( infiniteLoop );
    TQWhatsThis::add( infiniteLoop, i18n("<p>If this checkbox is selected, then the slideshow "
					"will restart at the first slide after the last slide "
					"has been displayed. It is only available if the "
					"<b>Automatic transition to next step or slide</b> "
					"button is selected above.</p> <p>This option may be "
					"useful if you are running a promotional display.</p>") );

    infiniteLoop->setEnabled( !m_doc->spManualSwitch() );
    connect( m_autoButton, TQT_SIGNAL( toggled(bool) ), infiniteLoop, TQT_SLOT( setEnabled(bool) ) );
    connect( m_autoButton, TQT_SIGNAL( toggled(bool) ), infiniteLoop, TQT_SLOT( setChecked(bool) ) );

    endOfPresentationSlide = new TQCheckBox( i18n( "&Show 'End of presentation' slide" ), generalPage );
    generalLayout->addWidget( endOfPresentationSlide );
    TQWhatsThis::add( endOfPresentationSlide, i18n("<p>If this checkbox is selected, when the slideshow "
					"has finished a black slideshow containing the "
					"message 'End of presentation. Click to exit' will "
					"be shown.") );
    endOfPresentationSlide->setChecked( m_doc->spShowEndOfPresentationSlide() );
    endOfPresentationSlide->setDisabled( infiniteLoop->isEnabled() && getInfiniteLoop() );
    connect( infiniteLoop, TQT_SIGNAL( toggled(bool) ), endOfPresentationSlide, TQT_SLOT( setDisabled(bool) ) );

    presentationDuration = new TQCheckBox( i18n( "Measure presentation &duration" ), generalPage );
    generalLayout->addWidget( presentationDuration );
    TQWhatsThis::add( presentationDuration, i18n("<p>If this checkbox is selected, the time that "
						"each slide was displayed for, and the total time "
						"for the presentation will be measured.</p> "
						"<p>The times will be displayed at the end of the "
						"presentation.</p> "
						"<p>This can be used during rehearsal to check "
						"coverage for each issue in the presentation, "
						"and to verify that the presentation duration "
						"is correct.</p>" ) );
    presentationDuration->setChecked( m_doc->presentationDuration() );

    // presentation pen (color and width)

    TQGroupBox* penGroup = new TQGroupBox( 2, Qt::Horizontal, i18n("Presentation Pen") , generalPage );
    generalLayout->addWidget( penGroup );
    TQWhatsThis::add( penGroup, i18n("<p>This part of the dialog allows you to configure the "
				    "<em>drawing mode</em>, which allows you to add additional "
				    "information, emphasise particular content, or to correct "
				    "errors during the presentation by drawing on the slides "
				    "using the mouse.</p>"
				    "<p>You can configure the color of the drawing pen and the "
				    "width of the pen.</p>" ) );
    penGroup->layout()->setSpacing(KDialog::marginHint());
    penGroup->layout()->setMargin(KDialog::spacingHint());
    //TQGridLayout *grid = new TQGridLayout(penGroup->layout(), 3, 2 );

    TQLabel* label = new TQLabel( i18n( "Color:" ), penGroup );
    //grid->addWidget( label, 0, 0 );
    penColor = new KColorButton( m_doc->presPen().color(), m_doc->presPen().color(), penGroup );
    //grid->addWidget( penColor, 0, 1 );

    label = new TQLabel( i18n( "Width:" ), penGroup );
    // grid->addWidget( label, 1, 0 );
    penWidth = new TQSpinBox( 1, 10, 1, penGroup );
    penWidth->setSuffix( i18n(" pt") );
    penWidth->setValue( m_doc->presPen().width() );
    //grid->addWidget( penWidth, 1, 1 );

    generalLayout->addStretch();
}

void KPrPgConfDia::setupPageSlides()
{
    TQFrame* slidesPage = addPage( i18n("&Slides") );
    TQWhatsThis::add( slidesPage, i18n("<p>This dialog allows you to configure which slides "
				      "are used in the presentation. Slides that are not "
				      "selected will not be displayed during the slide "
				      "show.</p>") );
    TQGridLayout *slidesLayout = new TQGridLayout( slidesPage,7 , 2, 0, KDialog::spacingHint());


    TQButtonGroup *group=new TQVButtonGroup( slidesPage );
    group->setRadioButtonExclusive( true );

    m_customSlide = new TQRadioButton( i18n( "Custom slide show" ), group, "customslide" );

    connect( m_customSlide, TQT_SIGNAL( clicked () ), this, TQT_SLOT( radioButtonClicked() ) );

    TQHBox *box = new TQHBox( group );

    m_labelCustomSlide = new TQLabel( i18n( "Custom slide:" ),box );

    m_customSlideCombobox = new TQComboBox( box );
    m_customSlideCombobox->insertStringList( m_doc->presentationList() );

    m_selectedSlide = new TQRadioButton( i18n( "Selected pages:" ), group, "selectedslide" );
    slidesLayout->addMultiCellWidget( group, 0,2,0,1 );
    connect( m_selectedSlide, TQT_SIGNAL( clicked () ), this, TQT_SLOT( radioButtonClicked() ) );

    slides = new TQListView( slidesPage );
    slidesLayout->addMultiCellWidget( slides, 3, 3, 0, 1 );
    slidesLayout->setRowStretch( 3, 10 );
    slides->addColumn( i18n("Slide") );
    slides->setSorting( -1 );
    slides->header()->hide();

    for ( int i = m_doc->getPageNums() - 1; i >= 0; --i )
    {
        KPrPage *page=m_doc->pageList().at( i );
        TQCheckListItem* item = new TQCheckListItem( slides,
                                                   page->pageTitle(),
                                                   TQCheckListItem::CheckBox );
        item->setOn( page->isSlideSelected() );
    }

    TQHBox* buttonGroup = new TQHBox( slidesPage );
    buttonGroup->setSpacing( KDialog::spacingHint() );

    TQPushButton* selectAllButton = new TQPushButton( i18n( "Select &All" ), buttonGroup );
    connect( selectAllButton, TQT_SIGNAL( clicked() ), this, TQT_SLOT( selectAllSlides() ) );

    TQPushButton* deselectAllButton = new TQPushButton( i18n( "&Deselect All" ), buttonGroup );
    connect( deselectAllButton, TQT_SIGNAL( clicked() ), this, TQT_SLOT( deselectAllSlides() ) );

    TQWidget* spacer = new TQWidget( buttonGroup );

    spacer->setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Expanding ) );
    slidesLayout->addMultiCellWidget( buttonGroup, 4, 4, 0, 1 );

    if ( !m_doc->presentationName().isEmpty() )
    {
        m_customSlide->setChecked( true );
        m_customSlideCombobox->setCurrentText( m_doc->presentationName() );
    }
    else
        m_selectedSlide->setChecked( true );

    if ( m_customSlideCombobox->count()==0 )
    {
        m_customSlide->setEnabled( false );
        m_labelCustomSlide->setEnabled( false );
        m_customSlideCombobox->setEnabled( false );
    }
    radioButtonClicked();
}

KPrPgConfDia::~KPrPgConfDia()
{
}

void KPrPgConfDia::radioButtonClicked()
{
    if ( m_customSlide->isChecked() )
    {
        m_labelCustomSlide->setEnabled( true );
        m_customSlideCombobox->setEnabled( true );
        slides->setEnabled( false );
    }
    else
    {
        m_labelCustomSlide->setEnabled( false );
        m_customSlideCombobox->setEnabled( false );
        slides->setEnabled( true );
    }
}

bool KPrPgConfDia::getInfiniteLoop() const
{
    return infiniteLoop->isChecked();
}

bool KPrPgConfDia::getShowEndOfPresentationSlide() const
{
    return endOfPresentationSlide->isChecked();
}

bool KPrPgConfDia::getManualSwitch() const
{
    return m_manualButton->isChecked();
}

bool KPrPgConfDia::getPresentationDuration() const
{
    return presentationDuration->isChecked();
}

TQPen KPrPgConfDia::getPen() const
{
    return TQPen( penColor->color(), penWidth->value() );
}

TQValueList<bool> KPrPgConfDia::getSelectedSlides() const
{
    TQValueList<bool> selectedSlides;

    TQListViewItem *item = slides->firstChild();
    while( item )
    {
        TQCheckListItem *checkItem = dynamic_cast<TQCheckListItem*>( item );
        bool selected = false;
        if( checkItem ) selected = checkItem->isOn();
        item = item->nextSibling();
        selectedSlides.append( selected );
    }
    return selectedSlides;
}

void KPrPgConfDia::selectAllSlides()
{
    TQListViewItem *item = slides->firstChild();
    while( item )
    {
        TQCheckListItem *checkItem = dynamic_cast<TQCheckListItem*>( item );
        if( checkItem ) checkItem->setOn( true );
        item = item->nextSibling();
    }
}

void KPrPgConfDia::deselectAllSlides()
{
    TQListViewItem *item = slides->firstChild();
    while( item )
    {
        TQCheckListItem *checkItem = dynamic_cast<TQCheckListItem*>( item );
        if( checkItem ) checkItem->setOn( false );
        item = item->nextSibling();
    }
}

TQString KPrPgConfDia::presentationName() const
{
    if ( m_customSlide->isChecked() )
        return m_customSlideCombobox->currentText();
    else
        return TQString();
}

#include "KPrGradient.h"
#include "KPrPgConfDia.moc"