mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
When notifying of a played track, show the source's image. Ideally we'd show the album cover but I can't find a good way to get at that (yet).
This commit is contained in:
@@ -154,9 +154,9 @@ AudioEngine::stop()
|
|||||||
sendWaitingNotification();
|
sendWaitingNotification();
|
||||||
else if ( TomahawkSettings::instance()->verboseNotifications() )
|
else if ( TomahawkSettings::instance()->verboseNotifications() )
|
||||||
{
|
{
|
||||||
Tomahawk::InfoSystem::InfoCriteriaHash stopInfo;
|
Tomahawk::InfoSystem::InfoCustomData stopInfo;
|
||||||
stopInfo["message"] = QString( "Tomahawk is stopped." );
|
stopInfo["message"] = QString( "Tomahawk is stopped." );
|
||||||
map[ Tomahawk::InfoSystem::InfoNotifyUser ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( stopInfo );
|
map[ Tomahawk::InfoSystem::InfoNotifyUser ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoCustomData >( stopInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( s_aeInfoIdentifier, map );
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( s_aeInfoIdentifier, map );
|
||||||
@@ -240,11 +240,11 @@ AudioEngine::mute()
|
|||||||
void
|
void
|
||||||
AudioEngine::sendWaitingNotification() const
|
AudioEngine::sendWaitingNotification() const
|
||||||
{
|
{
|
||||||
Tomahawk::InfoSystem::InfoCriteriaHash retryInfo;
|
Tomahawk::InfoSystem::InfoCustomData retryInfo;
|
||||||
retryInfo["message"] = QString( "The current track could not be resolved. Tomahawk will pick back up with the next resolvable track from this source." );
|
retryInfo["message"] = QString( "The current track could not be resolved. Tomahawk will pick back up with the next resolvable track from this source." );
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||||
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
|
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
|
||||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( retryInfo ) );
|
QVariant::fromValue< Tomahawk::InfoSystem::InfoCustomData >( retryInfo ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -329,12 +329,13 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
|||||||
|
|
||||||
if ( TomahawkSettings::instance()->verboseNotifications() )
|
if ( TomahawkSettings::instance()->verboseNotifications() )
|
||||||
{
|
{
|
||||||
Tomahawk::InfoSystem::InfoCriteriaHash playInfo;
|
Tomahawk::InfoSystem::InfoCustomData playInfo;
|
||||||
playInfo["message"] = QString( "Tomahawk is playing \"%1\" by %2 on album %3." )
|
playInfo["message"] = QString( "Tomahawk is playing \"%1\" by %2 on album %3." )
|
||||||
.arg( m_currentTrack->track() )
|
.arg( m_currentTrack->track() )
|
||||||
.arg( m_currentTrack->artist()->name() )
|
.arg( m_currentTrack->artist()->name() )
|
||||||
.arg( m_currentTrack->album()->name() );
|
.arg( m_currentTrack->album()->name() );
|
||||||
map[ Tomahawk::InfoSystem::InfoNotifyUser ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( playInfo );
|
playInfo["image"] = QVariant( m_currentTrack->collection()->source()->avatar().toImage() );
|
||||||
|
map[ Tomahawk::InfoSystem::InfoNotifyUser ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoCustomData >( playInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( s_aeInfoIdentifier, map );
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( s_aeInfoIdentifier, map );
|
||||||
|
@@ -63,12 +63,12 @@ FdoNotifyPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::Inf
|
|||||||
{
|
{
|
||||||
Q_UNUSED( caller );
|
Q_UNUSED( caller );
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if ( type != Tomahawk::InfoSystem::InfoNotifyUser || !pushData.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
|
if ( type != Tomahawk::InfoSystem::InfoNotifyUser || !pushData.canConvert< Tomahawk::InfoSystem::InfoCustomData >() )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << " not the right type or could not convert the hash";
|
qDebug() << Q_FUNC_INFO << " not the right type or could not convert the hash";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Tomahawk::InfoSystem::InfoCriteriaHash hash = pushData.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
|
Tomahawk::InfoSystem::InfoCustomData hash = pushData.value< Tomahawk::InfoSystem::InfoCustomData >();
|
||||||
if ( !hash.contains( "message" ) )
|
if ( !hash.contains( "message" ) )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << " hash did not contain a message";
|
qDebug() << Q_FUNC_INFO << " hash did not contain a message";
|
||||||
@@ -81,11 +81,18 @@ FdoNotifyPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::Inf
|
|||||||
arguments << quint32( 0 ); //notification_id
|
arguments << quint32( 0 ); //notification_id
|
||||||
arguments << QString(); //app_icon
|
arguments << QString(); //app_icon
|
||||||
arguments << QString( "Tomahawk" ); //summary
|
arguments << QString( "Tomahawk" ); //summary
|
||||||
arguments << hash["message"]; //body
|
arguments << hash["message"].toString(); //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-128x128.png" ) );
|
if ( hash.contains( "image" ) )
|
||||||
|
{
|
||||||
|
QVariant tempVariant = hash["image"];
|
||||||
|
QImage tempImage = tempVariant.value< QImage >();
|
||||||
|
dict["image_data"] = ImageConverter::variantForImage( tempImage );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dict["image_data"] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-128x128.png" ) );
|
||||||
arguments << dict; //hints
|
arguments << dict; //hints
|
||||||
arguments << qint32( -1 ); //expire_timeout
|
arguments << qint32( -1 ); //expire_timeout
|
||||||
message.setArguments( arguments );
|
message.setArguments( arguments );
|
||||||
|
Reference in New Issue
Block a user