~ubuntu-branches/debian/experimental/smplayer/experimental

« back to all changes in this revision

Viewing changes to src/widgetactions.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2009-01-03 17:08:06 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090103170806-eodntb2slv6g2pb6
Tags: 0.6.6-0ubuntu1
* The "just before FF" release.
* New upstream release.
* debian/control: Bumped Standards-Version to 3.8.0.
* debian/copyright: Changed (C) to © to fix Lintian warning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
*/
18
18
 
19
19
#include "widgetactions.h"
 
20
#include "colorutils.h"
 
21
#include <QLabel>
20
22
 
21
23
#if MINI_ARROW_BUTTONS
22
24
#include <QToolButton>
25
27
MyWidgetAction::MyWidgetAction( QWidget * parent )
26
28
        : QWidgetAction(parent)
27
29
{
 
30
        custom_style = 0;
 
31
        custom_stylesheet = "";
28
32
}
29
33
 
30
34
MyWidgetAction::~MyWidgetAction() {
63
67
        QList<QWidget *> l = createdWidgets();
64
68
        for (int n=0; n < l.count(); n++) {
65
69
                TimeSlider *s = (TimeSlider*) l[n];
 
70
                bool was_blocked= s->blockSignals(true);
66
71
                s->setPos(v);
 
72
                s->blockSignals(was_blocked);
67
73
        }
68
74
}
69
75
 
97
103
        TimeSlider *t = new TimeSlider(parent);
98
104
        t->setEnabled( isEnabled() );
99
105
 
 
106
        if (custom_style) t->setStyle(custom_style);
 
107
        if (!custom_stylesheet.isEmpty()) t->setStyleSheet(custom_stylesheet);
 
108
 
100
109
        connect( t,    SIGNAL(posChanged(int)), 
101
110
             this, SIGNAL(posChanged(int)) );
102
111
        connect( t,    SIGNAL(draggingPos(int)),
115
124
VolumeSliderAction::VolumeSliderAction( QWidget * parent )
116
125
        : MyWidgetAction(parent)
117
126
{
 
127
        tick_position = QSlider::TicksBelow;
118
128
}
119
129
 
120
130
VolumeSliderAction::~VolumeSliderAction() {
124
134
        QList<QWidget *> l = createdWidgets();
125
135
        for (int n=0; n < l.count(); n++) {
126
136
                MySlider *s = (MySlider*) l[n];
 
137
                bool was_blocked = s->blockSignals(true);
127
138
                s->setValue(v);
 
139
                s->blockSignals(was_blocked);
128
140
        }
129
141
}
130
142
 
138
150
        }
139
151
}
140
152
 
 
153
void VolumeSliderAction::setTickPosition(QSlider::TickPosition position) {
 
154
        // For new widgets
 
155
        tick_position = position; 
 
156
 
 
157
        // Propagate changes to all existing widgets
 
158
        QList<QWidget *> l = createdWidgets();
 
159
        for (int n=0; n < l.count(); n++) {
 
160
                MySlider *s = (MySlider*) l[n];
 
161
                s->setTickPosition(tick_position);
 
162
        }
 
163
}
 
164
 
141
165
QWidget * VolumeSliderAction::createWidget ( QWidget * parent ) {
142
166
        MySlider *t = new MySlider(parent);
 
167
 
 
168
        if (custom_style) t->setStyle(custom_style);
 
169
        if (!custom_stylesheet.isEmpty()) t->setStyleSheet(custom_stylesheet);
 
170
        if (fixed_size.isValid()) t->setFixedSize(fixed_size);
 
171
 
143
172
        t->setMinimum(0);
144
173
        t->setMaximum(100);
145
174
        t->setValue(50);
146
175
        t->setOrientation( Qt::Horizontal );
147
176
        t->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
148
177
        t->setFocusPolicy( Qt::NoFocus );
149
 
        t->setTickPosition( QSlider::TicksBelow );
 
178
        t->setTickPosition( tick_position );
150
179
        t->setTickInterval( 10 );
151
180
        t->setSingleStep( 1 );
152
181
        t->setPageStep( 10 );
153
182
        t->setToolTip( tr("Volume") );
154
183
        t->setEnabled( isEnabled() );
 
184
        t->setAttribute(Qt::WA_NoMousePropagation);
155
185
 
156
186
        connect( t,    SIGNAL(valueChanged(int)), 
157
187
             this, SIGNAL(valueChanged(int)) );
158
188
        return t;
159
189
}
160
190
 
 
191
 
 
192
TimeLabelAction::TimeLabelAction( QWidget * parent )
 
193
        : MyWidgetAction(parent)
 
194
{
 
195
}
 
196
 
 
197
TimeLabelAction::~TimeLabelAction() {
 
198
}
 
199
 
 
200
void TimeLabelAction::setText(QString s) {
 
201
        _text = s;
 
202
        emit newText(s);
 
203
}
 
204
 
 
205
QWidget * TimeLabelAction::createWidget ( QWidget * parent ) {
 
206
        QLabel * time_label = new QLabel(parent);
 
207
    time_label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
 
208
    time_label->setAutoFillBackground(true);
 
209
 
 
210
    ColorUtils::setBackgroundColor( time_label, QColor(0,0,0) );
 
211
    ColorUtils::setForegroundColor( time_label, QColor(255,255,255) );
 
212
    time_label->setText( "00:00:00 / 00:00:00" );
 
213
    time_label->setFrameShape( QFrame::Panel );
 
214
    time_label->setFrameShadow( QFrame::Sunken );
 
215
 
 
216
        connect( this, SIGNAL(newText(QString)), 
 
217
             time_label, SLOT(setText(QString)) );
 
218
 
 
219
        return time_label;
 
220
}
 
221
 
161
222
#if MINI_ARROW_BUTTONS
162
223
SeekingButton::SeekingButton( QList<QAction*> actions, QWidget * parent ) 
163
224
        : QWidgetAction(parent)
170
231
 
171
232
QWidget * SeekingButton::createWidget( QWidget * parent ) {
172
233
        QToolButton * button = new QToolButton(parent);
173
 
        button->setPopupMode(QToolButton::DelayedPopup);
 
234
        button->setPopupMode(QToolButton::MenuButtonPopup);
174
235
 
175
236
        if (_actions.count() > 0 ) {
176
237
                button->setDefaultAction( _actions[0] );