1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
3 | umplayer, Copyright (C) 2010 Ori Rejwan
|
---|
4 |
|
---|
5 | This program is free software; you can redistribute it and/or modify
|
---|
6 | it under the terms of the GNU General Public License as published by
|
---|
7 | the Free Software Foundation; either version 2 of the License, or
|
---|
8 | (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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
18 | */
|
---|
19 |
|
---|
20 | #ifndef PANELSEEKER_H
|
---|
21 | #define PANELSEEKER_H
|
---|
22 |
|
---|
23 | #include <QAbstractSlider>
|
---|
24 | #include <QPixmap>
|
---|
25 | #include <QTimer>
|
---|
26 | #include "mybutton.h"
|
---|
27 |
|
---|
28 | class PanelSeeker : public QAbstractSlider
|
---|
29 | {
|
---|
30 | Q_OBJECT
|
---|
31 |
|
---|
32 | Q_PROPERTY( QPixmap left READ leftIcon WRITE setLeftIcon)
|
---|
33 | Q_PROPERTY( QPixmap center READ centerIcon WRITE setCenterIcon)
|
---|
34 | Q_PROPERTY( QPixmap right READ rightIcon WRITE setRightIcon)
|
---|
35 | Q_PROPERTY( QPixmap progress READ progressIcon WRITE setProgressIcon )
|
---|
36 | Q_PROPERTY( QPixmap buffering READ bufferingIcon WRITE setBufferingIcon)
|
---|
37 | Q_PROPERTY( QPixmap knob READ knobIcon WRITE setKnobIcon )
|
---|
38 |
|
---|
39 | public:
|
---|
40 |
|
---|
41 | enum State
|
---|
42 | {
|
---|
43 | Normal = 2,
|
---|
44 | Hovered = 4,
|
---|
45 | Pressed = 8,
|
---|
46 | Disabled =16,
|
---|
47 | Stopped = 32,
|
---|
48 | Buffering = 64
|
---|
49 | };
|
---|
50 | Q_DECLARE_FLAGS(States, State)
|
---|
51 | explicit PanelSeeker(QWidget *parent = 0);
|
---|
52 | QPixmap leftIcon() { return leftPix; }
|
---|
53 | QPixmap centerIcon() { return centerPix; }
|
---|
54 | QPixmap rightIcon() { return rightPix; }
|
---|
55 | QPixmap progressIcon() { return progressPix; }
|
---|
56 | QPixmap bufferingIcon() { return bufferingPix; }
|
---|
57 | QPixmap knobIcon() { return knobPix.pixmap(MyIcon::Normal, MyIcon::Off); }
|
---|
58 | States states() { return state; }
|
---|
59 |
|
---|
60 | void setLeftIcon( QPixmap pix) { leftPix = pix; }
|
---|
61 | void setCenterIcon( QPixmap pix) { centerPix = pix; }
|
---|
62 | void setRightIcon( QPixmap pix) { rightPix = pix; }
|
---|
63 | void setProgressIcon ( QPixmap pix) { progressPix = pix; }
|
---|
64 | void setBufferingIcon( QPixmap pix) { bufferingPix = pix; }
|
---|
65 | void setKnobIcon( QPixmap pix );
|
---|
66 | /* void setSingleKnobIcon(QPixmap pix); */
|
---|
67 | void setState(State st, bool on = true);
|
---|
68 | void setLeftRightMargin( int margin) { leftRightMargin = margin; }
|
---|
69 | void setDelayPeriod(int period) { delayPeriod = period; }
|
---|
70 | void setFrozenPeriod(int period) { frozenPeriod = period; }
|
---|
71 | qreal valueForPos(int pos);
|
---|
72 |
|
---|
73 |
|
---|
74 |
|
---|
75 | private:
|
---|
76 | QPixmap leftPix;
|
---|
77 | QPixmap centerPix;
|
---|
78 | QPixmap rightPix;
|
---|
79 | QPixmap progressPix;
|
---|
80 | QPixmap bufferingPix;
|
---|
81 | MyIcon knobPix;
|
---|
82 | QRectF knobRect;
|
---|
83 | bool isPressed;
|
---|
84 | int leftRightMargin;
|
---|
85 | QPointF mousePressPos;
|
---|
86 | qreal mousePressDifference;
|
---|
87 | States state;
|
---|
88 | qreal bufferingPixShift;
|
---|
89 | QPixmap knobCurrentPix;
|
---|
90 | // freeze the knob after seeking through mouse for frozenPeriod
|
---|
91 | // so that knob is not reset by the signal from timeslider action.
|
---|
92 | bool frozen;
|
---|
93 | QTimer* freezeTimer;
|
---|
94 | // we dont seek the movie immediately, so that mutliple
|
---|
95 | // consecutive changes are clustered in one seek signal
|
---|
96 | QTimer* dragDelayTimer;
|
---|
97 | int delayPeriod;
|
---|
98 | int frozenPeriod;
|
---|
99 |
|
---|
100 |
|
---|
101 | void resetKnob( bool start = true);
|
---|
102 | void knobAdjust(qreal x, bool setValue = false);
|
---|
103 |
|
---|
104 |
|
---|
105 |
|
---|
106 |
|
---|
107 | signals:
|
---|
108 |
|
---|
109 | public slots:
|
---|
110 | void moved( int value);
|
---|
111 | void setSliderValue(int value);
|
---|
112 | void stopFreeze();
|
---|
113 | void goToSliderPosition();
|
---|
114 |
|
---|
115 |
|
---|
116 | protected:
|
---|
117 | void paintEvent(QPaintEvent * e);
|
---|
118 | void mousePressEvent(QMouseEvent * m);
|
---|
119 | void mouseMoveEvent(QMouseEvent * m);
|
---|
120 | void mouseReleaseEvent(QMouseEvent * m);
|
---|
121 | void resizeEvent(QResizeEvent *);
|
---|
122 | bool event(QEvent *e);
|
---|
123 | void changeEvent(QEvent *e);
|
---|
124 | void timerEvent(QTimerEvent * t);
|
---|
125 | void wheelEvent(QWheelEvent *e);
|
---|
126 |
|
---|
127 |
|
---|
128 | };
|
---|
129 | Q_DECLARE_OPERATORS_FOR_FLAGS(PanelSeeker::States)
|
---|
130 |
|
---|
131 | #endif // PANELSEEKER_H
|
---|