1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-08 15:16:34 +02:00

* Simplify Dashboard.

This commit is contained in:
Christian Muehlhaeuser
2014-08-13 08:02:07 +02:00
parent 87a43fad9d
commit 21fcefb843
3 changed files with 44 additions and 428 deletions

View File

@@ -20,6 +20,7 @@
#include "Dashboard.h" #include "Dashboard.h"
#include "ui_DashboardWidget.h" #include "ui_DashboardWidget.h"
#include "ui_HeaderWidget.h"
#include "libtomahawk-widgets/PlaylistDelegate.h" #include "libtomahawk-widgets/PlaylistDelegate.h"
@@ -30,6 +31,7 @@
#include "widgets/RecentlyPlayedPlaylistsModel.h" #include "widgets/RecentlyPlayedPlaylistsModel.h"
#include "MetaPlaylistInterface.h" #include "MetaPlaylistInterface.h"
#include "audio/AudioEngine.h" #include "audio/AudioEngine.h"
#include "playlist/TrackView.h"
#include "playlist/AlbumModel.h" #include "playlist/AlbumModel.h"
#include "playlist/RecentlyPlayedModel.h" #include "playlist/RecentlyPlayedModel.h"
#include "playlist/dynamic/GeneratorInterface.h" #include "playlist/dynamic/GeneratorInterface.h"
@@ -65,129 +67,62 @@ Dashboard::~Dashboard()
DashboardWidget::DashboardWidget( QWidget* parent ) DashboardWidget::DashboardWidget( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, ui( new Ui::DashboardWidget ) , ui( new Ui::DashboardWidget )
, uiHeader( new Ui::HeaderWidget )
{ {
QWidget* widget = new QWidget; QWidget* widget = new QWidget;
QWidget* headerWidget = new QWidget;
ui->setupUi( widget ); ui->setupUi( widget );
uiHeader->setupUi( headerWidget );
ui->lineAbove->setStyleSheet( QString( "QFrame { border: 1px solid black; }" ) ); headerWidget->setFixedHeight( 160 );
ui->lineBelow->setStyleSheet( QString( "QFrame { border: 1px solid %1; }" ).arg( TomahawkStyle::HEADER_BACKGROUND.name() ) );
{ {
m_tracksModel = new RecentlyPlayedModel( ui->tracksView, HISTORY_TRACK_ITEMS ); m_tracksModel = new RecentlyPlayedModel( ui->trackView->trackView(), HISTORY_TRACK_ITEMS );
ui->tracksView->proxyModel()->setStyle( PlayableProxyModel::Short ); ui->trackView->setPlayableModel( m_tracksModel );
ui->tracksView->overlay()->setEnabled( false ); ui->trackView->setCaption( tr( "Recently Played Tracks" ) );
ui->tracksView->setPlaylistModel( m_tracksModel ); ui->trackView->trackView()->setUniformRowHeights( false );
ui->tracksView->setAutoResize( true );
ui->tracksView->setAlternatingRowColors( false ); // ui->trackView->trackView()->setAutoResize( true );
m_tracksModel->setSource( source_ptr() ); m_tracksModel->setSource( source_ptr() );
QPalette p = ui->tracksView->palette();
p.setColor( QPalette::Text, TomahawkStyle::PAGE_TRACKLIST_TRACK_SOLVED );
p.setColor( QPalette::BrightText, TomahawkStyle::PAGE_TRACKLIST_TRACK_UNRESOLVED );
p.setColor( QPalette::Foreground, TomahawkStyle::PAGE_TRACKLIST_NUMBER );
p.setColor( QPalette::Highlight, TomahawkStyle::PAGE_TRACKLIST_HIGHLIGHT );
p.setColor( QPalette::HighlightedText, TomahawkStyle::PAGE_TRACKLIST_HIGHLIGHT_TEXT );
ui->tracksView->setPalette( p );
TomahawkStyle::stylePageFrame( ui->tracksView );
TomahawkStyle::stylePageFrame( ui->trackFrame );
} }
{ {
RecentPlaylistsModel* model = new RecentPlaylistsModel( HISTORY_PLAYLIST_ITEMS, this ); QFont f = uiHeader->artistLabel->font();
f.setBold( true );
f.setPointSize( 16 );
ui->playlistWidget->setFrameShape( QFrame::NoFrame ); QPalette p = uiHeader->artistLabel->palette();
ui->playlistWidget->setAttribute( Qt::WA_MacShowFocusRect, 0 ); p.setColor( QPalette::Foreground, Qt::white );
ui->playlistWidget->setItemDelegate( new PlaylistDelegate() );
ui->playlistWidget->setModel( model );
ui->playlistWidget->overlay()->resize( 380, 86 );
ui->playlistWidget->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
QPalette p = ui->playlistWidget->palette(); uiHeader->artistLabel->setFont( f );
p.setColor( QPalette::Text, TomahawkStyle::HEADER_TEXT ); uiHeader->artistLabel->setPalette( p );
p.setColor( QPalette::BrightText, TomahawkStyle::HEADER_TEXT ); uiHeader->artistLabel->setText( tr( "Dashboard" ).toUpper() );
p.setColor( QPalette::Foreground, TomahawkStyle::HEADER_TEXT );
p.setColor( QPalette::Highlight, TomahawkStyle::HEADER_TEXT );
p.setColor( QPalette::HighlightedText, TomahawkStyle::HEADER_BACKGROUND );
ui->playlistWidget->setPalette( p );
ui->playlistWidget->setMinimumHeight( 400 );
TomahawkStyle::styleScrollBar( ui->playlistWidget->verticalScrollBar() );
TomahawkStyle::stylePageFrame( ui->playlistWidget );
TomahawkStyle::stylePageFrame( ui->playlistFrame );
updatePlaylists();
connect( ui->playlistWidget, SIGNAL( activated( QModelIndex ) ), SLOT( onPlaylistActivated( QModelIndex ) ) );
connect( model, SIGNAL( emptinessChanged( bool ) ), this, SLOT( updatePlaylists() ) );
}
{
m_recentAlbumsModel = new AlbumModel( ui->additionsView );
ui->additionsView->setPlayableModel( m_recentAlbumsModel );
ui->additionsView->proxyModel()->sort( -1 );
TomahawkStyle::styleScrollBar( ui->additionsView->verticalScrollBar() );
TomahawkStyle::stylePageFrame( ui->additionsView );
TomahawkStyle::stylePageFrame( ui->additionsFrame );
}
{
QFont f = ui->label->font();
f.setFamily( "Pathway Gothic One" );
QPalette p = ui->label->palette();
p.setColor( QPalette::Foreground, TomahawkStyle::PAGE_CAPTION );
ui->label->setFont( f );
ui->label_2->setFont( f );
ui->label->setPalette( p );
ui->label_2->setPalette( p );
}
{
QFont f = ui->playlistLabel->font();
f.setFamily( "Pathway Gothic One" );
QPalette p = ui->playlistLabel->palette();
p.setColor( QPalette::Foreground, TomahawkStyle::HEADER_TEXT );
ui->playlistLabel->setFont( f );
ui->playlistLabel->setPalette( p );
} }
{ {
QScrollArea* area = new QScrollArea(); QScrollArea* area = new QScrollArea();
area->setWidgetResizable( true ); area->setWidgetResizable( true );
area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
area->setWidget( widget ); area->setWidget( widget );
QPalette pal = palette(); QPalette pal = palette();
pal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND ); pal.setBrush( backgroundRole(), Qt::white );
area->setPalette( pal ); area->setPalette( pal );
area->setAutoFillBackground( true ); area->setAutoFillBackground( true );
area->setFrameShape( QFrame::NoFrame ); area->setFrameShape( QFrame::NoFrame );
area->setAttribute( Qt::WA_MacShowFocusRect, 0 ); area->setAttribute( Qt::WA_MacShowFocusRect, 0 );
QVBoxLayout* layout = new QVBoxLayout(); QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget( headerWidget );
layout->addWidget( area ); layout->addWidget( area );
setLayout( layout ); setLayout( layout );
TomahawkUtils::unmarginLayout( layout ); TomahawkUtils::unmarginLayout( layout );
} }
{
QPalette pal = palette();
pal.setBrush( backgroundRole(), TomahawkStyle::PAGE_BACKGROUND );
ui->widget->setPalette( pal );
ui->widget->setAutoFillBackground( true );
}
MetaPlaylistInterface* mpl = new MetaPlaylistInterface(); MetaPlaylistInterface* mpl = new MetaPlaylistInterface();
mpl->addChildInterface( ui->tracksView->playlistInterface() ); mpl->addChildInterface( ui->trackView->trackView()->playlistInterface() );
mpl->addChildInterface( ui->additionsView->playlistInterface() );
m_playlistInterface = playlistinterface_ptr( mpl ); m_playlistInterface = playlistinterface_ptr( mpl );
connect( SourceList::instance(), SIGNAL( ready() ), SLOT( onSourcesReady() ) ); connect( ui->trackView, SIGNAL( pixmapChanged( QPixmap ) ), uiHeader->headerWidget, SLOT( setBackground( QPixmap ) ) );
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
} }
@@ -207,10 +142,7 @@ DashboardWidget::playlistInterface() const
bool bool
DashboardWidget::jumpToCurrentTrack() DashboardWidget::jumpToCurrentTrack()
{ {
if ( ui->tracksView->jumpToCurrentTrack() ) if ( ui->trackView->trackView()->jumpToCurrentTrack() )
return true;
if ( ui->additionsView->jumpToCurrentTrack() )
return true; return true;
return false; return false;
@@ -220,59 +152,7 @@ DashboardWidget::jumpToCurrentTrack()
bool bool
DashboardWidget::isBeingPlayed() const DashboardWidget::isBeingPlayed() const
{ {
if ( ui->additionsView->isBeingPlayed() ) return AudioEngine::instance()->currentTrackPlaylist() == ui->trackView->trackView()->playlistInterface();
return true;
return AudioEngine::instance()->currentTrackPlaylist() == ui->tracksView->playlistInterface();
}
void
DashboardWidget::onSourcesReady()
{
foreach ( const source_ptr& source, SourceList::instance()->sources() )
onSourceAdded( source );
updateRecentAdditions();
}
void
DashboardWidget::onSourceAdded( const Tomahawk::source_ptr& source )
{
connect( source->dbCollection().data(), SIGNAL( changed() ), SLOT( updateRecentAdditions() ), Qt::UniqueConnection );
}
void
DashboardWidget::updateRecentAdditions()
{
m_recentAlbumsModel->addFilteredCollection( collection_ptr(), 20, DatabaseCommand_AllAlbums::ModificationTime, true );
}
void
DashboardWidget::updatePlaylists()
{
int num = ui->playlistWidget->model()->rowCount( QModelIndex() );
if ( num == 0 )
{
ui->playlistWidget->overlay()->setText( tr( "No recently created playlists in your network." ) );
ui->playlistWidget->overlay()->show();
}
else
ui->playlistWidget->overlay()->hide();
}
void
DashboardWidget::onPlaylistActivated( const QModelIndex& item )
{
Tomahawk::playlist_ptr pl = item.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >();
if ( Tomahawk::dynplaylist_ptr dynplaylist = pl.dynamicCast< Tomahawk::DynamicPlaylist >() )
ViewManager::instance()->show( dynplaylist );
else
ViewManager::instance()->show( pl );
} }

View File

@@ -43,6 +43,7 @@ class BasicHeader;
namespace Ui namespace Ui
{ {
class DashboardWidget; class DashboardWidget;
class HeaderWidget;
} }
namespace Tomahawk namespace Tomahawk
@@ -66,19 +67,15 @@ public:
virtual bool jumpToCurrentTrack(); virtual bool jumpToCurrentTrack();
public slots: public slots:
void updatePlaylists();
void updateRecentAdditions();
private slots: private slots:
void onSourcesReady();
void onSourceAdded( const Tomahawk::source_ptr& source );
void onPlaylistActivated( const QModelIndex& );
protected: protected:
void changeEvent( QEvent* e ); void changeEvent( QEvent* e );
private: private:
Ui::DashboardWidget *ui; Ui::DashboardWidget *ui;
Ui::HeaderWidget *uiHeader;
RecentlyPlayedModel* m_tracksModel; RecentlyPlayedModel* m_tracksModel;
AlbumModel* m_recentAlbumsModel; AlbumModel* m_recentAlbumsModel;
@@ -104,7 +101,7 @@ public:
int sortValue() Q_DECL_OVERRIDE { return 2; } int sortValue() Q_DECL_OVERRIDE { return 2; }
bool showInfoBar() const Q_DECL_OVERRIDE { return true; } bool showInfoBar() const Q_DECL_OVERRIDE { return false; }
}; };

