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