1 | /* poppler-sound.cc: qt interface to poppler |
2 | * Copyright (C) 2008, 2010, Pino Toscano <pino@kde.org> |
3 | * Copyright (C) 2008, 2018, 2022, Albert Astals Cid <aacid@kde.org> |
4 | * Copyright (C) 2010, Carlos Garcia Campos <carlosgc@gnome.org> |
5 | * Copyright (C) 2012, Tobias Koenig <tobias.koenig@kdab.com> |
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-qt6.h" |
23 | |
24 | #include "Object.h" |
25 | #include "Annot.h" |
26 | #include "Movie.h" |
27 | |
28 | #include <QtGui/QImage> |
29 | |
30 | namespace Poppler { |
31 | |
32 | class MovieData |
33 | { |
34 | public: |
35 | MovieData() : m_movieObj(nullptr) { } |
36 | |
37 | ~MovieData() = default; |
38 | |
39 | MovieData(const MovieData &) = delete; |
40 | MovieData &operator=(const MovieData &) = delete; |
41 | |
42 | std::unique_ptr<Movie> m_movieObj; |
43 | QSize m_size; |
44 | int m_rotation; |
45 | QImage m_posterImage; |
46 | MovieObject::PlayMode m_playMode : 3; |
47 | bool m_showControls : 1; |
48 | }; |
49 | |
50 | MovieObject::MovieObject(AnnotMovie *ann) |
51 | { |
52 | m_movieData = new MovieData(); |
53 | m_movieData->m_movieObj = ann->getMovie()->copy(); |
54 | // TODO: copy poster image |
55 | |
56 | const MovieActivationParameters *mp = m_movieData->m_movieObj->getActivationParameters(); |
57 | int width, height; |
58 | m_movieData->m_movieObj->getFloatingWindowSize(width: &width, height: &height); |
59 | m_movieData->m_size = QSize(width, height); |
60 | m_movieData->m_rotation = m_movieData->m_movieObj->getRotationAngle(); |
61 | m_movieData->m_showControls = mp->showControls; |
62 | m_movieData->m_playMode = (MovieObject::PlayMode)mp->repeatMode; |
63 | } |
64 | |
65 | MovieObject::~MovieObject() |
66 | { |
67 | delete m_movieData; |
68 | } |
69 | |
70 | QString MovieObject::url() const |
71 | { |
72 | const GooString *goo = m_movieData->m_movieObj->getFileName(); |
73 | return goo ? QString(goo->c_str()) : QString(); |
74 | } |
75 | |
76 | QSize MovieObject::size() const |
77 | { |
78 | return m_movieData->m_size; |
79 | } |
80 | |
81 | int MovieObject::rotation() const |
82 | { |
83 | return m_movieData->m_rotation; |
84 | } |
85 | |
86 | bool MovieObject::showControls() const |
87 | { |
88 | return m_movieData->m_showControls; |
89 | } |
90 | |
91 | MovieObject::PlayMode MovieObject::playMode() const |
92 | { |
93 | return m_movieData->m_playMode; |
94 | } |
95 | |
96 | bool MovieObject::showPosterImage() const |
97 | { |
98 | return (m_movieData->m_movieObj->getShowPoster() == true); |
99 | } |
100 | |
101 | QImage MovieObject::posterImage() const |
102 | { |
103 | return m_movieData->m_posterImage; |
104 | } |
105 | |
106 | } |
107 | |