mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Work towards latch actions -- need to debug corner cases
This commit is contained in:
@@ -249,6 +249,7 @@ set( libHeaders
|
|||||||
functimeout.h
|
functimeout.h
|
||||||
|
|
||||||
aclsystem.h
|
aclsystem.h
|
||||||
|
actioncollection.h
|
||||||
collection.h
|
collection.h
|
||||||
query.h
|
query.h
|
||||||
resolver.h
|
resolver.h
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "LatchManager.h"
|
#include "LatchManager.h"
|
||||||
|
|
||||||
|
#include "actioncollection.h"
|
||||||
#include "audio/audioengine.h"
|
#include "audio/audioengine.h"
|
||||||
#include "database/database.h"
|
#include "database/database.h"
|
||||||
|
|
||||||
@@ -81,6 +82,8 @@ LatchManager::playlistChanged( PlaylistInterface* )
|
|||||||
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
||||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||||
|
|
||||||
|
ActionCollection::instance()->getAction( "latchOn" )->setText( tr( "&Catch Up" ) );
|
||||||
|
|
||||||
// If not, then keep waiting
|
// If not, then keep waiting
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -113,6 +116,8 @@ LatchManager::playlistChanged( PlaylistInterface* )
|
|||||||
m_latchedInterface.clear();
|
m_latchedInterface.clear();
|
||||||
|
|
||||||
m_state = NotLatched;
|
m_state = NotLatched;
|
||||||
|
|
||||||
|
ActionCollection::instance()->getAction( "latchOn" )->setText( tr( "&Listen Along" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -126,9 +131,8 @@ LatchManager::catchUpRequest()
|
|||||||
void
|
void
|
||||||
LatchManager::unlatchRequest( const source_ptr& source )
|
LatchManager::unlatchRequest( const source_ptr& source )
|
||||||
{
|
{
|
||||||
AudioEngine::instance()->playItem( source->getPlaylistInterface().data(), source->getPlaylistInterface()->nextItem() );
|
|
||||||
|
|
||||||
|
|
||||||
AudioEngine::instance()->stop();
|
AudioEngine::instance()->stop();
|
||||||
AudioEngine::instance()->setPlaylist( 0 );
|
AudioEngine::instance()->setPlaylist( 0 );
|
||||||
|
|
||||||
|
ActionCollection::instance()->getAction( "latchOn" )->setText( tr( "&Listen Along" ) );
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,8 @@ ActionCollection* ActionCollection::instance()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ActionCollection::ActionCollection()
|
ActionCollection::ActionCollection( QObject *parent )
|
||||||
|
: QObject( parent )
|
||||||
{
|
{
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
initActions();
|
initActions();
|
||||||
@@ -35,7 +36,8 @@ ActionCollection::ActionCollection()
|
|||||||
void
|
void
|
||||||
ActionCollection::initActions()
|
ActionCollection::initActions()
|
||||||
{
|
{
|
||||||
|
m_actionCollection[ "latchOn" ] = new QAction( tr( "&Listen Along" ), this );
|
||||||
|
m_actionCollection[ "latchOff" ] = new QAction( tr( "&Stop Listening Along" ), this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -24,13 +24,14 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
|
|
||||||
class DLLEXPORT ActionCollection
|
class DLLEXPORT ActionCollection : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ActionCollection* instance();
|
static ActionCollection* instance();
|
||||||
|
|
||||||
ActionCollection();
|
ActionCollection( QObject *parent);
|
||||||
~ActionCollection();
|
~ActionCollection();
|
||||||
|
|
||||||
void initActions();
|
void initActions();
|
||||||
|
@@ -700,6 +700,7 @@ AudioEngine::setPlaylist( PlaylistInterface* playlist )
|
|||||||
if ( !playlist )
|
if ( !playlist )
|
||||||
{
|
{
|
||||||
m_playlist.clear();
|
m_playlist.clear();
|
||||||
|
emit playlistChanged( playlist );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
#include "actioncollection.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "viewmanager.h"
|
#include "viewmanager.h"
|
||||||
#include "sourcesproxymodel.h"
|
#include "sourcesproxymodel.h"
|
||||||
@@ -80,8 +81,8 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
|||||||
// setAnimated( true );
|
// setAnimated( true );
|
||||||
|
|
||||||
m_delegate = new SourceDelegate( this );
|
m_delegate = new SourceDelegate( this );
|
||||||
connect( m_delegate, SIGNAL( latchOn( Tomahawk::source_ptr ) ), this, SIGNAL( latchRequest( Tomahawk::source_ptr ) ), Qt::QueuedConnection );
|
connect( m_delegate, SIGNAL( latchOn( Tomahawk::source_ptr ) ), this, SLOT( latchOnOrCatchUp( Tomahawk::source_ptr ) ) );
|
||||||
connect( m_delegate, SIGNAL( latchOff( Tomahawk::source_ptr ) ), this, SIGNAL( unlatchRequest( Tomahawk::source_ptr ) ), Qt::QueuedConnection );
|
connect( m_delegate, SIGNAL( latchOff( Tomahawk::source_ptr ) ), this, SLOT( latchOff( Tomahawk::source_ptr ) ) );
|
||||||
|
|
||||||
setItemDelegate( m_delegate );
|
setItemDelegate( m_delegate );
|
||||||
|
|
||||||
@@ -141,7 +142,8 @@ SourceTreeView::setupMenus()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_latchOnAction = m_latchMenu.addAction( tr( "&Listen Along" ) );
|
QAction* latchOnAction = ActionCollection::instance()->getAction( "latchOn" );
|
||||||
|
m_latchMenu.addAction( latchOnAction );
|
||||||
|
|
||||||
if ( type == SourcesModel::Collection )
|
if ( type == SourcesModel::Collection )
|
||||||
{
|
{
|
||||||
@@ -151,10 +153,10 @@ SourceTreeView::setupMenus()
|
|||||||
{
|
{
|
||||||
if ( m_latchManager->isLatched( source ) )
|
if ( m_latchManager->isLatched( source ) )
|
||||||
{
|
{
|
||||||
m_latchOnAction->setText( tr( "&Catch Up" ) );
|
|
||||||
m_latchMenu.addSeparator();
|
m_latchMenu.addSeparator();
|
||||||
m_latchOffAction = m_latchMenu.addAction( tr( "&Stop Listening Along" ) );
|
QAction *latchOffAction = ActionCollection::instance()->getAction( "latchOff" );
|
||||||
connect( m_latchOffAction, SIGNAL( triggered() ), SLOT( latchOff() ) );
|
m_latchMenu.addAction( latchOffAction );
|
||||||
|
connect( latchOffAction, SIGNAL( triggered() ), SLOT( latchOff() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,7 +191,7 @@ SourceTreeView::setupMenus()
|
|||||||
connect( m_deletePlaylistAction, SIGNAL( triggered() ), SLOT( deletePlaylist() ) );
|
connect( m_deletePlaylistAction, SIGNAL( triggered() ), SLOT( deletePlaylist() ) );
|
||||||
connect( m_copyPlaylistAction, SIGNAL( triggered() ), SLOT( copyPlaylistLink() ) );
|
connect( m_copyPlaylistAction, SIGNAL( triggered() ), SLOT( copyPlaylistLink() ) );
|
||||||
connect( m_addToLocalAction, SIGNAL( triggered() ), SLOT( addToLocal() ) );
|
connect( m_addToLocalAction, SIGNAL( triggered() ), SLOT( addToLocal() ) );
|
||||||
connect( m_latchOnAction, SIGNAL( triggered() ), SLOT( latchOnOrCatchUp() ) );
|
connect( latchOnAction, SIGNAL( triggered() ), SLOT( latchOnOrCatchUp() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -342,6 +344,7 @@ SourceTreeView::addToLocal()
|
|||||||
void
|
void
|
||||||
SourceTreeView::latchOnOrCatchUp()
|
SourceTreeView::latchOnOrCatchUp()
|
||||||
{
|
{
|
||||||
|
disconnect( this, SLOT( latchOnOrCatchUp() ) );
|
||||||
if ( !m_contextMenuIndex.isValid() )
|
if ( !m_contextMenuIndex.isValid() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -352,16 +355,14 @@ SourceTreeView::latchOnOrCatchUp()
|
|||||||
CollectionItem* item = itemFromIndex< CollectionItem >( m_contextMenuIndex );
|
CollectionItem* item = itemFromIndex< CollectionItem >( m_contextMenuIndex );
|
||||||
source_ptr source = item->source();
|
source_ptr source = item->source();
|
||||||
|
|
||||||
if ( m_latchManager->isLatched( source ) )
|
latchOnOrCatchUp( source );
|
||||||
emit catchUpRequest();
|
|
||||||
else
|
|
||||||
emit latchRequest( source );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceTreeView::latchOff()
|
SourceTreeView::latchOff()
|
||||||
{
|
{
|
||||||
|
disconnect( this, SLOT( latchOff() ) );
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if ( !m_contextMenuIndex.isValid() )
|
if ( !m_contextMenuIndex.isValid() )
|
||||||
return;
|
return;
|
||||||
@@ -372,11 +373,29 @@ SourceTreeView::latchOff()
|
|||||||
|
|
||||||
const CollectionItem* item = itemFromIndex< CollectionItem >( m_contextMenuIndex );
|
const CollectionItem* item = itemFromIndex< CollectionItem >( m_contextMenuIndex );
|
||||||
const source_ptr source = item->source();
|
const source_ptr source = item->source();
|
||||||
|
|
||||||
|
latchOff( source );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreeView::latchOnOrCatchUp( const Tomahawk::source_ptr& source )
|
||||||
|
{
|
||||||
|
if ( m_latchManager->isLatched( source ) )
|
||||||
|
emit catchUpRequest();
|
||||||
|
else
|
||||||
|
emit latchRequest( source );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreeView::latchOff( const Tomahawk::source_ptr& source )
|
||||||
|
{
|
||||||
emit unlatchRequest( source );
|
emit unlatchRequest( source );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceTreeView::renamePlaylist()
|
SourceTreeView::renamePlaylist()
|
||||||
{
|
{
|
||||||
|
@@ -72,7 +72,9 @@ private slots:
|
|||||||
|
|
||||||
void latchOnOrCatchUp();
|
void latchOnOrCatchUp();
|
||||||
void latchOff();
|
void latchOff();
|
||||||
|
void latchOnOrCatchUp( const Tomahawk::source_ptr& source );
|
||||||
|
void latchOff( const Tomahawk::source_ptr& source );
|
||||||
|
|
||||||
void onCustomContextMenu( const QPoint& pos );
|
void onCustomContextMenu( const QPoint& pos );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -161,7 +161,7 @@ TomahawkApp::init()
|
|||||||
new TomahawkSettings( this );
|
new TomahawkSettings( this );
|
||||||
TomahawkSettings* s = TomahawkSettings::instance();
|
TomahawkSettings* s = TomahawkSettings::instance();
|
||||||
|
|
||||||
new ActionCollection();
|
new ActionCollection( this );
|
||||||
|
|
||||||
tDebug( LOGINFO ) << "Setting NAM.";
|
tDebug( LOGINFO ) << "Setting NAM.";
|
||||||
#ifdef LIBLASTFM_FOUND
|
#ifdef LIBLASTFM_FOUND
|
||||||
@@ -319,8 +319,6 @@ TomahawkApp::~TomahawkApp()
|
|||||||
#ifdef LIBATTICA_FOUND
|
#ifdef LIBATTICA_FOUND
|
||||||
delete AtticaManager::instance();
|
delete AtticaManager::instance();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete ActionCollection::instance();
|
|
||||||
|
|
||||||
tLog() << "Finished shutdown.";
|
tLog() << "Finished shutdown.";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user