mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
Add (if verbose is turned on in config) play/stop notifications
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "playlistinterface.h"
|
#include "playlistinterface.h"
|
||||||
#include "sourceplaylistinterface.h"
|
#include "sourceplaylistinterface.h"
|
||||||
|
#include "tomahawksettings.h"
|
||||||
|
|
||||||
#include "database/database.h"
|
#include "database/database.h"
|
||||||
#include "database/databasecommand_logplayback.h"
|
#include "database/databasecommand_logplayback.h"
|
||||||
@@ -153,8 +154,20 @@ AudioEngine::stop( bool sendNotification )
|
|||||||
emit stopped();
|
emit stopped();
|
||||||
|
|
||||||
if ( sendNotification )
|
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(
|
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 );
|
DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( m_currentTrack, DatabaseCommand_LogPlayback::Started );
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoCriteriaHash trackInfo;
|
Tomahawk::InfoSystem::InfoMap map;
|
||||||
|
|
||||||
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::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
|
QByteArray
|
||||||
TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const
|
TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const
|
||||||
{
|
{
|
||||||
|
@@ -66,6 +66,9 @@ public:
|
|||||||
QByteArray mainWindowSplitterState() const;
|
QByteArray mainWindowSplitterState() const;
|
||||||
void setMainWindowSplitterState( const QByteArray& state );
|
void setMainWindowSplitterState( const QByteArray& state );
|
||||||
|
|
||||||
|
bool verboseNotifications() const;
|
||||||
|
void setVerboseNotifications( bool notifications );
|
||||||
|
|
||||||
/// Playlist stuff
|
/// Playlist stuff
|
||||||
QByteArray playlistColumnSizes( const QString& playlistid ) const;
|
QByteArray playlistColumnSizes( const QString& playlistid ) const;
|
||||||
void setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state );
|
void setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state );
|
||||||
|
Reference in New Issue
Block a user