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