Debian Codegraph @

qt5/src/poppler-movie.cc

raw
1 /* poppler-sound.cc: qt interface to poppler
2 * Copyright (C) 2008, 2010, Pino Toscano <[email protected]>
3 * Copyright (C) 2008, 2018, 2022, 2025, Albert Astals Cid <[email protected]>
4 * Copyright (C) 2010, Carlos Garcia Campos <[email protected]>
5 * Copyright (C) 2012, Tobias Koenig <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22 #include "poppler-qt5.h"
23
24 #include "Annot.h"
25 #include "Movie.h"
26
27 #include <QtGui/QImage>
28
29 namespace Poppler {
30
31 class MovieData
32 {
33 public:
34 MovieData() : m_movieObj(nullptr) { }
35
36 ~MovieData() = default;
37
38 MovieData(const MovieData &) = delete;
39 MovieData &operator=(const MovieData &) = delete;
40
41 std::unique_ptr<Movie> m_movieObj;
42 QSize m_size;
43 int m_rotation;
44 QImage m_posterImage;
45 MovieObject::PlayMode m_playMode : 3;
46 bool m_showControls : 1;
47 };
48
49 MovieObject::MovieObject(AnnotMovie *ann)
50 {
51 m_movieData = new MovieData();
52 m_movieData->m_movieObj = ann->getMovie()->copy();
53 // TODO: copy poster image
54
55 const MovieActivationParameters *mp = m_movieData->m_movieObj->getActivationParameters();
56 int width, height;
57 m_movieData->m_movieObj->getFloatingWindowSize(&width, &height);
58 m_movieData->m_size = QSize(width, height);
59 m_movieData->m_rotation = m_movieData->m_movieObj->getRotationAngle();
60 m_movieData->m_showControls = mp->showControls;
61 m_movieData->m_playMode = (MovieObject::PlayMode)mp->repeatMode;
62 }
63
64 MovieObject::~MovieObject()
65 {
66 delete m_movieData;
67 }
68
69 QString MovieObject::url() const
70 {
71 const GooString *goo = m_movieData->m_movieObj->getFileName();
72 return goo ? QString::fromStdString(goo->toStr()) : QString();
73 }
74
75 QSize MovieObject::size() const
76 {
77 return m_movieData->m_size;
78 }
79
80 int MovieObject::rotation() const
81 {
82 return m_movieData->m_rotation;
83 }
84
85 bool MovieObject::showControls() const
86 {
87 return m_movieData->m_showControls;
88 }
89
90 MovieObject::PlayMode MovieObject::playMode() const
91 {
92 return m_movieData->m_playMode;
93 }
94
95 bool MovieObject::showPosterImage() const
96 {
97 return (m_movieData->m_movieObj->getShowPoster() == true);
98 }
99
100 QImage MovieObject::posterImage() const
101 {
102 return m_movieData->m_posterImage;
103 }
104
105 }