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

List:       kde-commits
Subject:    [okular] core: Add Okular::RenditionAction class
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2012-10-22 11:05:51
Message-ID: 20121022110551.52765A6078 () git ! kde ! org
[Download RAW message or body]

Git commit 282950d1278f042ed705d2abbb64a0ff248983f0 by Tobias Koenig.
Committed on 27/09/2012 at 12:42.
Pushed by tokoe into branch 'master'.

Add Okular::RenditionAction class

REVIEW: 106603

M  +96   -0    core/action.cpp
M  +85   -1    core/action.h

http://commits.kde.org/okular/282950d1278f042ed705d2abbb64a0ff248983f0

diff --git a/core/action.cpp b/core/action.cpp
index d65f8e0..7c7b09c 100644
--- a/core/action.cpp
+++ b/core/action.cpp
@@ -14,6 +14,7 @@
 
 // local includes
 #include "document.h"
+#include "movie.h"
 #include "sourcereference_p.h"
 #include "sound.h"
 
@@ -462,3 +463,98 @@ MovieAnnotation* MovieAction::annotation() const
     Q_D( const Okular::MovieAction );
     return d->m_annotation;
 }
+
+// RenditionAction
+
+class Okular::RenditionActionPrivate : public Okular::ActionPrivate
+{
+    public:
+        RenditionActionPrivate( RenditionAction::OperationType operation, \
Okular::Movie *movie, enum ScriptType scriptType, const QString &script ) +           \
: ActionPrivate(), m_operation( operation ), m_movie( movie ), m_scriptType( \
scriptType ), +              m_script( script ), m_annotation( 0 )
+        {
+        }
+
+
+        RenditionAction::OperationType m_operation;
+        Okular::Movie *m_movie;
+        ScriptType m_scriptType;
+        QString m_script;
+        ScreenAnnotation *m_annotation;
+};
+
+RenditionAction::RenditionAction( OperationType operation, Okular::Movie *movie, \
enum ScriptType scriptType, const QString &script ) +    : Action( *new \
RenditionActionPrivate( operation, movie, scriptType, script ) ) +{
+}
+
+RenditionAction::~RenditionAction()
+{
+}
+
+Action::ActionType RenditionAction::actionType() const
+{
+    return Rendition;
+}
+
+QString RenditionAction::actionTip() const
+{
+    Q_D( const Okular::RenditionAction );
+
+    switch ( d->m_operation )
+    {
+      default:
+      case None:
+          switch ( d->m_scriptType )
+          {
+              case JavaScript:
+                  return i18n( "JavaScript Script" );
+              default:
+                  return QString();
+          }
+      case Play:
+          return i18n( "Play movie" );
+      case Stop:
+          return i18n( "Stop movie" );
+      case Pause:
+          return i18n( "Pause movie" );
+      case Resume:
+          return i18n( "Resume movie" );
+    }
+}
+
+RenditionAction::OperationType RenditionAction::operation() const
+{
+    Q_D( const Okular::RenditionAction );
+    return d->m_operation;
+}
+
+Okular::Movie* RenditionAction::movie() const
+{
+    Q_D( const Okular::RenditionAction );
+    return d->m_movie;
+}
+
+ScriptType RenditionAction::scriptType() const
+{
+    Q_D( const Okular::RenditionAction );
+    return d->m_scriptType;
+}
+
+QString RenditionAction::script() const
+{
+    Q_D( const Okular::RenditionAction );
+    return d->m_script;
+}
+
+void RenditionAction::setAnnotation( ScreenAnnotation *annotation )
+{
+    Q_D( Okular::RenditionAction );
+    d->m_annotation = annotation;
+}
+
+ScreenAnnotation* RenditionAction::annotation() const
+{
+    Q_D( const Okular::RenditionAction );
+    return d->m_annotation;
+}
diff --git a/core/action.h b/core/action.h
index cdf4c96..d089151 100644
--- a/core/action.h
+++ b/core/action.h
@@ -26,7 +26,10 @@ class DocumentActionPrivate;
 class SoundActionPrivate;
 class ScriptActionPrivate;
 class MovieActionPrivate;
+class RenditionActionPrivate;
 class MovieAnnotation;
+class ScreenAnnotation;
+class Movie;
 class Sound;
 class DocumentViewport;
 
@@ -50,7 +53,8 @@ class OKULAR_EXPORT Action
             DocAction,  ///< Start a custom action
             Sound,      ///< Play a sound
             Movie,      ///< Play a movie
-            Script      ///< Executes a Script code
+            Script,     ///< Executes a Script code
+            Rendition,  ///< Play a movie and/or execute a Script code @since 0.16 \
(KDE 4.10)  };
 
         /**
@@ -478,6 +482,86 @@ class OKULAR_EXPORT MovieAction : public Action
         Q_DISABLE_COPY( MovieAction )
 };
 
+/**
+ * The Rendition action executes an operation on a video or
+ * executes some JavaScript code on activation.
+ *
+ * @since 0.16 (KDE 4.10)
+ */
+class OKULAR_EXPORT RenditionAction : public Action
+{
+    public:
+        /**
+         * Describes the possible operation types.
+         */
+        enum OperationType {
+            None,   ///< Execute only the JavaScript
+            Play,   ///< Start playing the video
+            Stop,   ///< Stop playing the video
+            Pause,  ///< Pause the video
+            Resume  ///< Resume playing the video
+        };
+
+        /**
+         * Creates a new rendition action.
+         *
+         * @param operation The type of operation the action executes.
+         * @param movie The movie object the action references.
+         * @param scriptType The type of script the action executes.
+         * @param script The actual script the action executes.
+         */
+        RenditionAction( OperationType operation, Okular::Movie *movie, enum \
ScriptType scriptType, const QString &script ); +
+        /**
+         * Destroys the rendition action.
+         */
+        virtual ~RenditionAction();
+
+        /**
+         * Returns the action type.
+         */
+        ActionType actionType() const;
+
+        /**
+         * Returns the action tip.
+         */
+        QString actionTip() const;
+
+        /**
+         * Returns the operation type.
+         */
+        OperationType operation() const;
+
+        /**
+         * Returns the movie object or @c 0 if no movie object was set on \
construction time. +         */
+        Okular::Movie* movie() const;
+
+        /**
+         * Returns the type of script.
+         */
+        ScriptType scriptType() const;
+
+        /**
+         * Returns the script code.
+         */
+        QString script() const;
+
+        /**
+         * Sets the @p annotation that is associated with the rendition action.
+         */
+        void setAnnotation( ScreenAnnotation *annotation );
+
+        /**
+         * Returns the annotation or @c 0 if no annotation has been set.
+         */
+        ScreenAnnotation* annotation() const;
+
+    private:
+        Q_DECLARE_PRIVATE( RenditionAction )
+        Q_DISABLE_COPY( RenditionAction )
+};
+
 }
 
 #endif


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

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