diff --git a/src/sourcetree/sourcedelegate.cpp b/src/sourcetree/sourcedelegate.cpp index d45a17000..6cd00ce65 100644 --- a/src/sourcetree/sourcedelegate.cpp +++ b/src/sourcetree/sourcedelegate.cpp @@ -195,7 +195,7 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem& painter->setFont( normal ); textRect = option.rect.adjusted( iconRect.width() + 8, option.rect.height() / 2, -figWidth - 24, -6 ); - + bool privacyOn = TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::FullyPrivate; if ( !colItem->source().isNull() && colItem->source()->isLocal() && privacyOn ) { @@ -627,6 +627,12 @@ SourceDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QSt } } + // We emit our own clicked() signal instead of relying on QTreeView's, because that is fired whether or not a delegate accepts + // a mouse press event. Since we want to swallow click events when they are on headphones other action items, here wemake sure we only + // emit if we really want to + if ( event->type() == QEvent::MouseButtonRelease ) + emit clicked( index ); + return QStyledItemDelegate::editorEvent ( event, model, option, index ); } diff --git a/src/sourcetree/sourcedelegate.h b/src/sourcetree/sourcedelegate.h index 1f6cea627..d7a1d3ef6 100644 --- a/src/sourcetree/sourcedelegate.h +++ b/src/sourcetree/sourcedelegate.h @@ -42,6 +42,7 @@ public: SourceTreeItem::DropType hoveredDropType() const; signals: + void clicked( const QModelIndex& idx ); void latchOn( const Tomahawk::source_ptr& idx ); void latchOff( const Tomahawk::source_ptr& idx ); void toggleRealtimeLatch( const Tomahawk::source_ptr& idx, bool realtime ); diff --git a/src/sourcetree/sourcetreeview.cpp b/src/sourcetree/sourcetreeview.cpp index a00deaec2..ced9bda00 100644 --- a/src/sourcetree/sourcetreeview.cpp +++ b/src/sourcetree/sourcetreeview.cpp @@ -87,6 +87,7 @@ SourceTreeView::SourceTreeView( QWidget* parent ) connect( m_delegate, SIGNAL( latchOn( Tomahawk::source_ptr ) ), SLOT( latchOnOrCatchUp( Tomahawk::source_ptr ) ) ); connect( m_delegate, SIGNAL( latchOff( Tomahawk::source_ptr ) ), SLOT( latchOff( Tomahawk::source_ptr ) ) ); connect( m_delegate, SIGNAL( toggleRealtimeLatch( Tomahawk::source_ptr, bool ) ), m_latchManager, SLOT( latchModeChangeRequest( Tomahawk::source_ptr,bool ) ) ); + connect( m_delegate, SIGNAL( clicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) ); setItemDelegate( m_delegate ); @@ -104,7 +105,6 @@ SourceTreeView::SourceTreeView( QWidget* parent ) header()->setStretchLastSection( false ); header()->setResizeMode( 0, QHeaderView::Stretch ); - connect( this, SIGNAL( clicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) ); connect( this, SIGNAL( expanded( QModelIndex ) ), SLOT( onItemExpanded( QModelIndex ) ) ); // connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), SLOT( onSelectionChanged() ) ); @@ -431,11 +431,11 @@ SourceTreeView::latchModeToggled( bool checked ) qDebug() << Q_FUNC_INFO; if ( !m_contextMenuIndex.isValid() ) return; - + SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ).toInt(); if( type != SourcesModel::Collection ) return; - + const SourceItem* item = itemFromIndex< SourceItem >( m_contextMenuIndex ); const source_ptr source = item->source(); emit latchModeChangeRequest( source, checked );