1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 00:09:47 +01:00

Insert private listening actions into Tomahawk menu and tray icon menu.

Some visual feedback would be nice.
This commit is contained in:
Jeff Mitchell 2011-11-07 18:45:05 -05:00
parent 8e1cefbbb7
commit 4bafeb34fd
7 changed files with 41 additions and 2 deletions

View File

@ -131,6 +131,7 @@ LatchManager::catchUpRequest()
void
LatchManager::unlatchRequest( const source_ptr& source )
{
Q_UNUSED( source );
AudioEngine::instance()->stop();
AudioEngine::instance()->setPlaylist( 0 );

View File

@ -17,6 +17,7 @@
*/
#include "actioncollection.h"
#include "tomahawksettings.h"
ActionCollection* ActionCollection::s_instance = 0;
ActionCollection* ActionCollection::instance()
@ -38,6 +39,8 @@ ActionCollection::initActions()
{
m_actionCollection[ "latchOn" ] = new QAction( tr( "&Listen Along" ), this );
m_actionCollection[ "latchOff" ] = new QAction( tr( "&Stop Listening Along" ), this );
m_actionCollection[ "togglePrivacy" ] = new QAction( tr( QString( TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening ?
"&Listen Privately" : "&Listen Publicly" ).toAscii().constData() ), this );
}

View File

@ -21,7 +21,7 @@
#include "dllmacro.h"
#include <QAction>
#include <QtGui/QAction>
class DLLEXPORT ActionCollection : public QObject

View File

@ -24,16 +24,18 @@
#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"
#include "utils/qnr_iodevicestream.h"
#include "headlesscheck.h"
#include "album.h"
#include "utils/logger.h"
using namespace Tomahawk;
AudioEngine* AudioEngine::s_instance = 0;
@ -75,6 +77,11 @@ AudioEngine::AudioEngine()
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), this, SLOT( onVolumeChanged( qreal ) ) );
#ifndef TOMAHAWK_HEADLESS
tDebug() << Q_FUNC_INFO << "Connecting privacy toggle";
connect( ActionCollection::instance()->getAction( "togglePrivacy" ), SIGNAL( triggered( bool ) ), this, SLOT( togglePrivateListeningMode() ) );
#endif
onVolumeChanged( m_audioOutput->volume() );
#ifndef Q_WS_X11
@ -394,6 +401,25 @@ 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
ActionCollection::instance()->getAction( "togglePrivacy" )->setText(
tr( QString( TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening ?
"&Listen Privately" : "&Listen Publicly" ).toAscii().constData() )
);
#endif
}
bool
AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
{

View File

@ -103,6 +103,8 @@ 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 );

View File

@ -27,6 +27,7 @@
#include "tomahawkwindow.h"
#include "utils/logger.h"
#include <actioncollection.h>
TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
@ -48,6 +49,8 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
m_contextMenu->addSeparator();
m_prevAction = m_contextMenu->addAction( tr( "Previous Track" ) );
m_nextAction = m_contextMenu->addAction( tr( "Next Track" ) );
m_contextMenu->addSeparator();
m_contextMenu->addAction( ActionCollection::instance()->getAction( "togglePrivacy" ) );
#ifdef Q_WS_MAC
// On mac you can close the windows while leaving the app open. We then need a way to show the main window again

View File

@ -70,6 +70,7 @@
#include "utils/logger.h"
#include "jobview/JobStatusModel.h"
#include "LoadXSPFDialog.h"
#include <actioncollection.h>
using namespace Tomahawk;
@ -105,6 +106,9 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
ui->menu_Help->addSeparator();
ui->menu_Help->addAction( "Crash now...", this, SLOT( crashNow() ) );
}
ui->menuApp->insertAction( ui->actionCreatePlaylist, ActionCollection::instance()->getAction( "togglePrivacy" ) );
ui->menuApp->insertSeparator( ui->actionCreatePlaylist );
// set initial state
onSipDisconnected();