mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-25 02:09:48 +01:00
Fix sourcelist returning local source, and send stop listening along msg at right time
This commit is contained in:
parent
495fe05a75
commit
6c9c3ce7ec
@ -22,6 +22,7 @@
|
||||
#include "sourcelist.h"
|
||||
#include "JobStatusView.h"
|
||||
#include "JobStatusModel.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
LatchedStatusItem::LatchedStatusItem( const Tomahawk::source_ptr& from, const Tomahawk::source_ptr& to, LatchedStatusManager* parent )
|
||||
: JobStatusItem()
|
||||
@ -64,6 +65,8 @@ LatchedStatusManager::LatchedStatusManager( QObject* parent )
|
||||
{
|
||||
connect( SourceList::instance(), SIGNAL( sourceLatchedOn( Tomahawk::source_ptr, Tomahawk::source_ptr ) ), this, SLOT( latchedOn( Tomahawk::source_ptr, Tomahawk::source_ptr ) ) );
|
||||
connect( SourceList::instance(), SIGNAL( sourceLatchedOff( Tomahawk::source_ptr, Tomahawk::source_ptr ) ), this, SLOT( latchedOff( Tomahawk::source_ptr, Tomahawk::source_ptr ) ) );
|
||||
|
||||
m_pixmap.load( RESPATH "images/headphones.png" );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -188,6 +188,11 @@ SourceList::get( const QString& username, const QString& friendlyName )
|
||||
QMutexLocker lock( &m_mut );
|
||||
|
||||
source_ptr source;
|
||||
if ( Database::instance()->dbid() == username )
|
||||
{
|
||||
return m_local;
|
||||
}
|
||||
|
||||
if ( !m_sources.contains( username ) )
|
||||
{
|
||||
source = source_ptr( new Source( -1, username ) );
|
||||
|
@ -99,6 +99,8 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
||||
|
||||
showOfflineSources( TomahawkSettings::instance()->showOfflineSources() );
|
||||
|
||||
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistChanged( Tomahawk::PlaylistInterface* ) ) );
|
||||
|
||||
// Light-blue sourcetree on osx
|
||||
#ifdef Q_WS_MAC
|
||||
setStyleSheet( "SourceTreeView:active { background: #DDE4EB; } "
|
||||
@ -363,9 +365,30 @@ SourceTreeView::latchOn()
|
||||
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
|
||||
m_latch = source->getPlaylistInterface();
|
||||
AudioEngine::instance()->playItem( source->getPlaylistInterface().data(), source->getPlaylistInterface()->nextItem() );
|
||||
}
|
||||
|
||||
void
|
||||
SourceTreeView::playlistChanged( PlaylistInterface* newInterface )
|
||||
{
|
||||
// If we were latched on and changed, send the listening along stop
|
||||
if ( !m_latch.isNull() )
|
||||
{
|
||||
SourcePlaylistInterface* sourcepi = dynamic_cast< SourcePlaylistInterface* >( m_latch.data() );
|
||||
Q_ASSERT( sourcepi );
|
||||
|
||||
const source_ptr source = sourcepi->source();
|
||||
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction();
|
||||
cmd->setSource( SourceList::instance()->getLocal() );
|
||||
cmd->setAction( "latchOff");
|
||||
cmd->setComment( source->userName() );
|
||||
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
|
||||
m_latch.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SourceTreeView::latchOff()
|
||||
@ -382,13 +405,6 @@ SourceTreeView::latchOff()
|
||||
const CollectionItem* item = itemFromIndex< CollectionItem >( m_contextMenuIndex );
|
||||
const source_ptr source = item->source();
|
||||
|
||||
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction();
|
||||
cmd->setSource( SourceList::instance()->getLocal() );
|
||||
cmd->setAction( "latchOff");
|
||||
cmd->setComment( source->userName() );
|
||||
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
|
||||
AudioEngine::instance()->playItem( source->getPlaylistInterface().data(), source->getPlaylistInterface()->nextItem() );
|
||||
|
||||
|
||||
|
@ -19,9 +19,15 @@
|
||||
#ifndef SOURCETREEVIEW_H
|
||||
#define SOURCETREEVIEW_H
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QMenu>
|
||||
|
||||
namespace Tomahawk {
|
||||
class PlaylistInterface;
|
||||
}
|
||||
|
||||
class CollectionModel;
|
||||
class PlaylistModel;
|
||||
class SourcesModel;
|
||||
@ -59,6 +65,7 @@ private slots:
|
||||
|
||||
void latchOn();
|
||||
void latchOff();
|
||||
void playlistChanged( Tomahawk::PlaylistInterface* );
|
||||
|
||||
void onCustomContextMenu( const QPoint& pos );
|
||||
|
||||
@ -94,6 +101,7 @@ private:
|
||||
QAction* m_addToLocalAction;
|
||||
QAction* m_latchOnAction;
|
||||
QAction* m_latchOffAction;
|
||||
Tomahawk::playlistinterface_ptr m_latch;
|
||||
|
||||
bool m_dragging;
|
||||
QRect m_dropRect;
|
||||
|
Loading…
x
Reference in New Issue
Block a user