From 03451c91970ba267b090994f6e9db1bd70423431 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 19 May 2011 08:00:57 +0200 Subject: [PATCH] * Made Artist- / TreeView the default view. Disabled album mode for this release. --- .../{ => stylesheets}/topbar-radiobuttons.css | 18 ++++----- resources.qrc | 2 +- src/libtomahawk/playlist/artistview.cpp | 1 + src/libtomahawk/playlist/artistview.h | 6 ++- src/libtomahawk/playlist/collectionview.h | 5 ++- src/libtomahawk/playlist/playlistview.h | 2 + src/libtomahawk/playlist/topbar/topbar.cpp | 38 ++++++++++++------- src/libtomahawk/playlist/topbar/topbar.h | 5 ++- src/libtomahawk/playlistinterface.h | 6 +-- src/libtomahawk/viewmanager.cpp | 24 ++++++------ src/libtomahawk/viewmanager.h | 2 + src/libtomahawk/viewpage.h | 1 + 12 files changed, 68 insertions(+), 42 deletions(-) rename data/{ => stylesheets}/topbar-radiobuttons.css (89%) diff --git a/data/topbar-radiobuttons.css b/data/stylesheets/topbar-radiobuttons.css similarity index 89% rename from data/topbar-radiobuttons.css rename to data/stylesheets/topbar-radiobuttons.css index 077315fd7..6ee4719d6 100644 --- a/data/topbar-radiobuttons.css +++ b/data/stylesheets/topbar-radiobuttons.css @@ -18,28 +18,28 @@ QRadioButton::indicator { } QRadioButton::indicator::unchecked { - background-image: url(:/data/images/view-toggle-inactive-centre.png); - image: url(:/data/images/view-toggle-icon-artist-inactive.png); + background-image: url(:/data/images/view-toggle-inactive-right.png); + image: url(:/data/images/view-toggle-icon-list-inactive.png); } QRadioButton::indicator::checked { - background-image: url(:/data/images/view-toggle-active-centre.png); - image: url(:/data/images/view-toggle-icon-artist-active.png); + background-image: url(:/data/images/view-toggle-active-right.png); + image: url(:/data/images/view-toggle-icon-list-active.png); } QRadioButton::indicator::pressed { - background-image: url(:/data/images/view-toggle-pressed-centre.png); - image: url(:/data/images/view-toggle-icon-artist-active.png); + background-image: url(:/data/images/view-toggle-pressed-right.png); + image: url(:/data/images/view-toggle-icon-list-active.png); } QRadioButton#radioNormal::indicator::unchecked { background-image: url(:/data/images/view-toggle-inactive-left.png); - image: url(:/data/images/view-toggle-icon-list-inactive.png); + image: url(:/data/images/view-toggle-icon-artist-inactive.png); } QRadioButton#radioNormal::indicator::checked { background-image: url(:/data/images/view-toggle-active-left.png); - image: url(:/data/images/view-toggle-icon-list-active.png); + image: url(:/data/images/view-toggle-icon-artist-active.png); } QRadioButton#radioNormal::indicator::pressed { background-image: url(:/data/images/view-toggle-pressed-left.png); - image: url(:/data/images/view-toggle-icon-list-active.png); + image: url(:/data/images/view-toggle-icon-artist-active.png); } QRadioButton#radioCloud::indicator::unchecked { background-image: url(:/data/images/view-toggle-inactive-right.png); diff --git a/resources.qrc b/resources.qrc index b5845c966..5194ea273 100644 --- a/resources.qrc +++ b/resources.qrc @@ -88,7 +88,7 @@ ./data/images/music-settings.png ./data/images/resolvers-settings.png ./data/images/lastfm-settings.png - ./data/topbar-radiobuttons.css + ./data/stylesheets/topbar-radiobuttons.css ./data/icons/tomahawk-icon-16x16.png ./data/icons/tomahawk-icon-32x32.png ./data/icons/tomahawk-icon-64x64.png diff --git a/src/libtomahawk/playlist/artistview.cpp b/src/libtomahawk/playlist/artistview.cpp index c457b144d..a3d5ce592 100644 --- a/src/libtomahawk/playlist/artistview.cpp +++ b/src/libtomahawk/playlist/artistview.cpp @@ -46,6 +46,7 @@ ArtistView::ArtistView( QWidget* parent ) , m_proxyModel( 0 ) // , m_delegate( 0 ) , m_loadingSpinner( new LoadingSpinner( this ) ) + , m_showModes( true ) { setAlternatingRowColors( true ); setDragEnabled( true ); diff --git a/src/libtomahawk/playlist/artistview.h b/src/libtomahawk/playlist/artistview.h index 1059b0b3d..e7eaf9a96 100644 --- a/src/libtomahawk/playlist/artistview.h +++ b/src/libtomahawk/playlist/artistview.h @@ -55,7 +55,10 @@ public: virtual QPixmap pixmap() const { return QPixmap( RESPATH "images/music-icon.png" ); } virtual bool showStatsBar() const { return false; } - virtual bool showModes() const { return true; } + virtual bool showFilter() const { return false; } + + virtual void setShowModes( bool b ) { m_showModes = b; } + virtual bool showModes() const { return m_showModes; } virtual bool jumpToCurrentTrack(); @@ -83,6 +86,7 @@ private: LoadingSpinner* m_loadingSpinner; + bool m_showModes; QTimer m_timer; }; diff --git a/src/libtomahawk/playlist/collectionview.h b/src/libtomahawk/playlist/collectionview.h index 1fe261646..a9aad7b17 100644 --- a/src/libtomahawk/playlist/collectionview.h +++ b/src/libtomahawk/playlist/collectionview.h @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -45,8 +45,9 @@ public: virtual QString title() const { return model()->title(); } virtual QString description() const { return model()->description(); } virtual QPixmap pixmap() const { return QPixmap( RESPATH "images/music-icon.png" ); } - + virtual bool showModes() const { return true; } + virtual bool showFilter() const { return true; } virtual bool jumpToCurrentTrack(); diff --git a/src/libtomahawk/playlist/playlistview.h b/src/libtomahawk/playlist/playlistview.h index 589c5f815..f4cbc9c12 100644 --- a/src/libtomahawk/playlist/playlistview.h +++ b/src/libtomahawk/playlist/playlistview.h @@ -45,6 +45,8 @@ public: virtual QWidget* widget() { return this; } virtual PlaylistInterface* playlistInterface() const { return proxyModel(); } + virtual bool showFilter() const { return true; } + virtual QString title() const { return playlistModel()->title(); } virtual QString description() const { return m_model->description(); } virtual QPixmap pixmap() const { return QPixmap( RESPATH "images/playlist-icon.png" ); } diff --git a/src/libtomahawk/playlist/topbar/topbar.cpp b/src/libtomahawk/playlist/topbar/topbar.cpp index 9c0acda8b..c71edce0c 100644 --- a/src/libtomahawk/playlist/topbar/topbar.cpp +++ b/src/libtomahawk/playlist/topbar/topbar.cpp @@ -61,7 +61,7 @@ TopBar::TopBar( QWidget* parent ) m_dudes.append( manlbl ); } - QFile f( RESPATH "topbar-radiobuttons.css" ); + QFile f( RESPATH "stylesheets/topbar-radiobuttons.css" ); f.open( QFile::ReadOnly ); QString css = QString::fromAscii( f.readAll() ); f.close(); @@ -72,8 +72,10 @@ TopBar::TopBar( QWidget* parent ) ui->radioDetailed->setFocusPolicy( Qt::NoFocus ); ui->radioCloud->setFocusPolicy( Qt::NoFocus ); - connect( ui->radioNormal, SIGNAL( clicked() ), SIGNAL( flatMode() ) ); - connect( ui->radioDetailed, SIGNAL( clicked() ), SIGNAL( artistMode() ) ); + ui->radioCloud->hide(); + + connect( ui->radioNormal, SIGNAL( clicked() ), SIGNAL( artistMode() ) ); + connect( ui->radioDetailed, SIGNAL( clicked() ), SIGNAL( flatMode() ) ); connect( ui->radioCloud, SIGNAL( clicked() ), SIGNAL( albumMode() ) ); setNumSources( 0 ); @@ -81,28 +83,31 @@ TopBar::TopBar( QWidget* parent ) setNumArtists( 0 ); setNumShown( 0 ); - onFlatMode(); + onArtistMode(); connect( ViewManager::instance(), SIGNAL( numSourcesChanged( unsigned int ) ), - SLOT( setNumSources( unsigned int ) ) ); + SLOT( setNumSources( unsigned int ) ) ); connect( ViewManager::instance(), SIGNAL( numTracksChanged( unsigned int ) ), - SLOT( setNumTracks( unsigned int ) ) ); + SLOT( setNumTracks( unsigned int ) ) ); connect( ViewManager::instance(), SIGNAL( numArtistsChanged( unsigned int ) ), - SLOT( setNumArtists( unsigned int ) ) ); + SLOT( setNumArtists( unsigned int ) ) ); connect( ViewManager::instance(), SIGNAL( numShownChanged( unsigned int ) ), - SLOT( setNumShown( unsigned int ) ) ); + SLOT( setNumShown( unsigned int ) ) ); connect( ViewManager::instance(), SIGNAL( statsAvailable( bool ) ), - SLOT( setStatsVisible( bool ) ) ); + SLOT( setStatsVisible( bool ) ) ); connect( ViewManager::instance(), SIGNAL( modesAvailable( bool ) ), - SLOT( setModesVisible( bool ) ) ); + SLOT( setModesVisible( bool ) ) ); + + connect( ViewManager::instance(), SIGNAL( filterAvailable( bool ) ), + SLOT( setFilterVisible( bool ) ) ); connect( ViewManager::instance(), SIGNAL( modeChanged( PlaylistInterface::ViewMode ) ), - SLOT( onModeChanged( PlaylistInterface::ViewMode ) ) ); + SLOT( onModeChanged( PlaylistInterface::ViewMode ) ) ); } @@ -270,6 +275,13 @@ TopBar::setModesVisible( bool b ) } +void +TopBar::setFilterVisible( bool b ) +{ + ui->filterEdit->setEnabled( b ); +} + + void TopBar::setFilter( const QString& filter ) { @@ -304,14 +316,14 @@ TopBar::onModeChanged( PlaylistInterface::ViewMode mode ) void TopBar::onFlatMode() { - ui->radioNormal->setChecked( true ); + ui->radioDetailed->setChecked( true ); } void TopBar::onArtistMode() { - ui->radioDetailed->setChecked( true ); + ui->radioNormal->setChecked( true ); } diff --git a/src/libtomahawk/playlist/topbar/topbar.h b/src/libtomahawk/playlist/topbar/topbar.h index d48c953ed..652e0cc19 100644 --- a/src/libtomahawk/playlist/topbar/topbar.h +++ b/src/libtomahawk/playlist/topbar/topbar.h @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -55,6 +55,7 @@ public slots: void setStatsVisible( bool b ); void setModesVisible( bool b ); + void setFilterVisible( bool b ); void addSource(); void removeSource(); @@ -66,7 +67,7 @@ private slots: void onFlatMode(); void onArtistMode(); void onAlbumMode(); - + protected: void changeEvent( QEvent* e ); void resizeEvent( QResizeEvent* e ); diff --git a/src/libtomahawk/playlistinterface.h b/src/libtomahawk/playlistinterface.h index 2743a7d13..bbb0e2e5c 100644 --- a/src/libtomahawk/playlistinterface.h +++ b/src/libtomahawk/playlistinterface.h @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -31,8 +31,8 @@ class DLLEXPORT PlaylistInterface { public: enum RepeatMode { NoRepeat, RepeatOne, RepeatAll }; - enum ViewMode { Unknown, Flat, Tree, Album }; - + enum ViewMode { Unknown, Tree, Flat, Album }; + PlaylistInterface( QObject* parent = 0 ) : m_object( parent ) {} virtual ~PlaylistInterface() {} diff --git a/src/libtomahawk/viewmanager.cpp b/src/libtomahawk/viewmanager.cpp index e6abf3250..e319f66ca 100644 --- a/src/libtomahawk/viewmanager.cpp +++ b/src/libtomahawk/viewmanager.cpp @@ -67,7 +67,7 @@ ViewManager::ViewManager( QObject* parent ) : QObject( parent ) , m_widget( new QWidget() ) , m_welcomeWidget( new WelcomeWidget() ) - , m_currentMode( 0 ) + , m_currentMode( PlaylistInterface::Tree ) { s_instance = this; @@ -107,6 +107,7 @@ ViewManager::ViewManager( QObject* parent ) m_superCollectionView->setModel( m_superCollectionModel ); m_superCollectionView->setFrameShape( QFrame::NoFrame ); m_superCollectionView->setAttribute( Qt::WA_MacShowFocusRect, 0 ); + m_superCollectionView->setShowModes( false ); // m_superCollectionView->proxyModel()->setShowOfflineResults( false ); m_superAlbumView = new AlbumView(); @@ -275,7 +276,7 @@ ViewManager::show( const Tomahawk::collection_ptr& collection ) qDebug() << Q_FUNC_INFO << m_currentMode; m_currentCollection = collection; ViewPage* shown = 0; - if ( m_currentMode == 0 ) + if ( m_currentMode == PlaylistInterface::Flat ) { CollectionView* view; if ( !m_collectionViews.contains( collection ) ) @@ -299,7 +300,7 @@ ViewManager::show( const Tomahawk::collection_ptr& collection ) setPage( view ); } - if ( m_currentMode == 1 ) + if ( m_currentMode == PlaylistInterface::Tree ) { ArtistView* view; if ( !m_treeViews.contains( collection ) ) @@ -323,7 +324,7 @@ ViewManager::show( const Tomahawk::collection_ptr& collection ) setPage( view ); } - if ( m_currentMode == 2 ) + if ( m_currentMode == PlaylistInterface::Album ) { AlbumView* aview; if ( !m_collectionAlbumViews.contains( collection ) ) @@ -401,17 +402,17 @@ ViewManager::showSuperCollection() m_superAlbumModel->setTitle( tr( "All available albums" ) ); ViewPage* shown = 0; - if ( m_currentMode == 0 ) + if ( m_currentMode == PlaylistInterface::Tree ) { shown = m_superCollectionView; setPage( m_superCollectionView ); } - else if ( m_currentMode == 1 ) + else if ( m_currentMode == PlaylistInterface::Flat ) { shown = m_superCollectionView; setPage( m_superCollectionView ); } - else if ( m_currentMode == 2 ) + else if ( m_currentMode == PlaylistInterface::Album ) { shown = m_superAlbumView; setPage( m_superAlbumView ); @@ -450,7 +451,7 @@ ViewManager::setTableMode() { qDebug() << Q_FUNC_INFO; - m_currentMode = 0; + m_currentMode = PlaylistInterface::Flat; if ( isSuperCollectionVisible() ) showSuperCollection(); @@ -464,7 +465,7 @@ ViewManager::setTreeMode() { qDebug() << Q_FUNC_INFO; - m_currentMode = 1; + m_currentMode = PlaylistInterface::Tree; if ( isSuperCollectionVisible() ) showSuperCollection(); @@ -478,7 +479,7 @@ ViewManager::setAlbumMode() { qDebug() << Q_FUNC_INFO; - m_currentMode = 2; + m_currentMode = PlaylistInterface::Album; if ( isSuperCollectionVisible() ) showSuperCollection(); @@ -705,8 +706,9 @@ ViewManager::updateView() emit statsAvailable( currentPage()->showStatsBar() ); emit modesAvailable( currentPage()->showModes() ); + emit filterAvailable( currentPage()->showFilter() ); - if ( !currentPage()->showStatsBar() && !currentPage()->showModes() ) + if ( !currentPage()->showStatsBar() && !currentPage()->showModes() && !currentPage()->showFilter() ) m_topbar->setVisible( false ); else m_topbar->setVisible( true ); diff --git a/src/libtomahawk/viewmanager.h b/src/libtomahawk/viewmanager.h index 9ac8bc63d..0070f95e8 100644 --- a/src/libtomahawk/viewmanager.h +++ b/src/libtomahawk/viewmanager.h @@ -90,6 +90,7 @@ public: // only use this is you need to create a playlist and show it directly and want it to be // linked to the sidebar. call it right after creating the playlist PlaylistView* createPageForPlaylist( const Tomahawk::playlist_ptr& pl ); + signals: void numSourcesChanged( unsigned int sources ); void numTracksChanged( unsigned int tracks ); @@ -101,6 +102,7 @@ signals: void statsAvailable( bool b ); void modesAvailable( bool b ); + void filterAvailable( bool b ); void modeChanged( PlaylistInterface::ViewMode mode ); void playClicked(); diff --git a/src/libtomahawk/viewpage.h b/src/libtomahawk/viewpage.h index 356fabcf8..0921998b2 100644 --- a/src/libtomahawk/viewpage.h +++ b/src/libtomahawk/viewpage.h @@ -46,6 +46,7 @@ public: virtual bool showStatsBar() const { return true; } virtual bool showModes() const { return false; } + virtual bool showFilter() const { return false; } virtual bool queueVisible() const { return true; } virtual bool jumpToCurrentTrack() = 0;