mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
* Some FdoNotifyPlugin cleanups.
This commit is contained in:
@@ -70,6 +70,7 @@ FdoNotifyPlugin::FdoNotifyPlugin()
|
|||||||
QDBusConnection::sessionBus().callWithCallback( message, this, SLOT( dbusCapabiltiesReplyReceived( QDBusMessage ) ) );
|
QDBusConnection::sessionBus().callWithCallback( message, this, SLOT( dbusCapabiltiesReplyReceived( QDBusMessage ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FdoNotifyPlugin::~FdoNotifyPlugin()
|
FdoNotifyPlugin::~FdoNotifyPlugin()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
@@ -79,21 +80,25 @@ FdoNotifyPlugin::~FdoNotifyPlugin()
|
|||||||
void
|
void
|
||||||
FdoNotifyPlugin::dbusCapabiltiesReplyReceived( const QDBusMessage& reply )
|
FdoNotifyPlugin::dbusCapabiltiesReplyReceived( const QDBusMessage& reply )
|
||||||
{
|
{
|
||||||
if (reply.type() != QDBusMessage::ReplyMessage ) {
|
if ( reply.type() != QDBusMessage::ReplyMessage )
|
||||||
|
{
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Did not receive a ReplyMessage";
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Did not receive a ReplyMessage";
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList &list = reply.arguments().at( 0 ).toStringList();
|
const QStringList &list = reply.arguments().at( 0 ).toStringList();
|
||||||
QListIterator<QString> iter( list );
|
QListIterator<QString> iter( list );
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() )
|
||||||
|
{
|
||||||
QString capabilty = iter.next();
|
QString capabilty = iter.next();
|
||||||
if ( capabilty.compare( "body-markup" ) == 0 ) {
|
if ( capabilty.compare( "body-markup" ) == 0 )
|
||||||
|
{
|
||||||
m_wmSupportsBodyMarkup = true;
|
m_wmSupportsBodyMarkup = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FdoNotifyPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
|
FdoNotifyPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
|
||||||
{
|
{
|
||||||
@@ -143,6 +148,7 @@ void
|
|||||||
FdoNotifyPlugin::notifyUser( const QString& messageText )
|
FdoNotifyPlugin::notifyUser( const QString& messageText )
|
||||||
{
|
{
|
||||||
QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify" );
|
QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify" );
|
||||||
|
|
||||||
QList<QVariant> arguments;
|
QList<QVariant> arguments;
|
||||||
arguments << QString( "Tomahawk" ); //app_name
|
arguments << QString( "Tomahawk" ); //app_name
|
||||||
arguments << quint32( 0 ); //notification_id
|
arguments << quint32( 0 ); //notification_id
|
||||||
@@ -150,6 +156,7 @@ FdoNotifyPlugin::notifyUser( const QString &messageText )
|
|||||||
arguments << QString( "Tomahawk" ); //summary
|
arguments << QString( "Tomahawk" ); //summary
|
||||||
arguments << QString( messageText ); //body
|
arguments << QString( messageText ); //body
|
||||||
arguments << QStringList(); //actions
|
arguments << QStringList(); //actions
|
||||||
|
|
||||||
QVariantMap dict;
|
QVariantMap dict;
|
||||||
dict["desktop-entry"] = QString( "tomahawk" );
|
dict["desktop-entry"] = QString( "tomahawk" );
|
||||||
dict[ "image_data" ] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-512x512.png" ).scaledToHeight( getNotificationIconHeight() ) );
|
dict[ "image_data" ] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-512x512.png" ).scaledToHeight( getNotificationIconHeight() ) );
|
||||||
@@ -178,11 +185,13 @@ FdoNotifyPlugin::nowPlaying( const QVariant &input )
|
|||||||
|
|
||||||
QString messageText;
|
QString messageText;
|
||||||
// If the window manager supports notification styling then use it.
|
// If the window manager supports notification styling then use it.
|
||||||
if ( m_wmSupportsBodyMarkup ) {
|
if ( m_wmSupportsBodyMarkup )
|
||||||
|
{
|
||||||
// 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 = tr( "<br /><i>on</i> %1" ).arg( Qt::escape( hash[ "album" ] ) );
|
album = tr( "<br /><i>on</i> %1" ).arg( Qt::escape( hash[ "album" ] ) );
|
||||||
|
|
||||||
messageText = tr( "%1<br /><i>by</i> %2%3." )
|
messageText = tr( "%1<br /><i>by</i> %2%3." )
|
||||||
.arg( Qt::escape( hash[ "title" ] ) )
|
.arg( Qt::escape( hash[ "title" ] ) )
|
||||||
.arg( Qt::escape( hash[ "artist" ] ) )
|
.arg( Qt::escape( hash[ "artist" ] ) )
|
||||||
@@ -193,6 +202,7 @@ FdoNotifyPlugin::nowPlaying( const QVariant &input )
|
|||||||
QString album;
|
QString album;
|
||||||
if ( !hash[ "album" ].isEmpty() )
|
if ( !hash[ "album" ].isEmpty() )
|
||||||
album = QString( " %1" ).arg( tr( "on \"%1\"" ).arg( hash[ "album" ] ) );
|
album = QString( " %1" ).arg( tr( "on \"%1\"" ).arg( hash[ "album" ] ) );
|
||||||
|
|
||||||
messageText = tr( "\"%1\" by %2%3." )
|
messageText = tr( "\"%1\" by %2%3." )
|
||||||
.arg( hash[ "title" ] )
|
.arg( hash[ "title" ] )
|
||||||
.arg( hash[ "artist" ] )
|
.arg( hash[ "artist" ] )
|
||||||
@@ -229,6 +239,7 @@ FdoNotifyPlugin::nowPlaying( const QVariant &input )
|
|||||||
QDBusConnection::sessionBus().callWithCallback( message, this, SLOT( dbusPlayingReplyReceived( QDBusMessage ) ) );
|
QDBusConnection::sessionBus().callWithCallback( message, this, SLOT( dbusPlayingReplyReceived( QDBusMessage ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the DBus reply triggered by FdoNotifyPlugin::nowPlaying
|
* Handle the DBus reply triggered by FdoNotifyPlugin::nowPlaying
|
||||||
*/
|
*/
|
||||||
|
@@ -64,7 +64,6 @@ private:
|
|||||||
int getNotificationIconHeight();
|
int getNotificationIconHeight();
|
||||||
|
|
||||||
void notifyUser( const QString& messageText );
|
void notifyUser( const QString& messageText );
|
||||||
|
|
||||||
void nowPlaying( const QVariant& input );
|
void nowPlaying( const QVariant& input );
|
||||||
|
|
||||||
quint32 m_nowPlayingId;
|
quint32 m_nowPlayingId;
|
||||||
|
Reference in New Issue
Block a user