1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-26 02:32:35 +01:00

Add (if verbose is turned on in config) play/stop notifications

This commit is contained in:
Jeff Mitchell 2011-06-23 15:12:06 -04:00
parent d5266f7147
commit d455270c05
3 changed files with 50 additions and 9 deletions

@ -22,6 +22,7 @@
#include "playlistinterface.h"
#include "sourceplaylistinterface.h"
#include "tomahawksettings.h"
#include "database/database.h"
#include "database/databasecommand_logplayback.h"
@ -153,8 +154,20 @@ AudioEngine::stop( bool sendNotification )
emit stopped();
if ( sendNotification )
{
Tomahawk::InfoSystem::InfoMap map;
map[ Tomahawk::InfoSystem::InfoNowStopped ] = QVariant();
if ( TomahawkSettings::instance()->verboseNotifications() )
{
Tomahawk::InfoSystem::InfoCriteriaHash stopInfo;
stopInfo["message"] = QString( "Tomahawk is stopped." );
map[ Tomahawk::InfoSystem::InfoNotifyUser ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( stopInfo );
}
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowStopped, QVariant() );
s_aeInfoIdentifier, map );
}
}
@ -305,15 +318,26 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( m_currentTrack, DatabaseCommand_LogPlayback::Started );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
Tomahawk::InfoSystem::InfoCriteriaHash trackInfo;
trackInfo["title"] = m_currentTrack->track();
trackInfo["artist"] = m_currentTrack->artist()->name();
trackInfo["album"] = m_currentTrack->album()->name();
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowPlaying,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ) );
Tomahawk::InfoSystem::InfoMap map;
Tomahawk::InfoSystem::InfoCriteriaHash trackInfo;
trackInfo["title"] = m_currentTrack->track();
trackInfo["artist"] = m_currentTrack->artist()->name();
trackInfo["album"] = m_currentTrack->album()->name();
map[ Tomahawk::InfoSystem::InfoNowPlaying ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo );
if ( TomahawkSettings::instance()->verboseNotifications() )
{
Tomahawk::InfoSystem::InfoCriteriaHash playInfo;
playInfo["message"] = QString( "Tomahawk is playing \"%1\" by %2 on album %3." )
.arg( m_currentTrack->track() )
.arg( m_currentTrack->artist()->name() )
.arg( m_currentTrack->album()->name() );
map[ Tomahawk::InfoSystem::InfoNotifyUser ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( playInfo );
}
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
s_aeInfoIdentifier, map );
}
}

@ -420,6 +420,20 @@ TomahawkSettings::setMainWindowSplitterState( const QByteArray& state )
}
bool
TomahawkSettings::verboseNotifications() const
{
return value( "ui/notifications/verbose", false ).toBool();
}
void
TomahawkSettings::setVerboseNotifications( bool notifications )
{
setValue( "ui/notifications/verbose", notifications );
}
QByteArray
TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const
{

@ -66,6 +66,9 @@ public:
QByteArray mainWindowSplitterState() const;
void setMainWindowSplitterState( const QByteArray& state );
bool verboseNotifications() const;
void setVerboseNotifications( bool notifications );
/// Playlist stuff
QByteArray playlistColumnSizes( const QString& playlistid ) const;
void setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state );