Added D-Bus support
[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
35 namespace Ui {
36     class PlayerForm;
37 }
38
39 using SomePlayer::DataObjects::Library;
40 using SomePlayer::DataObjects::Playlist;
41 using SomePlayer::DataObjects::Track;
42 using SomePlayer::Playback::Player;
43 using SomePlayer::Playback::PlayerState;
44 using SomePlayer::DataObjects::TagResolver;
45
46 class PlayerForm : public QWidget
47 {
48     Q_OBJECT
49
50 public:
51         explicit PlayerForm(Library *lib, QWidget *parent = 0);
52         ~PlayerForm();
53         bool isEqualizerEnabled() { return _player->equalizerEnabled(); }
54         bool isEqualizerAvailable() { return _player->equalizerAvailable(); }
55
56 signals:
57         void library();
58         void showSearchPanel();
59         void hideSearchPanel();
60
61 public slots:
62         void reload(bool);
63         void search(QString &);
64         void nextItem();
65         void prevItem();
66         void cancelSearch();
67         void addFiles(QList<QString> files);
68         void stop();
69         void setEqualizerValue(int band, double value) { _player->setEqualizerValue(band, value); }
70         void equalizerValue(int band, double *value) { _player->equalizerValue(band, value); }
71         void enableEqualizer() { _player->enableEqualizer(); }
72         void disableEqualizer() { _player->disableEqualizer(); }
73         void updateIcons();
74         void portraitMode();
75         void landscapeMode();
76
77 private slots:
78         void _library();
79         void _toggle_view();
80         void _process_click(QModelIndex);
81         void _track_changed(Track);
82         void _tick(int, int);
83         void _slider_released();
84         void _custom_context_venu_requested ( const QPoint & pos );
85         void _delete_track();
86         void _enqueue_track();
87         void _add_to_favorites();
88         void _add_to_playlists();
89         void _edit_tags();
90         void _state_changed(PlayerState);
91         void _toggle_repeat();
92         void _toggle_random();
93         void _toggle_volume();
94         void _track_decoded(Track);
95         void _volume_changed();
96
97 private:
98     Ui::PlayerForm *ui;
99         Library *_lib;
100         Playlist _current_playlist;
101         QTime *_time;
102         QStandardItemModel *_model;
103         Player *_player;
104         QSlider *_seek_slider;
105         QMenu *_context_menu;
106         QString _search_pattern;
107
108         TrackRenderer *_track_renderer;
109         TagResolver *_tag_resolver;
110         void _display_track(Track);
111         int _search_current_id;
112
113         QString _icons_theme;
114         DBusAdaptop *_dbusadaptor;
115 };
116
117 #endif // PLAYERFORM_H