diff --git a/stage/part/CMakeLists.txt b/stage/part/CMakeLists.txt --- a/stage/part/CMakeLists.txt +++ b/stage/part/CMakeLists.txt @@ -69,6 +69,7 @@ KPrCustomSlideShowsModel.cpp KPrSlidesSorterItemDelegate.cpp KPrPageLayoutWidget.cpp + KPrPageTransition.cpp commands/KPrAnimationCreateCommand.cpp commands/KPrAnimationRemoveCommand.cpp @@ -83,6 +84,7 @@ commands/KPrAnimationEditNodeTypeCommand.cpp commands/KPrReorderAnimationCommand.cpp commands/KPrReplaceAnimationCommand.cpp + commands/KPrPageTransitionSetCommand.cpp dockers/KPrPreviewWidget.cpp diff --git a/stage/part/KPrAnimationDirector.h b/stage/part/KPrAnimationDirector.h --- a/stage/part/KPrAnimationDirector.h +++ b/stage/part/KPrAnimationDirector.h @@ -26,6 +26,8 @@ #include #include #include +#include + #include #include "KPrShapeAnimations.h" @@ -41,6 +43,7 @@ class KPrPage; class KPrShapeAnimation; + class KPrAnimationDirector : public QObject { Q_OBJECT @@ -55,6 +58,13 @@ LastPage }; + enum State + { + PresentationState, + EntryEffectState, + EntryAnimationState + }; + KPrAnimationDirector( KoPAView * view, KoPACanvas * canvas, const QList & pages, KoPAPageBase* currentPage ); ~KPrAnimationDirector() override; @@ -97,6 +107,8 @@ void deactivate(); + KoPAPageBase *page(int index) const; + protected: // set the page to be shon and update the UI void updateActivePage( KoPAPageBase * page ); @@ -135,9 +147,16 @@ // helper method for freeing the resources of the animations void clearAnimations(); - // check if there is a set animation in m_animations bool hasAnimation() const; + bool animationRunning() const; + bool moreAnimationSteps() const; + + bool hasPageEffect() const; + bool pageEffectRunning() const; + + bool hasAutoSlideTransition() const; + void startAutoSlideTransition(); void updatePageAnimation(); void updateStepAnimation(); @@ -148,6 +167,9 @@ // acts on the time line event void animate(); + void nextPage(); + void slotTimelineFinished(); + private: KoPAView * m_view; KoPACanvas * m_canvas; @@ -166,6 +188,9 @@ // true when there is an animation in this step bool m_hasAnimation; KPrAnimationCache * m_animationCache; + + State m_state; + QTimer m_autoTransitionTimer; }; #endif /* KPRANIMATIONDIRECTOR_H */ diff --git a/stage/part/KPrAnimationDirector.cpp b/stage/part/KPrAnimationDirector.cpp --- a/stage/part/KPrAnimationDirector.cpp +++ b/stage/part/KPrAnimationDirector.cpp @@ -51,10 +51,12 @@ #include "pageeffects/KPrPageEffectRunner.h" #include "pageeffects/KPrPageEffect.h" #include "KPrShapeAnimations.h" +#include "KPrPageTransition.h" #include "StageDebug.h" #include "animations/KPrAnimationCache.h" + KPrAnimationDirector::KPrAnimationDirector( KoPAView * view, KoPACanvas * canvas, const QList & pages, KoPAPageBase* currentPage ) : m_view( view ) , m_canvas( canvas ) @@ -64,6 +66,7 @@ , m_maxShapeDuration( 0 ) , m_hasAnimation( false ) , m_animationCache( 0 ) +, m_state(PresentationState) { Q_ASSERT( !m_pages.empty() ); m_animationCache = new KPrAnimationCache(); @@ -87,8 +90,16 @@ m_canvas->masterShapeManager()->setPaintingStrategy( new KPrShapeManagerAnimationStrategy( m_canvas->masterShapeManager(), m_animationCache, new KPrPageSelectStrategyActive( m_view->kopaCanvas() ) ) ); - if ( hasAnimation() ) { - startTimeLine( m_animations.at(m_stepIndex)->totalDuration() ); + + m_autoTransitionTimer.setSingleShot(true); + connect(&m_autoTransitionTimer, SIGNAL(timeout()), this, SLOT(nextPage())); + connect(&m_timeLine, SIGNAL(finished()), this, SLOT(slotTimelineFinished())); + if (hasAutoSlideTransition()) { + if (hasPageEffect() || hasAnimation()) { + nextStep(); + } else { + startAutoSlideTransition(); + } } } @@ -154,6 +165,11 @@ return m_pages.size(); } +KoPAPageBase *KPrAnimationDirector::page(int index) const +{ + return m_pages.value(index); +} + int KPrAnimationDirector::currentPage() const { return m_pageIndex; @@ -233,10 +249,6 @@ updateStepAnimation(); // trigger a repaint m_canvas->update(); - - if ( hasAnimation() ) { - startTimeLine( m_animations.at(m_stepIndex)->totalDuration() ); - } } void KPrAnimationDirector::updateActivePage( KoPAPageBase * page ) @@ -342,10 +354,6 @@ // trigger a repaint m_canvas->update(); - if ( hasAnimation() ) { - startTimeLine( m_animations.at(m_stepIndex)->totalDuration() ); - } - return false; } @@ -390,6 +398,7 @@ if ( m_stepIndex < numStepsInPage() - 1 ) { // if there are sub steps go to the next substep ++m_stepIndex; + m_state = EntryAnimationState; updateStepAnimation(); startTimeLine(m_animations.at(m_stepIndex)->totalDuration()); } @@ -422,6 +431,7 @@ newPainter.setRenderHint( QPainter::Antialiasing ); paintStep( newPainter ); + m_state = EntryEffectState; m_pageEffectRunner = new KPrPageEffectRunner( oldPage, newPage, m_canvas, effect ); startTimeLine( effect->duration() ); } @@ -431,13 +441,24 @@ updateStepAnimation(); m_canvas->update(); if ( hasAnimation() ) { + m_state = EntryAnimationState; startTimeLine( m_animations.at(m_stepIndex)->totalDuration() ); + } else if (hasAutoSlideTransition()) { + m_state = PresentationState; + startAutoSlideTransition(); + } else { + m_state = PresentationState; } } } return false; } +void KPrAnimationDirector::nextPage() +{ + nextStep(); +} + void KPrAnimationDirector::previousStep() { if ( m_stepIndex > 0 ) { @@ -465,11 +486,39 @@ finishAnimations(); } +bool KPrAnimationDirector::hasAutoSlideTransition() const +{ + return KPrPage::pageData( m_pages[m_pageIndex] )->pageTransition().type() == KPrPageTransition::Automatic; +} + +void KPrAnimationDirector::startAutoSlideTransition() +{ + m_autoTransitionTimer.start(KPrPage::pageData( m_pages[m_pageIndex] )->pageTransition().milliseconds()); +} + +bool KPrAnimationDirector::pageEffectRunning() const +{ + return m_pageEffectRunner; +} + +bool KPrAnimationDirector::hasPageEffect() const +{ + return KPrPage::pageData( m_pages[m_pageIndex] )->pageEffect() != nullptr; +} + +bool KPrAnimationDirector::animationRunning() const +{ + return hasAnimation() && m_timeLine.state() != QTimeLine::NotRunning; +} bool KPrAnimationDirector::hasAnimation() const { return m_animations.size() > 0; } +bool KPrAnimationDirector::moreAnimationSteps() const +{ + return m_stepIndex < m_animations.size() - 1; +} void KPrAnimationDirector::animate() { @@ -488,6 +537,7 @@ { m_animationCache->endStep(m_stepIndex); m_canvas->update(); + m_state = PresentationState; } void KPrAnimationDirector::startTimeLine( int duration ) @@ -502,8 +552,44 @@ m_timeLine.start(); } +void KPrAnimationDirector::slotTimelineFinished() +{ + switch (m_state) { + case PresentationState: + break; + case EntryEffectState: + if (hasAutoSlideTransition()) { + if (hasAnimation()) { + nextStep(); + } else { + m_state = PresentationState; + startAutoSlideTransition(); + } + } else { + m_state = PresentationState; + } + break; + case EntryAnimationState: + if (hasAutoSlideTransition()) { + if (moreAnimationSteps()) { + nextStep(); + } else if (hasAutoSlideTransition()) { + m_state = PresentationState; + startAutoSlideTransition(); + } else { + m_state = PresentationState; + } + } else { + m_state = PresentationState; + } + break; + } +} + void KPrAnimationDirector::deactivate() { + m_state = PresentationState; + m_autoTransitionTimer.stop(); foreach (KPrAnimationStep *step, m_animations) { step->deactivate(); } diff --git a/stage/part/KPrPage.cpp b/stage/part/KPrPage.cpp --- a/stage/part/KPrPage.cpp +++ b/stage/part/KPrPage.cpp @@ -176,6 +176,8 @@ } } } + // load page transition + data->pageTransition().loadOdfAttributes(element, context); return true; } @@ -226,6 +228,7 @@ if ( pageEffect ) { pageEffect->saveOdfSmilAttributes( style ); } + data->pageTransition().saveOdfAttributes(style); } void KPrPage::loadOdfPageTag( const KoXmlElement &element, KoPALoadingContext &loadingContext ) diff --git a/stage/part/KPrPageApplicationData.h b/stage/part/KPrPageApplicationData.h --- a/stage/part/KPrPageApplicationData.h +++ b/stage/part/KPrPageApplicationData.h @@ -1,5 +1,6 @@ /* This file is part of the KDE project Copyright (C) 2007 Thorsten Zachmann + Copyright (C) 2020 Dag Andersen This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -21,8 +22,16 @@ #include "stage_export.h" +#include "KPrPageTransition.h" + #include +#include + +class KoGenStyle; +class KoShapeLoadingContext; +class KoXmlElement; + class KPrPageEffect; class STAGE_EXPORT KPrPageApplicationData : public KoShapeApplicationData @@ -41,8 +50,18 @@ */ void setPageEffect( KPrPageEffect * effect ); + /** + * Get the page transition + */ + KPrPageTransition &pageTransition(); + /** + * Set the page transition + */ + void setPageTransition(const KPrPageTransition &transition); + private: KPrPageEffect * m_pageEffect; + KPrPageTransition m_pageTransition; }; #endif // KPRPAGEAPPLICATIONDATA_H diff --git a/stage/part/KPrPageApplicationData.cpp b/stage/part/KPrPageApplicationData.cpp --- a/stage/part/KPrPageApplicationData.cpp +++ b/stage/part/KPrPageApplicationData.cpp @@ -1,5 +1,6 @@ /* This file is part of the KDE project Copyright (C) 2007 Thorsten Zachmann + Copyright (C) 2020 Dag Andersen This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -39,3 +40,13 @@ { m_pageEffect = effect; } + +KPrPageTransition &KPrPageApplicationData::pageTransition() +{ + return m_pageTransition; +} + +void KPrPageApplicationData::setPageTransition( const KPrPageTransition &pageTransition ) +{ + m_pageTransition = pageTransition; +} diff --git a/stage/part/KPrPageTransition.h b/stage/part/KPrPageTransition.h new file mode 100644 --- /dev/null +++ b/stage/part/KPrPageTransition.h @@ -0,0 +1,70 @@ +/* This file is part of the KDE project + * Copyright (C) 2020 Dag Andersen + * + * 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. + */ + +#ifndef KPRPAGETRANSITION_H +#define KPRPAGETRANSITION_H + +#include "stage_export.h" + +#include +#include + +class KoShapeLoadingContext; +class KoXmlElement; +class KoGenStyle; + +class STAGE_EXPORT KPrPageTransition +{ +public: + KPrPageTransition(); + + /// Odf 20.233 presentation:transition-type + /// The presentation:transition-type attribute specifies the mode of a transition. + enum Type { + Manual, /// Slide transition and shape effects are started separately by the user + Automatic, /// Slide transition and shape effects start automatically + SemiAutomatic /// Slide transition starts automatically, shape effects are started by the user. + }; // NOTE: If this is changed, also update KPrPageEffectDocker + + /// Return the transition type + Type type() const; + /// Set the transition type to @p type + void setType(Type type); + /// Return the odf name of the type + QString odfName() const; + + /// Return the presentation duration + qreal duration() const; + /// Set presentation duration to @p duration + /// @p duration must be in seconds, e.g. 3.5 + void setDuration(qreal duration); + /// Return presentation duration in milliseconds + int milliseconds() const; + + void saveOdfAttributes(KoGenStyle &style) const; + bool loadOdfAttributes(const KoXmlElement &element, KoShapeLoadingContext &context); + +private: + Type m_type; + qreal m_duration; // duration in seconds + QMap m_odfNames; +}; +STAGE_EXPORT QDebug operator<<(QDebug dbg, const KPrPageTransition &t); + +#endif diff --git a/stage/part/KPrPageTransition.cpp b/stage/part/KPrPageTransition.cpp new file mode 100644 --- /dev/null +++ b/stage/part/KPrPageTransition.cpp @@ -0,0 +1,100 @@ +/* This file is part of the KDE project + * Copyright (C) 2020 Dag Andersen + * + * 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 "KPrPageTransition.h" + +#include +#include +#include +#include +#include +#include + + +KPrPageTransition::KPrPageTransition() +: m_type(Manual) +, m_duration(0.0) +{ + m_odfNames[Manual] = "manual"; + m_odfNames[Automatic] = "automatic"; + m_odfNames[SemiAutomatic] = "semi-automatic"; +} + +KPrPageTransition::Type KPrPageTransition::type() const +{ + return m_type; +} + +void KPrPageTransition::setType(KPrPageTransition::Type type) +{ + m_type = type; +} + +QString KPrPageTransition::odfName() const +{ + return m_odfNames[m_type]; +} + +qreal KPrPageTransition::duration() const +{ + return m_duration; +} + +void KPrPageTransition::setDuration(qreal duration) +{ + m_duration = duration; +} + +int KPrPageTransition::milliseconds() const +{ + return m_duration * 1000; +} + +void KPrPageTransition::saveOdfAttributes(KoGenStyle &style) const +{ + style.addProperty("presentation:transition-type", odfName()); + style.addProperty("presentation:duration", QString("PT%1S").arg(QString::number(m_duration))); +} + +bool KPrPageTransition::loadOdfAttributes(const KoXmlElement &element, KoShapeLoadingContext &context) +{ + KoOdfStylesReader& stylesReader = context.odfLoadingContext().stylesReader(); + const KoXmlElement * styleElement = stylesReader.findContentAutoStyle( element.attributeNS( KoXmlNS::draw, "style-name" ), "drawing-page" ); + if ( styleElement ) { + KoXmlElement element = styleElement->namedItemNS( KoXmlNS::style, "drawing-page-properties" ).toElement(); + if (!element.isNull()) { + if (element.hasAttributeNS(KoXmlNS::presentation, "transition-type")) { + m_type = m_odfNames.key(element.attributeNS(KoXmlNS::presentation, "transition-type")); + } + if (element.hasAttributeNS(KoXmlNS::presentation, "duration")) { + // NOTE: This is kept very simple as duration is specified as 'PTnS' (by LO and us) + // In general it can conform to the pattern: 'PnYndMnDTnHnMnS' + // However, as only seconds are actually used, reduces to 'PTnS' + // E.g. 'PT3.5S' for tree and a half seconds + m_duration = element.attributeNS(KoXmlNS::presentation, "duration").remove("PT").remove('S').toDouble(); + } + } + } + return true; +} + +QDebug operator<<(QDebug dbg, const KPrPageTransition &t) +{ + return dbg.noquote().nospace() << "KPrPageTransition[" << t.odfName() << ',' << t.duration() << ']'; +} diff --git a/stage/part/commands/KPrPageTransitionSetCommand.h b/stage/part/commands/KPrPageTransitionSetCommand.h new file mode 100644 --- /dev/null +++ b/stage/part/commands/KPrPageTransitionSetCommand.h @@ -0,0 +1,47 @@ +/* This file is part of the KDE project + * Copyright ( C ) 2020 Dag Andersen + * + * 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. + */ + +#ifndef KPRPAGETRANSITIONSETCOMMAND_H +#define KPRPAGETRANSITIONSETCOMMAND_H + +#include "stage_export.h" + +#include + +#include "KPrPageApplicationData.h" + +class KoPAPageBase; + +class STAGE_EXPORT KPrPageTransitionSetCommand : public KUndo2Command +{ +public: + KPrPageTransitionSetCommand(KoPAPageBase * page, const KPrPageTransition &transition, KUndo2Command *parent = nullptr); + + /// redo the command + void redo() override; + /// revert the actions done in redo + void undo() override; + +private: + KoPAPageBase *m_page; + KPrPageTransition m_new; + KPrPageTransition m_old; +}; + +#endif diff --git a/stage/part/commands/KPrPageTransitionSetCommand.cpp b/stage/part/commands/KPrPageTransitionSetCommand.cpp new file mode 100644 --- /dev/null +++ b/stage/part/commands/KPrPageTransitionSetCommand.cpp @@ -0,0 +1,43 @@ +/* This file is part of the KDE project + * Copyright ( C ) 2020 Dag Andersen + * + * 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 "KPrPageTransitionSetCommand.h" + +#include + +#include "KPrPage.h" + +KPrPageTransitionSetCommand::KPrPageTransitionSetCommand(KoPAPageBase *page, const KPrPageTransition &transition, KUndo2Command *parent) +: KUndo2Command(parent) +, m_page( page ) +, m_new(transition) +{ + m_old = KPrPage::pageData( m_page )->pageTransition(); + setText(kundo2_i18n("Modify Slide Transition")); +} + +void KPrPageTransitionSetCommand::redo() +{ + KPrPage::pageData( m_page )->setPageTransition(m_new); +} + +void KPrPageTransitionSetCommand::undo() +{ + KPrPage::pageData( m_page )->setPageTransition(m_old); +} diff --git a/stage/part/tools/animationtool/KPrPageEffectDocker.h b/stage/part/tools/animationtool/KPrPageEffectDocker.h --- a/stage/part/tools/animationtool/KPrPageEffectDocker.h +++ b/stage/part/tools/animationtool/KPrPageEffectDocker.h @@ -1,5 +1,6 @@ /* This file is part of the KDE project Copyright (C) 2007 Martin Pfeiffer + Copyright (C) 2020 Dag Andersen This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -25,6 +26,7 @@ class QComboBox; class QDoubleSpinBox; +class QTimeEdit; class QPushButton; class KPrPageEffect; class KPrPageEffectFactory; @@ -57,6 +59,7 @@ protected Q_SLOTS: void slotSubTypeChanged( int index ); void slotDurationChanged( double duration ); + void slotTransitionChanged(); void cleanup( QObject* object ); @@ -68,6 +71,8 @@ QComboBox* m_subTypeCombo; QPushButton *m_applyToAllSlidesButton; QDoubleSpinBox* m_durationSpinBox; + QComboBox *m_transitionType; + QDoubleSpinBox* m_transitionTime; KPrViewModePreviewPageEffect *m_previewMode; }; diff --git a/stage/part/tools/animationtool/KPrPageEffectDocker.cpp b/stage/part/tools/animationtool/KPrPageEffectDocker.cpp --- a/stage/part/tools/animationtool/KPrPageEffectDocker.cpp +++ b/stage/part/tools/animationtool/KPrPageEffectDocker.cpp @@ -1,6 +1,7 @@ /* This file is part of the KDE project Copyright (C) 2007 Martin Pfeiffer Copyright (C) 2007 Thorsten Zachmann + Copyright (C) 2020 Dag Andersen This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -38,9 +39,11 @@ #include "KPrPage.h" #include "KPrPageApplicationData.h" #include "KPrViewModePreviewPageEffect.h" +#include "KPrPageTransition.h" #include "pageeffects/KPrPageEffectRegistry.h" #include "pageeffects/KPrPageEffectFactory.h" #include "commands/KPrPageEffectSetCommand.h" +#include "commands/KPrPageTransitionSetCommand.h" #include @@ -90,6 +93,27 @@ connect( m_durationSpinBox, SIGNAL(valueChanged(double)), this, SLOT(slotDurationChanged(double)) ); + m_transitionType = new QComboBox(this); + m_transitionType->addItem(i18n("Manual")); + m_transitionType->addItem(i18n("Automatic")); + // NOTE: Not used as the definition in odf spec does not make sence to me (danders) + // m_transitionType->addItem(i18n("Semi-Automatic")); + + m_transitionTime = new QDoubleSpinBox( this ); + m_transitionTime->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + + QLabel *label = new QLabel(this); + label->setText(i18n("Slide Transition:")); + QHBoxLayout* transitionLayout = new QHBoxLayout(); + transitionLayout->addWidget(label); + transitionLayout->addWidget(m_transitionType); + transitionLayout->addWidget(m_transitionTime); + + connect( m_transitionTime, SIGNAL(valueChanged(double)), + this, SLOT(slotTransitionChanged())); + connect( m_transitionType, SIGNAL(currentIndexChanged(int)), + this, SLOT(slotTransitionChanged())); + m_applyToAllSlidesButton = new QPushButton(i18n("Apply To All Slides")); connect(m_applyToAllSlidesButton, SIGNAL(clicked()), @@ -100,6 +124,7 @@ layout->setMargin(0); layout->addLayout( optionLayout); layout->addWidget( m_subTypeCombo ); + layout->addLayout(transitionLayout); layout->addWidget(m_applyToAllSlidesButton); // The following widget activates a special feature in the @@ -168,6 +193,13 @@ m_durationSpinBox->blockSignals( true ); m_durationSpinBox->setValue( duration ); m_durationSpinBox->blockSignals( false ); + + m_transitionType->blockSignals(true); + m_transitionType->setCurrentIndex(pageData->pageTransition().type()); + m_transitionType->blockSignals(false); + m_transitionTime->blockSignals(true); + m_transitionTime->setValue(pageData->pageTransition().duration()); + m_transitionTime->blockSignals(false); } else { // disable the page effect docker as effects are only there on a normal page @@ -224,6 +256,14 @@ } } +void KPrPageEffectDocker::slotTransitionChanged() +{ + KPrPageTransition transition; + transition.setType(static_cast(m_transitionType->currentIndex())); + transition.setDuration(m_transitionTime->value()); + m_view->kopaCanvas()->addCommand(new KPrPageTransitionSetCommand(m_view->activePage(), transition)); +} + void KPrPageEffectDocker::slotApplyToAllSlides() { m_view->kopaCanvas()->addCommand(KPrPageEffectDocker::applyToAllSlidesCommand()); @@ -238,15 +278,25 @@ KUndo2Command *cmd = new KUndo2Command(kundo2_i18n("Apply Slide Effect to all Slides")); const KPrPageEffectFactory *factory = m_effectId != "" ? KPrPageEffectRegistry::instance()->value(m_effectId) : 0; + const KPrPageTransition &transition = KPrPage::pageData(m_view->activePage())->pageTransition(); foreach (KoPAPageBase *page, m_pages) { if (page != m_view->activePage()) { if (factory) { KPrPageEffect *currentPageEffect(createPageEffect(factory, m_subType, m_duration)); - new KPrPageEffectSetCommand(page, currentPageEffect, cmd); + KPrPageEffect *oldPageEffect = KPrPage::pageData(page)->pageEffect(); + if (oldPageEffect != currentPageEffect) { + new KPrPageEffectSetCommand(page, currentPageEffect, cmd); + } else { + delete currentPageEffect; + } } else { - KPrPageEffect *currentPageEffect = 0; - new KPrPageEffectSetCommand(page, currentPageEffect, cmd); + KPrPageEffect *oldPageEffect = KPrPage::pageData(page)->pageEffect(); + if (oldPageEffect) { + KPrPageEffect *currentPageEffect = nullptr; + new KPrPageEffectSetCommand(page, currentPageEffect, cmd); + } } + new KPrPageTransitionSetCommand(page, transition, cmd); } }