PageRenderTime 19ms CodeModel.GetById 8ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/src/libtomahawk/widgets/welcomewidget.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 134 lines | 81 code | 35 blank | 18 comment | 0 complexity | a744dc390555c7ebedc0bcee1790d612 MD5 | raw file
  1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2 *
  3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4 *   Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
  5 *
  6 *   Tomahawk is free software: you can redistribute it and/or modify
  7 *   it under the terms of the GNU General Public License as published by
  8 *   the Free Software Foundation, either version 3 of the License, or
  9 *   (at your option) any later version.
 10 *
 11 *   Tomahawk is distributed in the hope that it will be useful,
 12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 14 *   GNU General Public License for more details.
 15 *
 16 *   You should have received a copy of the GNU General Public License
 17 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
 18 */
 19
 20#ifndef WELCOMEWIDGET_H
 21#define WELCOMEWIDGET_H
 22
 23#include <QWidget>
 24#include <QListWidgetItem>
 25#include <QStyledItemDelegate>
 26
 27#include "PlaylistInterface.h"
 28
 29#include "Query.h"
 30#include "Source.h"
 31#include "ViewPage.h"
 32
 33#include "utils/TomahawkUtilsGui.h"
 34
 35#include "DllMacro.h"
 36
 37class AlbumModel;
 38class RecentlyPlayedModel;
 39class OverlayWidget;
 40class WelcomeWidgetInterface;
 41
 42namespace Ui
 43{
 44    class WelcomeWidget;
 45}
 46
 47class DLLEXPORT PlaylistDelegate : public QStyledItemDelegate
 48{
 49Q_OBJECT
 50
 51public:
 52    PlaylistDelegate()
 53    {
 54        m_playlistIcon = QPixmap( RESPATH "images/playlist-icon.png" );
 55        m_autoIcon = QPixmap( RESPATH "images/automatic-playlist.png" );
 56        m_stationIcon = QPixmap( RESPATH "images/station.png" );
 57        m_defaultAvatar = TomahawkUtils::createRoundedImage( QPixmap( RESPATH "images/user-avatar.png" ), QSize( 0, 0 ) );
 58    }
 59
 60protected:
 61    void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
 62    QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
 63
 64private:
 65    QPixmap m_playlistIcon, m_autoIcon, m_stationIcon, m_defaultAvatar;
 66};
 67
 68
 69class DLLEXPORT PlaylistWidget : public QListView
 70{
 71Q_OBJECT
 72
 73public:
 74    PlaylistWidget( QWidget* parent = 0 );
 75
 76    OverlayWidget* overlay() const { return m_overlay; }
 77
 78    virtual void setModel( QAbstractItemModel* model );
 79
 80signals:
 81    void modelChanged();
 82
 83private:
 84    OverlayWidget* m_overlay;
 85};
 86
 87
 88class DLLEXPORT WelcomeWidget : public QWidget, public Tomahawk::ViewPage
 89{
 90Q_OBJECT
 91
 92public:
 93    WelcomeWidget( QWidget* parent = 0 );
 94    virtual ~WelcomeWidget();
 95
 96    virtual QWidget* widget() { return this; }
 97    virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
 98
 99    virtual QString title() const { return tr( "Welcome to Tomahawk" ); }
100    virtual QString description() const { return QString(); }
101
102    virtual bool showInfoBar() const { return false; }
103    virtual bool isBeingPlayed() const;
104
105    virtual bool jumpToCurrentTrack();
106
107protected:
108    void changeEvent( QEvent* e );
109
110signals:
111    void destroyed( QWidget* widget );
112
113public slots:
114    void updatePlaylists();
115    void updateRecentAdditions();
116
117    void loadData();
118
119private slots:
120    void onSourcesReady();
121    void onSourceAdded( const Tomahawk::source_ptr& source );
122    void onPlaylistActivated( const QModelIndex& );
123
124private:
125    Ui::WelcomeWidget *ui;
126
127    RecentlyPlayedModel* m_tracksModel;
128    AlbumModel* m_recentAlbumsModel;
129    Tomahawk::playlistinterface_ptr m_playlistInterface;
130
131    friend class ::WelcomeWidgetInterface;
132};
133
134#endif // WELCOMEWIDGET_H