From ae1d641903becaa576e0cb396daf3d5cc621f423 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 8 Jun 2013 06:06:19 +0200 Subject: [PATCH] * Renamed and pagified Dashboard. --- src/libtomahawk/CMakeLists.txt | 4 +- .../{WelcomeWidget.cpp => Dashboard.cpp} | 115 ++++++--- .../widgets/{WelcomeWidget.h => Dashboard.h} | 19 +- src/libtomahawk/widgets/Dashboard.ui | 230 ++++++++++++++++++ src/libtomahawk/widgets/WelcomeWidget.ui | 107 -------- 5 files changed, 323 insertions(+), 152 deletions(-) rename src/libtomahawk/widgets/{WelcomeWidget.cpp => Dashboard.cpp} (74%) rename src/libtomahawk/widgets/{WelcomeWidget.h => Dashboard.h} (88%) create mode 100644 src/libtomahawk/widgets/Dashboard.ui delete mode 100644 src/libtomahawk/widgets/WelcomeWidget.ui diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index a97f483cd..2184f1223 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -135,7 +135,7 @@ set( libGuiSources widgets/SearchWidget.cpp widgets/SeekSlider.cpp widgets/PlaylistTypeSelectorDialog.cpp - widgets/WelcomeWidget.cpp + widgets/Dashboard.cpp widgets/WhatsHotWidget.cpp widgets/NewReleasesWidget.cpp widgets/ChartDataLoader.cpp @@ -364,7 +364,7 @@ set( libUI ${libUI} widgets/PlaylistTypeSelectorDialog.ui widgets/NewPlaylistWidget.ui widgets/SearchWidget.ui - widgets/WelcomeWidget.ui + widgets/Dashboard.ui widgets/WhatsHotWidget.ui widgets/NewReleasesWidget.ui widgets/SocialPlaylistWidget.ui diff --git a/src/libtomahawk/widgets/WelcomeWidget.cpp b/src/libtomahawk/widgets/Dashboard.cpp similarity index 74% rename from src/libtomahawk/widgets/WelcomeWidget.cpp rename to src/libtomahawk/widgets/Dashboard.cpp index c94027953..1a69def7c 100644 --- a/src/libtomahawk/widgets/WelcomeWidget.cpp +++ b/src/libtomahawk/widgets/Dashboard.cpp @@ -18,8 +18,8 @@ * along with Tomahawk. If not, see . */ -#include "WelcomeWidget.h" -#include "ui_WelcomeWidget.h" +#include "Dashboard.h" +#include "ui_Dashboard.h" #include "ViewManager.h" #include "SourceList.h" @@ -39,55 +39,106 @@ #include "utils/Logger.h" #include +#include #define HISTORY_PLAYLIST_ITEMS 10 +#define HISTORY_TRACK_ITEMS 15 using namespace Tomahawk; -WelcomeWidget::WelcomeWidget( QWidget* parent ) +Dashboard::Dashboard( QWidget* parent ) : QWidget( parent ) - , ui( new Ui::WelcomeWidget ) + , ui( new Ui::Dashboard ) { - ui->setupUi( this ); - - ui->splitter_2->setStretchFactor( 0, 3 ); - ui->splitter_2->setStretchFactor( 1, 1 ); - ui->splitter->setChildrenCollapsible( false ); - ui->splitter_2->setChildrenCollapsible( false ); + QWidget* widget = new QWidget; + ui->setupUi( widget ); RecentPlaylistsModel* model = new RecentPlaylistsModel( HISTORY_PLAYLIST_ITEMS, this ); + QPalette trackViewPal = ui->tracksView->palette(); + trackViewPal.setColor( QPalette::Foreground, Qt::white ); + trackViewPal.setColor( QPalette::Text, Qt::white ); + trackViewPal.setColor( QPalette::Highlight, QColor( "#252020" ) ); + trackViewPal.setColor( QPalette::HighlightedText, Qt::white ); + ui->playlistWidget->setFrameShape( QFrame::NoFrame ); ui->playlistWidget->setAttribute( Qt::WA_MacShowFocusRect, 0 ); - - TomahawkUtils::unmarginLayout( layout() ); - TomahawkUtils::unmarginLayout( ui->verticalLayout->layout() ); - TomahawkUtils::unmarginLayout( ui->verticalLayout_2->layout() ); - TomahawkUtils::unmarginLayout( ui->verticalLayout_3->layout() ); - TomahawkUtils::unmarginLayout( ui->verticalLayout_4->layout() ); - ui->playlistWidget->setItemDelegate( new PlaylistDelegate() ); ui->playlistWidget->setModel( model ); ui->playlistWidget->overlay()->resize( 380, 86 ); ui->playlistWidget->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); + ui->playlistWidget->setPalette( trackViewPal ); + ui->playlistWidget->setMinimumHeight( 400 ); updatePlaylists(); - m_tracksModel = new RecentlyPlayedModel( ui->tracksView ); + m_tracksModel = new RecentlyPlayedModel( ui->tracksView, HISTORY_TRACK_ITEMS ); ui->tracksView->proxyModel()->setStyle( PlayableProxyModel::ShortWithAvatars ); ui->tracksView->overlay()->setEnabled( false ); ui->tracksView->setPlaylistModel( m_tracksModel ); + ui->tracksView->setAutoResize( true ); m_tracksModel->setSource( source_ptr() ); + ui->tracksView->setPalette( trackViewPal ); + ui->tracksView->setAlternatingRowColors( false ); + ui->tracksView->setFrameShape( QFrame::NoFrame ); + ui->tracksView->setAttribute( Qt::WA_MacShowFocusRect, 0 ); + + m_recentAlbumsModel = new AlbumModel( ui->additionsView ); + ui->additionsView->setPlayableModel( m_recentAlbumsModel ); + ui->additionsView->proxyModel()->sort( -1 ); + + QScrollArea* area = new QScrollArea(); + area->setWidgetResizable( true ); + area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); + area->setWidget( widget ); + + QPalette pal = palette(); + pal.setBrush( backgroundRole(), TomahawkStyle::PAGE_BACKGROUND ); + area->setPalette( pal ); + area->setAutoFillBackground( true ); + area->setFrameShape( QFrame::NoFrame ); + area->setAttribute( Qt::WA_MacShowFocusRect, 0 ); + + QVBoxLayout* layout = new QVBoxLayout(); + layout->addWidget( area ); + setLayout( layout ); + TomahawkUtils::unmarginLayout( layout ); + + TomahawkUtils::styleScrollBar( ui->playlistWidget->verticalScrollBar() ); + TomahawkUtils::styleScrollBar( ui->additionsView->verticalScrollBar() ); + QFont f; f.setBold( true ); QFontMetrics fm( f ); ui->tracksView->setMinimumWidth( fm.width( tr( "Recently played tracks" ) ) * 2 ); - m_recentAlbumsModel = new AlbumModel( ui->additionsView ); - ui->additionsView->setPlayableModel( m_recentAlbumsModel ); - ui->additionsView->proxyModel()->sort( -1 ); + QPalette p = ui->label->palette(); + p.setColor( QPalette::Foreground, Qt::white ); + p.setColor( QPalette::Text, Qt::gray ); + + ui->label->setPalette( p ); + ui->label_2->setPalette( p ); + ui->label_3->setPalette( p ); + + ui->playlistWidget->setStyleSheet( "QListView { background-color: transparent; }" ); + ui->playlistFrame->setStyleSheet( "QFrame#playlistFrame { background-color: transparent; }" + "QFrame#playlistFrame { " + "border-image: url(" RESPATH "images/widget-border.png) 3 3 3 3 stretch stretch;" + "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); + + ui->additionsView->setStyleSheet( "QListView { background-color: transparent; }" ); + ui->additionsFrame->setStyleSheet( "QFrame#additionsFrame { background-color: transparent; }" + "QFrame#additionsFrame { " + "border-image: url(" RESPATH "images/widget-border.png) 3 3 3 3 stretch stretch;" + "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); + + ui->tracksView->setStyleSheet( "QTreeView#tracksView { background-color: transparent; }" ); + ui->trackFrame->setStyleSheet( "QFrame#trackFrame { background-color: transparent; }" + "QFrame#trackFrame { " + "border-image: url(" RESPATH "images/widget-border.png) 3 3 3 3 stretch stretch;" + "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); MetaPlaylistInterface* mpl = new MetaPlaylistInterface(); mpl->addChildInterface( ui->tracksView->playlistInterface() ); @@ -101,28 +152,28 @@ WelcomeWidget::WelcomeWidget( QWidget* parent ) } -WelcomeWidget::~WelcomeWidget() +Dashboard::~Dashboard() { delete ui; } void -WelcomeWidget::loadData() +Dashboard::loadData() { m_recentAlbumsModel->addFilteredCollection( collection_ptr(), 20, DatabaseCommand_AllAlbums::ModificationTime, true ); } Tomahawk::playlistinterface_ptr -WelcomeWidget::playlistInterface() const +Dashboard::playlistInterface() const { return m_playlistInterface; } bool -WelcomeWidget::jumpToCurrentTrack() +Dashboard::jumpToCurrentTrack() { if ( ui->tracksView->jumpToCurrentTrack() ) return true; @@ -135,7 +186,7 @@ WelcomeWidget::jumpToCurrentTrack() bool -WelcomeWidget::isBeingPlayed() const +Dashboard::isBeingPlayed() const { if ( ui->additionsView->isBeingPlayed() ) return true; @@ -145,7 +196,7 @@ WelcomeWidget::isBeingPlayed() const void -WelcomeWidget::onSourcesReady() +Dashboard::onSourcesReady() { foreach ( const source_ptr& source, SourceList::instance()->sources() ) onSourceAdded( source ); @@ -153,21 +204,21 @@ WelcomeWidget::onSourcesReady() void -WelcomeWidget::onSourceAdded( const Tomahawk::source_ptr& source ) +Dashboard::onSourceAdded( const Tomahawk::source_ptr& source ) { connect( source->dbCollection().data(), SIGNAL( changed() ), SLOT( updateRecentAdditions() ), Qt::UniqueConnection ); } void -WelcomeWidget::updateRecentAdditions() +Dashboard::updateRecentAdditions() { m_recentAlbumsModel->addFilteredCollection( collection_ptr(), 20, DatabaseCommand_AllAlbums::ModificationTime, true ); } void -WelcomeWidget::updatePlaylists() +Dashboard::updatePlaylists() { int num = ui->playlistWidget->model()->rowCount( QModelIndex() ); if ( num == 0 ) @@ -181,7 +232,7 @@ WelcomeWidget::updatePlaylists() void -WelcomeWidget::onPlaylistActivated( const QModelIndex& item ) +Dashboard::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 >() ) @@ -192,7 +243,7 @@ WelcomeWidget::onPlaylistActivated( const QModelIndex& item ) void -WelcomeWidget::changeEvent( QEvent* e ) +Dashboard::changeEvent( QEvent* e ) { QWidget::changeEvent( e ); switch ( e->type() ) diff --git a/src/libtomahawk/widgets/WelcomeWidget.h b/src/libtomahawk/widgets/Dashboard.h similarity index 88% rename from src/libtomahawk/widgets/WelcomeWidget.h rename to src/libtomahawk/widgets/Dashboard.h index 7e1e19b71..3083b6f1a 100644 --- a/src/libtomahawk/widgets/WelcomeWidget.h +++ b/src/libtomahawk/widgets/Dashboard.h @@ -17,8 +17,8 @@ * along with Tomahawk. If not, see . */ -#ifndef WELCOMEWIDGET_H -#define WELCOMEWIDGET_H +#ifndef DASHBOARD_H +#define DASHBOARD_H #include #include @@ -37,11 +37,10 @@ class AlbumModel; class RecentlyPlayedModel; class OverlayWidget; -class WelcomeWidgetInterface; namespace Ui { - class WelcomeWidget; + class Dashboard; } class DLLEXPORT PlaylistDelegate : public QStyledItemDelegate @@ -78,13 +77,13 @@ private: }; -class DLLEXPORT WelcomeWidget : public QWidget, public Tomahawk::ViewPage +class DLLEXPORT Dashboard : public QWidget, public Tomahawk::ViewPage { Q_OBJECT public: - WelcomeWidget( QWidget* parent = 0 ); - virtual ~WelcomeWidget(); + Dashboard( QWidget* parent = 0 ); + virtual ~Dashboard(); virtual QWidget* widget() { return this; } virtual Tomahawk::playlistinterface_ptr playlistInterface() const; @@ -115,13 +114,11 @@ private slots: void onPlaylistActivated( const QModelIndex& ); private: - Ui::WelcomeWidget *ui; + Ui::Dashboard *ui; RecentlyPlayedModel* m_tracksModel; AlbumModel* m_recentAlbumsModel; Tomahawk::playlistinterface_ptr m_playlistInterface; - - friend class ::WelcomeWidgetInterface; }; -#endif // WELCOMEWIDGET_H +#endif // DASHBOARD_H diff --git a/src/libtomahawk/widgets/Dashboard.ui b/src/libtomahawk/widgets/Dashboard.ui new file mode 100644 index 000000000..cebdebd93 --- /dev/null +++ b/src/libtomahawk/widgets/Dashboard.ui @@ -0,0 +1,230 @@ + + + Dashboard + + + + 0 + 0 + 965 + 1179 + + + + Form + + + + 16 + + + 12 + + + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 8 + + + 4 + + + 8 + + + 8 + + + + + + 18 + 75 + true + + + + Recently Played Tracks + + + 0 + + + + + + + + 0 + 0 + + + + true + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 8 + + + 4 + + + 8 + + + 4 + + + + + + Arial + 18 + 75 + true + + + + Recent Additions + + + 0 + + + + + + + + 0 + 0 + + + + + 0 + 190 + + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 8 + + + 4 + + + 8 + + + 4 + + + + + + Arial + 18 + 75 + true + + + + Newest Stations & Playlists + + + 0 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + GridView + QListView +
playlist/GridView.h
+
+ + PlaylistView + QTreeView +
playlist/PlaylistView.h
+
+ + PlaylistWidget + QListWidget +
widgets/Dashboard.h
+
+
+ + +
diff --git a/src/libtomahawk/widgets/WelcomeWidget.ui b/src/libtomahawk/widgets/WelcomeWidget.ui deleted file mode 100644 index f420a1a96..000000000 --- a/src/libtomahawk/widgets/WelcomeWidget.ui +++ /dev/null @@ -1,107 +0,0 @@ - - - WelcomeWidget - - - - 0 - 0 - 875 - 513 - - - - - - - Qt::Horizontal - - - 1 - - - - Qt::Vertical - - - 1 - - - - - - - Recent Additions - - - - - - - true - - - QAbstractItemView::ExtendedSelection - - - - - - - - - - - Newest Stations & Playlists - - - - - - - - - - - - - - - Recently Played Tracks - - - - - - - - - - - - - - - HeaderLabel - QLabel -
widgets/HeaderLabel.h
-
- - GridView - QListView -
playlist/GridView.h
-
- - PlaylistView - QTreeView -
playlist/PlaylistView.h
-
- - PlaylistWidget - QListWidget -
widgets/WelcomeWidget.h
-
-
- - -