Add Okular::RenditionAction class

REVIEW: 106603
remotes/origin/KDE/4.10
Tobias Koenig 14 years ago
parent c639a3434e
commit 282950d127
  1. 96
      core/action.cpp
  2. 86
      core/action.h

@ -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;
}

@ -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

Loading…
Cancel
Save