[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kpresenter/part
From:       Thorsten Zachmann <t.zachmann () zagge ! de>
Date:       2008-06-19 3:51:26
Message-ID: 1213847486.476008.1105.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 822088 by zachmann:

o use the KoEventAction
o don't navigate when an action was started
o stop an action before going on with navigation


 M  +18 -29    KPrPresentationTool.cpp  
 M  +6 -2      KPrPresentationTool.h  


--- trunk/koffice/kpresenter/part/KPrPresentationTool.cpp #822087:822088
@@ -24,24 +24,18 @@
 #include <KoShape.h>
 #include <KoShapeManager.h>
 #include <KoPointerEvent.h>
+#include <KoEventAction.h>
 #include <KoPACanvas.h>
-#include <KPrShapeApplicationData.h>
-#include <KPrSoundData.h>
-#include <phonon/phononnamespace.h>
-#include<Phonon/MediaObject>
 #include "KPrViewModePresentation.h"
 
 KPrPresentationTool::KPrPresentationTool( KPrViewModePresentation & viewMode )
 : KoTool( viewMode.canvas() )
 , m_viewMode( viewMode )
-,m_music(0)
 {
 }
 
 KPrPresentationTool::~KPrPresentationTool()
 {
-    if(m_music)
-        m_music->stop();
 }
 
 bool KPrPresentationTool::wantsAutoScroll()
@@ -55,28 +49,16 @@
 void KPrPresentationTool::mousePressEvent( KoPointerEvent *event )
 {
     if ( event->button() & Qt::LeftButton ) {
+        finishEventActions();
         KoShape * shapeClicked = m_canvas->shapeManager()->shapeAt( event->point );
-        if(shapeClicked) {
-            if(KPrShapeApplicationData *appData
-                                = dynamic_cast<KPrShapeApplicationData *>( \
                shapeClicked->applicationData())) {
-                switch(appData->m_invokeResponse) {
-                    case KPrShapeApplicationData::DoNavigate:
-                        m_viewMode.navigate( KPrAnimationDirector::PreviousStep );
-                        break;
-                    case KPrShapeApplicationData::DoNone:
-                    default:
-                        break;
+        if (shapeClicked) {
+            m_eventActions = shapeClicked->eventActions();
+            if ( m_eventActions.size() ) {
+                foreach ( KoEventAction * eventAction, m_eventActions ) {
+                    eventAction->execute( this );
                 }
-
-                if(m_music)
-                    m_music->stop();
-                if(appData->m_soundData)
-                {
-                    m_music = Phonon::createPlayer(Phonon::MusicCategory,
-                                                \
                Phonon::MediaSource(appData->m_soundData->nameOfTempFile()));
-                    connect(m_music, SIGNAL(finished()), m_music, \
                SLOT(deleteLater()));
-                    m_music->play();
-                }
+                // don't do next step if a action was executed
+                return;
             }
         }
         m_viewMode.navigate( KPrAnimationDirector::NextStep );
@@ -97,6 +79,7 @@
 
 void KPrPresentationTool::keyPressEvent( QKeyEvent *event )
 {
+    finishEventActions();
     event->accept();
 
     switch ( event->key() )
@@ -146,8 +129,14 @@
 
 void KPrPresentationTool::deactivate()
 {
-    if(m_music)
-        m_music->stop();
+    finishEventActions();
 }
 
+void KPrPresentationTool::finishEventActions()
+{
+    foreach ( KoEventAction * eventAction, m_eventActions ) {
+        eventAction->finish( this );
+    }
+}
+
 #include "KPrPresentationTool.moc"
--- trunk/koffice/kpresenter/part/KPrPresentationTool.h #822087:822088
@@ -20,8 +20,10 @@
 #define KPRPRESENTATIONTOOL_H
 
 #include <KoTool.h>
-#include<Phonon/MediaObject>
 
+#include <QList>
+
+class KoEventAction;
 class KPrViewModePresentation;
 
 /// The tool used for presentations
@@ -48,8 +50,10 @@
     void deactivate();
 
 private:
+    void finishEventActions();
+
     KPrViewModePresentation & m_viewMode;
-    Phonon::MediaObject *m_music;
+    QList<KoEventAction *> m_eventActions;
 };
 
 #endif /* KPRPRESENTATIONTOOL_H */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic