1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2 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 General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef WIDGETACTIONS_H
|
---|
20 | #define WIDGETACTIONS_H
|
---|
21 |
|
---|
22 | #include <QWidgetAction>
|
---|
23 | #include "timeslider.h"
|
---|
24 | #include "config.h"
|
---|
25 | #include "guiconfig.h"
|
---|
26 |
|
---|
27 | class QStyle;
|
---|
28 |
|
---|
29 | class MyWidgetAction : public QWidgetAction
|
---|
30 | {
|
---|
31 | Q_OBJECT
|
---|
32 |
|
---|
33 | public:
|
---|
34 | MyWidgetAction( QWidget * parent );
|
---|
35 | ~MyWidgetAction();
|
---|
36 |
|
---|
37 | void setCustomStyle(QStyle * style) { custom_style = style; };
|
---|
38 | QStyle * customStyle() { return custom_style; };
|
---|
39 |
|
---|
40 | void setStyleSheet(QString style) { custom_stylesheet = style; };
|
---|
41 | QString styleSheet() { return custom_stylesheet; };
|
---|
42 |
|
---|
43 | public slots:
|
---|
44 | virtual void enable(); // setEnabled in QAction is not virtual :(
|
---|
45 | virtual void disable();
|
---|
46 |
|
---|
47 | protected:
|
---|
48 | virtual void propagate_enabled(bool);
|
---|
49 |
|
---|
50 | protected:
|
---|
51 | QStyle * custom_style;
|
---|
52 | QString custom_stylesheet;
|
---|
53 | };
|
---|
54 |
|
---|
55 |
|
---|
56 | class TimeSliderAction : public MyWidgetAction
|
---|
57 | {
|
---|
58 | Q_OBJECT
|
---|
59 |
|
---|
60 | public:
|
---|
61 | TimeSliderAction( QWidget * parent );
|
---|
62 | ~TimeSliderAction();
|
---|
63 |
|
---|
64 | public slots:
|
---|
65 | virtual void setPos(int);
|
---|
66 | virtual int pos();
|
---|
67 | virtual void setDuration(double);
|
---|
68 | virtual double duration() { return total_time; };
|
---|
69 | #if ENABLE_DELAYED_DRAGGING
|
---|
70 | void setDragDelay(int);
|
---|
71 | int dragDelay();
|
---|
72 |
|
---|
73 | private:
|
---|
74 | int drag_delay;
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | private:
|
---|
78 | double total_time;
|
---|
79 |
|
---|
80 | signals:
|
---|
81 | void posChanged(int value);
|
---|
82 | void draggingPos(int value);
|
---|
83 | #if ENABLE_DELAYED_DRAGGING
|
---|
84 | void delayedDraggingPos(int);
|
---|
85 | #endif
|
---|
86 | void wheelUp();
|
---|
87 | void wheelDown();
|
---|
88 |
|
---|
89 | protected:
|
---|
90 | virtual QWidget * createWidget ( QWidget * parent );
|
---|
91 | };
|
---|
92 |
|
---|
93 |
|
---|
94 | class VolumeSliderAction : public MyWidgetAction
|
---|
95 | {
|
---|
96 | Q_OBJECT
|
---|
97 |
|
---|
98 | public:
|
---|
99 | VolumeSliderAction( QWidget * parent );
|
---|
100 | ~VolumeSliderAction();
|
---|
101 |
|
---|
102 | void setFixedSize(QSize size) { fixed_size = size; };
|
---|
103 | QSize fixedSize() { return fixed_size; };
|
---|
104 |
|
---|
105 | void setTickPosition(QSlider::TickPosition position);
|
---|
106 | QSlider::TickPosition tickPosition() { return tick_position; };
|
---|
107 |
|
---|
108 | public slots:
|
---|
109 | virtual void setValue(int);
|
---|
110 | virtual int value();
|
---|
111 |
|
---|
112 | signals:
|
---|
113 | void valueChanged(int value);
|
---|
114 |
|
---|
115 | protected:
|
---|
116 | virtual QWidget * createWidget ( QWidget * parent );
|
---|
117 |
|
---|
118 | private:
|
---|
119 | QSize fixed_size;
|
---|
120 | QSlider::TickPosition tick_position;
|
---|
121 | };
|
---|
122 |
|
---|
123 |
|
---|
124 | class TimeLabelAction : public MyWidgetAction
|
---|
125 | {
|
---|
126 | Q_OBJECT
|
---|
127 |
|
---|
128 | public:
|
---|
129 | enum TimeLabelType { CurrentTime = 0, TotalTime = 1, CurrentAndTotalTime = 2, RemainingTime = 3 };
|
---|
130 |
|
---|
131 | TimeLabelAction(TimeLabelType type, QWidget * parent );
|
---|
132 | ~TimeLabelAction();
|
---|
133 |
|
---|
134 | virtual QString text() { return current_text; };
|
---|
135 |
|
---|
136 | public slots:
|
---|
137 | virtual void setText(QString s);
|
---|
138 | virtual void setCurrentTime(double);
|
---|
139 | virtual void setTotalTime(double);
|
---|
140 |
|
---|
141 | signals:
|
---|
142 | void newText(QString s);
|
---|
143 |
|
---|
144 | protected:
|
---|
145 | virtual QWidget * createWidget ( QWidget * parent );
|
---|
146 | virtual void updateText();
|
---|
147 |
|
---|
148 | private:
|
---|
149 | QString current_text;
|
---|
150 | double current_time, total_time;
|
---|
151 | TimeLabelType label_type;
|
---|
152 | };
|
---|
153 |
|
---|
154 |
|
---|
155 | #if MINI_ARROW_BUTTONS
|
---|
156 | class SeekingButton : public QWidgetAction
|
---|
157 | {
|
---|
158 | Q_OBJECT
|
---|
159 |
|
---|
160 | public:
|
---|
161 | SeekingButton( QList<QAction*> actions, QWidget * parent );
|
---|
162 | ~SeekingButton();
|
---|
163 |
|
---|
164 | protected:
|
---|
165 | virtual QWidget * createWidget ( QWidget * parent );
|
---|
166 |
|
---|
167 | QList<QAction*> _actions;
|
---|
168 | };
|
---|
169 | #endif
|
---|
170 |
|
---|
171 | #endif
|
---|
172 |
|
---|