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