~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kpresenter/part/KPrView.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
   
 
4
   Copyright (C) 2009 Benjamin Port <port.benjamin@gmail.com>
 
5
   Copyright (C) 2009 Yannick Motta <yannick.motta@gmail.com>
 
6
 
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>
26
30
 
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>
32
40
 
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"
46
 
 
 
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"
51
 
#include <QDebug>
 
61
#include "ui/KPrHtmlExportDialog.h"
52
62
#include <QtGui/QDesktopWidget>
53
63
 
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 ) )
60
71
{
61
72
    initGUI();
80
91
    actionCollection()->action("page_last")->setText(i18n("Last Slide"));
81
92
    actionCollection()->action("configure")->setText(i18n("Configure KPresenter..."));
82
93
 
83
 
    masterShapeManager()->setPaintingStrategy( new KPrShapeManagerDisplayMasterStrategy( masterShapeManager() ) );
 
94
    masterShapeManager()->setPaintingStrategy( new KPrShapeManagerDisplayMasterStrategy( masterShapeManager(),
 
95
                                                   new KPrPageSelectStrategyActive( this ) ) );
 
96
 
 
97
    KoPACanvas * canvas = dynamic_cast<KoPACanvas*>(kopaCanvas());
 
98
    if (canvas) {
 
99
        m_slidesSorterMode = new KPrViewModeSlidesSorter(this, canvas);
 
100
    }
84
101
}
85
102
 
86
103
KPrView::~KPrView()
87
104
{
88
105
    delete m_presentationMode;
89
106
    delete m_notesMode;
 
107
    delete m_slidesSorterMode;
90
108
}
91
109
 
92
 
KoViewConverter * KPrView::viewConverter( KoPACanvas * canvas )
 
110
KoViewConverter * KPrView::viewConverter( KoPACanvasBase * canvas )
93
111
{
 
112
    Q_ASSERT(viewMode());
94
113
    return viewMode()->viewConverter( canvas );
95
114
}
96
115
 
114
133
    return ( viewMode() == m_presentationMode );
115
134
}
116
135
 
 
136
void KPrView::drawOnPresentation()
 
137
{
 
138
    if (isPresentationRunning())
 
139
    {
 
140
        m_presentationMode->presentationTool()->drawOnPresentation();
 
141
    }
 
142
}
 
143
 
 
144
void KPrView::highlightPresentation()
 
145
{
 
146
    if (isPresentationRunning())
 
147
    {
 
148
        m_presentationMode->presentationTool()->highlightPresentation();
 
149
    }
 
150
}
 
151
 
 
152
void KPrView::blackPresentation()
 
153
{
 
154
    if (isPresentationRunning())
 
155
    {
 
156
        m_presentationMode->presentationTool()->blackPresentation();
 
157
    }
 
158
}
 
159
 
117
160
void KPrView::initGUI()
118
161
{
119
162
    // add page effect docker to the main window
139
182
       setXMLFile( "kpresenter.rc" );
140
183
 
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()));
 
188
 
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()));
152
199
 
 
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()));
 
204
 
 
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()));
 
208
 
153
209
    QActionGroup *viewModesGroup = new QActionGroup(this);
154
210
    viewModesGroup->addAction(m_actionViewModeNormal);
155
211
    viewModesGroup->addAction(m_actionViewModeNotes);
 
212
    viewModesGroup->addAction(m_actionViewModeSlidesSorter);
156
213
 
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" ),
169
226
this );
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() ) );
 
242
 
 
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);
 
249
 
 
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);
 
256
 
 
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);
185
263
}
186
264
 
187
265
void KPrView::startPresentation()
188
266
{
 
267
    m_actionDrawOnPresentation->setEnabled(true);
 
268
    m_actionHighlightPresentation->setEnabled(true);
 
269
    m_actionBlackPresentation->setEnabled(true);
189
270
    setViewMode( m_presentationMode );
190
271
}
191
272
 
201
282
 
202
283
void KPrView::stopPresentation()
203
284
{
 
285
    m_actionDrawOnPresentation->setEnabled(false);
 
286
    m_actionHighlightPresentation->setEnabled(false);
 
287
    m_actionBlackPresentation->setEnabled(false);
 
288
 
204
289
    if ( isPresentationRunning() ) {
205
290
        m_presentationMode->activateSavedViewMode();
206
291
    }
213
298
    QList<KoShape*> selectedShapes = selection->selectedShapes();
214
299
    foreach( KoShape * shape, selectedShapes )
215
300
    {
216
 
        KPrShapeAnimation * animation = new KPrAnimationMoveAppear( shape, animationcount );
 
301
        Q_UNUSED(shape);
 
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 );*/
220
306
    }
221
307
    animationcount = ( animationcount + 1 ) % 3;
222
308
}
237
323
    setViewMode(m_notesMode);
238
324
}
239
325
 
 
326
void KPrView::showSlidesSorter()
 
327
{
 
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 );
 
333
    }
 
334
    setViewMode(m_slidesSorterMode);
 
335
}
 
336
 
240
337
void KPrView::dialogCustomSlideShows()
241
338
{
242
339
    KPrDocument *doc = static_cast<KPrDocument *>( kopaDocument() );
274
371
    delete dialog;
275
372
}
276
373
 
 
374
void KPrView::exportToHtml()
 
375
{
 
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()));
 
387
        }
 
388
   }
 
389
}
 
390
 
 
391
void KPrView::insertPictures()
 
392
{
 
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);
 
397
    }
 
398
    KPrPicturesImport pictureImport;
 
399
    pictureImport.import(this);
 
400
}
 
401
 
277
402
#include "KPrView.moc"