generic: make MPV recommended not required

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2016-05-14 10:07:58 +00:00
parent f109cc1695
commit 2d823ecdd8
4 changed files with 125 additions and 20 deletions

View file

@ -46,7 +46,7 @@ if(UNIX AND Q_WS_X11)
endif(NOT XCB_FOUND)
endif(UNIX AND Q_WS_X11)
# required features:
# required features
find_package(Perl)
set_package_properties(Perl PROPERTIES
URL "http://www.perl.org"
@ -70,13 +70,6 @@ set_package_properties(SharedMimeInfo PROPERTIES
PURPOSE "Allows KDE applications to determine file types"
)
find_package(MPV)
set_package_properties(MPV PROPERTIES
DESCRIPTION "A fork of mplayer2 and MPlayer"
URL "https://mpv.io/"
TYPE REQUIRED
)
# optional features
if(X11_FOUND)
#X11_Xrender discovery is done by FindX11
@ -122,6 +115,14 @@ set_package_properties(Strigi PROPERTIES
PURPOSE "Required by some critical kioslaves"
)
macro_optional_find_package(MPV)
set_package_properties(MPV PROPERTIES
DESCRIPTION "A fork of mplayer2 and MPlayer"
URL "https://mpv.io/"
TYPE RECOMMENDED
PURPOSE "Media preview, sound notifications, etc."
)
macro_optional_find_package(FAM)
set_package_properties(FAM PROPERTIES
DESCRIPTION "File alteration notification support via a separate service"

View file

@ -1,9 +1,11 @@
include_directories(
${MPV_INCLUDES}
)
set(kmediaplayer_OPTIONAL_LIBS)
if(MPV_FOUND)
include_directories(${MPV_INCLUDES})
add_definitions(-DHAVE_MPV)
set(kmediaplayer_OPTIONAL_LIBS ${MPV_LIBRARIES})
endif()
add_definitions(
-DMAKE_KMEDIAPLAYER_LIB
-DKDE_DEFAULT_DEBUG_AREA=940
)
@ -16,10 +18,10 @@ set(kmediaplayer_LIB_SRCS
add_library(kmediaplayer ${LIBRARY_TYPE} ${kmediaplayer_LIB_SRCS})
target_link_libraries(kmediaplayer
${MPV_LIBRARIES}
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KFILE_LIBS}
${kmediaplayer_OPTIONAL_LIBS}
)
set_target_properties(kmediaplayer PROPERTIES

View file

@ -24,9 +24,13 @@
#include <QDragEnterEvent>
#endif
#include "kmediaplayer.h"
#ifdef HAVE_MPV
#include <mpv/client.h>
#include <mpv/qthelper.hpp>
#else
static bool s_fullscreen = false;
#endif // HAVE_MPV
void KAbstractPlayer::load(QString path)
{
@ -145,7 +149,11 @@ bool KAbstractPlayer::isSeekable()
bool KAbstractPlayer::isFullscreen()
{
#ifdef HAVE_MPV
return property("fullscreen").toBool();
#else
return s_fullscreen;
#endif // HAVE_MPV
}
bool KAbstractPlayer::isProtocolSupported(QString protocol)
@ -189,9 +197,14 @@ void KAbstractPlayer::setAudioOutput(QString output)
void KAbstractPlayer::setFullscreen(bool fullscreen)
{
#ifdef HAVE_MPV
setProperty("fullscreen", fullscreen);
#else
s_fullscreen = fullscreen;
#endif // HAVE_MPV
}
#ifdef HAVE_MPV
/*
Since exposing mpv_handle is not desirable and sigals/slots cannot be virtual nor multiple
QObject inheritance works here are some pre-processor definitions used to share the code as
@ -488,4 +501,93 @@ bool KMediaPlayer::isMimeSupported(const QString mime) const
|| mime == QLatin1String("application/octet-stream");
}
#else // HAVE_MPV
/////
KAudioPlayer::KAudioPlayer(QObject *parent)
: QObject(parent)
{
kWarning() << i18n("KAudioPlayer is a stub");
}
KAudioPlayer::~KAudioPlayer()
{
}
void KAudioPlayer::command(const QVariant& command) const
{
Q_UNUSED(command);
}
void KAudioPlayer::setProperty(const QString& name, const QVariant& value) const
{
Q_UNUSED(name);
Q_UNUSED(value);
}
QVariant KAudioPlayer::property(const QString& name) const
{
Q_UNUSED(name);
return QVariant();
}
void KAudioPlayer::setOption(const QString& name, const QVariant& value) const
{
Q_UNUSED(name);
Q_UNUSED(value);
}
void KAudioPlayer::_processHandleEvents()
{
}
bool KAudioPlayer::isMimeSupported(const QString mime) const
{
Q_UNUSED(mime);
return false;
}
/////
KMediaPlayer::KMediaPlayer(QWidget *parent)
: QWidget(parent)
{
kWarning() << i18n("KMediaPlayer is a stub");
}
KMediaPlayer::~KMediaPlayer()
{
}
void KMediaPlayer::command(const QVariant& command) const
{
Q_UNUSED(command);
}
void KMediaPlayer::setProperty(const QString& name, const QVariant& value) const
{
Q_UNUSED(name);
Q_UNUSED(value);
}
QVariant KMediaPlayer::property(const QString& name) const
{
Q_UNUSED(name);
return QVariant();
}
void KMediaPlayer::setOption(const QString& name, const QVariant& value) const
{
}
void KMediaPlayer::_processHandleEvents()
{
}
bool KMediaPlayer::isMimeSupported(const QString mime) const
{
Q_UNUSED(mime);
return false;
}
#endif // HAVE_MPV
#include "moc_kmediaplayer.cpp"

View file

@ -25,7 +25,7 @@
#include <kmimetype.h>
#include <kmediaplayer_export.h>
#ifdef MAKE_KMEDIAPLAYER_LIB
#ifdef kmediaplayer_EXPORTS
typedef struct mpv_handle mpv_handle;
#endif
@ -270,9 +270,9 @@ private slots:
void _processHandleEvents();
private:
#ifdef MAKE_KMEDIAPLAYER_LIB
#ifdef kmediaplayer_EXPORTS
mpv_handle *m_handle;
#endif // MAKE_KMEDIAPLAYER_LIB
#endif // kmediaplayer_EXPORTS
QString m_appname;
QSettings *m_settings;
bool m_stopprocessing;
@ -337,9 +337,9 @@ private slots:
void _processHandleEvents();
private:
#ifdef MAKE_KMEDIAPLAYER_LIB
#ifdef kmediaplayer_EXPORTS
mpv_handle *m_handle;
#endif // MAKE_KMEDIAPLAYER_LIB
#endif // kmediaplayer_EXPORTS
QString m_appname;
QSettings *m_settings;
bool m_stopprocessing;