mirror of
https://invent.kde.org/graphics/okular
synced 2024-06-30 22:54:24 +00:00
Make phonon optional
In certain configurations not lugging around a multimedia framework could be preferred.
This commit is contained in:
parent
5f2f844577
commit
03368e06f4
|
@ -198,7 +198,14 @@ if(NOT WIN32 AND NOT ANDROID AND NOT APPLE)
|
|||
else()
|
||||
set(HAVE_X11 FALSE)
|
||||
endif()
|
||||
find_package(Phonon4Qt5 CONFIG REQUIRED)
|
||||
find_package(Phonon4Qt5 CONFIG)
|
||||
set_okular_optional_package_properties(Phonon4Qt5 PROPERTIES
|
||||
PURPOSE "Required for documents with audio or video elements")
|
||||
if (Phonon4Qt5_Found)
|
||||
set(HAVE_PHONON 1)
|
||||
else()
|
||||
set(HAVE_PHONON 0)
|
||||
endif()
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules)
|
||||
|
||||
|
@ -442,7 +449,6 @@ PRIVATE
|
|||
KF5::I18n
|
||||
KF5::ThreadWeaver
|
||||
KF5::Bookmarks
|
||||
Phonon::phonon4qt5
|
||||
Qt5::Svg
|
||||
${MATH_LIB}
|
||||
ZLIB::ZLIB
|
||||
|
@ -454,6 +460,9 @@ PUBLIC # these are included from the installed headers
|
|||
Qt5::Widgets
|
||||
Qt5::CorePrivate
|
||||
)
|
||||
if (Phonon4Qt5_FOUND)
|
||||
target_link_libraries(okularcore PRIVATE Phonon::phonon4qt5)
|
||||
endif()
|
||||
|
||||
|
||||
if (KF5Wallet_FOUND)
|
||||
|
@ -573,7 +582,6 @@ generate_export_header(okularpart BASE_NAME okularpart)
|
|||
target_link_libraries(okularpart okularcore
|
||||
${MATH_LIB}
|
||||
Qt5::Svg
|
||||
Phonon::phonon4qt5
|
||||
KF5::Archive
|
||||
KF5::Bookmarks
|
||||
KF5::I18n
|
||||
|
@ -587,6 +595,9 @@ target_link_libraries(okularpart okularcore
|
|||
KF5::WindowSystem
|
||||
KF5::TextWidgets
|
||||
)
|
||||
if (Phonon4Qt5_FOUND)
|
||||
target_link_libraries(okularpart Phonon::phonon4qt5)
|
||||
endif()
|
||||
|
||||
if(KF5Wallet_FOUND)
|
||||
target_link_libraries(okularpart KF5::Wallet)
|
||||
|
|
|
@ -18,3 +18,6 @@
|
|||
|
||||
/* Defines whether we are building with X11 support */
|
||||
#cmakedefine01 HAVE_X11
|
||||
|
||||
/* Defines wheter we are building with Phonon support */
|
||||
#cmakedefine01 HAVE_PHONON
|
||||
|
|
|
@ -5,26 +5,57 @@
|
|||
*/
|
||||
|
||||
#include "audioplayer.h"
|
||||
#include "audioplayer_p.h"
|
||||
|
||||
// qt/kde includes
|
||||
#include <KLocalizedString>
|
||||
#include <QBuffer>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
#include "config-okular.h"
|
||||
|
||||
#if HAVE_PHONON
|
||||
#include <phonon/abstractmediastream.h>
|
||||
#include <phonon/audiooutput.h>
|
||||
#include <phonon/mediaobject.h>
|
||||
#include <phonon/path.h>
|
||||
#endif
|
||||
|
||||
// local includes
|
||||
#include "action.h"
|
||||
#include "debug_p.h"
|
||||
#include "document.h"
|
||||
#include "sound.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
#if HAVE_PHONON
|
||||
|
||||
namespace Okular
|
||||
{
|
||||
class AudioPlayerPrivate
|
||||
{
|
||||
public:
|
||||
explicit AudioPlayerPrivate(AudioPlayer *qq);
|
||||
|
||||
~AudioPlayerPrivate();
|
||||
|
||||
int newId() const;
|
||||
bool play(const SoundInfo &si);
|
||||
void stopPlayings();
|
||||
|
||||
void finished(int);
|
||||
|
||||
AudioPlayer *q;
|
||||
|
||||
QHash<int, PlayData *> m_playing;
|
||||
QUrl m_currentDocument;
|
||||
AudioPlayer::State m_state;
|
||||
};
|
||||
}
|
||||
|
||||
// helper class used to store info about a sound to be played
|
||||
class SoundInfo
|
||||
{
|
||||
|
@ -247,4 +278,70 @@ AudioPlayer::State AudioPlayer::state() const
|
|||
return d->m_state;
|
||||
}
|
||||
|
||||
void AudioPlayer::resetDocument()
|
||||
{
|
||||
d->currentDocument = {};
|
||||
}
|
||||
|
||||
void AudioPlayer::setDocument(const QUrl &url, Okular::Document *document)
|
||||
{
|
||||
Q_UNUSED(document);
|
||||
d->currentDocument = url;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
namespace Okular
|
||||
{
|
||||
class AudioPlayerPrivate
|
||||
{
|
||||
public:
|
||||
Document *document;
|
||||
};
|
||||
}
|
||||
|
||||
AudioPlayer::AudioPlayer()
|
||||
: d(new AudioPlayerPrivate())
|
||||
{
|
||||
}
|
||||
|
||||
AudioPlayer *AudioPlayer::instance()
|
||||
{
|
||||
static AudioPlayer ap;
|
||||
return ≈
|
||||
}
|
||||
|
||||
void AudioPlayer::playSound(const Sound *sound, const SoundAction *linksound)
|
||||
{
|
||||
Q_UNUSED(sound);
|
||||
Q_UNUSED(linksound);
|
||||
Q_EMIT d->document->warning(i18n("This Okular is bulit without audio support"), 2000);
|
||||
}
|
||||
|
||||
AudioPlayer::State Okular::AudioPlayer::state() const
|
||||
{
|
||||
return State::StoppedState;
|
||||
}
|
||||
|
||||
void AudioPlayer::stopPlaybacks()
|
||||
{
|
||||
}
|
||||
|
||||
AudioPlayer::~AudioPlayer() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
void AudioPlayer::resetDocument()
|
||||
{
|
||||
d->document = nullptr;
|
||||
}
|
||||
|
||||
void AudioPlayer::setDocument(const QUrl &url, Okular::Document *document)
|
||||
{
|
||||
Q_UNUSED(url);
|
||||
d->document = document;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#include "moc_audioplayer.cpp"
|
||||
|
|
|
@ -70,6 +70,8 @@ public:
|
|||
|
||||
private:
|
||||
AudioPlayer();
|
||||
void resetDocument();
|
||||
void setDocument(const QUrl &url, Document *document);
|
||||
|
||||
friend class AudioPlayerPrivate;
|
||||
AudioPlayerPrivate *const d;
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2007 Pino Toscano <pino@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef _OKULAR_AUDIOPLAYER_P_H_
|
||||
#define _OKULAR_AUDIOPLAYER_P_H_
|
||||
|
||||
// qt/kde includes
|
||||
#include <QHash>
|
||||
#include <QUrl>
|
||||
|
||||
class PlayData;
|
||||
class SoundInfo;
|
||||
|
||||
namespace Okular
|
||||
{
|
||||
class AudioPlayer;
|
||||
|
||||
class AudioPlayerPrivate
|
||||
{
|
||||
public:
|
||||
explicit AudioPlayerPrivate(AudioPlayer *qq);
|
||||
|
||||
~AudioPlayerPrivate();
|
||||
|
||||
int newId() const;
|
||||
bool play(const SoundInfo &si);
|
||||
void stopPlayings();
|
||||
|
||||
void finished(int);
|
||||
|
||||
AudioPlayer *q;
|
||||
|
||||
QHash<int, PlayData *> m_playing;
|
||||
QUrl m_currentDocument;
|
||||
AudioPlayer::State m_state;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -71,7 +71,6 @@
|
|||
#include "annotations.h"
|
||||
#include "annotations_p.h"
|
||||
#include "audioplayer.h"
|
||||
#include "audioplayer_p.h"
|
||||
#include "bookmarkmanager.h"
|
||||
#include "chooseenginedialog_p.h"
|
||||
#include "debug_p.h"
|
||||
|
@ -2576,7 +2575,7 @@ Document::OpenResult Document::openDocument(const QString &docFile, const QUrl &
|
|||
d->m_nextDocumentDestination = QString();
|
||||
}
|
||||
|
||||
AudioPlayer::instance()->d->m_currentDocument = fromFileDescriptor ? QUrl() : d->m_url;
|
||||
AudioPlayer::instance()->setDocument(fromFileDescriptor ? QUrl() : d->m_url, this);
|
||||
|
||||
const QStringList docScripts = d->m_generator->metaData(QStringLiteral("DocumentScripts"), QStringLiteral("JavaScript")).toStringList();
|
||||
if (!docScripts.isEmpty()) {
|
||||
|
@ -2773,7 +2772,7 @@ void Document::closeDocument()
|
|||
d->m_documentInfo = DocumentInfo();
|
||||
d->m_documentInfoAskedKeys.clear();
|
||||
|
||||
AudioPlayer::instance()->d->m_currentDocument = QUrl();
|
||||
AudioPlayer::instance()->resetDocument();
|
||||
|
||||
d->m_undoStack->clear();
|
||||
d->m_docdataMigrationNeeded = false;
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "snapshottaker.h"
|
||||
|
||||
#if HAVE_PHONON
|
||||
|
||||
#include <phonon/mediaobject.h>
|
||||
#include <phonon/videowidget.h>
|
||||
|
||||
|
@ -41,3 +42,4 @@ void SnapshotTaker::stateChanged(Phonon::State newState, Phonon::State)
|
|||
deleteLater();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
#ifndef SNAPSHOTTAKER_H
|
||||
#define SNAPSHOTTAKER_H
|
||||
#include "config-okular.h"
|
||||
|
||||
#if HAVE_PHONON
|
||||
|
||||
#include <phonon/videoplayer.h>
|
||||
|
||||
|
@ -32,3 +35,4 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -22,9 +22,13 @@
|
|||
#include <KLocalizedString>
|
||||
#include <QIcon>
|
||||
|
||||
#include "config-okular.h"
|
||||
|
||||
#if HAVE_PHONON
|
||||
#include <phonon/mediaobject.h>
|
||||
#include <phonon/seekslider.h>
|
||||
#include <phonon/videoplayer.h>
|
||||
#endif
|
||||
|
||||
#include "core/annotations.h"
|
||||
#include "core/area.h"
|
||||
|
@ -32,6 +36,8 @@
|
|||
#include "core/movie.h"
|
||||
#include "snapshottaker.h"
|
||||
|
||||
#if HAVE_PHONON
|
||||
|
||||
static QAction *createToolBarButtonWithWidgetPopup(QToolBar *toolBar, QWidget *widget, const QIcon &icon)
|
||||
{
|
||||
QToolButton *button = new QToolButton(toolBar);
|
||||
|
@ -420,5 +426,94 @@ void VideoWidget::resizeEvent(QResizeEvent *event)
|
|||
d->seekSliderMenuAction->setVisible(false);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
class VideoWidget::Private
|
||||
{
|
||||
public:
|
||||
Okular::NormalizedRect geom;
|
||||
};
|
||||
|
||||
bool VideoWidget::event(QEvent *event)
|
||||
{
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
bool VideoWidget::eventFilter(QObject *object, QEvent *event)
|
||||
{
|
||||
return QWidget::eventFilter(object, event);
|
||||
}
|
||||
|
||||
bool VideoWidget::isPlaying() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Okular::NormalizedRect VideoWidget::normGeometry() const
|
||||
{
|
||||
return d->geom;
|
||||
}
|
||||
|
||||
void VideoWidget::pageEntered()
|
||||
{
|
||||
show();
|
||||
}
|
||||
|
||||
void VideoWidget::pageInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
void VideoWidget::pageLeft()
|
||||
{
|
||||
}
|
||||
void VideoWidget::pause()
|
||||
{
|
||||
}
|
||||
void VideoWidget::play()
|
||||
{
|
||||
}
|
||||
|
||||
void VideoWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void VideoWidget::setNormGeometry(const Okular::NormalizedRect &rect)
|
||||
{
|
||||
d->geom = rect;
|
||||
}
|
||||
|
||||
void VideoWidget::stop()
|
||||
{
|
||||
}
|
||||
|
||||
VideoWidget::VideoWidget(const Okular::Annotation *annotation, Okular::Movie *movie, Okular::Document *document, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, d(new VideoWidget::Private)
|
||||
{
|
||||
auto layout = new QVBoxLayout();
|
||||
d->geom = annotation->transformedBoundingRectangle();
|
||||
auto poster = new QLabel;
|
||||
if (movie->showPosterImage()) {
|
||||
auto posterImage = movie->posterImage();
|
||||
if (!posterImage.isNull()) {
|
||||
poster->setPixmap(QPixmap::fromImage(posterImage));
|
||||
}
|
||||
}
|
||||
Q_EMIT document->warning(i18n("Videos not supported in this okular"), 5000);
|
||||
poster->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
layout->addWidget(poster, 2);
|
||||
|
||||
auto label = new QLabel(i18n("Videos not supported in this Okular"));
|
||||
label->setAutoFillBackground(true);
|
||||
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
layout->addWidget(label, 1, Qt::AlignCenter);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
VideoWidget::~VideoWidget() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
#include "moc_videowidget.cpp"
|
||||
|
|
Loading…
Reference in New Issue
Block a user