-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 22 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 4 |
3 files changed, 8 insertions, 20 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index cd5bea4..5d929cb 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,340 +1,338 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <opie/oticker.h> | 37 | #include <opie/oticker.h> |
38 | 38 | ||
39 | #include <qwidget.h> | 39 | #include <qwidget.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qbutton.h> | 41 | #include <qbutton.h> |
42 | #include <qpainter.h> | 42 | #include <qpainter.h> |
43 | #include <qframe.h> | 43 | #include <qframe.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | 48 | ||
49 | #include "audiowidget.h" | 49 | #include "audiowidget.h" |
50 | #include "mediaplayerstate.h" | 50 | #include "mediaplayerstate.h" |
51 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
52 | 52 | ||
53 | namespace | 53 | namespace |
54 | { | 54 | { |
55 | 55 | ||
56 | const int xo = -2; // movable x offset | 56 | const int xo = -2; // movable x offset |
57 | const int yo = 22; // movable y offset | 57 | const int yo = 22; // movable y offset |
58 | 58 | ||
59 | const MediaWidget::SkinButtonInfo skinInfo[] = | 59 | const MediaWidget::SkinButtonInfo skinInfo[] = |
60 | { | 60 | { |
61 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, | 61 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, |
62 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | 62 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, |
63 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, | 63 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, |
64 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, | 64 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, |
65 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | 65 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, |
66 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | 66 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, |
67 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, | 67 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, |
68 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, | 68 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, |
69 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, | 69 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, |
70 | { MediaWidget::Back, "back", MediaWidget::NormalButton } | 70 | { MediaWidget::Back, "back", MediaWidget::NormalButton } |
71 | }; | 71 | }; |
72 | 72 | ||
73 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | 73 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); |
74 | 74 | ||
75 | void changeTextColor( QWidget * w) { | 75 | void changeTextColor( QWidget * w) { |
76 | QPalette p = w->palette(); | 76 | QPalette p = w->palette(); |
77 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 77 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
78 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 78 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
79 | w->setPalette( p ); | 79 | w->setPalette( p ); |
80 | } | 80 | } |
81 | 81 | ||
82 | } | 82 | } |
83 | 83 | ||
84 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 84 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
85 | 85 | ||
86 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), | 86 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), |
87 | audioSliderBeingMoved( false ) | 87 | audioSliderBeingMoved( false ) |
88 | { | 88 | { |
89 | setCaption( tr("OpiePlayer") ); | 89 | setCaption( tr("OpiePlayer") ); |
90 | 90 | ||
91 | loadSkin(); | 91 | loadSkin(); |
92 | 92 | ||
93 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 93 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
94 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); | 94 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); |
95 | 95 | ||
96 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 96 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
97 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 97 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
98 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 98 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
99 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 99 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
100 | 100 | ||
101 | // Intialise state | 101 | // Intialise state |
102 | setLength( mediaPlayerState.length() ); | 102 | setLength( mediaPlayerState.length() ); |
103 | setPosition( mediaPlayerState.position() ); | 103 | setPosition( mediaPlayerState.position() ); |
104 | setLooping( mediaPlayerState.isFullscreen() ); | 104 | setLooping( mediaPlayerState.isFullscreen() ); |
105 | // setPaused( mediaPlayerState->paused() ); | 105 | // setPaused( mediaPlayerState->paused() ); |
106 | setPlaying( mediaPlayerState.isPlaying() ); | 106 | setPlaying( mediaPlayerState.isPlaying() ); |
107 | } | 107 | } |
108 | 108 | ||
109 | AudioWidget::~AudioWidget() { | 109 | AudioWidget::~AudioWidget() { |
110 | 110 | ||
111 | // mediaPlayerState->setPlaying(false); | 111 | // mediaPlayerState->setPlaying(false); |
112 | } | 112 | } |
113 | 113 | ||
114 | MediaWidget::GUIInfo AudioWidget::guiInfo() | 114 | MediaWidget::GUIInfo AudioWidget::guiInfo() |
115 | { | 115 | { |
116 | return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); | 116 | return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); |
117 | } | 117 | } |
118 | 118 | ||
119 | void AudioWidget::resizeEvent( QResizeEvent *e ) { | 119 | void AudioWidget::resizeEvent( QResizeEvent *e ) { |
120 | int h = height(); | 120 | int h = height(); |
121 | int w = width(); | 121 | int w = width(); |
122 | 122 | ||
123 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 123 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
124 | slider.setFixedWidth( w - 110 ); | 124 | slider.setFixedWidth( w - 110 ); |
125 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 125 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
126 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 126 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
127 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 127 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
128 | 128 | ||
129 | upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; | 129 | upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; |
130 | upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; | 130 | upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; |
131 | 131 | ||
132 | MediaWidget::resizeEvent( e ); | 132 | MediaWidget::resizeEvent( e ); |
133 | } | 133 | } |
134 | 134 | ||
135 | void AudioWidget::sliderPressed() { | 135 | void AudioWidget::sliderPressed() { |
136 | audioSliderBeingMoved = TRUE; | 136 | audioSliderBeingMoved = TRUE; |
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
140 | void AudioWidget::sliderReleased() { | 140 | void AudioWidget::sliderReleased() { |
141 | audioSliderBeingMoved = FALSE; | 141 | audioSliderBeingMoved = FALSE; |
142 | if ( slider.width() == 0 ) | 142 | if ( slider.width() == 0 ) |
143 | return; | 143 | return; |
144 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); | 144 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); |
145 | mediaPlayerState.setPosition( val ); | 145 | mediaPlayerState.setPosition( val ); |
146 | } | 146 | } |
147 | 147 | ||
148 | void AudioWidget::setPosition( long i ) { | 148 | void AudioWidget::setPosition( long i ) { |
149 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 149 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
150 | updateSlider( i, mediaPlayerState.length() ); | 150 | updateSlider( i, mediaPlayerState.length() ); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | void AudioWidget::setLength( long max ) { | 154 | void AudioWidget::setLength( long max ) { |
155 | updateSlider( mediaPlayerState.position(), max ); | 155 | updateSlider( mediaPlayerState.position(), max ); |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 159 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
160 | if ( mediaType == MediaPlayerState::Audio ) { | 160 | if ( mediaType == MediaPlayerState::Audio ) { |
161 | // startTimer( 150 ); | 161 | // startTimer( 150 ); |
162 | showMaximized(); | 162 | showMaximized(); |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | 165 | ||
166 | killTimers(); | 166 | killTimers(); |
167 | hide(); | 167 | hide(); |
168 | } | 168 | } |
169 | 169 | ||
170 | void AudioWidget::loadSkin() | 170 | void AudioWidget::loadSkin() |
171 | { | 171 | { |
172 | loadDefaultSkin( guiInfo() ); | 172 | loadDefaultSkin( guiInfo() ); |
173 | 173 | ||
174 | setBackgroundPixmap( backgroundPixmap ); | ||
175 | |||
176 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 174 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
177 | // changeTextColor( &songInfo ); | 175 | // changeTextColor( &songInfo ); |
178 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 176 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
179 | // songInfo.setFrameStyle( QFrame::NoFrame); | 177 | // songInfo.setFrameStyle( QFrame::NoFrame); |
180 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 178 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
181 | // songInfo.setForegroundColor(Qt::white); | 179 | // songInfo.setForegroundColor(Qt::white); |
182 | 180 | ||
183 | slider.setFixedHeight( 20 ); | 181 | slider.setFixedHeight( 20 ); |
184 | slider.setMinValue( 0 ); | 182 | slider.setMinValue( 0 ); |
185 | slider.setMaxValue( 1 ); | 183 | slider.setMaxValue( 1 ); |
186 | slider.setFocusPolicy( QWidget::NoFocus ); | 184 | slider.setFocusPolicy( QWidget::NoFocus ); |
187 | slider.setBackgroundPixmap( backgroundPixmap ); | 185 | slider.setBackgroundPixmap( backgroundPixmap ); |
188 | 186 | ||
189 | // Config cofg("qpe"); | 187 | // Config cofg("qpe"); |
190 | // cofg.setGroup("Appearance"); | 188 | // cofg.setGroup("Appearance"); |
191 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | 189 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); |
192 | 190 | ||
193 | time.setFocusPolicy( QWidget::NoFocus ); | 191 | time.setFocusPolicy( QWidget::NoFocus ); |
194 | time.setAlignment( Qt::AlignCenter ); | 192 | time.setAlignment( Qt::AlignCenter ); |
195 | 193 | ||
196 | // time.setFrame(FALSE); | 194 | // time.setFrame(FALSE); |
197 | // changeTextColor( &time ); | 195 | // changeTextColor( &time ); |
198 | 196 | ||
199 | resizeEvent( 0 ); | 197 | resizeEvent( 0 ); |
200 | } | 198 | } |
201 | 199 | ||
202 | void AudioWidget::setSeekable( bool isSeekable ) { | 200 | void AudioWidget::setSeekable( bool isSeekable ) { |
203 | 201 | ||
204 | if ( !isSeekable ) { | 202 | if ( !isSeekable ) { |
205 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 203 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
206 | if( !slider.isHidden()) { | 204 | if( !slider.isHidden()) { |
207 | slider.hide(); | 205 | slider.hide(); |
208 | } | 206 | } |
209 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 207 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
210 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 208 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
211 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 209 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
212 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 210 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
213 | } else { | 211 | } else { |
214 | // this stops the slider from being moved, thus | 212 | // this stops the slider from being moved, thus |
215 | // does not stop stream when it reaches the end | 213 | // does not stop stream when it reaches the end |
216 | slider.show(); | 214 | slider.show(); |
217 | qDebug( " CONNECT SET POSTION " ); | 215 | qDebug( " CONNECT SET POSTION " ); |
218 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 216 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
219 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 217 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
220 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 218 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
221 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 219 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
222 | } | 220 | } |
223 | } | 221 | } |
224 | 222 | ||
225 | 223 | ||
226 | static QString timeAsString( long length ) { | 224 | static QString timeAsString( long length ) { |
227 | int minutes = length / 60; | 225 | int minutes = length / 60; |
228 | int seconds = length % 60; | 226 | int seconds = length % 60; |
229 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 227 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
230 | } | 228 | } |
231 | 229 | ||
232 | void AudioWidget::updateSlider( long i, long max ) { | 230 | void AudioWidget::updateSlider( long i, long max ) { |
233 | 231 | ||
234 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 232 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
235 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 233 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
236 | 234 | ||
237 | if ( max == 0 ) { | 235 | if ( max == 0 ) { |
238 | return; | 236 | return; |
239 | } | 237 | } |
240 | // Will flicker too much if we don't do this | 238 | // Will flicker too much if we don't do this |
241 | // Scale to something reasonable | 239 | // Scale to something reasonable |
242 | int width = slider.width(); | 240 | int width = slider.width(); |
243 | int val = int((double)i * width / max); | 241 | int val = int((double)i * width / max); |
244 | if ( !audioSliderBeingMoved ) { | 242 | if ( !audioSliderBeingMoved ) { |
245 | if ( slider.value() != val ) { | 243 | if ( slider.value() != val ) { |
246 | slider.setValue( val ); | 244 | slider.setValue( val ); |
247 | } | 245 | } |
248 | 246 | ||
249 | if ( slider.maxValue() != width ) { | 247 | if ( slider.maxValue() != width ) { |
250 | slider.setMaxValue( width ); | 248 | slider.setMaxValue( width ); |
251 | } | 249 | } |
252 | } | 250 | } |
253 | } | 251 | } |
254 | 252 | ||
255 | void AudioWidget::skipFor() { | 253 | void AudioWidget::skipFor() { |
256 | skipDirection = +1; | 254 | skipDirection = +1; |
257 | startTimer( 50 ); | 255 | startTimer( 50 ); |
258 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 256 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
259 | } | 257 | } |
260 | 258 | ||
261 | void AudioWidget::skipBack() { | 259 | void AudioWidget::skipBack() { |
262 | skipDirection = -1; | 260 | skipDirection = -1; |
263 | startTimer( 50 ); | 261 | startTimer( 50 ); |
264 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 262 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
265 | } | 263 | } |
266 | 264 | ||
267 | 265 | ||
268 | 266 | ||
269 | void AudioWidget::stopSkip() { | 267 | void AudioWidget::stopSkip() { |
270 | killTimers(); | 268 | killTimers(); |
271 | } | 269 | } |
272 | 270 | ||
273 | 271 | ||
274 | void AudioWidget::timerEvent( QTimerEvent * ) { | 272 | void AudioWidget::timerEvent( QTimerEvent * ) { |
275 | if ( skipDirection == +1 ) { | 273 | if ( skipDirection == +1 ) { |
276 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 274 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
277 | } else if ( skipDirection == -1 ) { | 275 | } else if ( skipDirection == -1 ) { |
278 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 276 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
279 | } | 277 | } |
280 | } | 278 | } |
281 | 279 | ||
282 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 280 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
283 | switch ( e->key() ) { | 281 | switch ( e->key() ) { |
284 | ////////////////////////////// Zaurus keys | 282 | ////////////////////////////// Zaurus keys |
285 | case Key_Home: | 283 | case Key_Home: |
286 | break; | 284 | break; |
287 | case Key_F9: //activity | 285 | case Key_F9: //activity |
288 | hide(); | 286 | hide(); |
289 | // qDebug("Audio F9"); | 287 | // qDebug("Audio F9"); |
290 | e->accept(); | 288 | e->accept(); |
291 | break; | 289 | break; |
292 | case Key_F10: //contacts | 290 | case Key_F10: //contacts |
293 | break; | 291 | break; |
294 | case Key_F11: //menu | 292 | case Key_F11: //menu |
295 | mediaPlayerState.toggleBlank(); | 293 | mediaPlayerState.toggleBlank(); |
296 | e->accept(); | 294 | e->accept(); |
297 | break; | 295 | break; |
298 | case Key_F12: //home | 296 | case Key_F12: //home |
299 | break; | 297 | break; |
300 | case Key_F13: //mail | 298 | case Key_F13: //mail |
301 | mediaPlayerState.toggleBlank(); | 299 | mediaPlayerState.toggleBlank(); |
302 | e->accept(); | 300 | e->accept(); |
303 | break; | 301 | break; |
304 | case Key_Space: { | 302 | case Key_Space: { |
305 | e->accept(); | 303 | e->accept(); |
306 | mediaPlayerState.togglePaused(); | 304 | mediaPlayerState.togglePaused(); |
307 | } | 305 | } |
308 | break; | 306 | break; |
309 | case Key_Down: | 307 | case Key_Down: |
310 | // toggleButton(6); | 308 | // toggleButton(6); |
311 | emit lessClicked(); | 309 | emit lessClicked(); |
312 | emit lessReleased(); | 310 | emit lessReleased(); |
313 | // toggleButton(6); | 311 | // toggleButton(6); |
314 | e->accept(); | 312 | e->accept(); |
315 | break; | 313 | break; |
316 | case Key_Up: | 314 | case Key_Up: |
317 | // toggleButton(5); | 315 | // toggleButton(5); |
318 | emit moreClicked(); | 316 | emit moreClicked(); |
319 | emit moreReleased(); | 317 | emit moreReleased(); |
320 | // toggleButton(5); | 318 | // toggleButton(5); |
321 | e->accept(); | 319 | e->accept(); |
322 | break; | 320 | break; |
323 | case Key_Right: | 321 | case Key_Right: |
324 | // toggleButton(3); | 322 | // toggleButton(3); |
325 | mediaPlayerState.setNext(); | 323 | mediaPlayerState.setNext(); |
326 | // toggleButton(3); | 324 | // toggleButton(3); |
327 | e->accept(); | 325 | e->accept(); |
328 | break; | 326 | break; |
329 | case Key_Left: | 327 | case Key_Left: |
330 | // toggleButton(4); | 328 | // toggleButton(4); |
331 | mediaPlayerState.setPrev(); | 329 | mediaPlayerState.setPrev(); |
332 | // toggleButton(4); | 330 | // toggleButton(4); |
333 | e->accept(); | 331 | e->accept(); |
334 | break; | 332 | break; |
335 | case Key_Escape: { | 333 | case Key_Escape: { |
336 | } | 334 | } |
337 | break; | 335 | break; |
338 | 336 | ||
339 | }; | 337 | }; |
340 | } | 338 | } |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 702e6d7..f7a22a3 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -1,266 +1,260 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <simon@lst.de> | 2 | Copyright (C) 2002 Simon Hausmann <simon@lst.de> |
3 | (C) 2002 Max Reiss <harlekin@handhelds.org> | 3 | (C) 2002 Max Reiss <harlekin@handhelds.org> |
4 | (C) 2002 L. Potter <ljp@llornkcor.com> | 4 | (C) 2002 L. Potter <ljp@llornkcor.com> |
5 | (C) 2002 Holger Freyther <zecke@handhelds.org> | 5 | (C) 2002 Holger Freyther <zecke@handhelds.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or | 7 | This program is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU General Public | 8 | modify it under the terms of the GNU General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | General Public License for more details. | 15 | General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; see the file COPYING. If not, write to | 18 | along with this program; see the file COPYING. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "mediawidget.h" | 23 | #include "mediawidget.h" |
24 | #include "playlistwidget.h" | 24 | #include "playlistwidget.h" |
25 | #include "skin.h" | 25 | #include "skin.h" |
26 | 26 | ||
27 | MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) | 27 | MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) |
28 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) | 28 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) |
29 | { | 29 | { |
30 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), | 30 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), |
31 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); | 31 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); |
32 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), | 32 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), |
33 | this, SLOT( setLength( long ) ) ); | 33 | this, SLOT( setLength( long ) ) ); |
34 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 34 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
35 | this, SLOT( setPlaying( bool ) ) ); | 35 | this, SLOT( setPlaying( bool ) ) ); |
36 | |||
37 | setBackgroundMode( NoBackground ); | ||
36 | } | 38 | } |
37 | 39 | ||
38 | MediaWidget::~MediaWidget() | 40 | MediaWidget::~MediaWidget() |
39 | { | 41 | { |
40 | } | 42 | } |
41 | 43 | ||
42 | void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, | 44 | void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, |
43 | const Skin &skin ) | 45 | const Skin &skin ) |
44 | { | 46 | { |
45 | buttonMask = skin.buttonMask( skinInfo, buttonCount ); | 47 | buttonMask = skin.buttonMask( skinInfo, buttonCount ); |
46 | 48 | ||
47 | buttons.clear(); | 49 | buttons.clear(); |
48 | buttons.reserve( buttonCount ); | 50 | buttons.reserve( buttonCount ); |
49 | 51 | ||
50 | for ( uint i = 0; i < buttonCount; ++i ) { | 52 | for ( uint i = 0; i < buttonCount; ++i ) { |
51 | Button button = setupButton( skinInfo[ i ], skin ); | 53 | Button button = setupButton( skinInfo[ i ], skin ); |
52 | buttons.push_back( button ); | 54 | buttons.push_back( button ); |
53 | } | 55 | } |
54 | } | 56 | } |
55 | 57 | ||
56 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) | 58 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) |
57 | { | 59 | { |
58 | Button button; | 60 | Button button; |
59 | button.command = buttonInfo.command; | 61 | button.command = buttonInfo.command; |
60 | button.type = buttonInfo.type; | 62 | button.type = buttonInfo.type; |
61 | button.mask = skin.buttonMaskImage( buttonInfo.fileName ); | 63 | button.mask = skin.buttonMaskImage( buttonInfo.fileName ); |
62 | 64 | ||
63 | return button; | 65 | return button; |
64 | } | 66 | } |
65 | 67 | ||
66 | void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) | 68 | void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) |
67 | { | 69 | { |
68 | Skin skin( guiInfo.fileNameInfix ); | 70 | Skin skin( guiInfo.fileNameInfix ); |
69 | loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); | 71 | loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); |
70 | } | 72 | } |
71 | 73 | ||
72 | void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) | 74 | void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) |
73 | { | 75 | { |
74 | backgroundPixmap = skin.backgroundImage(); | 76 | backgroundPixmap = skin.backgroundImage(); |
75 | buttonUpImage = skin.buttonUpImage(); | 77 | buttonUpImage = skin.buttonUpImage(); |
76 | buttonDownImage = skin.buttonDownImage(); | 78 | buttonDownImage = skin.buttonDownImage(); |
77 | 79 | ||
78 | setupButtons( skinInfo, buttonCount, skin ); | 80 | setupButtons( skinInfo, buttonCount, skin ); |
79 | } | 81 | } |
80 | 82 | ||
81 | void MediaWidget::closeEvent( QCloseEvent * ) | 83 | void MediaWidget::closeEvent( QCloseEvent * ) |
82 | { | 84 | { |
83 | mediaPlayerState.setList(); | 85 | mediaPlayerState.setList(); |
84 | } | 86 | } |
85 | 87 | ||
86 | void MediaWidget::paintEvent( QPaintEvent *pe ) | 88 | void MediaWidget::paintEvent( QPaintEvent *pe ) |
87 | { | 89 | { |
88 | QPainter p( this ); | 90 | QPainter p( this ); |
89 | 91 | ||
90 | if ( mediaPlayerState.isFullscreen() ) { | 92 | if ( mediaPlayerState.isFullscreen() ) { |
91 | // Clear the background | 93 | // Clear the background |
92 | p.setBrush( QBrush( Qt::black ) ); | 94 | p.setBrush( QBrush( Qt::black ) ); |
93 | return; | 95 | return; |
94 | } | ||
95 | |||
96 | if ( !pe->erased() ) { | ||
97 | // Combine with background and double buffer | ||
98 | QPixmap pix( pe->rect().size() ); | ||
99 | QPainter p( &pix ); | ||
100 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | ||
101 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); | ||
102 | paintAllButtons( p ); | ||
103 | QPainter p2( this ); | ||
104 | p2.drawPixmap( pe->rect().topLeft(), pix ); | ||
105 | } else { | ||
106 | QPainter p( this ); | ||
107 | paintAllButtons( p ); | ||
108 | } | 96 | } |
97 | |||
98 | QPixmap buffer( size() ); | ||
99 | QPainter bufferedPainter( &buffer ); | ||
100 | bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) ); | ||
101 | paintAllButtons( bufferedPainter ); | ||
102 | p.drawPixmap( 0, 0, buffer ); | ||
109 | } | 103 | } |
110 | 104 | ||
111 | void MediaWidget::resizeEvent( QResizeEvent *e ) | 105 | void MediaWidget::resizeEvent( QResizeEvent *e ) |
112 | { | 106 | { |
113 | QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); | 107 | QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); |
114 | QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); | 108 | QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); |
115 | 109 | ||
116 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { | 110 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { |
117 | Button &button = *it; | 111 | Button &button = *it; |
118 | 112 | ||
119 | if ( button.mask.isNull() ) | 113 | if ( button.mask.isNull() ) |
120 | continue; | 114 | continue; |
121 | button.pixUp = addMaskToPixmap( pixUp, button.mask ); | 115 | button.pixUp = addMaskToPixmap( pixUp, button.mask ); |
122 | button.pixDown = addMaskToPixmap( pixDn, button.mask ); | 116 | button.pixDown = addMaskToPixmap( pixDn, button.mask ); |
123 | } | 117 | } |
124 | 118 | ||
125 | QWidget::resizeEvent( e ); | 119 | QWidget::resizeEvent( e ); |
126 | } | 120 | } |
127 | 121 | ||
128 | MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) | 122 | MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) |
129 | { | 123 | { |
130 | if ( position.x() <= 0 || position.y() <= 0 || | 124 | if ( position.x() <= 0 || position.y() <= 0 || |
131 | position.x() >= buttonMask.width() || | 125 | position.x() >= buttonMask.width() || |
132 | position.y() >= buttonMask.height() ) | 126 | position.y() >= buttonMask.height() ) |
133 | return 0; | 127 | return 0; |
134 | 128 | ||
135 | int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); | 129 | int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); |
136 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) | 130 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) |
137 | if ( it->command + 1 == pixelIdx ) | 131 | if ( it->command + 1 == pixelIdx ) |
138 | return &( *it ); | 132 | return &( *it ); |
139 | 133 | ||
140 | return 0; | 134 | return 0; |
141 | } | 135 | } |
142 | 136 | ||
143 | void MediaWidget::mousePressEvent( QMouseEvent *event ) | 137 | void MediaWidget::mousePressEvent( QMouseEvent *event ) |
144 | { | 138 | { |
145 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); | 139 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); |
146 | 140 | ||
147 | if ( !button ) { | 141 | if ( !button ) { |
148 | QWidget::mousePressEvent( event ); | 142 | QWidget::mousePressEvent( event ); |
149 | return; | 143 | return; |
150 | } | 144 | } |
151 | 145 | ||
152 | switch ( button->command ) { | 146 | switch ( button->command ) { |
153 | case VolumeUp: emit moreClicked(); return; | 147 | case VolumeUp: emit moreClicked(); return; |
154 | case VolumeDown: emit lessClicked(); return; | 148 | case VolumeDown: emit lessClicked(); return; |
155 | case Back: emit backClicked(); return; | 149 | case Back: emit backClicked(); return; |
156 | case Forward: emit forwardClicked(); return; | 150 | case Forward: emit forwardClicked(); return; |
157 | default: break; | 151 | default: break; |
158 | } | 152 | } |
159 | } | 153 | } |
160 | 154 | ||
161 | void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) | 155 | void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) |
162 | { | 156 | { |
163 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); | 157 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); |
164 | 158 | ||
165 | if ( !button ) { | 159 | if ( !button ) { |
166 | QWidget::mouseReleaseEvent( event ); | 160 | QWidget::mouseReleaseEvent( event ); |
167 | return; | 161 | return; |
168 | } | 162 | } |
169 | 163 | ||
170 | if ( button->type == ToggleButton ) | 164 | if ( button->type == ToggleButton ) |
171 | toggleButton( *button ); | 165 | toggleButton( *button ); |
172 | 166 | ||
173 | handleCommand( button->command, button->isDown ); | 167 | handleCommand( button->command, button->isDown ); |
174 | } | 168 | } |
175 | 169 | ||
176 | void MediaWidget::makeVisible() | 170 | void MediaWidget::makeVisible() |
177 | { | 171 | { |
178 | } | 172 | } |
179 | 173 | ||
180 | void MediaWidget::handleCommand( Command command, bool buttonDown ) | 174 | void MediaWidget::handleCommand( Command command, bool buttonDown ) |
181 | { | 175 | { |
182 | switch ( command ) { | 176 | switch ( command ) { |
183 | case Play: mediaPlayerState.togglePaused(); return; | 177 | case Play: mediaPlayerState.togglePaused(); return; |
184 | case Stop: mediaPlayerState.setPlaying(FALSE); return; | 178 | case Stop: mediaPlayerState.setPlaying(FALSE); return; |
185 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 179 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
186 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 180 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
187 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; | 181 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; |
188 | case VolumeUp: emit moreReleased(); return; | 182 | case VolumeUp: emit moreReleased(); return; |
189 | case VolumeDown: emit lessReleased(); return; | 183 | case VolumeDown: emit lessReleased(); return; |
190 | case PlayList: mediaPlayerState.setList(); return; | 184 | case PlayList: mediaPlayerState.setList(); return; |
191 | case Forward: emit forwardReleased(); return; | 185 | case Forward: emit forwardReleased(); return; |
192 | case Back: emit backReleased(); return; | 186 | case Back: emit backReleased(); return; |
193 | case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; | 187 | case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; |
194 | default: assert( false ); | 188 | default: assert( false ); |
195 | } | 189 | } |
196 | } | 190 | } |
197 | 191 | ||
198 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const | 192 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const |
199 | { | 193 | { |
200 | return ( position.x() > 0 && position.y() > 0 && | 194 | return ( position.x() > 0 && position.y() > 0 && |
201 | position.x() < buttonMask.width() && | 195 | position.x() < buttonMask.width() && |
202 | position.y() < buttonMask.height() && | 196 | position.y() < buttonMask.height() && |
203 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); | 197 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); |
204 | } | 198 | } |
205 | 199 | ||
206 | void MediaWidget::paintAllButtons( QPainter &p ) | 200 | void MediaWidget::paintAllButtons( QPainter &p ) |
207 | { | 201 | { |
208 | for ( ButtonVector::const_iterator it = buttons.begin(); | 202 | for ( ButtonVector::const_iterator it = buttons.begin(); |
209 | it != buttons.end(); ++it ) | 203 | it != buttons.end(); ++it ) |
210 | paintButton( p, *it ); | 204 | paintButton( p, *it ); |
211 | } | 205 | } |
212 | 206 | ||
213 | void MediaWidget::paintButton( const Button &button ) | 207 | void MediaWidget::paintButton( const Button &button ) |
214 | { | 208 | { |
215 | QPainter p( this ); | 209 | QPainter p( this ); |
216 | paintButton( p, button ); | 210 | paintButton( p, button ); |
217 | } | 211 | } |
218 | 212 | ||
219 | void MediaWidget::paintButton( QPainter &p, const Button &button ) | 213 | void MediaWidget::paintButton( QPainter &p, const Button &button ) |
220 | { | 214 | { |
221 | if ( button.isDown ) | 215 | if ( button.isDown ) |
222 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); | 216 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); |
223 | else | 217 | else |
224 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); | 218 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); |
225 | } | 219 | } |
226 | 220 | ||
227 | void MediaWidget::setToggleButton( Command command, bool down ) | 221 | void MediaWidget::setToggleButton( Command command, bool down ) |
228 | { | 222 | { |
229 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) | 223 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) |
230 | if ( it->command == command ) { | 224 | if ( it->command == command ) { |
231 | setToggleButton( *it, down ); | 225 | setToggleButton( *it, down ); |
232 | return; | 226 | return; |
233 | } | 227 | } |
234 | } | 228 | } |
235 | 229 | ||
236 | void MediaWidget::setToggleButton( Button &button, bool down ) | 230 | void MediaWidget::setToggleButton( Button &button, bool down ) |
237 | { | 231 | { |
238 | if ( down != button.isDown ) | 232 | if ( down != button.isDown ) |
239 | toggleButton( button ); | 233 | toggleButton( button ); |
240 | } | 234 | } |
241 | 235 | ||
242 | void MediaWidget::toggleButton( Button &button ) | 236 | void MediaWidget::toggleButton( Button &button ) |
243 | { | 237 | { |
244 | button.isDown = !button.isDown; | 238 | button.isDown = !button.isDown; |
245 | 239 | ||
246 | paintButton( button ); | 240 | paintButton( button ); |
247 | } | 241 | } |
248 | 242 | ||
249 | QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset ) | 243 | QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset ) |
250 | { | 244 | { |
251 | QPixmap pix( image.size() ); | 245 | QPixmap pix( image.size() ); |
252 | QPainter p( &pix ); | 246 | QPainter p( &pix ); |
253 | p.drawTiledPixmap( pix.rect(), background, offset ); | 247 | p.drawTiledPixmap( pix.rect(), background, offset ); |
254 | p.drawImage( 0, 0, image ); | 248 | p.drawImage( 0, 0, image ); |
255 | return pix; | 249 | return pix; |
256 | } | 250 | } |
257 | 251 | ||
258 | QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ) | 252 | QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ) |
259 | { | 253 | { |
260 | QPixmap result( pix ); | 254 | QPixmap result( pix ); |
261 | result.setMask( mask ); | 255 | result.setMask( mask ); |
262 | return result; | 256 | return result; |
263 | } | 257 | } |
264 | 258 | ||
265 | /* vim: et sw=4 ts=4 | 259 | /* vim: et sw=4 ts=4 |
266 | */ | 260 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 2300630..755cd22 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,317 +1,313 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | 38 | ||
39 | #include <qwidget.h> | 39 | #include <qwidget.h> |
40 | #include <qpainter.h> | 40 | #include <qpainter.h> |
41 | #include <qpixmap.h> | 41 | #include <qpixmap.h> |
42 | #include <qslider.h> | 42 | #include <qslider.h> |
43 | #include <qdrawutil.h> | 43 | #include <qdrawutil.h> |
44 | #include "videowidget.h" | 44 | #include "videowidget.h" |
45 | #include "mediaplayerstate.h" | 45 | #include "mediaplayerstate.h" |
46 | #include "playlistwidget.h" | 46 | #include "playlistwidget.h" |
47 | 47 | ||
48 | 48 | ||
49 | #ifdef Q_WS_QWS | 49 | #ifdef Q_WS_QWS |
50 | # define USE_DIRECT_PAINTER | 50 | # define USE_DIRECT_PAINTER |
51 | # include <qdirectpainter_qws.h> | 51 | # include <qdirectpainter_qws.h> |
52 | # include <qgfxraster_qws.h> | 52 | # include <qgfxraster_qws.h> |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | 55 | ||
56 | namespace | 56 | namespace |
57 | { | 57 | { |
58 | 58 | ||
59 | const int xo = 2; // movable x offset | 59 | const int xo = 2; // movable x offset |
60 | const int yo = 0; // movable y offset | 60 | const int yo = 0; // movable y offset |
61 | 61 | ||
62 | const MediaWidget::SkinButtonInfo skinInfo[] = | 62 | const MediaWidget::SkinButtonInfo skinInfo[] = |
63 | { | 63 | { |
64 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, | 64 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, |
65 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | 65 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, |
66 | { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, | 66 | { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, |
67 | { MediaWidget::Previous, "back", MediaWidget::NormalButton }, | 67 | { MediaWidget::Previous, "back", MediaWidget::NormalButton }, |
68 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | 68 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, |
69 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | 69 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, |
70 | { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } | 70 | { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } |
71 | }; | 71 | }; |
72 | 72 | ||
73 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | 73 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); |
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 77 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
78 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) | 78 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) |
79 | { | 79 | { |
80 | setCaption( tr("OpiePlayer - Video") ); | 80 | setCaption( tr("OpiePlayer - Video") ); |
81 | 81 | ||
82 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 82 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
83 | 83 | ||
84 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 84 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
85 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 85 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
86 | 86 | ||
87 | slider = 0; | 87 | slider = 0; |
88 | 88 | ||
89 | loadSkin(); | 89 | loadSkin(); |
90 | 90 | ||
91 | setLength( mediaPlayerState.length() ); | 91 | setLength( mediaPlayerState.length() ); |
92 | setPosition( mediaPlayerState.position() ); | 92 | setPosition( mediaPlayerState.position() ); |
93 | setFullscreen( mediaPlayerState.isFullscreen() ); | 93 | setFullscreen( mediaPlayerState.isFullscreen() ); |
94 | setPlaying( mediaPlayerState.isPlaying() ); | 94 | setPlaying( mediaPlayerState.isPlaying() ); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | VideoWidget::~VideoWidget() | 98 | VideoWidget::~VideoWidget() |
99 | { | 99 | { |
100 | } | 100 | } |
101 | 101 | ||
102 | MediaWidget::GUIInfo VideoWidget::guiInfo() | 102 | MediaWidget::GUIInfo VideoWidget::guiInfo() |
103 | { | 103 | { |
104 | return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount ); | 104 | return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount ); |
105 | } | 105 | } |
106 | 106 | ||
107 | void VideoWidget::resizeEvent( QResizeEvent *e ) { | 107 | void VideoWidget::resizeEvent( QResizeEvent *e ) { |
108 | int h = height(); | 108 | int h = height(); |
109 | int w = width(); | 109 | int w = width(); |
110 | //int Vh = 160; | 110 | //int Vh = 160; |
111 | //int Vw = 220; | 111 | //int Vw = 220; |
112 | 112 | ||
113 | slider->setFixedWidth( w - 20 ); | 113 | slider->setFixedWidth( w - 20 ); |
114 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 114 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
115 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 115 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
116 | slider->setFocusPolicy( QWidget::NoFocus ); | 116 | slider->setFocusPolicy( QWidget::NoFocus ); |
117 | slider->setBackgroundPixmap( backgroundPixmap ); | 117 | slider->setBackgroundPixmap( backgroundPixmap ); |
118 | 118 | ||
119 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; | 119 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; |
120 | if(w>h) | 120 | if(w>h) |
121 | upperLeftOfButtonMask.ry() = 0; | 121 | upperLeftOfButtonMask.ry() = 0; |
122 | else | 122 | else |
123 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 123 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
124 | 124 | ||
125 | MediaWidget::resizeEvent( e ); | 125 | MediaWidget::resizeEvent( e ); |
126 | } | 126 | } |
127 | 127 | ||
128 | void VideoWidget::sliderPressed() { | 128 | void VideoWidget::sliderPressed() { |
129 | videoSliderBeingMoved = TRUE; | 129 | videoSliderBeingMoved = TRUE; |
130 | } | 130 | } |
131 | 131 | ||
132 | void VideoWidget::sliderReleased() { | 132 | void VideoWidget::sliderReleased() { |
133 | videoSliderBeingMoved = FALSE; | 133 | videoSliderBeingMoved = FALSE; |
134 | if ( slider->width() == 0 ) { | 134 | if ( slider->width() == 0 ) { |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); | 137 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); |
138 | mediaPlayerState.setPosition( val ); | 138 | mediaPlayerState.setPosition( val ); |
139 | } | 139 | } |
140 | 140 | ||
141 | void VideoWidget::setPosition( long i ) { | 141 | void VideoWidget::setPosition( long i ) { |
142 | updateSlider( i, mediaPlayerState.length() ); | 142 | updateSlider( i, mediaPlayerState.length() ); |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | void VideoWidget::setLength( long max ) { | 146 | void VideoWidget::setLength( long max ) { |
147 | updateSlider( mediaPlayerState.position(), max ); | 147 | updateSlider( mediaPlayerState.position(), max ); |
148 | } | 148 | } |
149 | 149 | ||
150 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 150 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
151 | { | 151 | { |
152 | if ( displayType == MediaPlayerState::Video ) { | 152 | if ( displayType == MediaPlayerState::Video ) { |
153 | makeVisible(); | 153 | makeVisible(); |
154 | return; | 154 | return; |
155 | } | 155 | } |
156 | 156 | ||
157 | // Effectively blank the view next time we show it so it looks nicer | 157 | // Effectively blank the view next time we show it so it looks nicer |
158 | scaledWidth = 0; | 158 | scaledWidth = 0; |
159 | scaledHeight = 0; | 159 | scaledHeight = 0; |
160 | hide(); | 160 | hide(); |
161 | } | 161 | } |
162 | 162 | ||
163 | void VideoWidget::loadSkin() | 163 | void VideoWidget::loadSkin() |
164 | { | 164 | { |
165 | loadDefaultSkin( guiInfo() ); | 165 | loadDefaultSkin( guiInfo() ); |
166 | 166 | ||
167 | setBackgroundPixmap( backgroundPixmap ); | ||
168 | |||
169 | delete slider; | 167 | delete slider; |
170 | slider = new QSlider( Qt::Horizontal, this ); | 168 | slider = new QSlider( Qt::Horizontal, this ); |
171 | slider->setMinValue( 0 ); | 169 | slider->setMinValue( 0 ); |
172 | slider->setMaxValue( 1 ); | 170 | slider->setMaxValue( 1 ); |
173 | slider->setBackgroundPixmap( backgroundPixmap ); | 171 | slider->setBackgroundPixmap( backgroundPixmap ); |
174 | //slider->setFocusPolicy( QWidget::NoFocus ); | 172 | //slider->setFocusPolicy( QWidget::NoFocus ); |
175 | 173 | ||
176 | resizeEvent( 0 ); | 174 | resizeEvent( 0 ); |
177 | } | 175 | } |
178 | 176 | ||
179 | void VideoWidget::updateSlider( long i, long max ) { | 177 | void VideoWidget::updateSlider( long i, long max ) { |
180 | // Will flicker too much if we don't do this | 178 | // Will flicker too much if we don't do this |
181 | if ( max == 0 ) { | 179 | if ( max == 0 ) { |
182 | return; | 180 | return; |
183 | } | 181 | } |
184 | int width = slider->width(); | 182 | int width = slider->width(); |
185 | int val = int((double)i * width / max); | 183 | int val = int((double)i * width / max); |
186 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 184 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
187 | if ( slider->value() != val ) { | 185 | if ( slider->value() != val ) { |
188 | slider->setValue( val ); | 186 | slider->setValue( val ); |
189 | } | 187 | } |
190 | if ( slider->maxValue() != width ) { | 188 | if ( slider->maxValue() != width ) { |
191 | slider->setMaxValue( width ); | 189 | slider->setMaxValue( width ); |
192 | } | 190 | } |
193 | } | 191 | } |
194 | } | 192 | } |
195 | 193 | ||
196 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 194 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
197 | if ( mediaPlayerState.isFullscreen() ) { | 195 | if ( mediaPlayerState.isFullscreen() ) { |
198 | mediaPlayerState.setFullscreen( FALSE ); | 196 | mediaPlayerState.setFullscreen( FALSE ); |
199 | makeVisible(); | 197 | makeVisible(); |
200 | } | 198 | } |
201 | MediaWidget::mouseReleaseEvent( event ); | 199 | MediaWidget::mouseReleaseEvent( event ); |
202 | } | 200 | } |
203 | 201 | ||
204 | void VideoWidget::backToNormal() { | 202 | void VideoWidget::backToNormal() { |
205 | mediaPlayerState.setFullscreen( FALSE ); | 203 | mediaPlayerState.setFullscreen( FALSE ); |
206 | makeVisible(); | 204 | makeVisible(); |
207 | setToggleButton( FullScreen, false ); | 205 | setToggleButton( FullScreen, false ); |
208 | } | 206 | } |
209 | 207 | ||
210 | void VideoWidget::makeVisible() { | 208 | void VideoWidget::makeVisible() { |
211 | if ( mediaPlayerState.isFullscreen() ) { | 209 | if ( mediaPlayerState.isFullscreen() ) { |
212 | setBackgroundMode( QWidget::NoBackground ); | ||
213 | showFullScreen(); | 210 | showFullScreen(); |
214 | resize( qApp->desktop()->size() ); | 211 | resize( qApp->desktop()->size() ); |
215 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 212 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
216 | 213 | ||
217 | slider->hide(); | 214 | slider->hide(); |
218 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 215 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
219 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 216 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
220 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 217 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
221 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 218 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
222 | 219 | ||
223 | } else { | 220 | } else { |
224 | showNormal(); | 221 | showNormal(); |
225 | showMaximized(); | 222 | showMaximized(); |
226 | setBackgroundPixmap( backgroundPixmap ); | ||
227 | QWidget *d = QApplication::desktop(); | 223 | QWidget *d = QApplication::desktop(); |
228 | int w = d->width(); | 224 | int w = d->width(); |
229 | int h = d->height(); | 225 | int h = d->height(); |
230 | 226 | ||
231 | if(w>h) { | 227 | if(w>h) { |
232 | int newW=(w/2)-(246/2); //this will only work with 320x240 | 228 | int newW=(w/2)-(246/2); //this will only work with 320x240 |
233 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); | 229 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); |
234 | } else { | 230 | } else { |
235 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 231 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
236 | } | 232 | } |
237 | 233 | ||
238 | if ( !mediaPlayerState.isSeekable() ) { | 234 | if ( !mediaPlayerState.isSeekable() ) { |
239 | if( !slider->isHidden()) { | 235 | if( !slider->isHidden()) { |
240 | slider->hide(); | 236 | slider->hide(); |
241 | } | 237 | } |
242 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 238 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
243 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 239 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
244 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 240 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
245 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 241 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
246 | } else { | 242 | } else { |
247 | slider->show(); | 243 | slider->show(); |
248 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 244 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
249 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 245 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
250 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 246 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
251 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 247 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
252 | } | 248 | } |
253 | } | 249 | } |
254 | } | 250 | } |
255 | 251 | ||
256 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 252 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
257 | switch ( e->key() ) { | 253 | switch ( e->key() ) { |
258 | ////////////////////////////// Zaurus keys | 254 | ////////////////////////////// Zaurus keys |
259 | case Key_Home: | 255 | case Key_Home: |
260 | break; | 256 | break; |
261 | case Key_F9: //activity | 257 | case Key_F9: //activity |
262 | break; | 258 | break; |
263 | case Key_F10: //contacts | 259 | case Key_F10: //contacts |
264 | // hide(); | 260 | // hide(); |
265 | break; | 261 | break; |
266 | case Key_F11: //menu | 262 | case Key_F11: //menu |
267 | break; | 263 | break; |
268 | case Key_F12: //home | 264 | case Key_F12: //home |
269 | break; | 265 | break; |
270 | case Key_F13: //mail | 266 | case Key_F13: //mail |
271 | break; | 267 | break; |
272 | case Key_Space: { | 268 | case Key_Space: { |
273 | if(mediaPlayerState.isPlaying()) { | 269 | if(mediaPlayerState.isPlaying()) { |
274 | mediaPlayerState.setPlaying(FALSE); | 270 | mediaPlayerState.setPlaying(FALSE); |
275 | } else { | 271 | } else { |
276 | mediaPlayerState.setPlaying(TRUE); | 272 | mediaPlayerState.setPlaying(TRUE); |
277 | } | 273 | } |
278 | } | 274 | } |
279 | break; | 275 | break; |
280 | case Key_Down: | 276 | case Key_Down: |
281 | // toggleButton(6); | 277 | // toggleButton(6); |
282 | emit lessClicked(); | 278 | emit lessClicked(); |
283 | emit lessReleased(); | 279 | emit lessReleased(); |
284 | // toggleButton(6); | 280 | // toggleButton(6); |
285 | break; | 281 | break; |
286 | case Key_Up: | 282 | case Key_Up: |
287 | // toggleButton(5); | 283 | // toggleButton(5); |
288 | emit moreClicked(); | 284 | emit moreClicked(); |
289 | emit moreReleased(); | 285 | emit moreReleased(); |
290 | // toggleButton(5); | 286 | // toggleButton(5); |
291 | break; | 287 | break; |
292 | case Key_Right: | 288 | case Key_Right: |
293 | mediaPlayerState.setNext(); | 289 | mediaPlayerState.setNext(); |
294 | break; | 290 | break; |
295 | case Key_Left: | 291 | case Key_Left: |
296 | mediaPlayerState.setPrev(); | 292 | mediaPlayerState.setPrev(); |
297 | break; | 293 | break; |
298 | case Key_Escape: | 294 | case Key_Escape: |
299 | break; | 295 | break; |
300 | 296 | ||
301 | }; | 297 | }; |
302 | } | 298 | } |
303 | 299 | ||
304 | XineVideoWidget* VideoWidget::vidWidget() { | 300 | XineVideoWidget* VideoWidget::vidWidget() { |
305 | return videoFrame; | 301 | return videoFrame; |
306 | } | 302 | } |
307 | 303 | ||
308 | 304 | ||
309 | void VideoWidget::setFullscreen ( bool b ) { | 305 | void VideoWidget::setFullscreen ( bool b ) { |
310 | setToggleButton( FullScreen, b ); | 306 | setToggleButton( FullScreen, b ); |
311 | } | 307 | } |
312 | 308 | ||
313 | 309 | ||
314 | void VideoWidget::setPlaying( bool b) { | 310 | void VideoWidget::setPlaying( bool b) { |
315 | setToggleButton( Play, b ); | 311 | setToggleButton( Play, b ); |
316 | } | 312 | } |
317 | 313 | ||