From kde-commits Sat May 09 04:32:44 2009 From: Thorsten Zachmann Date: Sat, 09 May 2009 04:32:44 +0000 To: kde-commits Subject: koffice/kpresenter Message-Id: <1241843564.783928.17165.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=124184361119722 SVN commit 965490 by zachmann: o merge changes from koffice-isi branch to trunk. This brings a highlight and a draw function to the presentation mode of kpresenter. With the highlight function it is possible to have a spotlight following the mouse to hightlight a part of the slide. With the draw function it is possible to draw onto the slide. This is a first merge form the branch. More to follow. Thanks to the students who worked on the koffice-isi branch for their hard work. M +8 -0 part/CMakeLists.txt AM part/KPrPresentationDrawStrategy.cpp branches/work/koffice-isi/kpresenter/part/KPrPresentationDrawStrategy.cpp#957434 [License: LGPL (v2+)] AM part/KPrPresentationDrawStrategy.h branches/work/koffice-isi/kpresenter/part/KPrPresentationDrawStrategy.h#957434 [License: LGPL (v2+)] AM part/KPrPresentationDrawWidget.cpp branches/work/koffice-isi/kpresenter/part/KPrPresentationDrawWidget.cpp#957434 [License: LGPL (v2+)] AM part/KPrPresentationDrawWidget.h branches/work/koffice-isi/kpresenter/part/KPrPresentationDrawWidget.h#957434 [License: LGPL (v2+)] AM part/KPrPresentationHighlightStrategy.cpp branches/work/koffice-isi/kpresenter/part/KPrPresentationHighlightStrategy.cpp#957434 [License: LGPL (v2+)] AM part/KPrPresentationHighlightStrategy.h branches/work/koffice-isi/kpresenter/part/KPrPresentationHighlightStrategy.h#957434 [License: LGPL (v2+)] AM part/KPrPresentationHighlightWidget.cpp branches/work/koffice-isi/kpresenter/part/KPrPresentationHighlightWidget.cpp#957434 [License: LGPL (v2+)] AM part/KPrPresentationHighlightWidget.h branches/work/koffice-isi/kpresenter/part/KPrPresentationHighlightWidget.h#957434 [License: LGPL (v2+)] AM part/KPrPresentationStrategy.cpp branches/work/koffice-isi/kpresenter/part/KPrPresentationStrategy.cpp#957708 [License: LGPL (v2+)] AM part/KPrPresentationStrategy.h branches/work/koffice-isi/kpresenter/part/KPrPresentationStrategy.h#957434 [License: LGPL (v2+)] AM part/KPrPresentationStrategyInterface.cpp branches/work/koffice-isi/kpresenter/part/KPrPresentationStrategyInterface.cpp#957434 [License: LGPL (v2+)] AM part/KPrPresentationStrategyInterface.h branches/work/koffice-isi/kpresenter/part/KPrPresentationStrategyInterface.h#957434 [License: LGPL (v2+)] M +135 -33 part/KPrPresentationTool.cpp M +20 -2 part/KPrPresentationTool.h M +4 -0 part/KPrSoundData.h M +4 -2 part/KPrViewModePresentation.cpp AM part/ui/KPrPresentationTool.ui branches/work/koffice-isi/kpresenter/part/ui/KPrPresentationTool.ui#953648 AM part/ui/KPrPresentationToolWidget.cpp branches/work/koffice-isi/kpresenter/part/ui/KPrPresentationToolWidget.cpp#958419 [License: LGPL (v2+)] AM part/ui/KPrPresentationToolWidget.h branches/work/koffice-isi/kpresenter/part/ui/KPrPresentationToolWidget.h#958419 [License: LGPL (v2+)] M +1 -1 pics/CMakeLists.txt AM pics/hi16-action-highlight.png branches/work/koffice-isi/kpresenter/part/ui/pics/hi16-action-highlight.png#953648 AM pics/hi16-action-pen.png branches/work/koffice-isi/kpresenter/part/ui/pics/hi16-action-pen.png#953648 --- trunk/koffice/kpresenter/part/CMakeLists.txt #965489:965490 @@ -45,6 +45,12 @@ KPrPlaceholderStrategy.cpp KPrPlaceholderPictureStrategy.cpp KPrPlaceholderTextStrategy.cpp + KPrPresentationHighlightWidget.cpp + KPrPresentationDrawWidget.cpp + KPrPresentationStrategy.cpp + KPrPresentationHighlightStrategy.cpp + KPrPresentationStrategyInterface.cpp + KPrPresentationDrawStrategy.cpp commands/KPrAnimationCreateCommand.cpp commands/KPrPageEffectSetCommand.cpp @@ -77,6 +83,7 @@ ui/KPrCustomSlideShowsDialog.cpp ui/KPrConfigureSlideShowDialog.cpp ui/KPrConfigurePresenterViewDialog.cpp + ui/KPrPresentationToolWidget.cpp tools/KPrPlaceholderTool.cpp tools/KPrPlaceholderToolFactory.cpp @@ -86,6 +93,7 @@ ui/KPrCustomSlideShowsDialog.ui ui/KPrConfigureSlideShow.ui ui/KPrConfigurePresenterView.ui + ui/KPrPresentationTool.ui ) kde4_add_library(kpresenterprivate SHARED ${kpresenterprivate_LIB_SRCS}) ** trunk/koffice/kpresenter/part/KPrPresentationDrawStrategy.cpp #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/KPrPresentationDrawStrategy.h #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/KPrPresentationDrawWidget.cpp #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/KPrPresentationDrawWidget.h #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/KPrPresentationHighlightStrategy.cpp #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/KPrPresentationHighlightStrategy.h #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/KPrPresentationHighlightWidget.cpp #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/KPrPresentationHighlightWidget.h #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/KPrPresentationStrategy.cpp #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/KPrPresentationStrategy.h #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/KPrPresentationStrategyInterface.cpp #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/KPrPresentationStrategyInterface.h #property svn:mergeinfo + --- trunk/koffice/kpresenter/part/KPrPresentationTool.cpp #965489:965490 @@ -1,5 +1,10 @@ /* This file is part of the KDE project - * Copyright (C) 2007 Thorsten Zachmann + * Copyright (C) 2007-2009 Thorsten Zachmann + * Copyright (C) 2008 Jim Courtiau + * Copyright (C) 2009 Alexia Allanic + * Copyright (C) 2009 Jean-Nicolas Artaud + * Copyright (C) 2009 Jérémy Lugagne + * Copyright (C) 2009 Johann Hingue * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -19,6 +24,9 @@ #include "KPrPresentationTool.h" +#include +#include +#include #include #include @@ -26,22 +34,48 @@ #include #include #include + #include "KPrViewModePresentation.h" +#include "KPrPresentationStrategy.h" +#include "KPrPresentationHighlightStrategy.h" +#include "KPrPresentationDrawStrategy.h" +#include "ui/KPrPresentationToolWidget.h" + KPrPresentationTool::KPrPresentationTool( KPrViewModePresentation & viewMode ) : KoTool( viewMode.canvas() ) , m_viewMode( viewMode ) +, m_strategy( new KPrPresentationStrategy( this ) ) { + // tool box + m_frame = new QFrame( m_viewMode.canvas() ); + + QVBoxLayout *frameLayout = new QVBoxLayout(); + + m_presentationToolWidget = new KPrPresentationToolWidget(m_viewMode.canvas()); + frameLayout->addWidget( m_presentationToolWidget, 0, Qt::AlignLeft | Qt::AlignBottom ); + m_frame->setLayout( frameLayout ); + m_frame->show(); + + m_presentationToolWidget->raise(); + m_presentationToolWidget->setVisible( false ); + m_presentationToolWidget->installEventFilter(this); + + // Connections of button clicked to slots + connect( m_presentationToolWidget->presentationToolUi().penButton, SIGNAL( clicked() ), this, SLOT( drawOnPresentation() ) ); + connect( m_presentationToolWidget->presentationToolUi().highLightButton, SIGNAL( clicked() ), this, SLOT( highLightPresentation() ) ); } KPrPresentationTool::~KPrPresentationTool() { + delete m_strategy; } bool KPrPresentationTool::wantsAutoScroll() { return false; } + void KPrPresentationTool::paint( QPainter &painter, const KoViewConverter &converter ) { } @@ -86,51 +120,67 @@ void KPrPresentationTool::keyPressEvent( QKeyEvent *event ) { finishEventActions(); - event->accept(); - - switch ( event->key() ) - { - case Qt::Key_Escape: - m_viewMode.activateSavedViewMode(); - break; - case Qt::Key_Home: - m_viewMode.navigate( KPrAnimationDirector::FirstPage ); - break; - case Qt::Key_Up: - case Qt::Key_PageUp: - m_viewMode.navigate( KPrAnimationDirector::PreviousPage ); - break; - case Qt::Key_Backspace: - case Qt::Key_Left: - m_viewMode.navigate( KPrAnimationDirector::PreviousStep ); - break; - case Qt::Key_Right: - case Qt::Key_Space: - m_viewMode.navigate( KPrAnimationDirector::NextStep ); - break; - case Qt::Key_Down: - case Qt::Key_PageDown: - m_viewMode.navigate( KPrAnimationDirector::NextPage ); - break; - case Qt::Key_End: - m_viewMode.navigate( KPrAnimationDirector::LastPage ); - break; - default: - event->ignore(); - break; + // first try to handle the event in the strategy if it is done there no need to use the default action + if ( ! m_strategy->keyPressEvent( event ) ) { + switch ( event->key() ) + { + case Qt::Key_Escape: + m_viewMode.activateSavedViewMode(); + break; + case Qt::Key_Home: + m_viewMode.navigate( KPrAnimationDirector::FirstPage ); + break; + case Qt::Key_Up: + case Qt::Key_PageUp: + m_viewMode.navigate( KPrAnimationDirector::PreviousPage ); + break; + case Qt::Key_Backspace: + case Qt::Key_Left: + m_viewMode.navigate( KPrAnimationDirector::PreviousStep ); + break; + case Qt::Key_Right: + case Qt::Key_Space: + m_viewMode.navigate( KPrAnimationDirector::NextStep ); + break; + case Qt::Key_Down: + case Qt::Key_PageDown: + m_viewMode.navigate( KPrAnimationDirector::NextPage ); + break; + case Qt::Key_End: + m_viewMode.navigate( KPrAnimationDirector::LastPage ); + break; + case Qt::Key_P: + drawOnPresentation(); + break; + case Qt::Key_H: + highLightPresentation(); + break; + default: + event->ignore(); + break; + } } } void KPrPresentationTool::keyReleaseEvent( QKeyEvent *event ) { + Q_UNUSED( event ); } void KPrPresentationTool::wheelEvent( KoPointerEvent * event ) { + Q_UNUSED( event ); } void KPrPresentationTool::activate( bool temporary ) { + Q_UNUSED( temporary ); + m_frame->setGeometry( m_canvas->canvasWidget()->geometry() ); + m_presentationToolWidget->setVisible( false ); + // redirect event to tool widget + m_frame->installEventFilter( this ); + // activate tracking for show/hide tool buttons + m_frame->setMouseTracking( true ); } void KPrPresentationTool::deactivate() @@ -145,4 +195,56 @@ } } +void KPrPresentationTool::switchStrategy( KPrPresentationStrategyInterface * strategy ) +{ + Q_ASSERT( strategy ); + Q_ASSERT( m_strategy != strategy ); + delete m_strategy; + m_strategy = strategy; +} + +// SLOTS +void KPrPresentationTool::highLightPresentation() +{ + KPrPresentationStrategyInterface * strategy; + if ( dynamic_cast( m_strategy ) ) { + strategy = new KPrPresentationStrategy( this ); + } + else { + strategy = new KPrPresentationHighlightStrategy( this ); + } + switchStrategy( strategy ); +} + +void KPrPresentationTool::drawOnPresentation() +{ + KPrPresentationStrategyInterface * strategy; + if ( dynamic_cast( m_strategy ) ) { + strategy = new KPrPresentationStrategy( this ); + } + else { + strategy = new KPrPresentationDrawStrategy( this ); + } + switchStrategy( strategy ); +} + +bool KPrPresentationTool::eventFilter( QObject *obj, QEvent * event ) +{ + if ( event->type() == QEvent::MouseMove ) { + QMouseEvent *mouseEvent = static_cast( event ); + QWidget *source = static_cast( obj ); + QPoint pos = source->mapFrom( m_viewMode.canvas(), mouseEvent->pos() ); + + QSize buttonSize = m_presentationToolWidget->size() + QSize( 20, 20 ); + QRect geometry = QRect( 0, m_frame->height() - buttonSize.height(), buttonSize.width(), buttonSize.height() ); + if ( geometry.contains( pos ) ) { + m_presentationToolWidget->setVisible( true ); + } + else { + m_presentationToolWidget->setVisible( false ); + } + } + return false; +} + #include "KPrPresentationTool.moc" --- trunk/koffice/kpresenter/part/KPrPresentationTool.h #965489:965490 @@ -1,5 +1,10 @@ /* This file is part of the KDE project - * Copyright (C) 2007 Thorsten Zachmann + * Copyright (C) 2007-2009 Thorsten Zachmann + * Copyright (C) 2008 Jim Courtiau + * Copyright (C) 2009 Alexia Allanic + * Copyright (C) 2009 Jean-Nicolas Artaud + * Copyright (C) 2009 Jérémy Lugagne + * Copyright (C) 2009 Johann Hingue * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -23,11 +28,15 @@ #include +class QFrame; class KoEventAction; class KPrViewModePresentation; +class KPrPresentationToolWidget; +class KPrPresentationStrategyInterface; /// The tool used for presentations -class KPrPresentationTool : public KoTool { +class KPrPresentationTool : public KoTool +{ Q_OBJECT public: explicit KPrPresentationTool( KPrViewModePresentation & viewMode ); @@ -48,12 +57,21 @@ public slots: void activate( bool temporary = false ); void deactivate(); + void highLightPresentation(); + void drawOnPresentation(); private: void finishEventActions(); + void switchStrategy( KPrPresentationStrategyInterface * strategy ); + bool eventFilter( QObject * obj, QEvent * event ); KPrViewModePresentation & m_viewMode; QList m_eventActions; + + KPrPresentationToolWidget * m_presentationToolWidget; + QFrame * m_frame; + KPrPresentationStrategyInterface * m_strategy; + friend class KPrPresentationStrategyInterface; }; #endif /* KPRPRESENTATIONTOOL_H */ --- trunk/koffice/kpresenter/part/KPrSoundData.h #965489:965490 @@ -32,6 +32,10 @@ * In KPresenter shapes can have click actions attached to them. One such action is playing sound. * The binary data for those sounds are saved in this class. */ + +/* + * TODO needs a file for playing, store it as a tmp file + */ class KPRESENTER_EXPORT KPrSoundData { public: /** --- trunk/koffice/kpresenter/part/KPrViewModePresentation.cpp #965489:965490 @@ -155,10 +155,12 @@ QRect presentationRect = desktop.screenGeometry( presentationscreen ); - m_canvas->move( presentationRect.topLeft() ); m_canvas->setWindowState( m_canvas->windowState() | Qt::WindowFullScreen ); // detach widget to make m_canvas->show(); m_canvas->setFocus(); // it shown full screen + // move and resize now as otherwise it is not set when we call activate on the tool. + m_canvas->move( presentationRect.topLeft() ); + m_canvas->resize( presentationRect.size() ); // the main animation director needs to be created first since it will set the active page // of the presentation @@ -175,7 +177,7 @@ m_presenterViewWidget->setWindowState( m_presenterViewWidget->windowState() | Qt::WindowFullScreen ); m_presenterViewWidget->move( pvRect.topLeft() ); - m_presenterViewWidget->updateWidget( pvRect.size(), presentationRect.size() ); + m_presenterViewWidget->updateWidget( pvRect.size(), presentationRect.size() ); m_presenterViewWidget->show(); m_presenterViewWidget->setFocus(); // it shown full screen ** trunk/koffice/kpresenter/part/ui/KPrPresentationTool.ui #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/ui/KPrPresentationToolWidget.cpp #property svn:mergeinfo + ** trunk/koffice/kpresenter/part/ui/KPrPresentationToolWidget.h #property svn:mergeinfo + --- trunk/koffice/kpresenter/pics/CMakeLists.txt #965489:965490 @@ -5,5 +5,5 @@ layout-elements.svg DESTINATION ${DATA_INSTALL_DIR}/kpresenter/pics) -kde4_install_icons( ${ICON_INSTALL_DIR} ) +kde4_install_icons( ${ICON_INSTALL_DIR} ) ** trunk/koffice/kpresenter/pics/hi16-action-highlight.png #property svn:mergeinfo + ** trunk/koffice/kpresenter/pics/hi16-action-highlight.png #property svn:mime-type + application/octet-stream ** trunk/koffice/kpresenter/pics/hi16-action-pen.png #property svn:mergeinfo + ** trunk/koffice/kpresenter/pics/hi16-action-pen.png #property svn:mime-type + application/octet-stream