mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
Make Freedesktop notification Qt5 compatible
This commit is contained in:
@@ -1,24 +1,15 @@
|
|||||||
# don't build with Qt5 because QX11Info is missing there
|
SET(fdo_srcs
|
||||||
if(NOT Qt5Core_DIR)
|
fdonotify/FdoNotifyPlugin.cpp
|
||||||
|
fdonotify/ImageConverter.cpp
|
||||||
|
)
|
||||||
|
SET(FDO_LINK_LIBRARIES ${LINK_LIBRARIES})
|
||||||
|
qt_add_dbus_interface(fdo_srcs fdonotify/org.freedesktop.Notifications.xml
|
||||||
|
FreedesktopNotificationsProxy)
|
||||||
|
|
||||||
IF(BUILD_GUI AND X11_FOUND)
|
tomahawk_add_plugin(fdonotify
|
||||||
INCLUDE_DIRECTORIES( ${THIRDPARTY_DIR}/libqnetwm )
|
TYPE infoplugin EXPORT_MACRO INFOPLUGINDLLEXPORT_PRO
|
||||||
SET(fdo_srcs
|
SOURCES "${fdo_srcs}" LINK_LIBRARIES "${FDO_LINK_LIBRARIES}"
|
||||||
fdonotify/FdoNotifyPlugin.cpp
|
)
|
||||||
fdonotify/ImageConverter.cpp
|
|
||||||
${THIRDPARTY_DIR}/libqnetwm/libqnetwm/netwm.cpp
|
|
||||||
)
|
|
||||||
SET(FDO_LINK_LIBRARIES ${LINK_LIBRARIES} ${X11_LIBRARIES})
|
|
||||||
qt_add_dbus_interface(fdo_srcs fdonotify/org.freedesktop.Notifications.xml
|
|
||||||
FreedesktopNotificationsProxy)
|
|
||||||
|
|
||||||
tomahawk_add_plugin(fdonotify
|
|
||||||
TYPE infoplugin EXPORT_MACRO INFOPLUGINDLLEXPORT_PRO
|
|
||||||
SOURCES "${fdo_srcs}" LINK_LIBRARIES "${FDO_LINK_LIBRARIES}"
|
|
||||||
)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
endif()
|
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} )
|
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||||
SET(mpris_srcs
|
SET(mpris_srcs
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||||
|
* Copyright 2013-2014, Uwe L. Korn <uwelk@xhochy.com>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -60,6 +61,14 @@ namespace Tomahawk
|
|||||||
namespace InfoSystem
|
namespace InfoSystem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
QString escapeHtml( const QString& str ) {
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||||
|
return str.toHtmlEscaped();
|
||||||
|
#else
|
||||||
|
return Qt::escape( str );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
FdoNotifyPlugin::FdoNotifyPlugin()
|
FdoNotifyPlugin::FdoNotifyPlugin()
|
||||||
: InfoPlugin()
|
: InfoPlugin()
|
||||||
, m_nowPlayingId( 0 )
|
, m_nowPlayingId( 0 )
|
||||||
@@ -195,9 +204,9 @@ void FdoNotifyPlugin::inboxReceived( const QVariant& input )
|
|||||||
{
|
{
|
||||||
// Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
|
// Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
|
||||||
messageText = tr( "%1 sent you\n%2%4 %3.", "%1 is a nickname, %2 is a title, %3 is an artist, %4 is the preposition used to link track and artist ('by' in english)" )
|
messageText = tr( "%1 sent you\n%2%4 %3.", "%1 is a nickname, %2 is a title, %3 is an artist, %4 is the preposition used to link track and artist ('by' in english)" )
|
||||||
.arg( Qt::escape( src["friendlyname"] ) )
|
.arg( escapeHtml( src["friendlyname"] ) )
|
||||||
.arg( Qt::escape( hash[ "title" ] ) )
|
.arg( escapeHtml( hash[ "title" ] ) )
|
||||||
.arg( Qt::escape( hash[ "artist" ] ) )
|
.arg( escapeHtml( hash[ "artist" ] ) )
|
||||||
.arg( QString( "\n<i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) );
|
.arg( QString( "\n<i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) );
|
||||||
|
|
||||||
// Dirty hack(TM) so that KNotify/QLabel recognizes the message as Rich Text
|
// Dirty hack(TM) so that KNotify/QLabel recognizes the message as Rich Text
|
||||||
@@ -253,11 +262,13 @@ FdoNotifyPlugin::nowPlaying( const QVariant& input )
|
|||||||
// Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
|
// Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
|
||||||
QString album;
|
QString album;
|
||||||
if ( !hash[ "album" ].isEmpty() )
|
if ( !hash[ "album" ].isEmpty() )
|
||||||
album = QString( "\n<i>%1</i> %2" ).arg( tr( "on", "'on' is followed by an album name" ) ).arg( Qt::escape( hash[ "album" ] ) );
|
album = QString( "\n<i>%1</i> %2" )
|
||||||
|
.arg( tr( "on", "'on' is followed by an album name" ) )
|
||||||
|
.arg( escapeHtml( hash[ "album" ] ) );
|
||||||
|
|
||||||
messageText = tr( "%1%4 %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing, %4 is the preposition used to link track and artist ('by' in english)" )
|
messageText = tr( "%1%4 %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing, %4 is the preposition used to link track and artist ('by' in english)" )
|
||||||
.arg( Qt::escape( hash[ "title" ] ) )
|
.arg( escapeHtml( hash[ "title" ] ) )
|
||||||
.arg( Qt::escape( hash[ "artist" ] ) )
|
.arg( escapeHtml( hash[ "artist" ] ) )
|
||||||
.arg( album )
|
.arg( album )
|
||||||
.arg( QString( "\n<i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) );
|
.arg( QString( "\n<i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user