mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-18 11:51:44 +02:00
Jump to and scroll to playing track in grid view on track page
This commit is contained in:
@@ -417,4 +417,15 @@ GridView::jumpToCurrentTrack()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QRect
|
||||
GridView::currentTrackRect() const
|
||||
{
|
||||
if ( !m_playing.isValid() )
|
||||
return QRect();
|
||||
|
||||
return visualRect( m_playing );
|
||||
}
|
||||
|
||||
|
||||
#include "GridView.moc"
|
||||
|
@@ -72,6 +72,7 @@ public:
|
||||
|
||||
virtual bool setFilter( const QString& filter );
|
||||
virtual bool jumpToCurrentTrack();
|
||||
QRect currentTrackRect() const;
|
||||
|
||||
virtual bool isBeingPlayed() const { return m_playing.isValid(); }
|
||||
|
||||
|
@@ -38,6 +38,7 @@ using namespace Tomahawk;
|
||||
TrackInfoWidget::TrackInfoWidget( const Tomahawk::query_ptr& query, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::TrackInfoWidget )
|
||||
, m_scrollArea( 0 )
|
||||
{
|
||||
QWidget* widget = new QWidget;
|
||||
ui->setupUi( widget );
|
||||
@@ -98,17 +99,17 @@ TrackInfoWidget::TrackInfoWidget( const Tomahawk::query_ptr& query, QWidget* par
|
||||
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, QSize( 48, 48 ) );
|
||||
ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::ScaledCover, QSize( ui->cover->sizeHint() ) ) );
|
||||
|
||||
QScrollArea* area = new QScrollArea();
|
||||
area->setWidgetResizable( true );
|
||||
area->setWidget( widget );
|
||||
area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
|
||||
m_scrollArea = new QScrollArea();
|
||||
m_scrollArea->setWidgetResizable( true );
|
||||
m_scrollArea->setWidget( widget );
|
||||
m_scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
|
||||
|
||||
area->setStyleSheet( "QScrollArea { background-color: #454e59 }" );
|
||||
area->setFrameShape( QFrame::NoFrame );
|
||||
area->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
m_scrollArea->setStyleSheet( "QScrollArea { background-color: #454e59 }" );
|
||||
m_scrollArea->setFrameShape( QFrame::NoFrame );
|
||||
m_scrollArea->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->addWidget( area );
|
||||
layout->addWidget( m_scrollArea );
|
||||
setLayout( layout );
|
||||
TomahawkUtils::unmarginLayout( layout );
|
||||
|
||||
@@ -141,12 +142,28 @@ TrackInfoWidget::playlistInterface() const
|
||||
bool
|
||||
TrackInfoWidget::isBeingPlayed() const
|
||||
{
|
||||
//tDebug() << Q_FUNC_INFO << "audioengine playlistInterface = " << AudioEngine::instance()->currentTrackPlaylist()->id();
|
||||
//tDebug() << Q_FUNC_INFO << "albumsView playlistInterface = " << ui->albumsView->playlistInterface()->id();
|
||||
//tDebug() << Q_FUNC_INFO << "tracksView playlistInterface = " << ui->tracksView->playlistInterface()->id();
|
||||
if ( ui->similarTracksView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
|
||||
return true;
|
||||
|
||||
if ( ui->similarTracksView->playlistInterface()->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TrackInfoWidget::jumpToCurrentTrack()
|
||||
{
|
||||
if ( ui->similarTracksView->jumpToCurrentTrack() && !ui->similarTracksView->currentTrackRect().isEmpty() )
|
||||
{
|
||||
// We embed the view in a scrollarea, so we have to manually ensure we make it visible
|
||||
const QRect itemRect = ui->similarTracksView->currentTrackRect();
|
||||
m_scrollArea->ensureVisible( itemRect.right(), itemRect.bottom(), 50, 50 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include "Typedefs.h"
|
||||
|
||||
class PlayableModel;
|
||||
class QScrollArea;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -68,7 +69,7 @@ public:
|
||||
virtual bool isTemporaryPage() const { return true; }
|
||||
virtual bool showInfoBar() const { return false; }
|
||||
|
||||
virtual bool jumpToCurrentTrack() { return false; }
|
||||
virtual bool jumpToCurrentTrack();
|
||||
|
||||
public slots:
|
||||
void load( const Tomahawk::query_ptr& query );
|
||||
@@ -88,6 +89,7 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::TrackInfoWidget *ui;
|
||||
QScrollArea* m_scrollArea;
|
||||
|
||||
Tomahawk::query_ptr m_query;
|
||||
Tomahawk::artist_ptr m_artist;
|
||||
|
Reference in New Issue
Block a user