mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 05:37:29 +02:00
ifdefs--: Move ActionCollection initialization code from AudioEngine to
Ac
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include "actioncollection.h"
|
#include "actioncollection.h"
|
||||||
#include <tomahawksettings.h>
|
#include <tomahawksettings.h>
|
||||||
#include <utils/tomahawkutils.h>
|
#include <utils/tomahawkutils.h>
|
||||||
|
#include "audio/audioengine.h"
|
||||||
|
|
||||||
ActionCollection* ActionCollection::s_instance = 0;
|
ActionCollection* ActionCollection::s_instance = 0;
|
||||||
ActionCollection* ActionCollection::instance()
|
ActionCollection* ActionCollection::instance()
|
||||||
@@ -50,6 +51,8 @@ ActionCollection::initActions()
|
|||||||
privacyToggle->setIcon( QIcon( RESPATH "images/private-listening.png" ) );
|
privacyToggle->setIcon( QIcon( RESPATH "images/private-listening.png" ) );
|
||||||
privacyToggle->setIconVisibleInMenu( isPublic );
|
privacyToggle->setIconVisibleInMenu( isPublic );
|
||||||
m_actionCollection[ "togglePrivacy" ] = privacyToggle;
|
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[ "loadPlaylist"] = new QAction( tr( "&Load Playlist" ), this );
|
||||||
m_actionCollection[ "renamePlaylist"] = new QAction( tr( "&Rename 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[ "previousTrack"] = new QAction( tr( "&Previous Track" ), this );
|
||||||
m_actionCollection[ "nextTrack"] = new QAction( tr( "&Next Track" ), this );
|
m_actionCollection[ "nextTrack"] = new QAction( tr( "&Next Track" ), this );
|
||||||
m_actionCollection[ "quit"] = new QAction( tr( "&Quit" ), 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;
|
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();
|
||||||
|
}
|
||||||
|
@@ -38,6 +38,13 @@ public:
|
|||||||
|
|
||||||
QAction* getAction( const QString &name );
|
QAction* getAction( const QString &name );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void togglePrivateListeningMode();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void privacyModeChanged();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static ActionCollection* s_instance;
|
static ActionCollection* s_instance;
|
||||||
|
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
#include "playlistinterface.h"
|
#include "playlistinterface.h"
|
||||||
#include "sourceplaylistinterface.h"
|
#include "sourceplaylistinterface.h"
|
||||||
#include "tomahawksettings.h"
|
#include "tomahawksettings.h"
|
||||||
#include "actioncollection.h"
|
|
||||||
#include "database/database.h"
|
#include "database/database.h"
|
||||||
#include "database/databasecommand_logplayback.h"
|
#include "database/databasecommand_logplayback.h"
|
||||||
#include "network/servent.h"
|
#include "network/servent.h"
|
||||||
@@ -77,16 +76,6 @@ AudioEngine::AudioEngine()
|
|||||||
|
|
||||||
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), this, SLOT( onVolumeChanged( qreal ) ) );
|
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() );
|
onVolumeChanged( m_audioOutput->volume() );
|
||||||
|
|
||||||
#ifndef Q_WS_X11
|
#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
|
bool
|
||||||
AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
|
@@ -102,8 +102,6 @@ public slots:
|
|||||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
void infoSystemFinished( QString caller );
|
void infoSystemFinished( QString caller );
|
||||||
|
|
||||||
void togglePrivateListeningMode();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loading( const Tomahawk::result_ptr& track );
|
void loading( const Tomahawk::result_ptr& track );
|
||||||
void started( const Tomahawk::result_ptr& track );
|
void started( const Tomahawk::result_ptr& track );
|
||||||
@@ -125,8 +123,6 @@ signals:
|
|||||||
|
|
||||||
void error( AudioErrorCode errorCode );
|
void error( AudioErrorCode errorCode );
|
||||||
|
|
||||||
void privacyModeChanged();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
bool loadTrack( const Tomahawk::result_ptr& result );
|
bool loadTrack( const Tomahawk::result_ptr& result );
|
||||||
void loadPreviousTrack();
|
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( unlatchRequest( Tomahawk::source_ptr ) ), m_latchManager, SLOT( unlatchRequest( Tomahawk::source_ptr ) ) );
|
||||||
connect( this, SIGNAL( catchUpRequest() ), m_latchManager, SLOT( catchUpRequest() ) );
|
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 );
|
new TomahawkSettings( this );
|
||||||
TomahawkSettings* s = TomahawkSettings::instance();
|
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.";
|
tDebug( LOGINFO ) << "Setting NAM.";
|
||||||
// Cause the creation of the nam, but don't need to address it directly, so prevent warning
|
// Cause the creation of the nam, but don't need to address it directly, so prevent warning
|
||||||
Q_UNUSED( TomahawkUtils::nam() );
|
Q_UNUSED( TomahawkUtils::nam() );
|
||||||
@@ -171,6 +166,11 @@ TomahawkApp::init()
|
|||||||
m_scanManager = QWeakPointer<ScanManager>( new ScanManager( this ) );
|
m_scanManager = QWeakPointer<ScanManager>( new ScanManager( this ) );
|
||||||
new Pipeline( 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 ) );
|
m_servent = QWeakPointer<Servent>( new Servent( this ) );
|
||||||
connect( m_servent.data(), SIGNAL( ready() ), SLOT( initSIP() ) );
|
connect( m_servent.data(), SIGNAL( ready() ), SLOT( initSIP() ) );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user