1
1
/* This file is part of the KDE project
2
2
Copyright (C) 2006-2007 Thorsten Zachmann <zachmann@kde.org>
3
3
Copyright (C) 2008 Carlos Licea <carlos.licea@kdemail.org>
4
Copyright (C) 2009 Benjamin Port <port.benjamin@gmail.com>
5
Copyright (C) 2009 Yannick Motta <yannick.motta@gmail.com>
5
7
This library is free software; you can redistribute it and/or
6
8
modify it under the terms of the GNU Library General Public
7
9
License as published by the Free Software Foundation; either
23
25
#include <ktoggleaction.h>
24
26
#include <kactioncollection.h>
25
27
#include <kactionmenu.h>
28
#include <kmessagebox.h>
29
#include <kfiledialog.h>
27
31
#include <KoSelection.h>
28
32
#include <KoShapeManager.h>
29
33
#include <KoMainWindow.h>
30
34
#include <KoPACanvas.h>
31
35
#include <KoPADocumentStructureDocker.h>
36
#include <KoPAPageInsertCommand.h>
37
#include <KoDocumentInfo.h>
38
#include <KoShapeRegistry.h>
39
#include <KoShapeLayer.h>
33
41
#include "KPrDocument.h"
34
42
#include "KPrPage.h"
37
45
#include "KPrViewAdaptor.h"
38
46
#include "KPrViewModePresentation.h"
39
47
#include "KPrViewModeNotes.h"
48
#include "KPrViewModeSlidesSorter.h"
40
49
#include "KPrShapeManagerDisplayMasterStrategy.h"
50
#include "KPrPageSelectStrategyActive.h"
51
#include "KPrPicturesImport.h"
41
52
#include "commands/KPrAnimationCreateCommand.h"
42
53
#include "commands/KPrSetCustomSlideShowsCommand.h"
43
54
#include "dockers/KPrPageLayoutDockerFactory.h"
44
55
#include "dockers/KPrPageLayoutDocker.h"
45
#include "shapeanimations/KPrAnimationMoveAppear.h"
56
#include "KPrHtmlExport.h"
47
57
#include "KPrCustomSlideShows.h"
48
58
#include "ui/KPrCustomSlideShowsDialog.h"
49
59
#include "ui/KPrConfigureSlideShowDialog.h"
50
60
#include "ui/KPrConfigurePresenterViewDialog.h"
61
#include "ui/KPrHtmlExportDialog.h"
52
62
#include <QtGui/QDesktopWidget>
54
64
KPrView::KPrView( KPrDocument *document, QWidget *parent )
56
66
, m_presentationMode( new KPrViewModePresentation( this, kopaCanvas() ))
57
67
, m_normalMode( viewMode() )
58
68
, m_notesMode( new KPrViewModeNotes( this, kopaCanvas() ))
69
// , m_slidesSorterMode( new KPrViewModeSlidesSorter( this, kopaCanvas() ))
59
70
, m_dbus( new KPrViewAdaptor( this ) )
80
91
actionCollection()->action("page_last")->setText(i18n("Last Slide"));
81
92
actionCollection()->action("configure")->setText(i18n("Configure KPresenter..."));
83
masterShapeManager()->setPaintingStrategy( new KPrShapeManagerDisplayMasterStrategy( masterShapeManager() ) );
94
masterShapeManager()->setPaintingStrategy( new KPrShapeManagerDisplayMasterStrategy( masterShapeManager(),
95
new KPrPageSelectStrategyActive( this ) ) );
97
KoPACanvas * canvas = dynamic_cast<KoPACanvas*>(kopaCanvas());
99
m_slidesSorterMode = new KPrViewModeSlidesSorter(this, canvas);
86
103
KPrView::~KPrView()
88
105
delete m_presentationMode;
89
106
delete m_notesMode;
107
delete m_slidesSorterMode;
92
KoViewConverter * KPrView::viewConverter( KoPACanvas * canvas )
110
KoViewConverter * KPrView::viewConverter( KoPACanvasBase * canvas )
112
Q_ASSERT(viewMode());
94
113
return viewMode()->viewConverter( canvas );
114
133
return ( viewMode() == m_presentationMode );
136
void KPrView::drawOnPresentation()
138
if (isPresentationRunning())
140
m_presentationMode->presentationTool()->drawOnPresentation();
144
void KPrView::highlightPresentation()
146
if (isPresentationRunning())
148
m_presentationMode->presentationTool()->highlightPresentation();
152
void KPrView::blackPresentation()
154
if (isPresentationRunning())
156
m_presentationMode->presentationTool()->blackPresentation();
117
160
void KPrView::initGUI()
119
162
// add page effect docker to the main window
139
182
setXMLFile( "kpresenter.rc" );
141
184
// do special kpresenter stuff here
185
m_actionExportHtml = new KAction(i18n("Export as HTML..."), this);
186
actionCollection()->addAction("file_export_html", m_actionExportHtml);
187
connect(m_actionExportHtml, SIGNAL(triggered()), this, SLOT(exportToHtml()));
142
189
m_actionViewModeNormal = new KAction(i18n("Normal"), this);
143
190
m_actionViewModeNormal->setCheckable(true);
144
191
m_actionViewModeNormal->setChecked(true);
150
197
actionCollection()->addAction("view_notes", m_actionViewModeNotes);
151
198
connect(m_actionViewModeNotes, SIGNAL(triggered()), this, SLOT(showNotes()));
200
m_actionViewModeSlidesSorter = new KAction(i18n("Slides Sorter"), this);
201
m_actionViewModeSlidesSorter->setCheckable(true);
202
actionCollection()->addAction("view_slides_sorter", m_actionViewModeSlidesSorter);
203
connect(m_actionViewModeSlidesSorter, SIGNAL(triggered()), this, SLOT(showSlidesSorter()));
205
m_actionInsertPictures = new KAction(i18n("Insert Pictures..."), this);
206
actionCollection()->addAction("insert_pictures", m_actionInsertPictures);
207
connect(m_actionInsertPictures, SIGNAL(activated()), this, SLOT(insertPictures()));
153
209
QActionGroup *viewModesGroup = new QActionGroup(this);
154
210
viewModesGroup->addAction(m_actionViewModeNormal);
155
211
viewModesGroup->addAction(m_actionViewModeNotes);
212
viewModesGroup->addAction(m_actionViewModeSlidesSorter);
157
214
m_actionCreateAnimation = new KAction( i18n( "Create Appear Animation" ), this );
158
215
actionCollection()->addAction( "edit_createanimation", m_actionCreateAnimation );
165
222
m_actionStartPresentation = new KActionMenu( KIcon("view-presentation"), i18n( "Start Presentation" ), this );
166
223
actionCollection()->addAction( "slideshow_start", m_actionStartPresentation );
167
224
connect( m_actionStartPresentation, SIGNAL( activated() ), this, SLOT( startPresentation() ) );
168
KAction* action = new KAction( i18n( "From Current Slide" ),
225
KAction* action = new KAction( i18n( "From Current Slide" ),
170
227
action->setShortcut(QKeySequence("Shift+F5"));
171
228
m_actionStartPresentation->addAction( action );
182
239
action = new KAction( i18n( "Configure Presenter View..." ), this );
183
240
actionCollection()->addAction( "slideshow_presenterview", action );
184
241
connect( action, SIGNAL( activated() ), this, SLOT( configurePresenterView() ) );
243
m_actionDrawOnPresentation = new KAction( i18n( "Draw on the presentation..." ), this );
244
m_actionDrawOnPresentation->setShortcut(Qt::Key_P);
245
m_actionDrawOnPresentation->setShortcutContext(Qt::ApplicationShortcut);
246
actionCollection()->addAction( "draw_on_presentation", m_actionDrawOnPresentation );
247
connect( m_actionDrawOnPresentation, SIGNAL( activated() ), this, SLOT( drawOnPresentation() ) );
248
m_actionDrawOnPresentation->setEnabled(false);
250
m_actionHighlightPresentation = new KAction( i18n( "Highlight the presentation..." ), this );
251
m_actionHighlightPresentation->setShortcut(Qt::Key_H);
252
m_actionHighlightPresentation->setShortcutContext(Qt::ApplicationShortcut);
253
actionCollection()->addAction( "highlight_presentation", m_actionHighlightPresentation );
254
connect( m_actionHighlightPresentation, SIGNAL( activated() ), this, SLOT( highlightPresentation() ) );
255
m_actionHighlightPresentation->setEnabled(false);
257
m_actionBlackPresentation = new KAction( i18n( "Blackscreen on the presentation..." ), this );
258
m_actionBlackPresentation->setShortcut(Qt::Key_B);
259
m_actionBlackPresentation->setShortcutContext(Qt::ApplicationShortcut);
260
actionCollection()->addAction( "black_presentation", m_actionBlackPresentation );
261
connect( m_actionBlackPresentation, SIGNAL( activated() ), this, SLOT( blackPresentation() ) );
262
m_actionBlackPresentation->setEnabled(false);
187
265
void KPrView::startPresentation()
267
m_actionDrawOnPresentation->setEnabled(true);
268
m_actionHighlightPresentation->setEnabled(true);
269
m_actionBlackPresentation->setEnabled(true);
189
270
setViewMode( m_presentationMode );
202
283
void KPrView::stopPresentation()
285
m_actionDrawOnPresentation->setEnabled(false);
286
m_actionHighlightPresentation->setEnabled(false);
287
m_actionBlackPresentation->setEnabled(false);
204
289
if ( isPresentationRunning() ) {
205
290
m_presentationMode->activateSavedViewMode();
213
298
QList<KoShape*> selectedShapes = selection->selectedShapes();
214
299
foreach( KoShape * shape, selectedShapes )
216
KPrShapeAnimation * animation = new KPrAnimationMoveAppear( shape, animationcount );
302
/*KPrShapeAnimationOld * animation = new KPrAnimationMoveAppear( shape, animationcount );
217
303
KPrDocument * doc = static_cast<KPrDocument *>( kopaDocument() );
218
304
KPrAnimationCreateCommand * command = new KPrAnimationCreateCommand( doc, animation );
219
kopaCanvas()->addCommand( command );
305
kopaCanvas()->addCommand( command );*/
221
307
animationcount = ( animationcount + 1 ) % 3;
237
323
setViewMode(m_notesMode);
326
void KPrView::showSlidesSorter()
328
// Make sure that we are not in master mode
329
// Sort master does not make sense
330
if ( viewMode()->masterMode() ) {
331
actionCollection()->action( "view_masterpages" )->setChecked( false );
332
setMasterMode( false );
334
setViewMode(m_slidesSorterMode);
240
337
void KPrView::dialogCustomSlideShows()
242
339
KPrDocument *doc = static_cast<KPrDocument *>( kopaDocument() );
374
void KPrView::exportToHtml()
376
KPrHtmlExportDialog *dialog = new KPrHtmlExportDialog(kopaDocument()->pages(),koDocument()->documentInfo()->aboutInfo("title"),
377
koDocument()->documentInfo()->authorInfo("creator"), this);
378
if (dialog->exec() == QDialog::Accepted && !dialog->checkedSlides().isEmpty()) {
379
// Get the export directory
380
KUrl directoryUrl = KFileDialog::getExistingDirectoryUrl();
381
if (directoryUrl.isValid()) {
382
directoryUrl.adjustPath(KUrl::AddTrailingSlash);
383
KPrHtmlExport exportHtml;
384
exportHtml.exportHtml(KPrHtmlExport::Parameter(dialog->templateUrl(), this, dialog->checkedSlides(),
385
directoryUrl, dialog->author(),
386
dialog->title(), dialog->slidesNames(), dialog->openBrowser()));
391
void KPrView::insertPictures()
393
// Make sure that we are in the normal mode and not on master pages
394
setViewMode(m_normalMode);
395
if (viewMode()->masterMode()) {
396
setMasterMode(false);
398
KPrPicturesImport pictureImport;
399
pictureImport.import(this);
277
402
#include "KPrView.moc"