View File

@@ -6,299 +6,38 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>965</width> <width>828</width>
<height>616</height> <height>635</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string notr="true" extracomment="not translatable because not shown to the user">Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>16</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>16</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="trackFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>20</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Recently Played Tracks</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="PlaylistView" name="tracksView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="additionsFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<family>Arial</family>
<pointsize>20</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Recent Additions</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="GridView" name="additionsView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>190</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="Line" name="lineAbove">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="Line" name="lineBelow">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="playlistContainer" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>16</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>16</number>
</property>
<item>
<widget class="QFrame" name="playlistFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="playlistLabel">
<property name="font">
<font>
<pointsize>20</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Newest Stations &amp; Playlists</string>
</property>
<property name="margin"> <property name="margin">
<number>0</number> <number>0</number>
</property> </property>
</widget>
</item>
<item> <item>
<widget class="Tomahawk::Widgets::PlaylistWidget" name="playlistWidget"/> <widget class="ContextView" name="trackView" native="true">
</item> <property name="sizePolicy">
</layout> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
</widget> <horstretch>0</horstretch>
</item> <verstretch>0</verstretch>
</layout> </sizepolicy>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>PlaylistView</class> <class>ContextView</class>
<extends>QTreeView</extends> <extends>QWidget</extends>
<header location="global">playlist/PlaylistView.h</header> <header>playlist/ContextView.h</header>
</customwidget> <container>1</container>
<customwidget>
<class>GridView</class>
<extends>QListView</extends>
<header location="global">playlist/GridView.h</header>
</customwidget>
<customwidget>
<class>Tomahawk::Widgets::PlaylistWidget</class>
<extends>QListWidget</extends>
<header>libtomahawk-widgets/PlaylistWidget.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>