mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
ifdefs--: Move ActionCollection initialization code from AudioEngine to
Ac
This commit is contained in:
parent
0f3ba435d9
commit
ea7e641bdd
@ -19,6 +19,7 @@
|
||||
#include "actioncollection.h"
|
||||
#include <tomahawksettings.h>
|
||||
#include <utils/tomahawkutils.h>
|
||||
#include "audio/audioengine.h"
|
||||
|
||||
ActionCollection* ActionCollection::s_instance = 0;
|
||||
ActionCollection* ActionCollection::instance()
|
||||
@ -50,6 +51,8 @@ ActionCollection::initActions()
|
||||
privacyToggle->setIcon( QIcon( RESPATH "images/private-listening.png" ) );
|
||||
privacyToggle->setIconVisibleInMenu( isPublic );
|
||||
m_actionCollection[ "togglePrivacy" ] = privacyToggle;
|
||||
connect( m_actionCollection[ "togglePrivacy" ], SIGNAL( triggered() ), SLOT( togglePrivateListeningMode() ), Qt::UniqueConnection );
|
||||
|
||||
|
||||
m_actionCollection[ "loadPlaylist"] = new QAction( tr( "&Load Playlist" ), this );
|
||||
m_actionCollection[ "renamePlaylist"] = new QAction( tr( "&Rename Playlist" ), this );
|
||||
@ -59,6 +62,13 @@ ActionCollection::initActions()
|
||||
m_actionCollection[ "previousTrack"] = new QAction( tr( "&Previous Track" ), this );
|
||||
m_actionCollection[ "nextTrack"] = new QAction( tr( "&Next Track" ), this );
|
||||
m_actionCollection[ "quit"] = new QAction( tr( "&Quit" ), this );
|
||||
|
||||
// connect actions to AudioEngine
|
||||
AudioEngine *ae = AudioEngine::instance();
|
||||
connect( m_actionCollection[ "playPause" ], SIGNAL( triggered() ), ae, SLOT( playPause() ), Qt::UniqueConnection );
|
||||
connect( m_actionCollection[ "stop" ], SIGNAL( triggered() ), ae, SLOT( stop() ), Qt::UniqueConnection );
|
||||
connect( m_actionCollection[ "previousTrack" ], SIGNAL( triggered() ), ae, SLOT( previous() ), Qt::UniqueConnection );
|
||||
connect( m_actionCollection[ "nextTrack" ], SIGNAL( triggered() ), ae, SLOT( next() ), Qt::UniqueConnection );
|
||||
}
|
||||
|
||||
|
||||
@ -75,3 +85,20 @@ ActionCollection::getAction( const QString& name )
|
||||
{
|
||||
return m_actionCollection.contains( name ) ? m_actionCollection[ name ] : 0;
|
||||
}
|
||||
|
||||
void
|
||||
ActionCollection::togglePrivateListeningMode()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
if ( TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening )
|
||||
TomahawkSettings::instance()->setPrivateListeningMode( TomahawkSettings::FullyPrivate );
|
||||
else
|
||||
TomahawkSettings::instance()->setPrivateListeningMode( TomahawkSettings::PublicListening );
|
||||
|
||||
QAction *privacyToggle = m_actionCollection[ "togglePrivacy" ];
|
||||
bool isPublic = TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening;
|
||||
privacyToggle->setText( ( isPublic ? tr( "&Listen Privately" ) : tr( "&Listen Publicly" ) ) );
|
||||
privacyToggle->setIconVisibleInMenu( isPublic );
|
||||
|
||||
emit privacyModeChanged();
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
class DLLEXPORT ActionCollection : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
static ActionCollection* instance();
|
||||
|
||||
@ -35,9 +35,16 @@ public:
|
||||
~ActionCollection();
|
||||
|
||||
void initActions();
|
||||
|
||||
|
||||
QAction* getAction( const QString &name );
|
||||
|
||||
|
||||
public slots:
|
||||
void togglePrivateListeningMode();
|
||||
|
||||
signals:
|
||||
void privacyModeChanged();
|
||||
|
||||
|
||||
private:
|
||||
static ActionCollection* s_instance;
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "playlistinterface.h"
|
||||
#include "sourceplaylistinterface.h"
|
||||
#include "tomahawksettings.h"
|
||||
#include "actioncollection.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databasecommand_logplayback.h"
|
||||
#include "network/servent.h"
|
||||
@ -77,16 +76,6 @@ AudioEngine::AudioEngine()
|
||||
|
||||
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), this, SLOT( onVolumeChanged( qreal ) ) );
|
||||
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
tDebug() << Q_FUNC_INFO << "Connecting privacy toggle";
|
||||
ActionCollection *ac = ActionCollection::instance();
|
||||
connect( ac->getAction( "togglePrivacy" ), SIGNAL( triggered() ), SLOT( togglePrivateListeningMode() ), Qt::UniqueConnection );
|
||||
connect( ac->getAction( "playPause" ), SIGNAL( triggered() ), SLOT( playPause() ), Qt::UniqueConnection );
|
||||
connect( ac->getAction( "stop" ), SIGNAL( triggered() ), SLOT( stop() ), Qt::UniqueConnection );
|
||||
connect( ac->getAction( "previousTrack" ), SIGNAL( triggered() ), SLOT( previous() ), Qt::UniqueConnection );
|
||||
connect( ac->getAction( "nextTrack" ), SIGNAL( triggered() ), SLOT( next() ), Qt::UniqueConnection );
|
||||
#endif
|
||||
|
||||
onVolumeChanged( m_audioOutput->volume() );
|
||||
|
||||
#ifndef Q_WS_X11
|
||||
@ -406,26 +395,6 @@ AudioEngine::infoSystemFinished( QString caller )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::togglePrivateListeningMode()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
if ( TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening )
|
||||
TomahawkSettings::instance()->setPrivateListeningMode( TomahawkSettings::FullyPrivate );
|
||||
else
|
||||
TomahawkSettings::instance()->setPrivateListeningMode( TomahawkSettings::PublicListening );
|
||||
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
QAction *privacyToggle = ActionCollection::instance()->getAction( "togglePrivacy" );
|
||||
bool isPublic = TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening;
|
||||
privacyToggle->setText( ( isPublic ? tr( "&Listen Privately" ) : tr( "&Listen Publicly" ) ) );
|
||||
privacyToggle->setIconVisibleInMenu( isPublic );
|
||||
#endif
|
||||
emit privacyModeChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
@ -502,7 +471,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
|
||||
if ( TomahawkSettings::instance()->verboseNotifications() )
|
||||
sendNowPlayingNotification();
|
||||
|
||||
|
||||
if ( TomahawkSettings::instance()->privateListeningMode() != TomahawkSettings::FullyPrivate )
|
||||
{
|
||||
DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( m_currentTrack, DatabaseCommand_LogPlayback::Started );
|
||||
|
@ -102,8 +102,6 @@ public slots:
|
||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void infoSystemFinished( QString caller );
|
||||
|
||||
void togglePrivateListeningMode();
|
||||
|
||||
signals:
|
||||
void loading( const Tomahawk::result_ptr& track );
|
||||
void started( const Tomahawk::result_ptr& track );
|
||||
@ -125,8 +123,6 @@ signals:
|
||||
|
||||
void error( AudioErrorCode errorCode );
|
||||
|
||||
void privacyModeChanged();
|
||||
|
||||
private slots:
|
||||
bool loadTrack( const Tomahawk::result_ptr& result );
|
||||
void loadPreviousTrack();
|
||||
|
@ -115,7 +115,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
||||
connect( this, SIGNAL( unlatchRequest( Tomahawk::source_ptr ) ), m_latchManager, SLOT( unlatchRequest( Tomahawk::source_ptr ) ) );
|
||||
connect( this, SIGNAL( catchUpRequest() ), m_latchManager, SLOT( catchUpRequest() ) );
|
||||
|
||||
connect( AudioEngine::instance(), SIGNAL( privacyModeChanged() ), SLOT( repaint() ) );
|
||||
connect( ActionCollection::instance(), SIGNAL( privacyModeChanged() ), SLOT( repaint() ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,11 +158,6 @@ TomahawkApp::init()
|
||||
new TomahawkSettings( this );
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
new ActionCollection( this );
|
||||
connect( ActionCollection::instance()->getAction( "quit" ), SIGNAL( triggered() ), SLOT( quit() ), Qt::UniqueConnection );
|
||||
#endif
|
||||
|
||||
tDebug( LOGINFO ) << "Setting NAM.";
|
||||
// Cause the creation of the nam, but don't need to address it directly, so prevent warning
|
||||
Q_UNUSED( TomahawkUtils::nam() );
|
||||
@ -171,6 +166,11 @@ TomahawkApp::init()
|
||||
m_scanManager = QWeakPointer<ScanManager>( new ScanManager( this ) );
|
||||
new Pipeline( this );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
new ActionCollection( this );
|
||||
connect( ActionCollection::instance()->getAction( "quit" ), SIGNAL( triggered() ), SLOT( quit() ), Qt::UniqueConnection );
|
||||
#endif
|
||||
|
||||
m_servent = QWeakPointer<Servent>( new Servent( this ) );
|
||||
connect( m_servent.data(), SIGNAL( ready() ), SLOT( initSIP() ) );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user