-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 |
6 files changed, 7 insertions, 12 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 3070bc3..f6e6086 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,522 +1,517 @@ | |||
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 | static const int xo = -2; // movable x offset | 53 | static const int xo = -2; // movable x offset |
54 | static const int yo = 22; // movable y offset | 54 | static const int yo = 22; // movable y offset |
55 | 55 | ||
56 | struct MediaButton { | 56 | struct MediaButton { |
57 | bool isToggle, isHeld, isDown; | 57 | bool isToggle, isHeld, isDown; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | //Layout information for the audioButtons (and if it is a toggle button or not) | 60 | //Layout information for the audioButtons (and if it is a toggle button or not) |
61 | MediaButton audioButtons[] = { | 61 | MediaButton audioButtons[] = { |
62 | { TRUE, FALSE, FALSE }, // play | 62 | { TRUE, FALSE, FALSE }, // play |
63 | { FALSE, FALSE, FALSE }, // stop | 63 | { FALSE, FALSE, FALSE }, // stop |
64 | { FALSE, FALSE, FALSE }, // next | 64 | { FALSE, FALSE, FALSE }, // next |
65 | { FALSE, FALSE, FALSE }, // previous | 65 | { FALSE, FALSE, FALSE }, // previous |
66 | { FALSE, FALSE, FALSE }, // volume up | 66 | { FALSE, FALSE, FALSE }, // volume up |
67 | { FALSE, FALSE, FALSE }, // volume down | 67 | { FALSE, FALSE, FALSE }, // volume down |
68 | { TRUE, FALSE, FALSE }, // repeat/loop | 68 | { TRUE, FALSE, FALSE }, // repeat/loop |
69 | { FALSE, FALSE, FALSE }, // playlist | 69 | { FALSE, FALSE, FALSE }, // playlist |
70 | { FALSE, FALSE, FALSE }, // forward | 70 | { FALSE, FALSE, FALSE }, // forward |
71 | { FALSE, FALSE, FALSE } // back | 71 | { FALSE, FALSE, FALSE } // back |
72 | }; | 72 | }; |
73 | 73 | ||
74 | const char * const skin_mask_file_names[10] = { | 74 | const char * const skin_mask_file_names[10] = { |
75 | "play", "stop", "next", "prev", "up", | 75 | "play", "stop", "next", "prev", "up", |
76 | "down", "loop", "playlist", "forward", "back" | 76 | "down", "loop", "playlist", "forward", "back" |
77 | }; | 77 | }; |
78 | 78 | ||
79 | 79 | ||
80 | static void changeTextColor( QWidget *w ) { | 80 | static void changeTextColor( QWidget *w ) { |
81 | QPalette p = w->palette(); | 81 | QPalette p = w->palette(); |
82 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 82 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
83 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 83 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
84 | w->setPalette( p ); | 84 | w->setPalette( p ); |
85 | } | 85 | } |
86 | 86 | ||
87 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 87 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
88 | 88 | ||
89 | 89 | ||
90 | AudioWidget::AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 90 | AudioWidget::AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
91 | 91 | ||
92 | MediaWidget( mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 92 | MediaWidget( mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
93 | 93 | ||
94 | setCaption( tr("OpiePlayer") ); | 94 | setCaption( tr("OpiePlayer") ); |
95 | 95 | ||
96 | Config cfg("OpiePlayer"); | 96 | Config cfg("OpiePlayer"); |
97 | cfg.setGroup("Options"); | 97 | cfg.setGroup("Options"); |
98 | skin = cfg.readEntry("Skin","default"); | 98 | skin = cfg.readEntry("Skin","default"); |
99 | //skin = "scaleTest"; | 99 | //skin = "scaleTest"; |
100 | // color of background, frame, degree of transparency | 100 | // color of background, frame, degree of transparency |
101 | 101 | ||
102 | QString skinPath = "opieplayer2/skins/" + skin; | 102 | QString skinPath = "opieplayer2/skins/" + skin; |
103 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 103 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
104 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 104 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
105 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 105 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
106 | 106 | ||
107 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 107 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
108 | imgButtonMask.fill( 0 ); | 108 | imgButtonMask.fill( 0 ); |
109 | 109 | ||
110 | for ( int i = 0; i < 10; i++ ) { | 110 | for ( int i = 0; i < 10; i++ ) { |
111 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 111 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); |
112 | masks[i] = new QBitmap( filename ); | 112 | masks[i] = new QBitmap( filename ); |
113 | 113 | ||
114 | if ( !masks[i]->isNull() ) { | 114 | if ( !masks[i]->isNull() ) { |
115 | QImage imgMask = masks[i]->convertToImage(); | 115 | QImage imgMask = masks[i]->convertToImage(); |
116 | uchar **dest = imgButtonMask.jumpTable(); | 116 | uchar **dest = imgButtonMask.jumpTable(); |
117 | for ( int y = 0; y < imgUp.height(); y++ ) { | 117 | for ( int y = 0; y < imgUp.height(); y++ ) { |
118 | uchar *line = dest[y]; | 118 | uchar *line = dest[y]; |
119 | for ( int x = 0; x < imgUp.width(); x++ ) | 119 | for ( int x = 0; x < imgUp.width(); x++ ) |
120 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 120 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
121 | line[x] = i + 1; | 121 | line[x] = i + 1; |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | } | 125 | } |
126 | 126 | ||
127 | for ( int i = 0; i < 10; i++ ) { | 127 | for ( int i = 0; i < 10; i++ ) { |
128 | buttonPixUp[i] = 0l; | 128 | buttonPixUp[i] = 0l; |
129 | buttonPixDown[i] = 0l; | 129 | buttonPixDown[i] = 0l; |
130 | } | 130 | } |
131 | 131 | ||
132 | setBackgroundPixmap( pixBg ); | 132 | setBackgroundPixmap( pixBg ); |
133 | 133 | ||
134 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 134 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
135 | // changeTextColor( &songInfo ); | 135 | // changeTextColor( &songInfo ); |
136 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 136 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
137 | // songInfo.setFrameStyle( QFrame::NoFrame); | 137 | // songInfo.setFrameStyle( QFrame::NoFrame); |
138 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 138 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
139 | // songInfo.setForegroundColor(Qt::white); | 139 | // songInfo.setForegroundColor(Qt::white); |
140 | 140 | ||
141 | slider.setFixedHeight( 20 ); | 141 | slider.setFixedHeight( 20 ); |
142 | slider.setMinValue( 0 ); | 142 | slider.setMinValue( 0 ); |
143 | slider.setMaxValue( 1 ); | 143 | slider.setMaxValue( 1 ); |
144 | slider.setFocusPolicy( QWidget::NoFocus ); | 144 | slider.setFocusPolicy( QWidget::NoFocus ); |
145 | slider.setBackgroundPixmap( pixBg ); | 145 | slider.setBackgroundPixmap( pixBg ); |
146 | 146 | ||
147 | // Config cofg("qpe"); | 147 | // Config cofg("qpe"); |
148 | // cofg.setGroup("Appearance"); | 148 | // cofg.setGroup("Appearance"); |
149 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | 149 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); |
150 | 150 | ||
151 | time.setFocusPolicy( QWidget::NoFocus ); | 151 | time.setFocusPolicy( QWidget::NoFocus ); |
152 | time.setAlignment( Qt::AlignCenter ); | 152 | time.setAlignment( Qt::AlignCenter ); |
153 | 153 | ||
154 | // time.setFrame(FALSE); | 154 | // time.setFrame(FALSE); |
155 | // changeTextColor( &time ); | 155 | // changeTextColor( &time ); |
156 | 156 | ||
157 | resizeEvent( NULL ); | 157 | resizeEvent( NULL ); |
158 | 158 | ||
159 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 159 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
160 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); | 160 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); |
161 | 161 | ||
162 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 162 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
163 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 163 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
164 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 164 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
165 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 165 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
166 | 166 | ||
167 | // Intialise state | 167 | // Intialise state |
168 | setLength( mediaPlayerState.length() ); | 168 | setLength( mediaPlayerState.length() ); |
169 | setPosition( mediaPlayerState.position() ); | 169 | setPosition( mediaPlayerState.position() ); |
170 | setLooping( mediaPlayerState.isFullscreen() ); | 170 | setLooping( mediaPlayerState.isFullscreen() ); |
171 | // setPaused( mediaPlayerState->paused() ); | 171 | // setPaused( mediaPlayerState->paused() ); |
172 | setPlaying( mediaPlayerState.isPlaying() ); | 172 | setPlaying( mediaPlayerState.isPlaying() ); |
173 | 173 | ||
174 | } | 174 | } |
175 | 175 | ||
176 | AudioWidget::~AudioWidget() { | 176 | AudioWidget::~AudioWidget() { |
177 | 177 | ||
178 | for ( int i = 0; i < 10; i++ ) { | 178 | for ( int i = 0; i < 10; i++ ) { |
179 | delete buttonPixUp[i]; | 179 | delete buttonPixUp[i]; |
180 | delete buttonPixDown[i]; | 180 | delete buttonPixDown[i]; |
181 | } | 181 | } |
182 | for ( int i = 0; i < 10; i++ ) { | 182 | for ( int i = 0; i < 10; i++ ) { |
183 | delete masks[i]; | 183 | delete masks[i]; |
184 | } | 184 | } |
185 | // mediaPlayerState->setPlaying(false); | 185 | // mediaPlayerState->setPlaying(false); |
186 | } | 186 | } |
187 | 187 | ||
188 | namespace { | 188 | namespace { |
189 | 189 | ||
190 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 190 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
191 | QPixmap pix( img.width(), img.height() ); | 191 | QPixmap pix( img.width(), img.height() ); |
192 | QPainter p( &pix ); | 192 | QPainter p( &pix ); |
193 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 193 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
194 | p.drawImage( 0, 0, img ); | 194 | p.drawImage( 0, 0, img ); |
195 | return pix; | 195 | return pix; |
196 | } | 196 | } |
197 | 197 | ||
198 | 198 | ||
199 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { | 199 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { |
200 | QPixmap *pixmap = new QPixmap( pix ); | 200 | QPixmap *pixmap = new QPixmap( pix ); |
201 | pixmap->setMask( mask ); | 201 | pixmap->setMask( mask ); |
202 | return pixmap; | 202 | return pixmap; |
203 | } | 203 | } |
204 | 204 | ||
205 | }; | 205 | }; |
206 | 206 | ||
207 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 207 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
208 | int h = height(); | 208 | int h = height(); |
209 | int w = width(); | 209 | int w = width(); |
210 | 210 | ||
211 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 211 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
212 | slider.setFixedWidth( w - 110 ); | 212 | slider.setFixedWidth( w - 110 ); |
213 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 213 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
214 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 214 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
215 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 215 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
216 | 216 | ||
217 | xoff = ( w - imgUp.width() ) / 2; | 217 | xoff = ( w - imgUp.width() ) / 2; |
218 | yoff = (( h - imgUp.height() ) / 2) - 10; | 218 | yoff = (( h - imgUp.height() ) / 2) - 10; |
219 | QPoint p( xoff, yoff ); | 219 | QPoint p( xoff, yoff ); |
220 | 220 | ||
221 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); | 221 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); |
222 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); | 222 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); |
223 | 223 | ||
224 | for ( int i = 0; i < 10; i++ ) { | 224 | for ( int i = 0; i < 10; i++ ) { |
225 | if ( !masks[i]->isNull() ) { | 225 | if ( !masks[i]->isNull() ) { |
226 | delete buttonPixUp[i]; | 226 | delete buttonPixUp[i]; |
227 | delete buttonPixDown[i]; | 227 | delete buttonPixDown[i]; |
228 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); | 228 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); |
229 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); | 229 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | } | 232 | } |
233 | 233 | ||
234 | static bool audioSliderBeingMoved = FALSE; | 234 | static bool audioSliderBeingMoved = FALSE; |
235 | 235 | ||
236 | 236 | ||
237 | void AudioWidget::sliderPressed() { | 237 | void AudioWidget::sliderPressed() { |
238 | audioSliderBeingMoved = TRUE; | 238 | audioSliderBeingMoved = TRUE; |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | void AudioWidget::sliderReleased() { | 242 | void AudioWidget::sliderReleased() { |
243 | audioSliderBeingMoved = FALSE; | 243 | audioSliderBeingMoved = FALSE; |
244 | if ( slider.width() == 0 ) | 244 | if ( slider.width() == 0 ) |
245 | return; | 245 | return; |
246 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); | 246 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); |
247 | mediaPlayerState.setPosition( val ); | 247 | mediaPlayerState.setPosition( val ); |
248 | } | 248 | } |
249 | 249 | ||
250 | void AudioWidget::setPosition( long i ) { | 250 | void AudioWidget::setPosition( long i ) { |
251 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 251 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
252 | updateSlider( i, mediaPlayerState.length() ); | 252 | updateSlider( i, mediaPlayerState.length() ); |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | void AudioWidget::setLength( long max ) { | 256 | void AudioWidget::setLength( long max ) { |
257 | updateSlider( mediaPlayerState.position(), max ); | 257 | updateSlider( mediaPlayerState.position(), max ); |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 261 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
262 | if ( mediaType == MediaPlayerState::Audio ) { | 262 | if ( mediaType == MediaPlayerState::Audio ) { |
263 | // startTimer( 150 ); | 263 | // startTimer( 150 ); |
264 | showMaximized(); | 264 | showMaximized(); |
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | killTimers(); | 268 | killTimers(); |
269 | hide(); | 269 | hide(); |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | void AudioWidget::setSeekable( bool isSeekable ) { | 273 | void AudioWidget::setSeekable( bool isSeekable ) { |
274 | 274 | ||
275 | if ( !isSeekable ) { | 275 | if ( !isSeekable ) { |
276 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 276 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
277 | if( !slider.isHidden()) { | 277 | if( !slider.isHidden()) { |
278 | slider.hide(); | 278 | slider.hide(); |
279 | } | 279 | } |
280 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 280 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
281 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 281 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
282 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 282 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
283 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 283 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
284 | } else { | 284 | } else { |
285 | // this stops the slider from being moved, thus | 285 | // this stops the slider from being moved, thus |
286 | // does not stop stream when it reaches the end | 286 | // does not stop stream when it reaches the end |
287 | slider.show(); | 287 | slider.show(); |
288 | qDebug( " CONNECT SET POSTION " ); | 288 | qDebug( " CONNECT SET POSTION " ); |
289 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 289 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
290 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 290 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
291 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 291 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
292 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 292 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
293 | } | 293 | } |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | static QString timeAsString( long length ) { | 297 | static QString timeAsString( long length ) { |
298 | int minutes = length / 60; | 298 | int minutes = length / 60; |
299 | int seconds = length % 60; | 299 | int seconds = length % 60; |
300 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 300 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
301 | } | 301 | } |
302 | 302 | ||
303 | void AudioWidget::updateSlider( long i, long max ) { | 303 | void AudioWidget::updateSlider( long i, long max ) { |
304 | 304 | ||
305 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 305 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
306 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 306 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
307 | 307 | ||
308 | if ( max == 0 ) { | 308 | if ( max == 0 ) { |
309 | return; | 309 | return; |
310 | } | 310 | } |
311 | // Will flicker too much if we don't do this | 311 | // Will flicker too much if we don't do this |
312 | // Scale to something reasonable | 312 | // Scale to something reasonable |
313 | int width = slider.width(); | 313 | int width = slider.width(); |
314 | int val = int((double)i * width / max); | 314 | int val = int((double)i * width / max); |
315 | if ( !audioSliderBeingMoved ) { | 315 | if ( !audioSliderBeingMoved ) { |
316 | if ( slider.value() != val ) { | 316 | if ( slider.value() != val ) { |
317 | slider.setValue( val ); | 317 | slider.setValue( val ); |
318 | } | 318 | } |
319 | 319 | ||
320 | if ( slider.maxValue() != width ) { | 320 | if ( slider.maxValue() != width ) { |
321 | slider.setMaxValue( width ); | 321 | slider.setMaxValue( width ); |
322 | } | 322 | } |
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
326 | 326 | ||
327 | void AudioWidget::setToggleButton( int i, bool down ) { | 327 | void AudioWidget::setToggleButton( int i, bool down ) { |
328 | qDebug("setToggleButton %d", i); | 328 | qDebug("setToggleButton %d", i); |
329 | if ( down != audioButtons[i].isDown ) { | 329 | if ( down != audioButtons[i].isDown ) { |
330 | toggleButton( i ); | 330 | toggleButton( i ); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | void AudioWidget::toggleButton( int i ) { | 335 | void AudioWidget::toggleButton( int i ) { |
336 | audioButtons[i].isDown = !audioButtons[i].isDown; | 336 | audioButtons[i].isDown = !audioButtons[i].isDown; |
337 | QPainter p(this); | 337 | QPainter p(this); |
338 | paintButton ( &p, i ); | 338 | paintButton ( &p, i ); |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void AudioWidget::paintButton( QPainter *p, int i ) { | 342 | void AudioWidget::paintButton( QPainter *p, int i ) { |
343 | if ( audioButtons[i].isDown ) { | 343 | if ( audioButtons[i].isDown ) { |
344 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 344 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
345 | } else { | 345 | } else { |
346 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 346 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | 350 | ||
351 | void AudioWidget::skipFor() { | 351 | void AudioWidget::skipFor() { |
352 | skipDirection = +1; | 352 | skipDirection = +1; |
353 | startTimer( 50 ); | 353 | startTimer( 50 ); |
354 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 354 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
355 | } | 355 | } |
356 | 356 | ||
357 | void AudioWidget::skipBack() { | 357 | void AudioWidget::skipBack() { |
358 | skipDirection = -1; | 358 | skipDirection = -1; |
359 | startTimer( 50 ); | 359 | startTimer( 50 ); |
360 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 360 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | 364 | ||
365 | void AudioWidget::stopSkip() { | 365 | void AudioWidget::stopSkip() { |
366 | killTimers(); | 366 | killTimers(); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | void AudioWidget::timerEvent( QTimerEvent * ) { | 370 | void AudioWidget::timerEvent( QTimerEvent * ) { |
371 | if ( skipDirection == +1 ) { | 371 | if ( skipDirection == +1 ) { |
372 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 372 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
373 | } else if ( skipDirection == -1 ) { | 373 | } else if ( skipDirection == -1 ) { |
374 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 374 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | 377 | ||
378 | 378 | ||
379 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 379 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
380 | for ( int i = 0; i < numButtons; i++ ) { | 380 | for ( int i = 0; i < numButtons; i++ ) { |
381 | if ( event->state() == QMouseEvent::LeftButton ) { | 381 | if ( event->state() == QMouseEvent::LeftButton ) { |
382 | // The test to see if the mouse click is inside the button or not | 382 | // The test to see if the mouse click is inside the button or not |
383 | int x = event->pos().x() - xoff; | 383 | int x = event->pos().x() - xoff; |
384 | int y = event->pos().y() - yoff; | 384 | int y = event->pos().y() - yoff; |
385 | 385 | ||
386 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() | 386 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() |
387 | && y < imgButtonMask.height() | 387 | && y < imgButtonMask.height() |
388 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); | 388 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); |
389 | 389 | ||
390 | if ( isOnButton && !audioButtons[i].isHeld ) { | 390 | if ( isOnButton && !audioButtons[i].isHeld ) { |
391 | audioButtons[i].isHeld = TRUE; | 391 | audioButtons[i].isHeld = TRUE; |
392 | toggleButton(i); | 392 | toggleButton(i); |
393 | switch (i) { | 393 | switch (i) { |
394 | case VolumeUp: | 394 | case VolumeUp: |
395 | emit moreClicked(); | 395 | emit moreClicked(); |
396 | return; | 396 | return; |
397 | case VolumeDown: | 397 | case VolumeDown: |
398 | emit lessClicked(); | 398 | emit lessClicked(); |
399 | return; | 399 | return; |
400 | case Forward: | 400 | case Forward: |
401 | emit forwardClicked(); | 401 | emit forwardClicked(); |
402 | return; | 402 | return; |
403 | case Back: | 403 | case Back: |
404 | emit backClicked(); | 404 | emit backClicked(); |
405 | return; | 405 | return; |
406 | } | 406 | } |
407 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 407 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
408 | audioButtons[i].isHeld = FALSE; | 408 | audioButtons[i].isHeld = FALSE; |
409 | toggleButton(i); | 409 | toggleButton(i); |
410 | } | 410 | } |
411 | } else { | 411 | } else { |
412 | if ( audioButtons[i].isHeld ) { | 412 | if ( audioButtons[i].isHeld ) { |
413 | audioButtons[i].isHeld = FALSE; | 413 | audioButtons[i].isHeld = FALSE; |
414 | if ( !audioButtons[i].isToggle ) { | 414 | if ( !audioButtons[i].isToggle ) { |
415 | setToggleButton( i, FALSE ); | 415 | setToggleButton( i, FALSE ); |
416 | } | 416 | } |
417 | qDebug("mouseEvent %d", i); | 417 | qDebug("mouseEvent %d", i); |
418 | handleCommand( static_cast<Command>( i ), audioButtons[ i ].isDown ); | 418 | handleCommand( static_cast<Command>( i ), audioButtons[ i ].isDown ); |
419 | } | 419 | } |
420 | } | 420 | } |
421 | } | 421 | } |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 425 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
426 | mouseMoveEvent( event ); | 426 | mouseMoveEvent( event ); |
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 430 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
431 | mouseMoveEvent( event ); | 431 | mouseMoveEvent( event ); |
432 | } | 432 | } |
433 | 433 | ||
434 | 434 | ||
435 | void AudioWidget::showEvent( QShowEvent* ) { | 435 | void AudioWidget::showEvent( QShowEvent* ) { |
436 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 436 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
437 | mouseMoveEvent( &event ); | 437 | mouseMoveEvent( &event ); |
438 | } | 438 | } |
439 | 439 | ||
440 | 440 | ||
441 | void AudioWidget::closeEvent( QCloseEvent* ) { | ||
442 | mediaPlayerState.setList(); | ||
443 | } | ||
444 | |||
445 | |||
446 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | 441 | void AudioWidget::paintEvent( QPaintEvent * pe ) { |
447 | if ( !pe->erased() ) { | 442 | if ( !pe->erased() ) { |
448 | // Combine with background and double buffer | 443 | // Combine with background and double buffer |
449 | QPixmap pix( pe->rect().size() ); | 444 | QPixmap pix( pe->rect().size() ); |
450 | QPainter p( &pix ); | 445 | QPainter p( &pix ); |
451 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 446 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
452 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); | 447 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); |
453 | for ( int i = 0; i < numButtons; i++ ) | 448 | for ( int i = 0; i < numButtons; i++ ) |
454 | paintButton( &p, i ); | 449 | paintButton( &p, i ); |
455 | QPainter p2( this ); | 450 | QPainter p2( this ); |
456 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 451 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
457 | } else { | 452 | } else { |
458 | QPainter p( this ); | 453 | QPainter p( this ); |
459 | for ( int i = 0; i < numButtons; i++ ) | 454 | for ( int i = 0; i < numButtons; i++ ) |
460 | paintButton( &p, i ); | 455 | paintButton( &p, i ); |
461 | } | 456 | } |
462 | } | 457 | } |
463 | 458 | ||
464 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 459 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
465 | switch ( e->key() ) { | 460 | switch ( e->key() ) { |
466 | ////////////////////////////// Zaurus keys | 461 | ////////////////////////////// Zaurus keys |
467 | case Key_Home: | 462 | case Key_Home: |
468 | break; | 463 | break; |
469 | case Key_F9: //activity | 464 | case Key_F9: //activity |
470 | hide(); | 465 | hide(); |
471 | // qDebug("Audio F9"); | 466 | // qDebug("Audio F9"); |
472 | break; | 467 | break; |
473 | case Key_F10: //contacts | 468 | case Key_F10: //contacts |
474 | break; | 469 | break; |
475 | case Key_F11: //menu | 470 | case Key_F11: //menu |
476 | mediaPlayerState.toggleBlank(); | 471 | mediaPlayerState.toggleBlank(); |
477 | break; | 472 | break; |
478 | case Key_F12: //home | 473 | case Key_F12: //home |
479 | break; | 474 | break; |
480 | case Key_F13: //mail | 475 | case Key_F13: //mail |
481 | mediaPlayerState.toggleBlank(); | 476 | mediaPlayerState.toggleBlank(); |
482 | break; | 477 | break; |
483 | case Key_Space: { | 478 | case Key_Space: { |
484 | if(mediaPlayerState.isPlaying()) { | 479 | if(mediaPlayerState.isPlaying()) { |
485 | // toggleButton(1); | 480 | // toggleButton(1); |
486 | mediaPlayerState.setPlaying(FALSE); | 481 | mediaPlayerState.setPlaying(FALSE); |
487 | // toggleButton(1); | 482 | // toggleButton(1); |
488 | } else { | 483 | } else { |
489 | // toggleButton(0); | 484 | // toggleButton(0); |
490 | mediaPlayerState.setPlaying(TRUE); | 485 | mediaPlayerState.setPlaying(TRUE); |
491 | // toggleButton(0); | 486 | // toggleButton(0); |
492 | } | 487 | } |
493 | } | 488 | } |
494 | break; | 489 | break; |
495 | case Key_Down: | 490 | case Key_Down: |
496 | // toggleButton(6); | 491 | // toggleButton(6); |
497 | emit lessClicked(); | 492 | emit lessClicked(); |
498 | emit lessReleased(); | 493 | emit lessReleased(); |
499 | // toggleButton(6); | 494 | // toggleButton(6); |
500 | break; | 495 | break; |
501 | case Key_Up: | 496 | case Key_Up: |
502 | // toggleButton(5); | 497 | // toggleButton(5); |
503 | emit moreClicked(); | 498 | emit moreClicked(); |
504 | emit moreReleased(); | 499 | emit moreReleased(); |
505 | // toggleButton(5); | 500 | // toggleButton(5); |
506 | break; | 501 | break; |
507 | case Key_Right: | 502 | case Key_Right: |
508 | // toggleButton(3); | 503 | // toggleButton(3); |
509 | mediaPlayerState.setNext(); | 504 | mediaPlayerState.setNext(); |
510 | // toggleButton(3); | 505 | // toggleButton(3); |
511 | break; | 506 | break; |
512 | case Key_Left: | 507 | case Key_Left: |
513 | // toggleButton(4); | 508 | // toggleButton(4); |
514 | mediaPlayerState.setPrev(); | 509 | mediaPlayerState.setPrev(); |
515 | // toggleButton(4); | 510 | // toggleButton(4); |
516 | break; | 511 | break; |
517 | case Key_Escape: { | 512 | case Key_Escape: { |
518 | } | 513 | } |
519 | break; | 514 | break; |
520 | 515 | ||
521 | }; | 516 | }; |
522 | } | 517 | } |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 1778a30..f092699 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -1,118 +1,117 @@ | |||
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 | #ifndef AUDIO_WIDGET_H | 34 | #ifndef AUDIO_WIDGET_H |
35 | #define AUDIO_WIDGET_H | 35 | #define AUDIO_WIDGET_H |
36 | 36 | ||
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | #include <qdrawutil.h> | 38 | #include <qdrawutil.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include <qstring.h> | 40 | #include <qstring.h> |
41 | #include <qslider.h> | 41 | #include <qslider.h> |
42 | #include <qframe.h> | 42 | #include <qframe.h> |
43 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
44 | #include <qimage.h> | 44 | #include <qimage.h> |
45 | 45 | ||
46 | #include <opie/oticker.h> | 46 | #include <opie/oticker.h> |
47 | 47 | ||
48 | #include "mediawidget.h" | 48 | #include "mediawidget.h" |
49 | 49 | ||
50 | class QPixmap; | 50 | class QPixmap; |
51 | 51 | ||
52 | class AudioWidget : public MediaWidget { | 52 | class AudioWidget : public MediaWidget { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | public: | 54 | public: |
55 | AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 55 | AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
56 | ~AudioWidget(); | 56 | ~AudioWidget(); |
57 | void setTickerText( const QString &text ) { songInfo.setText( text ); } | 57 | void setTickerText( const QString &text ) { songInfo.setText( text ); } |
58 | public slots: | 58 | public slots: |
59 | void updateSlider( long, long ); | 59 | void updateSlider( long, long ); |
60 | void sliderPressed( ); | 60 | void sliderPressed( ); |
61 | void sliderReleased( ); | 61 | void sliderReleased( ); |
62 | void setLooping( bool b) { setToggleButton( Loop, b ); } | 62 | void setLooping( bool b) { setToggleButton( Loop, b ); } |
63 | void setPosition( long ); | 63 | void setPosition( long ); |
64 | void setSeekable( bool ); | 64 | void setSeekable( bool ); |
65 | 65 | ||
66 | public: | 66 | public: |
67 | virtual void setLength( long ); | 67 | virtual void setLength( long ); |
68 | virtual void setPlaying( bool b) { setToggleButton( Play, b ); } | 68 | virtual void setPlaying( bool b) { setToggleButton( Play, b ); } |
69 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 69 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
70 | 70 | ||
71 | signals: | 71 | signals: |
72 | void moreClicked(); | 72 | void moreClicked(); |
73 | void lessClicked(); | 73 | void lessClicked(); |
74 | void forwardClicked(); | 74 | void forwardClicked(); |
75 | void backClicked(); | 75 | void backClicked(); |
76 | void sliderMoved(long); | 76 | void sliderMoved(long); |
77 | 77 | ||
78 | protected: | 78 | protected: |
79 | void doBlank(); | 79 | void doBlank(); |
80 | void doUnblank(); | 80 | void doUnblank(); |
81 | void paintEvent( QPaintEvent *pe ); | 81 | void paintEvent( QPaintEvent *pe ); |
82 | void showEvent( QShowEvent *se ); | 82 | void showEvent( QShowEvent *se ); |
83 | void resizeEvent( QResizeEvent *re ); | 83 | void resizeEvent( QResizeEvent *re ); |
84 | void mouseMoveEvent( QMouseEvent *event ); | 84 | void mouseMoveEvent( QMouseEvent *event ); |
85 | void mousePressEvent( QMouseEvent *event ); | 85 | void mousePressEvent( QMouseEvent *event ); |
86 | void mouseReleaseEvent( QMouseEvent *event ); | 86 | void mouseReleaseEvent( QMouseEvent *event ); |
87 | void timerEvent( QTimerEvent *event ); | 87 | void timerEvent( QTimerEvent *event ); |
88 | void closeEvent( QCloseEvent *event ); | ||
89 | void keyReleaseEvent( QKeyEvent *e); | 88 | void keyReleaseEvent( QKeyEvent *e); |
90 | private slots: | 89 | private slots: |
91 | void skipFor(); | 90 | void skipFor(); |
92 | void skipBack(); | 91 | void skipBack(); |
93 | void stopSkip(); | 92 | void stopSkip(); |
94 | private: | 93 | private: |
95 | void toggleButton( int ); | 94 | void toggleButton( int ); |
96 | void setToggleButton( int, bool ); | 95 | void setToggleButton( int, bool ); |
97 | void paintButton( QPainter *p, int i ); | 96 | void paintButton( QPainter *p, int i ); |
98 | int skipDirection; | 97 | int skipDirection; |
99 | QString skin; | 98 | QString skin; |
100 | QPixmap pixBg; | 99 | QPixmap pixBg; |
101 | QImage imgUp; | 100 | QImage imgUp; |
102 | QImage imgDn; | 101 | QImage imgDn; |
103 | QImage imgButtonMask; | 102 | QImage imgButtonMask; |
104 | QBitmap *masks[10]; | 103 | QBitmap *masks[10]; |
105 | QPixmap *buttonPixUp[10]; | 104 | QPixmap *buttonPixUp[10]; |
106 | QPixmap *buttonPixDown[10]; | 105 | QPixmap *buttonPixDown[10]; |
107 | 106 | ||
108 | QPixmap *pixmaps[4]; | 107 | QPixmap *pixmaps[4]; |
109 | OTicker songInfo; | 108 | OTicker songInfo; |
110 | QSlider slider; | 109 | QSlider slider; |
111 | QLineEdit time; | 110 | QLineEdit time; |
112 | int xoff, yoff; | 111 | int xoff, yoff; |
113 | bool isStreaming : 1; | 112 | bool isStreaming : 1; |
114 | }; | 113 | }; |
115 | 114 | ||
116 | 115 | ||
117 | #endif // AUDIO_WIDGET_H | 116 | #endif // AUDIO_WIDGET_H |
118 | 117 | ||
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 01a7295..2992fd6 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -1,58 +1,63 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | 20 | ||
21 | #include "mediawidget.h" | 21 | #include "mediawidget.h" |
22 | #include "playlistwidget.h" | 22 | #include "playlistwidget.h" |
23 | 23 | ||
24 | extern PlayListWidget *playList; | 24 | extern PlayListWidget *playList; |
25 | 25 | ||
26 | MediaWidget::MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) | 26 | MediaWidget::MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) |
27 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ) | 27 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ) |
28 | { | 28 | { |
29 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), | 29 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), |
30 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); | 30 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); |
31 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), | 31 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), |
32 | this, SLOT( setLength( long ) ) ); | 32 | this, SLOT( setLength( long ) ) ); |
33 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 33 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
34 | this, SLOT( setPlaying( bool ) ) ); | 34 | this, SLOT( setPlaying( bool ) ) ); |
35 | } | 35 | } |
36 | 36 | ||
37 | MediaWidget::~MediaWidget() | 37 | MediaWidget::~MediaWidget() |
38 | { | 38 | { |
39 | } | 39 | } |
40 | 40 | ||
41 | void MediaWidget::closeEvent( QCloseEvent * ) | ||
42 | { | ||
43 | mediaPlayerState.setList(); | ||
44 | } | ||
45 | |||
41 | void MediaWidget::handleCommand( Command command, bool buttonDown ) | 46 | void MediaWidget::handleCommand( Command command, bool buttonDown ) |
42 | { | 47 | { |
43 | switch ( command ) { | 48 | switch ( command ) { |
44 | case Play: mediaPlayerState.togglePaused(); | 49 | case Play: mediaPlayerState.togglePaused(); |
45 | case Stop: mediaPlayerState.setPlaying(FALSE); return; | 50 | case Stop: mediaPlayerState.setPlaying(FALSE); return; |
46 | case Next: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 51 | case Next: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
47 | case Previous: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 52 | case Previous: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
48 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; | 53 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; |
49 | case VolumeUp: emit moreReleased(); return; | 54 | case VolumeUp: emit moreReleased(); return; |
50 | case VolumeDown: emit lessReleased(); return; | 55 | case VolumeDown: emit lessReleased(); return; |
51 | case PlayList: mediaPlayerState.setList(); return; | 56 | case PlayList: mediaPlayerState.setList(); return; |
52 | case Forward: emit forwardReleased(); return; | 57 | case Forward: emit forwardReleased(); return; |
53 | case Back: emit backReleased(); return; | 58 | case Back: emit backReleased(); return; |
54 | } | 59 | } |
55 | } | 60 | } |
56 | 61 | ||
57 | /* vim: et sw=4 ts=4 | 62 | /* vim: et sw=4 ts=4 |
58 | */ | 63 | */ |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 550f0fc..e3f09ce 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -1,55 +1,57 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #ifndef MEDIAWIDGET_H | 20 | #ifndef MEDIAWIDGET_H |
21 | #define MEDIAWIDGET_H | 21 | #define MEDIAWIDGET_H |
22 | 22 | ||
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | 24 | ||
25 | #include "mediaplayerstate.h" | 25 | #include "mediaplayerstate.h" |
26 | 26 | ||
27 | class MediaWidget : public QWidget | 27 | class MediaWidget : public QWidget |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; | 31 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; |
32 | 32 | ||
33 | MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); | 33 | MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); |
34 | virtual ~MediaWidget(); | 34 | virtual ~MediaWidget(); |
35 | 35 | ||
36 | public slots: | 36 | public slots: |
37 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; | 37 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; |
38 | virtual void setLength( long length ) = 0; | 38 | virtual void setLength( long length ) = 0; |
39 | virtual void setPlaying( bool playing ) = 0; | 39 | virtual void setPlaying( bool playing ) = 0; |
40 | 40 | ||
41 | signals: | 41 | signals: |
42 | void moreReleased(); | 42 | void moreReleased(); |
43 | void lessReleased(); | 43 | void lessReleased(); |
44 | void forwardReleased(); | 44 | void forwardReleased(); |
45 | void backReleased(); | 45 | void backReleased(); |
46 | 46 | ||
47 | protected: | 47 | protected: |
48 | virtual void closeEvent( QCloseEvent * ); | ||
49 | |||
48 | void handleCommand( Command command, bool buttonDown ); | 50 | void handleCommand( Command command, bool buttonDown ); |
49 | 51 | ||
50 | MediaPlayerState &mediaPlayerState; | 52 | MediaPlayerState &mediaPlayerState; |
51 | }; | 53 | }; |
52 | 54 | ||
53 | #endif // MEDIAWIDGET_H | 55 | #endif // MEDIAWIDGET_H |
54 | /* vim: et sw=4 ts=4 | 56 | /* vim: et sw=4 ts=4 |
55 | */ | 57 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index b4ecb4c..41dddb7 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,516 +1,511 @@ | |||
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 | extern PlayListWidget *playList; | 56 | extern PlayListWidget *playList; |
57 | 57 | ||
58 | 58 | ||
59 | static const int xo = 2; // movable x offset | 59 | static const int xo = 2; // movable x offset |
60 | static const int yo = 0; // movable y offset | 60 | static const int yo = 0; // movable y offset |
61 | 61 | ||
62 | 62 | ||
63 | struct MediaButton { | 63 | struct MediaButton { |
64 | bool isToggle, isHeld, isDown; | 64 | bool isToggle, isHeld, isDown; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | MediaButton videoButtons[] = { | 67 | MediaButton videoButtons[] = { |
68 | { FALSE, FALSE, FALSE }, // stop | 68 | { FALSE, FALSE, FALSE }, // stop |
69 | { TRUE, FALSE, FALSE }, // play | 69 | { TRUE, FALSE, FALSE }, // play |
70 | { FALSE, FALSE, FALSE }, // previous | 70 | { FALSE, FALSE, FALSE }, // previous |
71 | { FALSE, FALSE, FALSE }, // next | 71 | { FALSE, FALSE, FALSE }, // next |
72 | { FALSE, FALSE, FALSE }, // volUp | 72 | { FALSE, FALSE, FALSE }, // volUp |
73 | { FALSE, FALSE, FALSE }, // volDown | 73 | { FALSE, FALSE, FALSE }, // volDown |
74 | { TRUE, FALSE, FALSE } // fullscreen | 74 | { TRUE, FALSE, FALSE } // fullscreen |
75 | }; | 75 | }; |
76 | 76 | ||
77 | const char *skinV_mask_file_names[7] = { | 77 | const char *skinV_mask_file_names[7] = { |
78 | "stop","play","back","fwd","up","down","full" | 78 | "stop","play","back","fwd","up","down","full" |
79 | }; | 79 | }; |
80 | 80 | ||
81 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 81 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
82 | 82 | ||
83 | 83 | ||
84 | VideoWidget::VideoWidget(MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 84 | VideoWidget::VideoWidget(MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
85 | MediaWidget( mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) { | 85 | MediaWidget( mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) { |
86 | 86 | ||
87 | 87 | ||
88 | setCaption( tr("OpiePlayer - Video") ); | 88 | setCaption( tr("OpiePlayer - Video") ); |
89 | 89 | ||
90 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 90 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
91 | 91 | ||
92 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 92 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
93 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 93 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
94 | 94 | ||
95 | Config cfg("OpiePlayer"); | 95 | Config cfg("OpiePlayer"); |
96 | cfg.setGroup("Options"); | 96 | cfg.setGroup("Options"); |
97 | skin = cfg.readEntry("Skin","default"); | 97 | skin = cfg.readEntry("Skin","default"); |
98 | 98 | ||
99 | QString skinPath = "opieplayer2/skins/" + skin; | 99 | QString skinPath = "opieplayer2/skins/" + skin; |
100 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 100 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
101 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 101 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
102 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 102 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
103 | 103 | ||
104 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 104 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
105 | imgButtonMask->fill( 0 ); | 105 | imgButtonMask->fill( 0 ); |
106 | 106 | ||
107 | for ( int i = 0; i < 7; i++ ) { | 107 | for ( int i = 0; i < 7; i++ ) { |
108 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 108 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
109 | masks[i] = new QBitmap( filename ); | 109 | masks[i] = new QBitmap( filename ); |
110 | 110 | ||
111 | if ( !masks[i]->isNull() ) { | 111 | if ( !masks[i]->isNull() ) { |
112 | QImage imgMask = masks[i]->convertToImage(); | 112 | QImage imgMask = masks[i]->convertToImage(); |
113 | uchar **dest = imgButtonMask->jumpTable(); | 113 | uchar **dest = imgButtonMask->jumpTable(); |
114 | for ( int y = 0; y < imgUp->height(); y++ ) { | 114 | for ( int y = 0; y < imgUp->height(); y++ ) { |
115 | uchar *line = dest[y]; | 115 | uchar *line = dest[y]; |
116 | for ( int x = 0; x < imgUp->width(); x++ ) { | 116 | for ( int x = 0; x < imgUp->width(); x++ ) { |
117 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 117 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
118 | line[x] = i + 1; | 118 | line[x] = i + 1; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | for ( int i = 0; i < 7; i++ ) { | 124 | for ( int i = 0; i < 7; i++ ) { |
125 | buttonPixUp[i] = NULL; | 125 | buttonPixUp[i] = NULL; |
126 | buttonPixDown[i] = NULL; | 126 | buttonPixDown[i] = NULL; |
127 | } | 127 | } |
128 | 128 | ||
129 | setBackgroundPixmap( *pixBg ); | 129 | setBackgroundPixmap( *pixBg ); |
130 | 130 | ||
131 | slider = new QSlider( Qt::Horizontal, this ); | 131 | slider = new QSlider( Qt::Horizontal, this ); |
132 | slider->setMinValue( 0 ); | 132 | slider->setMinValue( 0 ); |
133 | slider->setMaxValue( 1 ); | 133 | slider->setMaxValue( 1 ); |
134 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 134 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
135 | //slider->setFocusPolicy( QWidget::NoFocus ); | 135 | //slider->setFocusPolicy( QWidget::NoFocus ); |
136 | 136 | ||
137 | resizeEvent( NULL ); | 137 | resizeEvent( NULL ); |
138 | 138 | ||
139 | setLength( mediaPlayerState.length() ); | 139 | setLength( mediaPlayerState.length() ); |
140 | setPosition( mediaPlayerState.position() ); | 140 | setPosition( mediaPlayerState.position() ); |
141 | setFullscreen( mediaPlayerState.isFullscreen() ); | 141 | setFullscreen( mediaPlayerState.isFullscreen() ); |
142 | setPlaying( mediaPlayerState.isPlaying() ); | 142 | setPlaying( mediaPlayerState.isPlaying() ); |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | VideoWidget::~VideoWidget() { | 146 | VideoWidget::~VideoWidget() { |
147 | 147 | ||
148 | for ( int i = 0; i < 7; i++ ) { | 148 | for ( int i = 0; i < 7; i++ ) { |
149 | delete buttonPixUp[i]; | 149 | delete buttonPixUp[i]; |
150 | delete buttonPixDown[i]; | 150 | delete buttonPixDown[i]; |
151 | } | 151 | } |
152 | 152 | ||
153 | delete pixBg; | 153 | delete pixBg; |
154 | delete imgUp; | 154 | delete imgUp; |
155 | delete imgDn; | 155 | delete imgDn; |
156 | delete imgButtonMask; | 156 | delete imgButtonMask; |
157 | for ( int i = 0; i < 7; i++ ) { | 157 | for ( int i = 0; i < 7; i++ ) { |
158 | delete masks[i]; | 158 | delete masks[i]; |
159 | } | 159 | } |
160 | 160 | ||
161 | } | 161 | } |
162 | 162 | ||
163 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 163 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
164 | QPixmap pix( img.width(), img.height() ); | 164 | QPixmap pix( img.width(), img.height() ); |
165 | QPainter p( &pix ); | 165 | QPainter p( &pix ); |
166 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 166 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
167 | p.drawImage( 0, 0, img ); | 167 | p.drawImage( 0, 0, img ); |
168 | return new QPixmap( pix ); | 168 | return new QPixmap( pix ); |
169 | } | 169 | } |
170 | 170 | ||
171 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 171 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
172 | QPixmap *pixmap = new QPixmap( pix ); | 172 | QPixmap *pixmap = new QPixmap( pix ); |
173 | pixmap->setMask( mask ); | 173 | pixmap->setMask( mask ); |
174 | return pixmap; | 174 | return pixmap; |
175 | } | 175 | } |
176 | 176 | ||
177 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 177 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
178 | int h = height(); | 178 | int h = height(); |
179 | int w = width(); | 179 | int w = width(); |
180 | //int Vh = 160; | 180 | //int Vh = 160; |
181 | //int Vw = 220; | 181 | //int Vw = 220; |
182 | 182 | ||
183 | slider->setFixedWidth( w - 20 ); | 183 | slider->setFixedWidth( w - 20 ); |
184 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 184 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
185 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 185 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
186 | slider->setFocusPolicy( QWidget::NoFocus ); | 186 | slider->setFocusPolicy( QWidget::NoFocus ); |
187 | slider->setBackgroundPixmap( *pixBg ); | 187 | slider->setBackgroundPixmap( *pixBg ); |
188 | 188 | ||
189 | xoff = 0;// ( imgUp->width() ) / 2; | 189 | xoff = 0;// ( imgUp->width() ) / 2; |
190 | if(w>h) | 190 | if(w>h) |
191 | yoff = 0; | 191 | yoff = 0; |
192 | else | 192 | else |
193 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 193 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
194 | QPoint p( xoff, yoff ); | 194 | QPoint p( xoff, yoff ); |
195 | 195 | ||
196 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 196 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
197 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 197 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
198 | 198 | ||
199 | for ( int i = 0; i < 7; i++ ) { | 199 | for ( int i = 0; i < 7; i++ ) { |
200 | if ( !masks[i]->isNull() ) { | 200 | if ( !masks[i]->isNull() ) { |
201 | delete buttonPixUp[i]; | 201 | delete buttonPixUp[i]; |
202 | delete buttonPixDown[i]; | 202 | delete buttonPixDown[i]; |
203 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 203 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
204 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 204 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | delete pixUp; | 208 | delete pixUp; |
209 | delete pixDn; | 209 | delete pixDn; |
210 | } | 210 | } |
211 | 211 | ||
212 | static bool videoSliderBeingMoved = FALSE; | 212 | static bool videoSliderBeingMoved = FALSE; |
213 | 213 | ||
214 | void VideoWidget::sliderPressed() { | 214 | void VideoWidget::sliderPressed() { |
215 | videoSliderBeingMoved = TRUE; | 215 | videoSliderBeingMoved = TRUE; |
216 | } | 216 | } |
217 | 217 | ||
218 | void VideoWidget::sliderReleased() { | 218 | void VideoWidget::sliderReleased() { |
219 | videoSliderBeingMoved = FALSE; | 219 | videoSliderBeingMoved = FALSE; |
220 | if ( slider->width() == 0 ) { | 220 | if ( slider->width() == 0 ) { |
221 | return; | 221 | return; |
222 | } | 222 | } |
223 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); | 223 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); |
224 | mediaPlayerState.setPosition( val ); | 224 | mediaPlayerState.setPosition( val ); |
225 | } | 225 | } |
226 | 226 | ||
227 | void VideoWidget::setPosition( long i ) { | 227 | void VideoWidget::setPosition( long i ) { |
228 | updateSlider( i, mediaPlayerState.length() ); | 228 | updateSlider( i, mediaPlayerState.length() ); |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void VideoWidget::setLength( long max ) { | 232 | void VideoWidget::setLength( long max ) { |
233 | updateSlider( mediaPlayerState.position(), max ); | 233 | updateSlider( mediaPlayerState.position(), max ); |
234 | } | 234 | } |
235 | 235 | ||
236 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 236 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
237 | { | 237 | { |
238 | if ( displayType == MediaPlayerState::Video ) { | 238 | if ( displayType == MediaPlayerState::Video ) { |
239 | makeVisible(); | 239 | makeVisible(); |
240 | return; | 240 | return; |
241 | } | 241 | } |
242 | 242 | ||
243 | // Effectively blank the view next time we show it so it looks nicer | 243 | // Effectively blank the view next time we show it so it looks nicer |
244 | scaledWidth = 0; | 244 | scaledWidth = 0; |
245 | scaledHeight = 0; | 245 | scaledHeight = 0; |
246 | hide(); | 246 | hide(); |
247 | } | 247 | } |
248 | 248 | ||
249 | void VideoWidget::updateSlider( long i, long max ) { | 249 | void VideoWidget::updateSlider( long i, long max ) { |
250 | // Will flicker too much if we don't do this | 250 | // Will flicker too much if we don't do this |
251 | if ( max == 0 ) { | 251 | if ( max == 0 ) { |
252 | return; | 252 | return; |
253 | } | 253 | } |
254 | int width = slider->width(); | 254 | int width = slider->width(); |
255 | int val = int((double)i * width / max); | 255 | int val = int((double)i * width / max); |
256 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 256 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
257 | if ( slider->value() != val ) { | 257 | if ( slider->value() != val ) { |
258 | slider->setValue( val ); | 258 | slider->setValue( val ); |
259 | } | 259 | } |
260 | if ( slider->maxValue() != width ) { | 260 | if ( slider->maxValue() != width ) { |
261 | slider->setMaxValue( width ); | 261 | slider->setMaxValue( width ); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | void VideoWidget::setToggleButton( int i, bool down ) { | 266 | void VideoWidget::setToggleButton( int i, bool down ) { |
267 | if ( down != videoButtons[i].isDown ) { | 267 | if ( down != videoButtons[i].isDown ) { |
268 | toggleButton( i ); | 268 | toggleButton( i ); |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | void VideoWidget::toggleButton( int i ) { | 272 | void VideoWidget::toggleButton( int i ) { |
273 | videoButtons[i].isDown = !videoButtons[i].isDown; | 273 | videoButtons[i].isDown = !videoButtons[i].isDown; |
274 | QPainter p(this); | 274 | QPainter p(this); |
275 | paintButton ( &p, i ); | 275 | paintButton ( &p, i ); |
276 | } | 276 | } |
277 | 277 | ||
278 | void VideoWidget::paintButton( QPainter *p, int i ) { | 278 | void VideoWidget::paintButton( QPainter *p, int i ) { |
279 | 279 | ||
280 | if ( videoButtons[i].isDown ) { | 280 | if ( videoButtons[i].isDown ) { |
281 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 281 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
282 | } else { | 282 | } else { |
283 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 283 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 287 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
288 | for ( int i = 0; i < numVButtons; i++ ) { | 288 | for ( int i = 0; i < numVButtons; i++ ) { |
289 | if ( event->state() == QMouseEvent::LeftButton ) { | 289 | if ( event->state() == QMouseEvent::LeftButton ) { |
290 | // The test to see if the mouse click is inside the button or not | 290 | // The test to see if the mouse click is inside the button or not |
291 | int x = event->pos().x() - xoff; | 291 | int x = event->pos().x() - xoff; |
292 | int y = event->pos().y() - yoff; | 292 | int y = event->pos().y() - yoff; |
293 | 293 | ||
294 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 294 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
295 | && y < imgButtonMask->height() | 295 | && y < imgButtonMask->height() |
296 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 296 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
297 | 297 | ||
298 | if ( isOnButton && !videoButtons[i].isHeld ) { | 298 | if ( isOnButton && !videoButtons[i].isHeld ) { |
299 | videoButtons[i].isHeld = TRUE; | 299 | videoButtons[i].isHeld = TRUE; |
300 | toggleButton(i); | 300 | toggleButton(i); |
301 | 301 | ||
302 | switch (i) { | 302 | switch (i) { |
303 | case VideoVolUp: | 303 | case VideoVolUp: |
304 | emit moreClicked(); | 304 | emit moreClicked(); |
305 | return; | 305 | return; |
306 | case VideoVolDown: | 306 | case VideoVolDown: |
307 | emit lessClicked(); | 307 | emit lessClicked(); |
308 | return; | 308 | return; |
309 | } | 309 | } |
310 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | 310 | } else if ( !isOnButton && videoButtons[i].isHeld ) { |
311 | videoButtons[i].isHeld = FALSE; | 311 | videoButtons[i].isHeld = FALSE; |
312 | toggleButton(i); | 312 | toggleButton(i); |
313 | } | 313 | } |
314 | } else { | 314 | } else { |
315 | 315 | ||
316 | if ( videoButtons[i].isHeld ) { | 316 | if ( videoButtons[i].isHeld ) { |
317 | videoButtons[i].isHeld = FALSE; | 317 | videoButtons[i].isHeld = FALSE; |
318 | if ( !videoButtons[i].isToggle ) { | 318 | if ( !videoButtons[i].isToggle ) { |
319 | setToggleButton( i, FALSE ); | 319 | setToggleButton( i, FALSE ); |
320 | } | 320 | } |
321 | 321 | ||
322 | switch(i) { | 322 | switch(i) { |
323 | 323 | ||
324 | case VideoPlay: { | 324 | case VideoPlay: { |
325 | if( mediaPlayerState.isPaused() ) { | 325 | if( mediaPlayerState.isPaused() ) { |
326 | setToggleButton( i, FALSE ); | 326 | setToggleButton( i, FALSE ); |
327 | mediaPlayerState.setPaused( FALSE ); | 327 | mediaPlayerState.setPaused( FALSE ); |
328 | return; | 328 | return; |
329 | } else if( !mediaPlayerState.isPaused() ) { | 329 | } else if( !mediaPlayerState.isPaused() ) { |
330 | setToggleButton( i, TRUE ); | 330 | setToggleButton( i, TRUE ); |
331 | mediaPlayerState.setPaused( TRUE ); | 331 | mediaPlayerState.setPaused( TRUE ); |
332 | return; | 332 | return; |
333 | } else { | 333 | } else { |
334 | return; | 334 | return; |
335 | } | 335 | } |
336 | } | 336 | } |
337 | 337 | ||
338 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; | 338 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; |
339 | case VideoNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 339 | case VideoNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
340 | case VideoPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 340 | case VideoPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
341 | case VideoVolUp: emit moreReleased(); return; | 341 | case VideoVolUp: emit moreReleased(); return; |
342 | case VideoVolDown: emit lessReleased(); return; | 342 | case VideoVolDown: emit lessReleased(); return; |
343 | case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; | 343 | case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; |
344 | } | 344 | } |
345 | } | 345 | } |
346 | } | 346 | } |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 350 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
351 | mouseMoveEvent( event ); | 351 | mouseMoveEvent( event ); |
352 | } | 352 | } |
353 | 353 | ||
354 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 354 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
355 | if ( mediaPlayerState.isFullscreen() ) { | 355 | if ( mediaPlayerState.isFullscreen() ) { |
356 | mediaPlayerState.setFullscreen( FALSE ); | 356 | mediaPlayerState.setFullscreen( FALSE ); |
357 | makeVisible(); | 357 | makeVisible(); |
358 | } | 358 | } |
359 | mouseMoveEvent( event ); | 359 | mouseMoveEvent( event ); |
360 | } | 360 | } |
361 | 361 | ||
362 | void VideoWidget::showEvent( QShowEvent* ) { | 362 | void VideoWidget::showEvent( QShowEvent* ) { |
363 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 363 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
364 | mouseMoveEvent( &event ); | 364 | mouseMoveEvent( &event ); |
365 | } | 365 | } |
366 | 366 | ||
367 | 367 | ||
368 | void VideoWidget::backToNormal() { | 368 | void VideoWidget::backToNormal() { |
369 | mediaPlayerState.setFullscreen( FALSE ); | 369 | mediaPlayerState.setFullscreen( FALSE ); |
370 | makeVisible(); | 370 | makeVisible(); |
371 | } | 371 | } |
372 | 372 | ||
373 | void VideoWidget::makeVisible() { | 373 | void VideoWidget::makeVisible() { |
374 | if ( mediaPlayerState.isFullscreen() ) { | 374 | if ( mediaPlayerState.isFullscreen() ) { |
375 | setBackgroundMode( QWidget::NoBackground ); | 375 | setBackgroundMode( QWidget::NoBackground ); |
376 | showFullScreen(); | 376 | showFullScreen(); |
377 | resize( qApp->desktop()->size() ); | 377 | resize( qApp->desktop()->size() ); |
378 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 378 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
379 | 379 | ||
380 | slider->hide(); | 380 | slider->hide(); |
381 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 381 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
382 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 382 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
383 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 383 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
384 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 384 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
385 | 385 | ||
386 | } else { | 386 | } else { |
387 | showNormal(); | 387 | showNormal(); |
388 | showMaximized(); | 388 | showMaximized(); |
389 | setBackgroundPixmap( *pixBg ); | 389 | setBackgroundPixmap( *pixBg ); |
390 | QWidget *d = QApplication::desktop(); | 390 | QWidget *d = QApplication::desktop(); |
391 | int w = d->width(); | 391 | int w = d->width(); |
392 | int h = d->height(); | 392 | int h = d->height(); |
393 | 393 | ||
394 | if(w>h) { | 394 | if(w>h) { |
395 | int newW=(w/2)-(246/2); //this will only work with 320x240 | 395 | int newW=(w/2)-(246/2); //this will only work with 320x240 |
396 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); | 396 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); |
397 | } else { | 397 | } else { |
398 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 398 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
399 | } | 399 | } |
400 | 400 | ||
401 | if ( !mediaPlayerState.isSeekable() ) { | 401 | if ( !mediaPlayerState.isSeekable() ) { |
402 | if( !slider->isHidden()) { | 402 | if( !slider->isHidden()) { |
403 | slider->hide(); | 403 | slider->hide(); |
404 | } | 404 | } |
405 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 405 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
406 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 406 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
407 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 407 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
408 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 408 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
409 | } else { | 409 | } else { |
410 | slider->show(); | 410 | slider->show(); |
411 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 411 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
412 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 412 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
413 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 413 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
414 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 414 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
415 | } | 415 | } |
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | 420 | ||
421 | 421 | ||
422 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 422 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
423 | QPainter p( this ); | 423 | QPainter p( this ); |
424 | 424 | ||
425 | if ( mediaPlayerState.isFullscreen() ) { | 425 | if ( mediaPlayerState.isFullscreen() ) { |
426 | // Clear the background | 426 | // Clear the background |
427 | p.setBrush( QBrush( Qt::black ) ); | 427 | p.setBrush( QBrush( Qt::black ) ); |
428 | } else { | 428 | } else { |
429 | if ( !pe->erased() ) { | 429 | if ( !pe->erased() ) { |
430 | // Combine with background and double buffer | 430 | // Combine with background and double buffer |
431 | QPixmap pix( pe->rect().size() ); | 431 | QPixmap pix( pe->rect().size() ); |
432 | QPainter p( &pix ); | 432 | QPainter p( &pix ); |
433 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 433 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
434 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 434 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
435 | for ( int i = 0; i < numVButtons; i++ ) { | 435 | for ( int i = 0; i < numVButtons; i++ ) { |
436 | paintButton( &p, i ); | 436 | paintButton( &p, i ); |
437 | } | 437 | } |
438 | QPainter p2( this ); | 438 | QPainter p2( this ); |
439 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 439 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
440 | } else { | 440 | } else { |
441 | QPainter p( this ); | 441 | QPainter p( this ); |
442 | for ( int i = 0; i < numVButtons; i++ ) | 442 | for ( int i = 0; i < numVButtons; i++ ) |
443 | paintButton( &p, i ); | 443 | paintButton( &p, i ); |
444 | } | 444 | } |
445 | //slider->repaint( TRUE ); | 445 | //slider->repaint( TRUE ); |
446 | } | 446 | } |
447 | } | 447 | } |
448 | 448 | ||
449 | 449 | ||
450 | void VideoWidget::closeEvent( QCloseEvent* ) { | ||
451 | mediaPlayerState.setList(); | ||
452 | } | ||
453 | |||
454 | |||
455 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 450 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
456 | switch ( e->key() ) { | 451 | switch ( e->key() ) { |
457 | ////////////////////////////// Zaurus keys | 452 | ////////////////////////////// Zaurus keys |
458 | case Key_Home: | 453 | case Key_Home: |
459 | break; | 454 | break; |
460 | case Key_F9: //activity | 455 | case Key_F9: //activity |
461 | break; | 456 | break; |
462 | case Key_F10: //contacts | 457 | case Key_F10: //contacts |
463 | // hide(); | 458 | // hide(); |
464 | break; | 459 | break; |
465 | case Key_F11: //menu | 460 | case Key_F11: //menu |
466 | break; | 461 | break; |
467 | case Key_F12: //home | 462 | case Key_F12: //home |
468 | break; | 463 | break; |
469 | case Key_F13: //mail | 464 | case Key_F13: //mail |
470 | break; | 465 | break; |
471 | case Key_Space: { | 466 | case Key_Space: { |
472 | if(mediaPlayerState.isPlaying()) { | 467 | if(mediaPlayerState.isPlaying()) { |
473 | mediaPlayerState.setPlaying(FALSE); | 468 | mediaPlayerState.setPlaying(FALSE); |
474 | } else { | 469 | } else { |
475 | mediaPlayerState.setPlaying(TRUE); | 470 | mediaPlayerState.setPlaying(TRUE); |
476 | } | 471 | } |
477 | } | 472 | } |
478 | break; | 473 | break; |
479 | case Key_Down: | 474 | case Key_Down: |
480 | // toggleButton(6); | 475 | // toggleButton(6); |
481 | emit lessClicked(); | 476 | emit lessClicked(); |
482 | emit lessReleased(); | 477 | emit lessReleased(); |
483 | // toggleButton(6); | 478 | // toggleButton(6); |
484 | break; | 479 | break; |
485 | case Key_Up: | 480 | case Key_Up: |
486 | // toggleButton(5); | 481 | // toggleButton(5); |
487 | emit moreClicked(); | 482 | emit moreClicked(); |
488 | emit moreReleased(); | 483 | emit moreReleased(); |
489 | // toggleButton(5); | 484 | // toggleButton(5); |
490 | break; | 485 | break; |
491 | case Key_Right: | 486 | case Key_Right: |
492 | mediaPlayerState.setNext(); | 487 | mediaPlayerState.setNext(); |
493 | break; | 488 | break; |
494 | case Key_Left: | 489 | case Key_Left: |
495 | mediaPlayerState.setPrev(); | 490 | mediaPlayerState.setPrev(); |
496 | break; | 491 | break; |
497 | case Key_Escape: | 492 | case Key_Escape: |
498 | break; | 493 | break; |
499 | 494 | ||
500 | }; | 495 | }; |
501 | } | 496 | } |
502 | 497 | ||
503 | XineVideoWidget* VideoWidget::vidWidget() { | 498 | XineVideoWidget* VideoWidget::vidWidget() { |
504 | return videoFrame; | 499 | return videoFrame; |
505 | } | 500 | } |
506 | 501 | ||
507 | 502 | ||
508 | void VideoWidget::setFullscreen ( bool b ) { | 503 | void VideoWidget::setFullscreen ( bool b ) { |
509 | setToggleButton( VideoFullscreen, b ); | 504 | setToggleButton( VideoFullscreen, b ); |
510 | } | 505 | } |
511 | 506 | ||
512 | 507 | ||
513 | void VideoWidget::setPlaying( bool b) { | 508 | void VideoWidget::setPlaying( bool b) { |
514 | setToggleButton( VideoPlay, b ); | 509 | setToggleButton( VideoPlay, b ); |
515 | } | 510 | } |
516 | 511 | ||
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 38eb726..149c78e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -1,127 +1,126 @@ | |||
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 | #ifndef VIDEO_WIDGET_H | 34 | #ifndef VIDEO_WIDGET_H |
35 | #define VIDEO_WIDGET_H | 35 | #define VIDEO_WIDGET_H |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include "xinevideowidget.h" | 38 | #include "xinevideowidget.h" |
39 | 39 | ||
40 | #include "mediawidget.h" | 40 | #include "mediawidget.h" |
41 | 41 | ||
42 | class QPixmap; | 42 | class QPixmap; |
43 | class QSlider; | 43 | class QSlider; |
44 | 44 | ||
45 | enum VideoButtons { | 45 | enum VideoButtons { |
46 | VideoStop = 0, | 46 | VideoStop = 0, |
47 | VideoPlay, | 47 | VideoPlay, |
48 | // VideoPause, | 48 | // VideoPause, |
49 | VideoPrevious, | 49 | VideoPrevious, |
50 | VideoNext, | 50 | VideoNext, |
51 | VideoVolUp, | 51 | VideoVolUp, |
52 | VideoVolDown, | 52 | VideoVolDown, |
53 | VideoFullscreen | 53 | VideoFullscreen |
54 | }; | 54 | }; |
55 | 55 | ||
56 | class VideoWidget : public MediaWidget { | 56 | class VideoWidget : public MediaWidget { |
57 | Q_OBJECT | 57 | Q_OBJECT |
58 | public: | 58 | public: |
59 | VideoWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 59 | VideoWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
60 | ~VideoWidget(); | 60 | ~VideoWidget(); |
61 | 61 | ||
62 | 62 | ||
63 | XineVideoWidget* vidWidget(); | 63 | XineVideoWidget* vidWidget(); |
64 | public slots: | 64 | public slots: |
65 | void updateSlider( long, long ); | 65 | void updateSlider( long, long ); |
66 | void sliderPressed( ); | 66 | void sliderPressed( ); |
67 | void sliderReleased( ); | 67 | void sliderReleased( ); |
68 | void setFullscreen( bool b ); | 68 | void setFullscreen( bool b ); |
69 | void makeVisible(); | 69 | void makeVisible(); |
70 | void backToNormal(); | 70 | void backToNormal(); |
71 | void setPosition( long ); | 71 | void setPosition( long ); |
72 | 72 | ||
73 | public: | 73 | public: |
74 | virtual void setPlaying( bool b); | 74 | virtual void setPlaying( bool b); |
75 | virtual void setLength( long ); | 75 | virtual void setLength( long ); |
76 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 76 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
77 | 77 | ||
78 | signals: | 78 | signals: |
79 | void moreClicked(); | 79 | void moreClicked(); |
80 | void lessClicked(); | 80 | void lessClicked(); |
81 | void moreReleased(); | 81 | void moreReleased(); |
82 | void lessReleased(); | 82 | void lessReleased(); |
83 | void sliderMoved( long ); | 83 | void sliderMoved( long ); |
84 | void videoResized ( const QSize &s ); | 84 | void videoResized ( const QSize &s ); |
85 | 85 | ||
86 | protected: | 86 | protected: |
87 | 87 | ||
88 | void resizeEvent( QResizeEvent * ); | 88 | void resizeEvent( QResizeEvent * ); |
89 | void paintEvent( QPaintEvent *pe ); | 89 | void paintEvent( QPaintEvent *pe ); |
90 | void showEvent( QShowEvent *se ); | 90 | void showEvent( QShowEvent *se ); |
91 | void mouseMoveEvent( QMouseEvent *event ); | 91 | void mouseMoveEvent( QMouseEvent *event ); |
92 | void mousePressEvent( QMouseEvent *event ); | 92 | void mousePressEvent( QMouseEvent *event ); |
93 | void mouseReleaseEvent( QMouseEvent *event ); | 93 | void mouseReleaseEvent( QMouseEvent *event ); |
94 | void closeEvent( QCloseEvent *event ); | ||
95 | void keyReleaseEvent( QKeyEvent *e); | 94 | void keyReleaseEvent( QKeyEvent *e); |
96 | 95 | ||
97 | private: | 96 | private: |
98 | // Ticker songInfo; | 97 | // Ticker songInfo; |
99 | QPixmap *pixBg; | 98 | QPixmap *pixBg; |
100 | QImage *imgUp; | 99 | QImage *imgUp; |
101 | QImage *imgDn; | 100 | QImage *imgDn; |
102 | QImage *imgButtonMask; | 101 | QImage *imgButtonMask; |
103 | QBitmap *masks[7]; | 102 | QBitmap *masks[7]; |
104 | QPixmap *buttonPixUp[7]; | 103 | QPixmap *buttonPixUp[7]; |
105 | QPixmap *buttonPixDown[7]; | 104 | QPixmap *buttonPixDown[7]; |
106 | QString skin; | 105 | QString skin; |
107 | // QPixmap *pixmaps[4]; | 106 | // QPixmap *pixmaps[4]; |
108 | int xoff, yoff; | 107 | int xoff, yoff; |
109 | 108 | ||
110 | 109 | ||
111 | void paintButton( QPainter *p, int i ); | 110 | void paintButton( QPainter *p, int i ); |
112 | void toggleButton( int ); | 111 | void toggleButton( int ); |
113 | void setToggleButton( int, bool ); | 112 | void setToggleButton( int, bool ); |
114 | 113 | ||
115 | QString backgroundPix; | 114 | QString backgroundPix; |
116 | QSlider *slider; | 115 | QSlider *slider; |
117 | QPixmap *pixmaps[3]; | 116 | QPixmap *pixmaps[3]; |
118 | QImage *currentFrame; | 117 | QImage *currentFrame; |
119 | int scaledWidth; | 118 | int scaledWidth; |
120 | int scaledHeight; | 119 | int scaledHeight; |
121 | XineVideoWidget* videoFrame; | 120 | XineVideoWidget* videoFrame; |
122 | }; | 121 | }; |
123 | 122 | ||
124 | #endif // VIDEO_WIDGET_H | 123 | #endif // VIDEO_WIDGET_H |
125 | 124 | ||
126 | 125 | ||
127 | 126 | ||