mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-21 00:12:06 +02:00
* AlbumViews are now sorted by Artist - Album.
* Tweaked mode switching. * Hide stats & mode buttons for certain view types.
This commit is contained in:
parent
d621411c0d
commit
7b5f16355d
@ -40,10 +40,9 @@ AudioEngine::AudioEngine()
|
||||
|
||||
AudioEngine::~AudioEngine()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "waiting for event loop to finish..";
|
||||
qDebug() << Q_FUNC_INFO << "waiting for event loop to finish...";
|
||||
quit();
|
||||
wait( 1000 );
|
||||
qDebug() << Q_FUNC_INFO << "ok";
|
||||
|
||||
m_input.clear();
|
||||
delete m_audio;
|
||||
|
@ -11,6 +11,8 @@ AlbumProxyModel::AlbumProxyModel( QObject* parent )
|
||||
: QSortFilterProxyModel( parent )
|
||||
, PlaylistInterface( this )
|
||||
, m_model( 0 )
|
||||
, m_repeatMode( PlaylistInterface::NoRepeat )
|
||||
, m_shuffled( false )
|
||||
{
|
||||
qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) );
|
||||
|
||||
@ -71,6 +73,26 @@ AlbumProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParen
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AlbumProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
|
||||
{
|
||||
AlbumItem* p1 = sourceModel()->itemFromIndex( left );
|
||||
AlbumItem* p2 = sourceModel()->itemFromIndex( right );
|
||||
|
||||
if ( !p1 )
|
||||
return true;
|
||||
if ( !p2 )
|
||||
return false;
|
||||
|
||||
if ( p1->album()->artist()->name() == p2->album()->artist()->name() )
|
||||
{
|
||||
return QString::localeAwareCompare( p1->album()->name(), p2->album()->name() ) < 0;
|
||||
}
|
||||
|
||||
return QString::localeAwareCompare( p1->album()->artist()->name(), p2->album()->artist()->name() ) < 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumProxyModel::removeIndex( const QModelIndex& index )
|
||||
{
|
||||
|
@ -45,6 +45,7 @@ public slots:
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||
bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
|
||||
|
||||
private:
|
||||
AlbumModel* m_model;
|
||||
|
@ -33,7 +33,6 @@ AlbumView::AlbumView( QWidget* parent )
|
||||
setResizeMode( Adjust );
|
||||
setViewMode( IconMode );
|
||||
setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
|
||||
// setIconSize( QSize( 64, 64 ) );
|
||||
|
||||
setProxyModel( new AlbumProxyModel( this ) );
|
||||
|
||||
@ -63,7 +62,10 @@ AlbumView::setModel( AlbumModel* model )
|
||||
m_model = model;
|
||||
|
||||
if ( m_proxyModel )
|
||||
{
|
||||
m_proxyModel->setSourceModel( model );
|
||||
m_proxyModel->sort( 0 );
|
||||
}
|
||||
|
||||
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
||||
|
||||
|
@ -28,6 +28,8 @@ PlaylistManager::PlaylistManager( QObject* parent )
|
||||
, m_currentInterface( 0 )
|
||||
, m_currentMode( 0 )
|
||||
, m_superCollectionVisible( true )
|
||||
, m_statsAvailable( false )
|
||||
, m_modesAvailable( false )
|
||||
{
|
||||
m_stack = new QStackedWidget();
|
||||
|
||||
@ -54,7 +56,12 @@ PlaylistManager::PlaylistManager( QObject* parent )
|
||||
m_superCollectionFlatModel = new CollectionFlatModel( m_superCollectionView );
|
||||
m_superCollectionView->setModel( m_superCollectionFlatModel );
|
||||
|
||||
m_superAlbumView = new AlbumView();
|
||||
m_superAlbumModel = new AlbumModel( m_superAlbumView );
|
||||
m_superAlbumView->setModel( m_superAlbumModel );
|
||||
|
||||
m_stack->addWidget( m_superCollectionView );
|
||||
m_stack->addWidget( m_superAlbumView );
|
||||
m_currentInterface = m_superCollectionView->proxyModel();
|
||||
|
||||
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
|
||||
@ -102,6 +109,8 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
||||
}
|
||||
|
||||
m_superCollectionVisible = false;
|
||||
m_statsAvailable = true;
|
||||
m_modesAvailable = false;
|
||||
linkPlaylist();
|
||||
|
||||
emit numSourcesChanged( APP->sourcelist().count() );
|
||||
@ -136,6 +145,8 @@ PlaylistManager::show( const Tomahawk::album_ptr& album )
|
||||
}
|
||||
|
||||
m_superCollectionVisible = false;
|
||||
m_statsAvailable = false;
|
||||
m_modesAvailable = false;
|
||||
linkPlaylist();
|
||||
|
||||
emit numSourcesChanged( 1 );
|
||||
@ -148,6 +159,7 @@ PlaylistManager::show( const Tomahawk::collection_ptr& collection )
|
||||
{
|
||||
unlinkPlaylist();
|
||||
|
||||
m_currentCollection = collection;
|
||||
if ( m_currentMode == 0 )
|
||||
{
|
||||
if ( !m_collectionViews.contains( collection ) )
|
||||
@ -195,6 +207,8 @@ PlaylistManager::show( const Tomahawk::collection_ptr& collection )
|
||||
}
|
||||
|
||||
m_superCollectionVisible = false;
|
||||
m_statsAvailable = ( m_currentMode == 0 );
|
||||
m_modesAvailable = true;
|
||||
linkPlaylist();
|
||||
|
||||
emit numSourcesChanged( 1 );
|
||||
@ -223,6 +237,10 @@ PlaylistManager::show( const Tomahawk::source_ptr& source )
|
||||
|
||||
m_stack->setCurrentWidget( m_currentInfoWidget );
|
||||
m_superCollectionVisible = false;
|
||||
m_statsAvailable = false;
|
||||
m_modesAvailable = false;
|
||||
|
||||
linkPlaylist();
|
||||
|
||||
emit numSourcesChanged( 1 );
|
||||
return true;
|
||||
@ -238,13 +256,24 @@ PlaylistManager::showSuperCollection()
|
||||
{
|
||||
m_superCollections.append( source->collection() );
|
||||
m_superCollectionFlatModel->addCollection( source->collection() );
|
||||
m_superAlbumModel->addCollection( source->collection() );
|
||||
}
|
||||
}
|
||||
|
||||
m_stack->setCurrentWidget( m_superCollectionView );
|
||||
m_currentInterface = m_superCollectionView->proxyModel();
|
||||
if ( m_currentMode == 0 )
|
||||
{
|
||||
m_stack->setCurrentWidget( m_superCollectionView );
|
||||
m_currentInterface = m_superCollectionView->proxyModel();
|
||||
}
|
||||
else if ( m_currentMode == 2 )
|
||||
{
|
||||
m_stack->setCurrentWidget( m_superAlbumView );
|
||||
m_currentInterface = m_superAlbumView->proxyModel();
|
||||
}
|
||||
|
||||
m_superCollectionVisible = true;
|
||||
m_statsAvailable = ( m_currentMode == 0 );
|
||||
m_modesAvailable = true;
|
||||
linkPlaylist();
|
||||
|
||||
emit numSourcesChanged( m_superCollections.count() );
|
||||
@ -258,7 +287,11 @@ PlaylistManager::setTableMode()
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_currentMode = 0;
|
||||
m_stack->setCurrentWidget( m_superCollectionView );
|
||||
|
||||
if ( m_superCollectionVisible )
|
||||
showSuperCollection();
|
||||
else
|
||||
show( m_currentCollection );
|
||||
}
|
||||
|
||||
|
||||
@ -270,7 +303,11 @@ PlaylistManager::setTreeMode()
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_currentMode = 1;
|
||||
m_stack->setCurrentWidget( m_superCollectionView );
|
||||
|
||||
if ( m_superCollectionVisible )
|
||||
showSuperCollection();
|
||||
else
|
||||
show( m_currentCollection );
|
||||
}
|
||||
|
||||
|
||||
@ -280,7 +317,11 @@ PlaylistManager::setAlbumMode()
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_currentMode = 2;
|
||||
m_stack->setCurrentWidget( m_superCollectionView );
|
||||
|
||||
if ( m_superCollectionVisible )
|
||||
showSuperCollection();
|
||||
else
|
||||
show( m_currentCollection );
|
||||
}
|
||||
|
||||
|
||||
@ -377,13 +418,17 @@ PlaylistManager::linkPlaylist()
|
||||
applyFilter();
|
||||
APP->audioEngine()->setPlaylist( m_currentInterface );
|
||||
|
||||
if ( m_currentInterface )
|
||||
if ( m_currentInterface && m_statsAvailable )
|
||||
{
|
||||
emit numTracksChanged( m_currentInterface->unfilteredTrackCount() );
|
||||
emit numShownChanged( m_currentInterface->trackCount() );
|
||||
emit repeatModeChanged( m_currentInterface->repeatMode() );
|
||||
emit shuffleModeChanged( m_currentInterface->shuffled() );
|
||||
|
||||
}
|
||||
|
||||
emit statsAvailable( m_statsAvailable );
|
||||
emit modesAvailable( m_modesAvailable );
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "tomahawk/playlistinterface.h"
|
||||
|
||||
class AnimatedSplitter;
|
||||
class AlbumModel;
|
||||
class AlbumView;
|
||||
class CollectionModel;
|
||||
class CollectionFlatModel;
|
||||
@ -51,6 +52,9 @@ signals:
|
||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void statsAvailable( bool b );
|
||||
void modesAvailable( bool b );
|
||||
|
||||
public slots:
|
||||
void setTreeMode();
|
||||
void setTableMode();
|
||||
@ -78,6 +82,8 @@ private:
|
||||
PlaylistModel* m_queueModel;
|
||||
QueueView* m_queueView;
|
||||
|
||||
AlbumModel* m_superAlbumModel;
|
||||
AlbumView* m_superAlbumView;
|
||||
CollectionFlatModel* m_superCollectionFlatModel;
|
||||
CollectionView* m_superCollectionView;
|
||||
|
||||
@ -94,8 +100,12 @@ private:
|
||||
|
||||
QWidget* m_currentInfoWidget;
|
||||
|
||||
Tomahawk::collection_ptr m_currentCollection;
|
||||
|
||||
int m_currentMode;
|
||||
bool m_superCollectionVisible;
|
||||
bool m_statsAvailable;
|
||||
bool m_modesAvailable;
|
||||
|
||||
QTimer m_filterTimer;
|
||||
QString m_filter;
|
||||
|
@ -337,7 +337,6 @@ void
|
||||
TrackModel::onPlaybackFinished( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
PlItem* oldEntry = itemFromIndex( m_currentIndex );
|
||||
qDebug() << oldEntry->query();
|
||||
if ( oldEntry && !oldEntry->query().isNull() && oldEntry->query()->results().contains( result ) )
|
||||
{
|
||||
oldEntry->setIsPlaying( false );
|
||||
|
@ -142,6 +142,12 @@ TomahawkWindow::setupSignals()
|
||||
connect( m_topbar, SIGNAL( albumMode() ),
|
||||
playlistManager(), SLOT( setAlbumMode() ) );
|
||||
|
||||
connect( playlistManager(), SIGNAL( statsAvailable( bool ) ),
|
||||
m_topbar, SLOT( setStatsVisible( bool ) ) );
|
||||
|
||||
connect( playlistManager(), SIGNAL( modesAvailable( bool ) ),
|
||||
m_topbar, SLOT( setModesVisible( bool ) ) );
|
||||
|
||||
// <From PlaylistManager>
|
||||
connect( playlistManager(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
||||
m_audioControls, SLOT( onRepeatModeChanged( PlaylistInterface::RepeatMode ) ) );
|
||||
|
@ -171,7 +171,6 @@ void
|
||||
TopBar::setNumTracks( unsigned int i )
|
||||
{
|
||||
m_tracks = i;
|
||||
ui->statsLabelNumTracks->setVisible( m_tracks > 0 );
|
||||
ui->statsLabelNumTracks->setVal( i );
|
||||
}
|
||||
|
||||
@ -189,7 +188,7 @@ void
|
||||
TopBar::setNumShown( unsigned int i )
|
||||
{
|
||||
m_shown = i;
|
||||
ui->statsLabelNumShown->setVisible( m_shown != m_tracks );
|
||||
ui->statsLabelNumShown->setVisible( m_shown != m_tracks && ui->statsLabelNumTracks->isVisible() );
|
||||
ui->statsLabelNumShown->setText( QString( "%L1 %2" ).arg( i ).arg( tr( "Shown" ) ) );
|
||||
}
|
||||
|
||||
@ -209,3 +208,23 @@ TopBar::removeSource()
|
||||
Q_ASSERT( m_sources > 0 );
|
||||
setNumSources( m_sources - 1 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TopBar::setStatsVisible( bool b )
|
||||
{
|
||||
foreach( QLabel* dude, m_dudes )
|
||||
dude->setVisible( b );
|
||||
|
||||
// ui->statsLabelNumArtists->setVisible( b );
|
||||
// ui->statsLabelNumShown->setVisible( b );
|
||||
ui->statsLabelNumSources->setVisible( b );
|
||||
ui->statsLabelNumTracks->setVisible( b );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TopBar::setModesVisible( bool b )
|
||||
{
|
||||
ui->widgetRadio->setVisible( b );
|
||||
}
|
||||
|
@ -33,6 +33,9 @@ public slots:
|
||||
void setNumArtists( unsigned int );
|
||||
void setNumShown( unsigned int );
|
||||
|
||||
void setStatsVisible( bool b );
|
||||
void setModesVisible( bool b );
|
||||
|
||||
void addSource();
|
||||
void removeSource();
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>27</height>
|
||||
<height>38</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -31,6 +31,13 @@ public:
|
||||
}
|
||||
|
||||
public slots:
|
||||
void setVisible( bool b )
|
||||
{
|
||||
QLabel::setVisible( b );
|
||||
if ( !m_diff.isNull() )
|
||||
m_diff.data()->setVisible( b );
|
||||
}
|
||||
|
||||
void frame( int f )
|
||||
{
|
||||
m_displayed = f;
|
||||
@ -65,24 +72,25 @@ public slots:
|
||||
void showDiff()
|
||||
{
|
||||
int differ = m_val - m_oldval;
|
||||
QLabel* diff = new QLabel( QString("%1 %L2" ).arg( differ > 0 ? "+" : "" )
|
||||
m_diff = new QLabel( QString("%1 %L2" ).arg( differ > 0 ? "+" : "" )
|
||||
.arg( (int)m_val - (int)m_oldval ),
|
||||
this->parentWidget() );
|
||||
|
||||
diff->setStyleSheet( "font-size:9px; color:grey;" );
|
||||
diff->move( QPoint( this->pos().x(), this->pos().y() ) );
|
||||
QPropertyAnimation* a = new QPropertyAnimation( diff, "pos" );
|
||||
m_diff.data()->setStyleSheet( "font-size:9px; color:grey;" );
|
||||
m_diff.data()->move( QPoint( this->pos().x(), this->pos().y() ) );
|
||||
QPropertyAnimation* a = new QPropertyAnimation( m_diff.data(), "pos" );
|
||||
a->setEasingCurve( QEasingCurve( QEasingCurve::InQuad ) );
|
||||
a->setStartValue( diff->pos() + QPoint( 0, -10 ) );
|
||||
a->setEndValue( QPoint( diff->pos().x(), diff->pos().y() - 25 ) );
|
||||
a->setStartValue( m_diff.data()->pos() + QPoint( 0, -10 ) );
|
||||
a->setEndValue( QPoint( m_diff.data()->pos().x(), m_diff.data()->pos().y() - 25 ) );
|
||||
a->setDuration( 1000 );
|
||||
// qDebug() << "ANIMATING DIFF:" << a->startValue() << a->endValue();
|
||||
|
||||
connect( a, SIGNAL( finished() ), diff, SLOT( hide() ) );
|
||||
connect( a, SIGNAL( finished() ), diff, SLOT( deleteLater() ) );
|
||||
connect( a, SIGNAL( finished() ), m_diff.data(), SLOT( hide() ) );
|
||||
connect( a, SIGNAL( finished() ), m_diff.data(), SLOT( deleteLater() ) );
|
||||
connect( a, SIGNAL( finished() ), a, SLOT( deleteLater() ) );
|
||||
|
||||
diff->show();
|
||||
m_diff.data()->show();
|
||||
m_diff.data()->setVisible( this->isVisible() );
|
||||
a->start();
|
||||
}
|
||||
|
||||
@ -96,7 +104,7 @@ private:
|
||||
unsigned int m_val, m_oldval;
|
||||
|
||||
QString m_format;
|
||||
|
||||
QWeakPointer<QLabel> m_diff;
|
||||
};
|
||||
|
||||
#endif // ANIMATEDCOUNTERLABEL_H
|
||||
|
@ -98,8 +98,6 @@ AnimatedSplitter::addWidget( AnimatedWidget* widget )
|
||||
QSplitter::addWidget( widget );
|
||||
m_sizes << widget->hiddenSize();
|
||||
|
||||
qDebug() << m_sizes.count();
|
||||
|
||||
connect( widget, SIGNAL( showWidget() ), SLOT( onShowRequest() ) );
|
||||
connect( widget, SIGNAL( hideWidget() ), SLOT( onHideRequest() ) );
|
||||
connect( widget, SIGNAL( hiddenSizeChanged() ), SLOT( onHiddenSizeChanged() ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user