| 1 | /* |
| 2 | Copyright (C) 2005-2014 Mario Stephan <[email protected]> |
| 3 | |
| 4 | This library is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU Lesser General Public License as published |
| 6 | by the Free Software Foundation; either version 2.1 of the License, or |
| 7 | (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public License |
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #ifndef PLAYERWIDGET_H |
| 19 | #define PLAYERWIDGET_H |
| 20 | |
| 21 | #include <QLabel> |
| 22 | #include <QStyle> |
| 23 | #include <QToolButton> |
| 24 | #include <QVBoxLayout> |
| 25 | #include <QWidget> |
| 26 | #include <QtCore/QTimer> |
| 27 | |
| 28 | #include "player.h" |
| 29 | #include "vumeter.h" |
| 30 | |
| 31 | #include "playlistitem.h" |
| 32 | #include "trackanalyser.h" |
| 33 | |
| 34 | namespace Ui { |
| 35 | class PlayerWidget; |
| 36 | } |
| 37 | |
| 38 | class PlayerWidget : public QWidget { |
| 39 | Q_OBJECT |
| 40 | public: |
| 41 | explicit PlayerWidget(QWidget* parent = 0); |
| 42 | ~PlayerWidget(); |
| 43 | |
| 44 | enum EqBand { EQ_Low = 0, |
| 45 | EQ_Mid = 1, |
| 46 | EQ_High = 2 |
| 47 | }; |
| 48 | |
| 49 | float currentLevelLeft(); |
| 50 | float currentLevelRight(); |
| 51 | void loadFile(QUrl); |
| 52 | |
| 53 | void play(); |
| 54 | void stop(); |
| 55 | void pause(); |
| 56 | bool isStarted() { return m_isStarted; } |
| 57 | |
| 58 | void setTrackFinishEmitTime(const int sec); |
| 59 | int TrackFinishEmitTime() { return mTrackFinishEmitTime; } |
| 60 | void setVolume(double volume); |
| 61 | void setGain(double gain); |
| 62 | void setSkipSilentEnd(bool checked) |
| 63 | { |
| 64 | m_skipSilentEnd = checked; |
| 65 | setPositionMarkers(); |
| 66 | } |
| 67 | void setSkipSilentBegin(bool checked) |
| 68 | { |
| 69 | m_skipSilentBegin = checked; |
| 70 | setPositionMarkers(); |
| 71 | } |
| 72 | |
| 73 | public Q_SLOTS: |
| 74 | void loadTrack(Track*); |
| 75 | void analyseGainFinished(); |
| 76 | void setEqualizer(EqBand, int); |
| 77 | void setInfo(QPair<int, int> info); |
| 78 | |
| 79 | Q_SIGNALS: |
| 80 | void trackFinished(); |
| 81 | void aboutFinished(); |
| 82 | void trackDropped(Track*); |
| 83 | void trackPlayed(Track*); |
| 84 | void forwardPressed(); |
| 85 | void rewindPressed(); |
| 86 | void statusChanged(bool); |
| 87 | void gainChanged(double); |
| 88 | void levelChanged(double, double); |
| 89 | |
| 90 | private Q_SLOTS: |
| 91 | |
| 92 | void on_butCue_clicked(); |
| 93 | void on_sliPosition_actionTriggered(int action); |
| 94 | void updateTimeAndPositionDisplay(bool isPassive = true); |
| 95 | void playerFinished(); |
| 96 | void playerError(); |
| 97 | void playerLoaded(); |
| 98 | void timerLevel_timeOut(); |
| 99 | void timerPosition_timeOut(); |
| 100 | void on_sliPosition_sliderMoved(int); |
| 101 | |
| 102 | void on_butPlay_clicked(); |
| 103 | void on_butRew_clicked(); |
| 104 | void on_butFwd_clicked(); |
| 105 | |
| 106 | protected: |
| 107 | VUMeter* vuMeter; |
| 108 | |
| 109 | long songTime; |
| 110 | |
| 111 | private: |
| 112 | //ToDo: move privates to struct Private |
| 113 | Ui::PlayerWidget* ui; |
| 114 | QToolButton* initButton(QStyle::StandardPixmap icon, const QString& tip, |
| 115 | QObject* dstobj, const char* slot_method, QLayout* layout); |
| 116 | |
| 117 | void createUI(QBoxLayout* appLayout); |
| 118 | void resizeEvent(QResizeEvent* e); |
| 119 | void drawTitle(); |
| 120 | |
| 121 | Player* player; |
| 122 | TrackAnalyser* trackanalyser; |
| 123 | float m_level; |
| 124 | QLabel* m_positionLabel; |
| 125 | QLabel* m_volumeLabel; |
| 126 | |
| 127 | QTimer* timerLevel; |
| 128 | QTimer* timerPosition; |
| 129 | void dropEvent(QDropEvent*); |
| 130 | void dragEnterEvent(QDragEnterEvent*); |
| 131 | void dragMoveEvent(QDragMoveEvent*); |
| 132 | void setPositionMarkers(); |
| 133 | int mTrackFinishEmitTime; |
| 134 | Track* m_CurrentTrack; |
| 135 | long remainCueTime; |
| 136 | bool m_isStarted; |
| 137 | bool m_isHanging; |
| 138 | bool m_skipSilentEnd; |
| 139 | bool m_skipSilentBegin; |
| 140 | |
| 141 | struct PlayerWidgetPrivate* p; |
| 142 | }; |
| 143 | |
| 144 | #endif // PLAYERWIDGET_H |