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