diff --git a/CMakeLists.txt b/CMakeLists.txt index 536aed08d..1467f8da2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ set(okularcore_SRCS core/generator.cpp core/generator_p.cpp core/misc.cpp + core/movie.cpp core/observer.cpp core/page.cpp core/pagecontroller.cpp diff --git a/core/annotations.cpp b/core/annotations.cpp index 3432ca8e9..1fbd01a2c 100644 --- a/core/annotations.cpp +++ b/core/annotations.cpp @@ -16,6 +16,7 @@ // local includes #include "document.h" +#include "movie.h" #include "page_p.h" #include "sound.h" @@ -2330,3 +2331,74 @@ void SoundAnnotation::setSound( Sound *s ) Q_D( SoundAnnotation ); d->sound = s; } + +/** MovieAnnotation [Annotation] */ + +class Okular::MovieAnnotationPrivate : public Okular::AnnotationPrivate +{ + public: + MovieAnnotationPrivate() + : AnnotationPrivate(), movie( 0 ) + { + } + ~MovieAnnotationPrivate() + { + delete movie; + } + + // data fields + Movie *movie; +}; + +MovieAnnotation::MovieAnnotation() + : Annotation( *new MovieAnnotationPrivate() ) +{ +} + +MovieAnnotation::MovieAnnotation( const QDomNode & node ) + : Annotation( *new MovieAnnotationPrivate(), node ) +{ + // loop through the whole children looking for a 'movie' element + QDomNode subNode = node.firstChild(); + while( subNode.isElement() ) + { + QDomElement e = subNode.toElement(); + subNode = subNode.nextSibling(); + if ( e.tagName() != "movie" ) + continue; + + // loading complete + break; + } +} + +MovieAnnotation::~MovieAnnotation() +{ +} + +void MovieAnnotation::store( QDomNode & node, QDomDocument & document ) const +{ + // recurse to parent objects storing properties + Annotation::store( node, document ); + + // create [movie] element + QDomElement movieElement = document.createElement( "movie" ); + node.appendChild( movieElement ); +} + +Annotation::SubType MovieAnnotation::subType() const +{ + return AMovie; +} + +Movie* MovieAnnotation::movie() const +{ + Q_D( const MovieAnnotation ); + return d->movie; +} + +void MovieAnnotation::setMovie( Movie *movie ) +{ + Q_D( MovieAnnotation ); + d->movie = movie; +} diff --git a/core/annotations.h b/core/annotations.h index cc1127828..3584073ba 100644 --- a/core/annotations.h +++ b/core/annotations.h @@ -31,6 +31,7 @@ class EmbeddedFile; class Page; class PagePrivate; class Sound; +class Movie; class TextAnnotationPrivate; class LineAnnotationPrivate; class GeomAnnotationPrivate; @@ -40,6 +41,7 @@ class InkAnnotationPrivate; class CaretAnnotationPrivate; class FileAttachmentAnnotationPrivate; class SoundAnnotationPrivate; +class MovieAnnotationPrivate; /** * @short Helper class for (recursive) annotation retrieval/storage. @@ -109,6 +111,7 @@ class OKULAR_EXPORT Annotation ACaret = 8, ///< A caret annotation AFileAttachment = 9, ///< A file attachment annotation ASound = 10, ///< A sound annotation + AMovie = 11, ///< A movie annotation A_BASE = 0 ///< The annotation base class }; @@ -1414,6 +1417,51 @@ class OKULAR_EXPORT SoundAnnotation : public Annotation Q_DISABLE_COPY( SoundAnnotation ) }; +/** + * \short Movie annotation. + * + * The movie annotation represents a movie to be played when activated. + * + * @since 0.8 (KDE 4.2) + */ +class OKULAR_EXPORT MovieAnnotation : public Annotation +{ + public: + /** + * Creates a new movie annotation. + */ + MovieAnnotation(); + /** + * Creates a new movie annotation from the xml @p description + */ + MovieAnnotation( const QDomNode &description ); + /** + * Destroys the movie annotation. + */ + virtual ~MovieAnnotation(); + /** + * Gets the movie object. + */ + Movie* movie() const; + /** + * Sets the new @p movie object. + */ + void setMovie( Movie *movie ); + /** + * Returns the sub type of the movie annotation. + */ + SubType subType() const; + /** + * Stores the movie annotation as xml in @p document + * under the given @p parentNode. + */ + void store( QDomNode &parentNode, QDomDocument &document ) const; + + private: + Q_DECLARE_PRIVATE( MovieAnnotation ) + Q_DISABLE_COPY( MovieAnnotation ) +}; + } #endif diff --git a/core/movie.cpp b/core/movie.cpp new file mode 100644 index 000000000..185e75005 --- /dev/null +++ b/core/movie.cpp @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (C) 2008 by Pino Toscano * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include "movie.h" + +// qt/kde includes +#include + +using namespace Okular; + +class Movie::Private +{ + public: + Private( const QString &url ) + : m_url( url ), + m_rotation( Rotation0 ) + { + } + + QString m_url; + QSize m_aspect; + Rotation m_rotation; +}; + +Movie::Movie( const QString& fileName ) + : d( new Private( fileName ) ) +{ +} + +Movie::~Movie() +{ + delete d; +} + +QString Movie::url() const +{ + return d->m_url; +} + +void Movie::setSize( const QSize &aspect ) +{ + d->m_aspect = aspect; +} + +QSize Movie::size() const +{ + return d->m_aspect; +} + +void Movie::setRotation( Rotation rotation ) +{ + d->m_rotation = rotation; +} + +Rotation Movie::rotation() const +{ + return d->m_rotation; +} diff --git a/core/movie.h b/core/movie.h new file mode 100644 index 000000000..ca633fcb2 --- /dev/null +++ b/core/movie.h @@ -0,0 +1,72 @@ +/*************************************************************************** + * Copyright (C) 2008 by Pino Toscano * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#ifndef _OKULAR_MOVIE_H_ +#define _OKULAR_MOVIE_H_ + +#include +#include + +#include + +namespace Okular { + +/** + * @short Contains information about a movie object. + * + * @since 0.8 (KDE 4.2) + */ +class OKULAR_EXPORT Movie +{ + public: + /** + * Creates a new movie object with the given external @p fileName. + */ + explicit Movie( const QString& fileName ); + + /** + * Destroys the movie object. + */ + ~Movie(); + + /** + * Returns the url of the movie. + */ + QString url() const; + + /** + * Sets the size for the movie. + */ + void setSize( const QSize &aspect ); + + /** + * Returns the size of the movie. + */ + QSize size() const; + + /** + * Sets the @p rotation of the movie. + */ + void setRotation( Rotation rotation ); + + /** + * Returns the rotation of the movie. + */ + Rotation rotation() const; + + private: + class Private; + Private* const d; + + Q_DISABLE_COPY( Movie ) +}; + +} + +#endif