source: smplayer/vendor/current/src/widgetactions.cpp@ 177

Last change on this file since 177 was 175, checked in by Silvan Scherrer, 10 years ago

smplayer: update vendor to version 16.4

File size: 6.4 KB
RevLine 
[90]1/* smplayer, GUI front-end for mplayer.
[175]2 Copyright (C) 2006-2016 Ricardo Villalba <[email protected]>
[90]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#include "widgetactions.h"
20#include "colorutils.h"
21#include <QLabel>
[175]22#include <QDebug>
[90]23
24#if MINI_ARROW_BUTTONS
25#include <QToolButton>
26#endif
27
28MyWidgetAction::MyWidgetAction( QWidget * parent )
29 : QWidgetAction(parent)
30{
31 custom_style = 0;
32 custom_stylesheet = "";
33}
34
35MyWidgetAction::~MyWidgetAction() {
36}
37
38void MyWidgetAction::enable() {
39 propagate_enabled(true);
40}
41
42void MyWidgetAction::disable() {
43 propagate_enabled(false);
44}
45
46void MyWidgetAction::propagate_enabled(bool b) {
47 QList<QWidget *> l = createdWidgets();
48 for (int n=0; n < l.count(); n++) {
49 TimeSlider *s = (TimeSlider*) l[n];
50 s->setEnabled(b);;
51 }
52 setEnabled(b);
53}
54
55
56TimeSliderAction::TimeSliderAction( QWidget * parent )
57 : MyWidgetAction(parent)
58{
59#if ENABLE_DELAYED_DRAGGING
60 drag_delay = 200;
61#endif
62}
63
64TimeSliderAction::~TimeSliderAction() {
65}
66
67void TimeSliderAction::setPos(int v) {
68 QList<QWidget *> l = createdWidgets();
69 for (int n=0; n < l.count(); n++) {
70 TimeSlider *s = (TimeSlider*) l[n];
71 bool was_blocked= s->blockSignals(true);
72 s->setPos(v);
73 s->blockSignals(was_blocked);
74 }
75}
76
77int TimeSliderAction::pos() {
78 QList<QWidget *> l = createdWidgets();
79 if (l.count() >= 1) {
80 TimeSlider *s = (TimeSlider*) l[0];
81 return s->pos();
82 } else {
83 return -1;
84 }
85}
86
[175]87void TimeSliderAction::setDuration(double t) {
88 qDebug() << "TimeSliderAction::setDuration:" << t;
89 total_time = t;
90 QList<QWidget *> l = createdWidgets();
91 for (int n=0; n < l.count(); n++) {
92 TimeSlider *s = (TimeSlider*) l[n];
93 s->setDuration(t);
94 }
95}
96
[90]97#if ENABLE_DELAYED_DRAGGING
98void TimeSliderAction::setDragDelay(int d) {
99 drag_delay = d;
100
101 QList<QWidget *> l = createdWidgets();
102 for (int n=0; n < l.count(); n++) {
103 TimeSlider *s = (TimeSlider*) l[n];
104 s->setDragDelay(drag_delay);
105 }
106}
107
108int TimeSliderAction::dragDelay() {
109 return drag_delay;
110}
111#endif
112
113QWidget * TimeSliderAction::createWidget ( QWidget * parent ) {
114 TimeSlider *t = new TimeSlider(parent);
115 t->setEnabled( isEnabled() );
116
117 if (custom_style) t->setStyle(custom_style);
118 if (!custom_stylesheet.isEmpty()) t->setStyleSheet(custom_stylesheet);
119
120 connect( t, SIGNAL(posChanged(int)),
121 this, SIGNAL(posChanged(int)) );
122 connect( t, SIGNAL(draggingPos(int)),
123 this, SIGNAL(draggingPos(int)) );
124#if ENABLE_DELAYED_DRAGGING
125 t->setDragDelay(drag_delay);
126