Full implementation of library manager
[someplayer] / src / playerform.h
1 /*
2  * SomePlayer - An alternate music player for Maemo 5
3  * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef PLAYERFORM_H
21 #define PLAYERFORM_H
22
23 #include <QWidget>
24 #include "someplayer.h"
25 #include "playlist.h"
26 #include <QStandardItemModel>
27 #include "player/player.h"
28 #include <QSlider>
29 #include <QMenu>
30 #include <QTime>
31 #include "trackrenderer.h"
32 #include "tagresolver.h"
33 #include "dbusadaptor.h"
34 #include "toolswidget.h"
35
36 namespace Ui {
37     class PlayerForm;
38 }
39
40 using SomePlayer::DataObjects::Library;
41 using SomePlayer::DataObjects::Playlist;
42 using SomePlayer::DataObjects::Track;
43 using SomePlayer::Playback::Player;
44 using SomePlayer::Playback::PlayerState;
45 using SomePlayer::DataObjects::TagResolver;
46
47 class PlayerForm : public QWidget
48 {
49     Q_OBJECT
50
51 public:
52         explicit PlayerForm(Library *lib, QWidget *parent = 0);
53         ~PlayerForm();
54         bool isEqualizerEnabled() { return _player->equalizerEnabled(); }
55         bool isEqualizerAvailable() { return _player->equalizerAvailable(); }
56
57 signals:
58         void library();
59         void fullscreen(bool);
60         void clearPlaylist();
61         void refreshLibrary();
62
63 public slots:
64         void reload(bool);
65         void search(QString);
66         void nextItem();
67         void prevItem();
68         void cancelSearch();
69         void addFiles(QList<QString> files);
70         void stop();
71         void setEqualizerValue(int band, double value) { _player->setEqualizerValue(band, value); }
72         void equalizerValue(int band, double *value) { _player->equalizerValue(band, value); }
73         void enableEqualizer() { _player->enableEqualizer(); }
74         void disableEqualizer() { _player->disableEqualizer(); }
75         void portraitMode();
76         void landscapeMode();
77         void updateIcons();
78         void checkGradient();
79         void play(Track);
80
81 private slots:
82         void _library();
83         void _toggle_view();
84         void _process_click(QModelIndex);
85         void _track_changed(Track);
86         void _tick(int, int);
87         void _slider_released();
88         void _custom_context_menu_requested ( const QPoint & pos );
89         void _delete_track();
90         void _enqueue_track();
91         void _add_to_favorites();
92         void _add_to_playlists();
93         void _edit_tags();
94         void _state_changed(PlayerState);
95         void _toggle_repeat();
96         void _toggle_random();
97         void _toggle_volume();
98         void _track_decoded(Track);
99         void _volume_changed();
100         void _tools_widget_toggle();
101
102 private:
103     Ui::PlayerForm *ui;
104         Library *_lib;
105         Playlist _current_playlist;
106         QTime *_time;
107         QStandardItemModel *_model;
108         Player *_player;
109         QSlider *_seek_slider;
110         QMenu *_context_menu;
111         QString _search_pattern;
112         ToolsWidget *_tools_widget;
113         bool landscape;
114         QString _icons_theme;
115         QString _top_gradient;
116         QString _bottom_gradient;
117
118         TrackRenderer *_track_renderer;
119         TagResolver *_tag_resolver;
120         void _display_track(Track);
121         int _search_current_id;
122
123         DBusAdaptop *_dbusadaptor;
124 };
125
126 #endif // PLAYERFORM_H