summaryrefslogtreecommitdiffstats
path: root/playerwidget.h
blob: 5f9210c34c69fb0094d0c3bdef2373c4a0c9c70f (plain)
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
#ifndef PLAYERWIDGET_H
#define PLAYERWIDGET_H

#include <QWidget>
#include <QMediaPlayer>

class QStandardItemModel;
class QStandardItem;
class QLineEdit;
class QLabel;
class QSlider;
class QTextEdit;
class QMediaPlayer;
class QToolBar;
class QAction;
class BeetPlayerProxy;
class BeetView;

class PlayerWidget : public QWidget {
    Q_OBJECT
    public:
        enum ItemType { Artist, Album, Song, Genre };
        enum PopulateType { FilterType, IdType, EmptyType };
        enum CustomRoles { TypeRole = Qt::UserRole + 1, IdRole = Qt::UserRole + 2, FullPathRole = Qt::UserRole + 3, GenreRole = Qt::UserRole + 4, ArtistRole = Qt::UserRole + 5, TitleRole = Qt::UserRole + 6, AlbumRole = Qt::UserRole + 7 };
        explicit PlayerWidget(QWidget *parent = 0);

    public slots:
        void doPopulateByArtist();
        void doPopulateByAlbum();
        void doPopulateByGenre();
        void doPopulateBySong();
        void doFilter();
        void clearFilter();
        void reindex();
        void addToPlayList();
        void addToPlayListAndClear();
        void removeFromPlayList();
        void clearPlayList();
        void shufflePlayList();
        void randomPlay();
        void playCurrent(const QModelIndex &index);
        void mute(bool triggered);
        void volumeChanged(int volume);
        void next();
        void previous();
        void setPosition(qint64 pos);
        void setDuration(qint64 dur);
        void slide(int value);
        void continuePlaying(QMediaPlayer::State state);
        void expand();

    private:
        void setupGui();
        void createActions();
        void populateByArtist(QStandardItem *parent, const QString &filter);
        void populateByAlbum(QStandardItem *parent, const QVariant &filter, int type);
        void populateBySong(QStandardItem *parent, const QVariant &filter, int type);
        void populateByGenre(QStandardItem *parent, const QString &filter);
        void recurse(const QModelIndex &parent);
        void addSong(const QModelIndex &idx);
        void play(const QString &fullPath);
        void advance(int numSongs);
        void expandRecursive(const QModelIndex &idx);
        QLineEdit *mSearch;
        QMediaPlayer *mPlayer;
        BeetView *mView;
        QStandardItemModel *mViewModel;
        QStandardItemModel *mSearchModel;
        QStandardItemModel *currentModel;
        QLabel *mNowPlayingL;
        QSlider *mSongSlider;
        QLabel *mPos;
        QSlider *mVolumeSlider;
        QLabel *mVolumePos;
        QTextEdit *mCurrentTE;
        BeetView *mPlayListView;
        QStandardItemModel *mPlayListModel;
        QToolBar *mToolBar;
        QAction *mPlayA;
        QAction *mStopA;
        qint64 mDurSecs;
};

#endif // PLAYERWIDGET_H