1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 15:59:42 +01:00

* Renamed and pagified Dashboard.

This commit is contained in:
Christian Muehlhaeuser 2013-06-08 06:06:19 +02:00
parent bc72050fb0
commit ae1d641903
5 changed files with 323 additions and 152 deletions

View File

@ -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

View File

@ -18,8 +18,8 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#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 <QPainter>
#include <QScrollArea>
#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() )

View File

@ -17,8 +17,8 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WELCOMEWIDGET_H
#define WELCOMEWIDGET_H
#ifndef DASHBOARD_H
#define DASHBOARD_H
#include <QWidget>
#include <QListWidgetItem>
@ -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

View File

@ -0,0 +1,230 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dashboard</class>
<widget class="QWidget" name="Dashboard">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>965</width>
<height>1179</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true" extracomment="not translatable because not shown to the user">Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1">
<property name="spacing">
<number>16</number>
</property>
<property name="margin">
<number>12</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<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>8</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</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>18</pointsize>
<weight>75</weight>
<bold>true</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>
<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="label_3">
<property name="font">
<font>
<family>Arial</family>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Newest Stations &amp; Playlists</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="PlaylistWidget" name="playlistWidget"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GridView</class>
<extends>QListView</extends>
<header location="global">playlist/GridView.h</header>
</customwidget>
<customwidget>
<class>PlaylistView</class>
<extends>QTreeView</extends>
<header>playlist/PlaylistView.h</header>
</customwidget>
<customwidget>
<class>PlaylistWidget</class>
<extends>QListWidget</extends>
<header>widgets/Dashboard.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,107 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WelcomeWidget</class>
<widget class="QWidget" name="WelcomeWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>875</width>
<height>513</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QSplitter" name="splitter_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="handleWidth">
<number>1</number>
</property>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="handleWidth">
<number>1</number>
</property>
<widget class="QWidget" name="layoutWidget1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="HeaderLabel" name="label_4">
<property name="text">
<string>Recent Additions</string>
</property>
</widget>
</item>
<item>
<widget class="GridView" name="additionsView">
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="HeaderLabel" name="label_2">
<property name="text">
<string>Newest Stations &amp; Playlists</string>
</property>
</widget>
</item>
<item>
<widget class="PlaylistWidget" name="playlistWidget"/>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="HeaderLabel" name="label_3">
<property name="text">
<string>Recently Played Tracks</string>
</property>
</widget>
</item>
<item>
<widget class="PlaylistView" name="tracksView"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HeaderLabel</class>
<extends>QLabel</extends>
<header location="global">widgets/HeaderLabel.h</header>
</customwidget>
<customwidget>
<class>GridView</class>
<extends>QListView</extends>
<header>playlist/GridView.h</header>
</customwidget>
<customwidget>
<class>PlaylistView</class>
<extends>QTreeView</extends>
<header>playlist/PlaylistView.h</header>
</customwidget>
<customwidget>
<class>PlaylistWidget</class>
<extends>QListWidget</extends>
<header>widgets/WelcomeWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>