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