• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

okular

  • sources
  • kde-4.12
  • kdegraphics
  • okular
  • core
movie.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
3  * Copyright (C) 2012 by Guillermo A. Amaral B. <gamaral@kde.org> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  ***************************************************************************/
10 
11 #include "movie.h"
12 
13 // qt/kde includes
14 #include <qdir.h>
15 #include <qimage.h>
16 #include <qstring.h>
17 #include <qtemporaryfile.h>
18 
19 #include <kdebug.h>
20 
21 #include "debug_p.h"
22 
23 using namespace Okular;
24 
25 class Movie::Private
26 {
27  public:
28  Private( const QString &url )
29  : m_url( url ),
30  m_rotation( Rotation0 ),
31  m_playMode( PlayOnce ),
32  m_tmp( 0 ),
33  m_showControls( false ),
34  m_autoPlay( false ),
35  m_showPosterImage( false )
36  {
37  }
38 
39  QString m_url;
40  QSize m_aspect;
41  Rotation m_rotation;
42  PlayMode m_playMode;
43  QTemporaryFile *m_tmp;
44  QImage m_posterImage;
45  bool m_showControls : 1;
46  bool m_autoPlay : 1;
47  bool m_showPosterImage : 1;
48 };
49 
50 Movie::Movie( const QString& fileName )
51  : d( new Private( fileName ) )
52 {
53 }
54 
55 Movie::Movie( const QString& fileName, const QByteArray &data )
56  : d( new Private( fileName ) )
57 {
58  /* Store movie data as temporary file.
59  *
60  * Originally loaded movie data directly using a QBuffer, but sadly phonon
61  * fails to play on a few of my test systems (I think it's the Phonon
62  * GStreamer backend). Storing the data in a temporary file works fine
63  * though, not to mention, it releases much needed memory. (gamaral)
64  */
65  d->m_tmp = new QTemporaryFile( QString( "%1/okrXXXXXX" ).arg( QDir::tempPath() ) );
66  if ( d->m_tmp->open() ) {
67  d->m_tmp->write( data );
68  d->m_tmp->flush();
69  }
70  else kDebug(OkularDebug) << "Failed to create temporary file for video data.";
71 }
72 
73 Movie::~Movie()
74 {
75  delete d->m_tmp;
76  delete d;
77 }
78 
79 QString Movie::url() const
80 {
81  if (d->m_tmp)
82  return d->m_tmp->fileName();
83  else
84  return d->m_url;
85 }
86 
87 void Movie::setSize( const QSize &aspect )
88 {
89  d->m_aspect = aspect;
90 }
91 
92 QSize Movie::size() const
93 {
94  return d->m_aspect;
95 }
96 
97 void Movie::setRotation( Rotation rotation )
98 {
99  d->m_rotation = rotation;
100 }
101 
102 Rotation Movie::rotation() const
103 {
104  return d->m_rotation;
105 }
106 
107 void Movie::setShowControls( bool show )
108 {
109  d->m_showControls = show;
110 }
111 
112 bool Movie::showControls() const
113 {
114  return d->m_showControls;
115 }
116 
117 void Movie::setPlayMode( Movie::PlayMode mode )
118 {
119  d->m_playMode = mode;
120 }
121 
122 Movie::PlayMode Movie::playMode() const
123 {
124  return d->m_playMode;
125 }
126 
127 void Movie::setAutoPlay( bool autoPlay )
128 {
129  d->m_autoPlay = autoPlay;
130 }
131 
132 bool Movie::autoPlay() const
133 {
134  return d->m_autoPlay;
135 }
136 
137 void Movie::setShowPosterImage( bool show )
138 {
139  d->m_showPosterImage = show;
140 }
141 
142 bool Movie::showPosterImage() const
143 {
144  return d->m_showPosterImage;
145 }
146 
147 void Movie::setPosterImage( const QImage &image )
148 {
149  d->m_posterImage = image;
150 }
151 
152 QImage Movie::posterImage() const
153 {
154  return d->m_posterImage;
155 }
Okular::Rotation
Rotation
A rotation.
Definition: global.h:44
Okular::Movie::Movie
Movie(const QString &fileName)
Creates a new movie object with the given external fileName.
Definition: movie.cpp:50
Okular::Movie::setSize
void setSize(const QSize &aspect)
Sets the size for the movie.
Definition: movie.cpp:87
Okular::Movie::rotation
Rotation rotation() const
Returns the rotation of the movie.
Definition: movie.cpp:102
debug_p.h
Okular::Movie::setShowPosterImage
void setShowPosterImage(bool show)
Sets whether to show a poster image.
Definition: movie.cpp:137
Okular::Rotation0
Not rotated.
Definition: global.h:46
Okular::Movie::setPlayMode
void setPlayMode(PlayMode mode)
Sets the way the movie should be played.
Definition: movie.cpp:117
Okular::Movie::setAutoPlay
void setAutoPlay(bool autoPlay)
Sets whether to play the movie automatically.
Definition: movie.cpp:127
Okular::Movie::autoPlay
bool autoPlay() const
Whether to play the movie automatically.
Definition: movie.cpp:132
Okular::Movie::~Movie
~Movie()
Destroys the movie object.
Definition: movie.cpp:73
Okular::Movie::PlayOnce
Play the movie once, closing the movie controls at the end.
Definition: movie.h:36
Okular::Movie::setPosterImage
void setPosterImage(const QImage &image)
Sets the poster image.
Definition: movie.cpp:147
Okular::Movie::PlayMode
PlayMode
The play mode for playing the movie.
Definition: movie.h:34
Okular::Movie::showControls
bool showControls() const
Whether show a bar with movie controls.
Definition: movie.cpp:112
OkularDebug
#define OkularDebug
Definition: debug_p.h:13
Okular::Movie::size
QSize size() const
Returns the size of the movie.
Definition: movie.cpp:92
Okular::Movie::playMode
PlayMode playMode() const
How to play the movie.
Definition: movie.cpp:122
Okular::Movie::setRotation
void setRotation(Rotation rotation)
Sets the rotation of the movie.
Definition: movie.cpp:97
Okular::Movie::posterImage
QImage posterImage() const
Returns the poster image.
Definition: movie.cpp:152
Okular::Movie::setShowControls
void setShowControls(bool show)
Sets whether show a bar with movie controls.
Definition: movie.cpp:107
Okular::Movie::showPosterImage
bool showPosterImage() const
Whether to show a poster image.
Definition: movie.cpp:142
movie.h
Okular::Movie::url
QString url() const
Returns the url of the movie.
Definition: movie.cpp:79
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:45:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal