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