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