File indexing completed on 2024-05-12 16:36:49
0001 /* This file is part of the KDE project 0002 Copyright (C) 2006-2007 Thorsten Zachmann <zachmann@kde.org> 0003 Copyright (C) 2008 Carlos Licea <carlos.licea@kdemail.org> 0004 Copyright (C) 2009-2010 Benjamin Port <port.benjamin@gmail.com> 0005 Copyright (C) 2009 Yannick Motta <yannick.motta@gmail.com> 0006 0007 This library is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU Library General Public 0009 License as published by the Free Software Foundation; either 0010 version 2 of the License, or (at your option) any later version. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Library General Public License for more details. 0016 0017 You should have received a copy of the GNU Library General Public License 0018 along with this library; see the file COPYING.LIB. If not, write to 0019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 * Boston, MA 02110-1301, USA. 0021 */ 0022 #include "KPrView.h" 0023 0024 #include <QStatusBar> 0025 #include <QFileDialog> 0026 #include <QUrl> 0027 0028 #include <KSharedConfig> 0029 #include <klocalizedstring.h> 0030 #include <ktoggleaction.h> 0031 #include <kactioncollection.h> 0032 #include <kactionmenu.h> 0033 0034 #include <KoIcon.h> 0035 0036 #include <KoComponentData.h> 0037 #include <KoSelection.h> 0038 #include <KoShapeManager.h> 0039 #include <KoMainWindow.h> 0040 #include <KoPACanvasBase.h> 0041 #include <KoDocumentInfo.h> 0042 #include <KoShapeLayer.h> 0043 #include <KoZoomController.h> 0044 #include <KoToolManager.h> 0045 #include <tools/backgroundTool/KoPABackgroundTool.h> 0046 0047 #include "KPrDocument.h" 0048 #include "KPrPart.h" 0049 #include "KPrPage.h" 0050 #include "KPrMasterPage.h" 0051 #include "KPrPageApplicationData.h" 0052 0053 #ifndef QT_NO_DBUS 0054 #include "KPrViewAdaptor.h" 0055 #endif 0056 0057 #include "KPrViewModePresentation.h" 0058 #include "KPrViewModeNotes.h" 0059 #include "KPrViewModeSlidesSorter.h" 0060 #include "KPrShapeManagerDisplayMasterStrategy.h" 0061 #include "KPrPageSelectStrategyActive.h" 0062 #include "KPrPicturesImport.h" 0063 #include "KPrFactory.h" 0064 #include "commands/KPrAnimationCreateCommand.h" 0065 #include "KPrPageLayoutWidget.h" 0066 #include "KPrHtmlExport.h" 0067 #include "KPrCustomSlideShows.h" 0068 #include "ui/KPrConfigureSlideShowDialog.h" 0069 #include "ui/KPrConfigurePresenterViewDialog.h" 0070 #include "ui/KPrHtmlExportDialog.h" 0071 0072 #include "KPrPdfPrintJob.h" 0073 #include "gemini/ViewModeSwitchEvent.h" 0074 0075 KPrView::KPrView(KPrPart *part, KPrDocument *document, QWidget *parent) 0076 : KoPAView(part, document, KoPAView::ModeBox, parent) 0077 , m_part(part) 0078 , m_presentationMode( new KPrViewModePresentation( this, kopaCanvas() )) 0079 , m_normalMode( viewMode() ) 0080 , m_notesMode( new KPrViewModeNotes( this, kopaCanvas() )) 0081 , m_slidesSorterMode(new KPrViewModeSlidesSorter(this, kopaCanvas())) 0082 #ifndef QT_NO_DBUS 0083 , m_dbus( new KPrViewAdaptor( this ) ) 0084 #endif 0085 { 0086 m_normalMode->setName(i18n("Normal")); 0087 initGUI(); 0088 initActions(); 0089 0090 // Change strings because in Stage it's called slides and not pages 0091 actionCollection()->action("view_masterpages")->setText(i18n("Show Master Slides")); 0092 actionCollection()->action("import_document")->setText(i18n("Import Slideshow...")); 0093 actionCollection()->action("page_insertpage")->setText(i18n( "Insert Slide")); 0094 actionCollection()->action("page_insertpage")->setToolTip(i18n("Insert a new slide after the current one")); 0095 actionCollection()->action("page_insertpage")->setWhatsThis(i18n("Insert a new slide after the current one")); 0096 actionCollection()->action("page_copypage")->setText(i18n("Copy Slide")); 0097 actionCollection()->action("page_copypage")->setToolTip(i18n("Copy the current slide")); 0098 actionCollection()->action("page_copypage")->setWhatsThis(i18n("Copy the current slide")); 0099 actionCollection()->action("page_deletepage")->setText(i18n("Delete Slide")); 0100 actionCollection()->action("page_deletepage")->setToolTip(i18n("Delete the current slide")); 0101 actionCollection()->action("page_deletepage")->setWhatsThis(i18n("Delete the current slide")); 0102 actionCollection()->action("format_masterpage")->setText(i18n("Master Slide...")); 0103 actionCollection()->action("page_previous")->setText(i18n("Previous Slide")); 0104 actionCollection()->action("page_previous")->setToolTip(i18n("Go to previous slide")); 0105 actionCollection()->action("page_previous")->setWhatsThis(i18n("Go to previous slide")); 0106 actionCollection()->action("page_next")->setText(i18n("Next Slide")); 0107 actionCollection()->action("page_next")->setToolTip(i18n("Go to next slide")); 0108 actionCollection()->action("page_next")->setWhatsThis(i18n("Go to next slide")); 0109 actionCollection()->action("page_first")->setText(i18n("First Slide")); 0110 actionCollection()->action("page_first")->setToolTip(i18n("Go to first slide")); 0111 actionCollection()->action("page_first")->setWhatsThis(i18n("Go to first slide")); 0112 actionCollection()->action("page_last")->setText(i18n("Last Slide")); 0113 actionCollection()->action("page_last")->setToolTip(i18n("Go to last slide")); 0114 actionCollection()->action("page_last")->setWhatsThis(i18n("Go to last slide")); 0115 actionCollection()->action("configure")->setText(i18n("Configure Stage...")); 0116 0117 masterShapeManager()->setPaintingStrategy( new KPrShapeManagerDisplayMasterStrategy( masterShapeManager(), 0118 new KPrPageSelectStrategyActive( kopaCanvas() ) ) ); 0119 0120 connect(zoomController(), SIGNAL(zoomChanged(KoZoomMode::Mode,qreal)), this, SLOT(zoomChanged(KoZoomMode::Mode,qreal))); 0121 0122 setAcceptDrops(true); 0123 } 0124 0125 KPrView::~KPrView() 0126 { 0127 stopPresentation(); 0128 saveZoomConfig(zoomMode(), zoom()); 0129 delete m_presentationMode; 0130 delete m_notesMode; 0131 delete m_slidesSorterMode; 0132 } 0133 0134 KoViewConverter * KPrView::viewConverter( KoPACanvasBase * canvas ) 0135 { 0136 Q_ASSERT(viewMode()); 0137 return viewMode()->viewConverter( canvas ); 0138 } 0139 0140 KPrDocument * KPrView::kprDocument() const 0141 { 0142 return static_cast<KPrDocument *>( kopaDocument() ); 0143 } 0144 0145 #ifndef QT_NO_DBUS 0146 KPrViewAdaptor * KPrView::dbusObject() const 0147 { 0148 return m_dbus; 0149 } 0150 #endif 0151 0152 KPrViewModePresentation * KPrView::presentationMode() const 0153 { 0154 return m_presentationMode; 0155 } 0156 0157 0158 KPrViewModeSlidesSorter * KPrView::slidesSorter() const 0159 { 0160 return m_slidesSorterMode; 0161 } 0162 0163 bool KPrView::isPresentationRunning() const 0164 { 0165 return ( viewMode() == m_presentationMode ); 0166 } 0167 0168 void KPrView::drawOnPresentation() 0169 { 0170 if (isPresentationRunning()) 0171 { 0172 m_presentationMode->presentationTool()->drawOnPresentation(); 0173 } 0174 } 0175 0176 void KPrView::highlightPresentation() 0177 { 0178 if (isPresentationRunning()) 0179 { 0180 m_presentationMode->presentationTool()->highlightPresentation(); 0181 } 0182 } 0183 0184 void KPrView::blackPresentation() 0185 { 0186 if (isPresentationRunning()) 0187 { 0188 m_presentationMode->presentationTool()->blackPresentation(); 0189 } 0190 } 0191 0192 void KPrView::showStatusBar(bool toggled) 0193 { 0194 statusBar()->setVisible(toggled); 0195 } 0196 0197 void KPrView::initGUI() 0198 { 0199 // add page effect docker to the main window 0200 /* 0201 if (mainWindow()) { 0202 KPrPageLayoutDockerFactory pageLayoutFactory; 0203 KPrPageLayoutDocker *pageLayoutDocker = qobject_cast<KPrPageLayoutDocker*>( mainWindow()->createDockWidget( &pageLayoutFactory ) ); 0204 pageLayoutDocker->setView( this ); 0205 } 0206 }*/ 0207 KoPABackgroundTool *designTool = dynamic_cast<KoPABackgroundTool *>(KoToolManager::instance()->toolById(kopaCanvas(), "KoPABackgroundTool")); 0208 if (designTool) { 0209 KPrPageLayoutWidget *plw = new KPrPageLayoutWidget(); 0210 plw->setView(this); 0211 designTool->addOptionWidget(plw); 0212 } 0213 KConfigGroup group( KSharedConfig::openConfig(), "stage" ); 0214 if ( !group.hasKey( "State" ) ) { 0215 QString state = "AAAA/wAAAAD9AAAAAgAAAAAAAAEHAAACdfwCAAAAA/sAAAAOAFQAbwBvAGwAQgBvAHgBAAAAUgAAAF8AAABIAP////sAAAAuAEsAbwBTAGgAYQBwAGUAQwBvAGwAbABlAGMAdABpAG8AbgBEAG8AYwBrAGUAcgEAAAC0AAAAZQAAAE0A////+wAAACoAZABvAGMAdQBtAGUAbgB0ACAAcwBlAGMAdABpAG8AbgAgAHYAaQBlAHcBAAABHAAAAasAAABvAP///wAAAAEAAADlAAACdfwCAAAAEPsAAAAgAFMAaABhAHAAZQAgAFAAcgBvAHAAZQByAHQAaQBlAHMAAAAAAP////8AAAAYAP////sAAAAiAFMAaABhAGQAbwB3ACAAUAByAG8AcABlAHIAdABpAGUAcwAAAAAA/////wAAAJ8A////+wAAACQAUwBpAG0AcABsAGUAIABUAGUAeAB0ACAARQBkAGkAdABvAHIAAAAAAP////8AAAFOAP////sAAAAwAEQAZQBmAGEAdQBsAHQAVABvAG8AbABBAHIAcgBhAG4AZwBlAFcAaQBkAGcAZQB0AQAAAFIAAABOAAAATgD////7AAAAIgBEAGUAZgBhAHUAbAB0AFQAbwBvAGwAVwBpAGQAZwBlAHQBAAAAowAAAGMAAABjAP////sAAAAqAFMAbgBhAHAARwB1AGkAZABlAEMAbwBuAGYAaQBnAFcAaQBkAGcAZQB0AQAAAQkAAABQAAAAUAD////7AAAAIgBTAHQAcgBvAGsAZQAgAFAAcgBvAHAAZQByAHQAaQBlAHMBAAABXAAAALcAAAC3AP////sAAAAWAFMAdAB5AGwAZQBEAG8AYwBrAGUAcgEAAAIWAAAAWAAAAFgA////+wAAABgAUwBsAGkAZABlACAAbABhAHkAbwB1AHQBAAACcQAAAFYAAABWAP////sAAAAoAFAAaQBjAHQAdQByAGUAVABvAG8AbABGAGEAYwB0AG8AcgB5AEkAZAEAAAN6AAAAMQAAAAAAAAAA+wAAACQAVABlAHgAdABUAG8AbwBsAEYAYQBjAHQAbwByAHkAXwBJAEQBAAADJwAAAIQAAAAAAAAAAPsAAAAoAEMAZQBsAGwAVABvAG8AbABPAHAAdABpAG8AbgBXAGkAZABnAGUAdAEAAALBAAAA6gAAAAAAAAAA+wAAADAASwBvAFAAQQBCAGEAYwBrAGcAcgBvAHUAbgBkAFQAbwBvAGwAVwBpAGQAZwBlAHQBAAADnQAAAFgAAAAAAAAAAPsAAAAeAEQAdQBtAG0AeQBUAG8AbwBsAFcAaQBkAGcAZQB0AQAAAqgAAAAaAAAAAAAAAAD7AAAAKABQAGEAdAB0AGUAcgBuAE8AcAB0AGkAbwBuAHMAVwBpAGQAZwBlAHQBAAACxQAAAIYAAAAAAAAAAPsAAAAoAEsAYQByAGIAbwBuAFAAYQB0AHQAZQByAG4AQwBoAG8AbwBzAGUAcgEAAANOAAAAXQAAAAAAAAAAAAADfgAAAnUAAAAEAAAABAAAAAgAAAAI/AAAAAEAAAACAAAAAQAAABYAbQBhAGkAbgBUAG8AbwBsAEIAYQByAQAAAAAAAAVwAAAAAAAAAAA="; 0216 group.writeEntry( "State", state ); 0217 } 0218 initZoomConfig(); 0219 0220 //unhide tab bar and populate with view modes 0221 setTabBarPosition(Qt::Horizontal); 0222 tabBar()->show(); 0223 tabBar()->addTab(m_normalMode->name()); 0224 tabBar()->addTab(m_notesMode->name()); 0225 tabBar()->addTab(m_slidesSorterMode->name()); 0226 tabBar()->setCurrentIndex(0); 0227 } 0228 0229 void KPrView::initActions() 0230 { 0231 setComponentName(KPrFactory::componentData().componentName(), KPrFactory::componentData().componentDisplayName()); 0232 if (!koDocument()->isReadWrite() ) 0233 setXMLFile( "calligrastage_readonly.rc" ); 0234 else 0235 setXMLFile( "calligrastage.rc" ); 0236 0237 // do special stage stuff here 0238 m_actionExportHtml = new QAction(i18n("Export as HTML..."), this); 0239 actionCollection()->addAction("file_export_html", m_actionExportHtml); 0240 connect(m_actionExportHtml, SIGNAL(triggered()), this, SLOT(exportToHtml())); 0241 0242 m_actionViewModeNormal = new QAction(m_normalMode->name(), this); 0243 m_actionViewModeNormal->setCheckable(true); 0244 m_actionViewModeNormal->setChecked(true); 0245 actionCollection()->setDefaultShortcut(m_actionViewModeNormal, QKeySequence("CTRL+F5")); 0246 actionCollection()->addAction("view_normal", m_actionViewModeNormal); 0247 connect(m_actionViewModeNormal, SIGNAL(triggered()), this, SLOT(showNormal())); 0248 0249 m_actionViewModeNotes = new QAction(m_notesMode->name(), this); 0250 m_actionViewModeNotes->setCheckable(true); 0251 actionCollection()->setDefaultShortcut(m_actionViewModeNotes, QKeySequence("CTRL+F6")); 0252 actionCollection()->addAction("view_notes", m_actionViewModeNotes); 0253 connect(m_actionViewModeNotes, SIGNAL(triggered()), this, SLOT(showNotes())); 0254 0255 m_actionViewModeSlidesSorter = new QAction(m_slidesSorterMode->name(), this); 0256 m_actionViewModeSlidesSorter->setCheckable(true); 0257 actionCollection()->setDefaultShortcut(m_actionViewModeSlidesSorter, QKeySequence("CTRL+F7")); 0258 actionCollection()->addAction("view_slides_sorter", m_actionViewModeSlidesSorter); 0259 connect(m_actionViewModeSlidesSorter, SIGNAL(triggered()), this, SLOT(showSlidesSorter())); 0260 0261 if ( QAction *action = actionCollection()->action("view_masterpages") ) 0262 actionCollection()->setDefaultShortcut(action, QKeySequence("CTRL+F8")); 0263 0264 m_actionInsertPictures = new QAction(i18n("Insert Pictures as Slides..."), this); 0265 actionCollection()->addAction("insert_pictures", m_actionInsertPictures); 0266 connect(m_actionInsertPictures, SIGNAL(triggered()), this, SLOT(insertPictures())); 0267 0268 QActionGroup *viewModesGroup = new QActionGroup(this); 0269 viewModesGroup->addAction(m_actionViewModeNormal); 0270 viewModesGroup->addAction(m_actionViewModeNotes); 0271 viewModesGroup->addAction(m_actionViewModeSlidesSorter); 0272 0273 m_actionCreateAnimation = new QAction( i18n( "Create Appear Animation" ), this ); 0274 actionCollection()->addAction( "edit_createanimation", m_actionCreateAnimation ); 0275 connect( m_actionCreateAnimation, SIGNAL(triggered()), this, SLOT(createAnimation()) ); 0276 0277 m_actionEditCustomSlideShows = new QAction( i18n( "Edit Custom Slide Shows..." ), this ); 0278 actionCollection()->addAction( "edit_customslideshows", m_actionEditCustomSlideShows ); 0279 connect( m_actionEditCustomSlideShows, SIGNAL(triggered()), this, SLOT(editCustomSlideShows()) ); 0280 0281 KActionMenu *actionStartPresentation = new KActionMenu(koIcon("view-presentation"), i18n("Start Presentation"), this); 0282 actionCollection()->addAction( "slideshow_start", actionStartPresentation ); 0283 connect( actionStartPresentation, SIGNAL(triggered()), this, SLOT(startPresentation()) ); // for the toolbar button 0284 QAction* action = new QAction( i18n( "From Current Slide" ), this ); 0285 action->setShortcut(QKeySequence("Shift+F5")); 0286 actionStartPresentation->addAction( action ); 0287 connect( action, SIGNAL(triggered()), this, SLOT(startPresentation()) ); 0288 action = new QAction( i18n( "From First Slide" ), this ); 0289 action->setShortcut(QKeySequence("F5")); 0290 actionStartPresentation->addAction( action ); 0291 connect( action, SIGNAL(triggered()), this, SLOT(startPresentationFromBeginning()) ); 0292 0293 m_actionStopPresentation = new QAction( i18n( "Stop presentation" ), this ); 0294 actionCollection()->addAction( "slideshow_stop", m_actionStopPresentation ); 0295 m_actionStopPresentation->setShortcut(Qt::Key_Escape); 0296 connect(m_actionStopPresentation, SIGNAL(triggered()), this, SLOT(stopPresentation())); 0297 m_actionStopPresentation->setEnabled(false); 0298 0299 KToggleAction *showStatusbarAction = new KToggleAction(i18n("Show Status Bar"), this); 0300 showStatusbarAction->setCheckedState(KGuiItem(i18n("Hide Status Bar"))); 0301 showStatusbarAction->setToolTip(i18n("Shows or hides the status bar")); 0302 actionCollection()->addAction("showStatusBar", showStatusbarAction); 0303 connect(showStatusbarAction, SIGNAL(toggled(bool)), this, SLOT(showStatusBar(bool))); 0304 0305 //Update state of status bar action 0306 if (showStatusbarAction && statusBar()){ 0307 showStatusbarAction->setChecked(! statusBar()->isHidden()); 0308 } 0309 0310 action = new QAction( i18n( "Configure Slide Show..." ), this ); 0311 actionCollection()->addAction( "slideshow_configure", action ); 0312 connect( action, SIGNAL(triggered()), this, SLOT(configureSlideShow()) ); 0313 0314 action = new QAction( i18n( "Configure Presenter View..." ), this ); 0315 actionCollection()->addAction( "slideshow_presenterview", action ); 0316 connect( action, SIGNAL(triggered()), this, SLOT(configurePresenterView()) ); 0317 0318 m_actionDrawOnPresentation = new QAction( i18n( "Draw on the presentation..." ), this ); 0319 actionCollection()->setDefaultShortcut(m_actionDrawOnPresentation, Qt::Key_P); 0320 m_actionDrawOnPresentation->setShortcutContext(Qt::ApplicationShortcut); 0321 actionCollection()->addAction( "draw_on_presentation", m_actionDrawOnPresentation ); 0322 connect( m_actionDrawOnPresentation, SIGNAL(triggered()), this, SLOT(drawOnPresentation()) ); 0323 m_actionDrawOnPresentation->setEnabled(false); 0324 0325 m_actionHighlightPresentation = new QAction( i18n( "Highlight the presentation..." ), this ); 0326 actionCollection()->setDefaultShortcut(m_actionHighlightPresentation, Qt::Key_H); 0327 m_actionHighlightPresentation->setShortcutContext(Qt::ApplicationShortcut); 0328 actionCollection()->addAction( "highlight_presentation", m_actionHighlightPresentation ); 0329 connect( m_actionHighlightPresentation, SIGNAL(triggered()), this, SLOT(highlightPresentation()) ); 0330 m_actionHighlightPresentation->setEnabled(false); 0331 0332 m_actionBlackPresentation = new QAction( i18n( "Blackscreen on the presentation..." ), this ); 0333 actionCollection()->setDefaultShortcut(m_actionBlackPresentation, Qt::Key_B); 0334 m_actionBlackPresentation->setShortcutContext(Qt::ApplicationShortcut); 0335 actionCollection()->addAction( "black_presentation", m_actionBlackPresentation ); 0336 connect( m_actionBlackPresentation, SIGNAL(triggered()), this, SLOT(blackPresentation()) ); 0337 m_actionBlackPresentation->setEnabled(false); 0338 0339 connect(tabBar(), SIGNAL(currentChanged(int)), this, SLOT(changeViewByIndex(int))); 0340 } 0341 0342 bool KPrView::event(QEvent* event) 0343 { 0344 switch(static_cast<int>(event->type())) { 0345 case ViewModeSwitchEvent::AboutToSwitchViewModeEvent: { 0346 ViewModeSynchronisationObject* syncObject = static_cast<ViewModeSwitchEvent*>(event)->synchronisationObject(); 0347 if (activePage()) { 0348 syncObject->currentIndex = kopaDocument()->pageIndex(activePage()); 0349 syncObject->shapes = shapeManager()->shapes(); 0350 syncObject->initialized = true; 0351 } 0352 0353 return true; 0354 } 0355 case ViewModeSwitchEvent::SwitchedToDesktopModeEvent: { 0356 ViewModeSynchronisationObject* syncObject = static_cast<ViewModeSwitchEvent*>(event)->synchronisationObject(); 0357 if (syncObject->initialized) { 0358 shapeManager()->setShapes(syncObject->shapes); 0359 doUpdateActivePage( kopaDocument()->pageByIndex(syncObject->currentIndex, false) ); 0360 KoToolManager::instance()->switchToolRequested("InteractionTool"); 0361 } 0362 0363 return true; 0364 } 0365 } 0366 return QWidget::event(event); 0367 } 0368 0369 void KPrView::startPresentation() 0370 { 0371 m_actionDrawOnPresentation->setEnabled(true); 0372 m_actionHighlightPresentation->setEnabled(true); 0373 m_actionBlackPresentation->setEnabled(true); 0374 m_actionStopPresentation->setEnabled(true); 0375 setViewMode( m_presentationMode ); 0376 } 0377 0378 void KPrView::startPresentationFromBeginning() 0379 { 0380 KPrDocument * doc = static_cast<KPrDocument *>( kopaDocument() ); 0381 QList<KoPAPageBase*> slideshow = doc->slideShow(); 0382 if ( !slideshow.isEmpty() ) { 0383 setActivePage( slideshow.first() ); 0384 } 0385 startPresentation(); 0386 } 0387 0388 void KPrView::stopPresentation() 0389 { 0390 m_actionDrawOnPresentation->setEnabled(false); 0391 m_actionHighlightPresentation->setEnabled(false); 0392 m_actionBlackPresentation->setEnabled(false); 0393 m_actionStopPresentation->setEnabled(false); 0394 0395 if ( isPresentationRunning() ) { 0396 m_presentationMode->activateSavedViewMode(); 0397 } 0398 } 0399 0400 void KPrView::createAnimation() 0401 { 0402 static int animationcount = 0; 0403 KoSelection * selection = kopaCanvas()->shapeManager()->selection(); 0404 QList<KoShape*> selectedShapes = selection->selectedShapes(); 0405 foreach( KoShape * shape, selectedShapes ) 0406 { 0407 Q_UNUSED(shape); 0408 /*KPrShapeAnimationOld * animation = new KPrAnimationMoveAppear( shape, animationcount ); 0409 KPrDocument * doc = static_cast<KPrDocument *>( kopaDocument() ); 0410 KPrAnimationCreateCommand * command = new KPrAnimationCreateCommand( doc, animation ); 0411 kopaCanvas()->addCommand( command );*/ 0412 } 0413 animationcount = ( animationcount + 1 ) % 3; 0414 } 0415 0416 void KPrView::showNormal() 0417 { 0418 setViewMode(m_normalMode); 0419 QAction *action = actionCollection()->action("view_normal"); 0420 tabBar()->setCurrentIndex(0); 0421 if (action){ 0422 action-> setChecked(true); 0423 } 0424 } 0425 0426 void KPrView::showNotes() 0427 { 0428 // Make sure that we are not in master mode 0429 // since notes master is not supported yet 0430 if ( viewMode()->masterMode() ) { 0431 actionCollection()->action( "view_masterpages" )->setChecked( false ); 0432 setMasterMode( false ); 0433 } 0434 tabBar()->setCurrentIndex(1); 0435 setViewMode(m_notesMode); 0436 } 0437 0438 void KPrView::showSlidesSorter() 0439 { 0440 // Make sure that we are not in master mode 0441 // Sort master does not make sense 0442 if ( viewMode()->masterMode() ) { 0443 actionCollection()->action( "view_masterpages" )->setChecked( false ); 0444 setMasterMode( false ); 0445 } 0446 tabBar()->setCurrentIndex(2); 0447 setViewMode(m_slidesSorterMode); 0448 } 0449 0450 0451 void KPrView::changeViewByIndex(int index) 0452 { 0453 switch (index) { 0454 case 0: 0455 m_actionViewModeNormal->trigger(); 0456 break; 0457 case 1: 0458 m_actionViewModeNotes->trigger(); 0459 break; 0460 case 2: 0461 m_actionViewModeSlidesSorter->trigger(); 0462 break; 0463 default: 0464 break; 0465 } 0466 } 0467 0468 void KPrView::editCustomSlideShows() 0469 { 0470 slidesSorter()->setActiveCustomSlideShow(1); 0471 showSlidesSorter(); 0472 } 0473 0474 void KPrView::configureSlideShow() 0475 { 0476 KPrDocument *doc = static_cast<KPrDocument *>( kopaDocument() ); 0477 KPrConfigureSlideShowDialog *dialog = new KPrConfigureSlideShowDialog(doc, this); 0478 0479 if ( dialog->exec() == QDialog::Accepted ) { 0480 doc->setActiveCustomSlideShow( dialog->activeCustomSlideShow() ); 0481 } 0482 delete dialog; 0483 } 0484 0485 void KPrView::configurePresenterView() 0486 { 0487 KPrDocument *doc = static_cast<KPrDocument *>( kopaDocument() ); 0488 KPrConfigurePresenterViewDialog *dialog = new KPrConfigurePresenterViewDialog( doc, this ); 0489 0490 if ( dialog->exec() == QDialog::Accepted ) { 0491 doc->setPresentationMonitor( dialog->presentationMonitor() ); 0492 doc->setPresenterViewEnabled( dialog->presenterViewEnabled() ); 0493 } 0494 delete dialog; 0495 } 0496 0497 void KPrView::exportToHtml() 0498 { 0499 KPrHtmlExportDialog *dialog = new KPrHtmlExportDialog(kopaDocument()->pages(),koDocument()->documentInfo()->aboutInfo("title"), 0500 koDocument()->documentInfo()->authorInfo("creator"), this); 0501 if (dialog->exec() == QDialog::Accepted && !dialog->checkedSlides().isEmpty()) { 0502 // Get the export directory 0503 QUrl directoryUrl = QFileDialog::getExistingDirectoryUrl(); 0504 if (directoryUrl.isValid()) { 0505 KPrHtmlExport exportHtml; 0506 exportHtml.exportHtml(KPrHtmlExport::Parameter(dialog->templateUrl(), this, dialog->checkedSlides(), 0507 directoryUrl, dialog->author(), 0508 dialog->title(), dialog->slidesNames(), dialog->openBrowser())); 0509 } 0510 } 0511 } 0512 0513 KoPrintJob *KPrView::createPdfPrintJob() 0514 { 0515 return new KPrPdfPrintJob(this); 0516 } 0517 0518 0519 void KPrView::insertPictures() 0520 { 0521 // Make sure that we are in the normal mode and not on master pages 0522 setViewMode(m_normalMode); 0523 if (viewMode()->masterMode()) { 0524 setMasterMode(false); 0525 } 0526 KPrPicturesImport pictureImport; 0527 pictureImport.import(this); 0528 } 0529 0530 void KPrView::initZoomConfig() 0531 { 0532 KSharedConfigPtr config = KPrFactory::componentData().config(); 0533 int m_zoom = 100; 0534 KoZoomMode::Mode m_zoomMode = KoZoomMode::ZOOM_PAGE; 0535 0536 if (config->hasGroup("Interface")) { 0537 const KConfigGroup interface = config->group("Interface"); 0538 m_zoom = interface.readEntry("Zoom", m_zoom); 0539 m_zoomMode = static_cast<KoZoomMode::Mode>(interface.readEntry("ZoomMode", (int) m_zoomMode)); 0540 } 0541 zoomController()->setZoom(m_zoomMode, m_zoom/100.); 0542 setZoom(m_zoomMode, m_zoom); 0543 centerPage(); 0544 } 0545 0546 void KPrView::zoomChanged(KoZoomMode::Mode mode, qreal zoom) 0547 { 0548 setZoom(mode, qRound(zoom * 100.)); 0549 } 0550 0551 void KPrView::saveZoomConfig(KoZoomMode::Mode mode, int zoom) 0552 { 0553 KSharedConfigPtr config = KPrFactory::componentData().config(); 0554 0555 if (config->hasGroup("Interface")) { 0556 KConfigGroup interface = config->group("Interface"); 0557 interface.writeEntry("Zoom", zoom); 0558 interface.writeEntry("ZoomMode", (int)mode); 0559 } 0560 } 0561 0562 void KPrView::setZoom(KoZoomMode::Mode zoomMode, int zoom) 0563 { 0564 m_zoom = zoom; 0565 m_zoomMode = zoomMode; 0566 } 0567 0568 int KPrView::zoom() 0569 { 0570 return m_zoom; 0571 } 0572 0573 KoZoomMode::Mode KPrView::zoomMode() 0574 { 0575 return m_zoomMode; 0576 } 0577 0578 void KPrView::restoreZoomConfig() 0579 { 0580 zoomController()->setZoom(zoomMode(), zoom()/100.); 0581 centerPage(); 0582 } 0583 0584 void KPrView::replaceActivePage(KoPAPageBase *page, KoPAPageBase *newActivePage) 0585 { 0586 if (page == activePage() ) { 0587 viewMode()->updateActivePage(newActivePage); 0588 } 0589 }