author | llornkcor <llornkcor> | 2002-04-21 14:06:57 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-21 14:06:57 (UTC) |
commit | 05158fd95b12800666a7a0620a32390e61979385 (patch) (unidiff) | |
tree | 5b62d42fada3eda8a518389fc04d3aaf2f02aefd | |
parent | 2da038246124a92248add8195126ac7bd21512f6 (diff) | |
download | opie-05158fd95b12800666a7a0620a32390e61979385.zip opie-05158fd95b12800666a7a0620a32390e61979385.tar.gz opie-05158fd95b12800666a7a0620a32390e61979385.tar.bz2 |
really fixed slider
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index b9561d5..e2e3603 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp | |||
@@ -72,98 +72,104 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | |||
72 | pixmaps[3] = new QPixmap( Resource::loadPixmap( "opieplayer/animatedButton" ) ); | 72 | pixmaps[3] = new QPixmap( Resource::loadPixmap( "opieplayer/animatedButton" ) ); |
73 | 73 | ||
74 | songInfo = new Ticker( this ); | 74 | songInfo = new Ticker( this ); |
75 | songInfo->setFocusPolicy( QWidget::NoFocus ); | 75 | songInfo->setFocusPolicy( QWidget::NoFocus ); |
76 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); | 76 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); |
77 | 77 | ||
78 | slider = new QSlider( Qt::Horizontal, this ); | 78 | slider = new QSlider( Qt::Horizontal, this ); |
79 | slider->setFixedWidth( 220 ); | 79 | slider->setFixedWidth( 220 ); |
80 | slider->setFixedHeight( 20 ); | 80 | slider->setFixedHeight( 20 ); |
81 | slider->setMinValue( 0 ); | 81 | slider->setMinValue( 0 ); |
82 | slider->setMaxValue( 1 ); | 82 | slider->setMaxValue( 1 ); |
83 | slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); | 83 | slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
84 | slider->setFocusPolicy( QWidget::NoFocus ); | 84 | slider->setFocusPolicy( QWidget::NoFocus ); |
85 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); | 85 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); |
86 | 86 | ||
87 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 87 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
88 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 88 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
89 | 89 | ||
90 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 90 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
91 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 91 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
92 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 92 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
93 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 93 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
94 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 94 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
95 | 95 | ||
96 | if( !mediaPlayerState->isStreaming) { // this stops the slider from being moved, thus | ||
97 | // does not stop stream when it reaches the end | ||
98 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
99 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
100 | } | ||
101 | // Intialise state | 96 | // Intialise state |
102 | setLength( mediaPlayerState->length() ); | 97 | setLength( mediaPlayerState->length() ); |
103 | setPosition( mediaPlayerState->position() ); | 98 | setPosition( mediaPlayerState->position() ); |
104 | setLooping( mediaPlayerState->fullscreen() ); | 99 | setLooping( mediaPlayerState->fullscreen() ); |
105 | setPaused( mediaPlayerState->paused() ); | 100 | setPaused( mediaPlayerState->paused() ); |
106 | setPlaying( mediaPlayerState->playing() ); | 101 | setPlaying( mediaPlayerState->playing() ); |
107 | if (mediaPlayerState->isStreaming) slider->hide(); | ||
108 | 102 | ||
109 | } | 103 | } |
110 | 104 | ||
111 | 105 | ||
112 | AudioWidget::~AudioWidget() { | 106 | AudioWidget::~AudioWidget() { |
113 | for ( int i = 0; i < 4; i++ ) | 107 | for ( int i = 0; i < 4; i++ ) |
114 | delete pixmaps[i]; | 108 | delete pixmaps[i]; |
115 | } | 109 | } |
116 | 110 | ||
117 | 111 | ||
118 | static bool audioSliderBeingMoved = FALSE; | 112 | static bool audioSliderBeingMoved = FALSE; |
119 | 113 | ||
120 | 114 | ||
121 | void AudioWidget::sliderPressed() { | 115 | void AudioWidget::sliderPressed() { |
122 | audioSliderBeingMoved = TRUE; | 116 | audioSliderBeingMoved = TRUE; |
123 | } | 117 | } |
124 | 118 | ||
125 | 119 | ||
126 | void AudioWidget::sliderReleased() { | 120 | void AudioWidget::sliderReleased() { |
127 | audioSliderBeingMoved = FALSE; | 121 | audioSliderBeingMoved = FALSE; |
128 | if ( slider->width() == 0 ) | 122 | if ( slider->width() == 0 ) |
129 | return; | 123 | return; |
130 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 124 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
131 | mediaPlayerState->setPosition( val ); | 125 | mediaPlayerState->setPosition( val ); |
132 | } | 126 | } |
133 | 127 | ||
134 | 128 | ||
135 | void AudioWidget::setPosition( long i ) { | 129 | void AudioWidget::setPosition( long i ) { |
136 | updateSlider( i, mediaPlayerState->length() ); | 130 | updateSlider( i, mediaPlayerState->length() ); |
137 | } | 131 | } |
138 | 132 | ||
139 | 133 | ||
140 | void AudioWidget::setLength( long max ) { | 134 | void AudioWidget::setLength( long max ) { |
141 | updateSlider( mediaPlayerState->position(), max ); | 135 | updateSlider( mediaPlayerState->position(), max ); |
142 | } | 136 | } |
143 | 137 | ||
144 | 138 | ||
145 | void AudioWidget::setView( char view ) { | 139 | void AudioWidget::setView( char view ) { |
140 | if (mediaPlayerState->isStreaming) { | ||
141 | if( !slider->isHidden()) slider->hide(); | ||
142 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
143 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
144 | } else { | ||
145 | // this stops the slider from being moved, thus | ||
146 | // does not stop stream when it reaches the end | ||
147 | if( slider->isHidden()) slider->show(); | ||
148 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
149 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
150 | } | ||
151 | |||
146 | if ( view == 'a' ) { | 152 | if ( view == 'a' ) { |
147 | startTimer( 150 ); | 153 | startTimer( 150 ); |
148 | showMaximized(); | 154 | showMaximized(); |
149 | } else { | 155 | } else { |
150 | killTimers(); | 156 | killTimers(); |
151 | hide(); | 157 | hide(); |
152 | } | 158 | } |
153 | } | 159 | } |
154 | 160 | ||
155 | 161 | ||
156 | void AudioWidget::updateSlider( long i, long max ) { | 162 | void AudioWidget::updateSlider( long i, long max ) { |
157 | if ( max == 0 ) | 163 | if ( max == 0 ) |
158 | return; | 164 | return; |
159 | // Will flicker too much if we don't do this | 165 | // Will flicker too much if we don't do this |
160 | // Scale to something reasonable | 166 | // Scale to something reasonable |
161 | int width = slider->width(); | 167 | int width = slider->width(); |
162 | int val = int((double)i * width / max); | 168 | int val = int((double)i * width / max); |
163 | if ( !audioSliderBeingMoved ) { | 169 | if ( !audioSliderBeingMoved ) { |
164 | if ( slider->value() != val ) | 170 | if ( slider->value() != val ) |
165 | slider->setValue( val ); | 171 | slider->setValue( val ); |
166 | if ( slider->maxValue() != width ) | 172 | if ( slider->maxValue() != width ) |
167 | slider->setMaxValue( width ); | 173 | slider->setMaxValue( width ); |
168 | } | 174 | } |
169 | } | 175 | } |