-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 52 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.h | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/opieplayer2.pro | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 29 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/volumecontrol.cpp | 59 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/volumecontrol.h | 47 |
9 files changed, 156 insertions, 58 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 0e9e7ea..955169c 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,497 +1,497 @@ | |||
1 | 1 | ||
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | 5 | ||
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
8 | #include <qbutton.h> | 8 | #include <qbutton.h> |
9 | #include <qpainter.h> | 9 | #include <qpainter.h> |
10 | #include <qframe.h> | 10 | #include <qframe.h> |
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | 12 | ||
13 | #include <stdlib.h> | 13 | #include <stdlib.h> |
14 | #include <stdio.h> | 14 | #include <stdio.h> |
15 | 15 | ||
16 | #include "audiowidget.h" | 16 | #include "audiowidget.h" |
17 | #include "mediaplayerstate.h" | 17 | #include "mediaplayerstate.h" |
18 | 18 | ||
19 | extern MediaPlayerState *mediaPlayerState; | 19 | extern MediaPlayerState *mediaPlayerState; |
20 | 20 | ||
21 | static const int xo = -2; // movable x offset | 21 | static const int xo = -2; // movable x offset |
22 | static const int yo = 22; // movable y offset | 22 | static const int yo = 22; // movable y offset |
23 | 23 | ||
24 | 24 | ||
25 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { | 25 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { |
26 | setFrameStyle( WinPanel | Sunken ); | 26 | setFrameStyle( WinPanel | Sunken ); |
27 | setText( "No Song" ); | 27 | setText( "No Song" ); |
28 | } | 28 | } |
29 | 29 | ||
30 | Ticker::~Ticker() { | 30 | Ticker::~Ticker() { |
31 | } | 31 | } |
32 | 32 | ||
33 | void Ticker::setText( const QString& text ) { | 33 | void Ticker::setText( const QString& text ) { |
34 | pos = 0; // reset it everytime the text is changed | 34 | pos = 0; // reset it everytime the text is changed |
35 | scrollText = text; | 35 | scrollText = text; |
36 | pixelLen = fontMetrics().width( scrollText ); | 36 | pixelLen = fontMetrics().width( scrollText ); |
37 | killTimers(); | 37 | killTimers(); |
38 | if ( pixelLen > width() ) { | 38 | if ( pixelLen > width() ) { |
39 | startTimer( 50 ); | 39 | startTimer( 50 ); |
40 | } | 40 | } |
41 | update(); | 41 | update(); |
42 | } | 42 | } |
43 | 43 | ||
44 | 44 | ||
45 | void Ticker::timerEvent( QTimerEvent * ) { | 45 | void Ticker::timerEvent( QTimerEvent * ) { |
46 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | 46 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; |
47 | scroll( -1, 0, contentsRect() ); | 47 | scroll( -1, 0, contentsRect() ); |
48 | repaint( FALSE ); | 48 | repaint( FALSE ); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Ticker::drawContents( QPainter *p ) { | 51 | void Ticker::drawContents( QPainter *p ) { |
52 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | 52 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) |
53 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 53 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
54 | QPixmap pm( width(), height() ); | 54 | QPixmap pm( width(), height() ); |
55 | pm.fill( colorGroup().base() ); | 55 | pm.fill( colorGroup().base() ); |
56 | QPainter pmp( &pm ); | 56 | QPainter pmp( &pm ); |
57 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | 57 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { |
58 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 58 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
59 | } | 59 | } |
60 | p->drawPixmap( 0, 0, pm ); | 60 | p->drawPixmap( 0, 0, pm ); |
61 | } | 61 | } |
62 | 62 | ||
63 | struct MediaButton { | 63 | struct MediaButton { |
64 | bool isToggle, isHeld, isDown; | 64 | bool isToggle, isHeld, isDown; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | //Layout information for the audioButtons (and if it is a toggle button or not) | 67 | //Layout information for the audioButtons (and if it is a toggle button or not) |
68 | MediaButton audioButtons[] = { | 68 | MediaButton audioButtons[] = { |
69 | { TRUE, FALSE, FALSE }, // play | 69 | { TRUE, FALSE, FALSE }, // play |
70 | { FALSE, FALSE, FALSE }, // stop | 70 | { FALSE, FALSE, FALSE }, // stop |
71 | { TRUE, FALSE, FALSE }, // pause | 71 | { FALSE, FALSE, FALSE }, // pause |
72 | { FALSE, FALSE, FALSE }, // next | 72 | { FALSE, FALSE, FALSE }, // next |
73 | { FALSE, FALSE, FALSE }, // previous | 73 | { FALSE, FALSE, FALSE }, // previous |
74 | { FALSE, FALSE, FALSE }, // volume up | 74 | { FALSE, FALSE, FALSE }, // volume up |
75 | { FALSE, FALSE, FALSE }, // volume down | 75 | { FALSE, FALSE, FALSE }, // volume down |
76 | { TRUE, FALSE, FALSE }, // repeat/loop | 76 | { TRUE, FALSE, FALSE }, // repeat/loop |
77 | { FALSE, FALSE, FALSE }, // playlist | 77 | { FALSE, FALSE, FALSE }, // playlist |
78 | { FALSE, FALSE, FALSE }, // forward | 78 | { FALSE, FALSE, FALSE }, // forward |
79 | { FALSE, FALSE, FALSE } // back | 79 | { FALSE, FALSE, FALSE } // back |
80 | }; | 80 | }; |
81 | 81 | ||
82 | const char *skin_mask_file_names[11] = { | 82 | const char *skin_mask_file_names[11] = { |
83 | "play", "stop", "pause", "next", "prev", "up", | 83 | "play", "stop", "pause", "next", "prev", "up", |
84 | "down", "loop", "playlist", "forward", "back" | 84 | "down", "loop", "playlist", "forward", "back" |
85 | }; | 85 | }; |
86 | 86 | ||
87 | 87 | ||
88 | static void changeTextColor( QWidget *w ) { | 88 | static void changeTextColor( QWidget *w ) { |
89 | QPalette p = w->palette(); | 89 | QPalette p = w->palette(); |
90 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 90 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
91 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 91 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
92 | w->setPalette( p ); | 92 | w->setPalette( p ); |
93 | } | 93 | } |
94 | 94 | ||
95 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 95 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
96 | 96 | ||
97 | 97 | ||
98 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 98 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
99 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 99 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
100 | setCaption( tr("OpiePlayer") ); | 100 | setCaption( tr("OpiePlayer") ); |
101 | 101 | ||
102 | Config cfg("OpiePlayer"); | 102 | Config cfg("OpiePlayer"); |
103 | cfg.setGroup("AudioWidget"); | 103 | cfg.setGroup("AudioWidget"); |
104 | skin = cfg.readEntry("Skin","default"); | 104 | skin = cfg.readEntry("Skin","default"); |
105 | //skin = "scaleTest"; | 105 | //skin = "scaleTest"; |
106 | // color of background, frame, degree of transparency | 106 | // color of background, frame, degree of transparency |
107 | 107 | ||
108 | QString skinPath = "opieplayer/skins/" + skin; | 108 | QString skinPath = "opieplayer/skins/" + skin; |
109 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 109 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
110 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 110 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
111 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 111 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
112 | 112 | ||
113 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 113 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
114 | imgButtonMask->fill( 0 ); | 114 | imgButtonMask->fill( 0 ); |
115 | 115 | ||
116 | for ( int i = 0; i < 11; i++ ) { | 116 | for ( int i = 0; i < 11; i++ ) { |
117 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; | 117 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; |
118 | masks[i] = new QBitmap( filename ); | 118 | masks[i] = new QBitmap( filename ); |
119 | 119 | ||
120 | if ( !masks[i]->isNull() ) { | 120 | if ( !masks[i]->isNull() ) { |
121 | QImage imgMask = masks[i]->convertToImage(); | 121 | QImage imgMask = masks[i]->convertToImage(); |
122 | uchar **dest = imgButtonMask->jumpTable(); | 122 | uchar **dest = imgButtonMask->jumpTable(); |
123 | for ( int y = 0; y < imgUp->height(); y++ ) { | 123 | for ( int y = 0; y < imgUp->height(); y++ ) { |
124 | uchar *line = dest[y]; | 124 | uchar *line = dest[y]; |
125 | for ( int x = 0; x < imgUp->width(); x++ ) | 125 | for ( int x = 0; x < imgUp->width(); x++ ) |
126 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 126 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
127 | line[x] = i + 1; | 127 | line[x] = i + 1; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | } | 131 | } |
132 | 132 | ||
133 | for ( int i = 0; i < 11; i++ ) { | 133 | for ( int i = 0; i < 11; i++ ) { |
134 | buttonPixUp[i] = NULL; | 134 | buttonPixUp[i] = NULL; |
135 | buttonPixDown[i] = NULL; | 135 | buttonPixDown[i] = NULL; |
136 | } | 136 | } |
137 | 137 | ||
138 | setBackgroundPixmap( *pixBg ); | 138 | setBackgroundPixmap( *pixBg ); |
139 | 139 | ||
140 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 140 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
141 | changeTextColor( &songInfo ); | 141 | changeTextColor( &songInfo ); |
142 | 142 | ||
143 | slider.setFixedHeight( 20 ); | 143 | slider.setFixedHeight( 20 ); |
144 | slider.setMinValue( 0 ); | 144 | slider.setMinValue( 0 ); |
145 | slider.setMaxValue( 1 ); | 145 | slider.setMaxValue( 1 ); |
146 | slider.setFocusPolicy( QWidget::NoFocus ); | 146 | slider.setFocusPolicy( QWidget::NoFocus ); |
147 | slider.setBackgroundPixmap( *pixBg ); | 147 | slider.setBackgroundPixmap( *pixBg ); |
148 | 148 | ||
149 | time.setFocusPolicy( QWidget::NoFocus ); | 149 | time.setFocusPolicy( QWidget::NoFocus ); |
150 | time.setAlignment( Qt::AlignCenter ); | 150 | time.setAlignment( Qt::AlignCenter ); |
151 | time.setFrame(FALSE); | 151 | time.setFrame(FALSE); |
152 | changeTextColor( &time ); | 152 | changeTextColor( &time ); |
153 | 153 | ||
154 | resizeEvent( NULL ); | 154 | resizeEvent( NULL ); |
155 | 155 | ||
156 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 156 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
157 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 157 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
158 | 158 | ||
159 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 159 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
160 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 160 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
161 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 161 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
162 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 162 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
163 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 163 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
164 | 164 | ||
165 | // Intialise state | 165 | // Intialise state |
166 | setLength( mediaPlayerState->length() ); | 166 | setLength( mediaPlayerState->length() ); |
167 | setPosition( mediaPlayerState->position() ); | 167 | setPosition( mediaPlayerState->position() ); |
168 | setLooping( mediaPlayerState->fullscreen() ); | 168 | setLooping( mediaPlayerState->fullscreen() ); |
169 | setPaused( mediaPlayerState->paused() ); | 169 | setPaused( mediaPlayerState->paused() ); |
170 | setPlaying( mediaPlayerState->playing() ); | 170 | setPlaying( mediaPlayerState->playing() ); |
171 | 171 | ||
172 | } | 172 | } |
173 | 173 | ||
174 | AudioWidget::~AudioWidget() { | 174 | AudioWidget::~AudioWidget() { |
175 | 175 | ||
176 | for ( int i = 0; i < 11; i++ ) { | 176 | for ( int i = 0; i < 11; i++ ) { |
177 | delete buttonPixUp[i]; | 177 | delete buttonPixUp[i]; |
178 | delete buttonPixDown[i]; | 178 | delete buttonPixDown[i]; |
179 | } | 179 | } |
180 | delete pixBg; | 180 | delete pixBg; |
181 | delete imgUp; | 181 | delete imgUp; |
182 | delete imgDn; | 182 | delete imgDn; |
183 | delete imgButtonMask; | 183 | delete imgButtonMask; |
184 | for ( int i = 0; i < 11; i++ ) { | 184 | for ( int i = 0; i < 11; i++ ) { |
185 | delete masks[i]; | 185 | delete masks[i]; |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 189 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
190 | QPixmap pix( img.width(), img.height() ); | 190 | QPixmap pix( img.width(), img.height() ); |
191 | QPainter p( &pix ); | 191 | QPainter p( &pix ); |
192 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 192 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
193 | p.drawImage( 0, 0, img ); | 193 | p.drawImage( 0, 0, img ); |
194 | return new QPixmap( pix ); | 194 | return new QPixmap( pix ); |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) | 198 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) |
199 | { | 199 | { |
200 | QPixmap *pixmap = new QPixmap( pix ); | 200 | QPixmap *pixmap = new QPixmap( pix ); |
201 | pixmap->setMask( mask ); | 201 | pixmap->setMask( mask ); |
202 | return pixmap; | 202 | return pixmap; |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | 206 | ||
207 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 207 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
208 | int h = height(); | 208 | int h = height(); |
209 | int w = width(); | 209 | int w = width(); |
210 | 210 | ||
211 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | 211 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); |
212 | slider.setFixedWidth( w - 110 ); | 212 | slider.setFixedWidth( w - 110 ); |
213 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 213 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
214 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 214 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
215 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 215 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
216 | 216 | ||
217 | xoff = ( w - imgUp->width() ) / 2; | 217 | xoff = ( w - imgUp->width() ) / 2; |
218 | yoff = (( h - imgUp->height() ) / 2) - 10; | 218 | yoff = (( h - imgUp->height() ) / 2) - 10; |
219 | QPoint p( xoff, yoff ); | 219 | QPoint p( xoff, yoff ); |
220 | 220 | ||
221 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); | 221 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); |
222 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); | 222 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); |
223 | 223 | ||
224 | for ( int i = 0; i < 11; i++ ) { | 224 | for ( int i = 0; i < 11; i++ ) { |
225 | if ( !masks[i]->isNull() ) { | 225 | if ( !masks[i]->isNull() ) { |
226 | delete buttonPixUp[i]; | 226 | delete buttonPixUp[i]; |
227 | delete buttonPixDown[i]; | 227 | delete buttonPixDown[i]; |
228 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); | 228 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); |
229 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); | 229 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | 232 | ||
233 | delete pixUp; | 233 | delete pixUp; |
234 | delete pixDn; | 234 | delete pixDn; |
235 | } | 235 | } |
236 | 236 | ||
237 | static bool audioSliderBeingMoved = FALSE; | 237 | static bool audioSliderBeingMoved = FALSE; |
238 | 238 | ||
239 | 239 | ||
240 | void AudioWidget::sliderPressed() { | 240 | void AudioWidget::sliderPressed() { |
241 | audioSliderBeingMoved = TRUE; | 241 | audioSliderBeingMoved = TRUE; |
242 | } | 242 | } |
243 | 243 | ||
244 | 244 | ||
245 | void AudioWidget::sliderReleased() { | 245 | void AudioWidget::sliderReleased() { |
246 | audioSliderBeingMoved = FALSE; | 246 | audioSliderBeingMoved = FALSE; |
247 | if ( slider.width() == 0 ) | 247 | if ( slider.width() == 0 ) |
248 | return; | 248 | return; |
249 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 249 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
250 | mediaPlayerState->setPosition( val ); | 250 | mediaPlayerState->setPosition( val ); |
251 | } | 251 | } |
252 | 252 | ||
253 | void AudioWidget::setPosition( long i ) { | 253 | void AudioWidget::setPosition( long i ) { |
254 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 254 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
255 | updateSlider( i, mediaPlayerState->length() ); | 255 | updateSlider( i, mediaPlayerState->length() ); |
256 | } | 256 | } |
257 | 257 | ||
258 | 258 | ||
259 | void AudioWidget::setLength( long max ) { | 259 | void AudioWidget::setLength( long max ) { |
260 | updateSlider( mediaPlayerState->position(), max ); | 260 | updateSlider( mediaPlayerState->position(), max ); |
261 | } | 261 | } |
262 | 262 | ||
263 | 263 | ||
264 | void AudioWidget::setView( char view ) { | 264 | void AudioWidget::setView( char view ) { |
265 | slider.show(); | 265 | slider.show(); |
266 | 266 | ||
267 | // this isnt working for some reason | 267 | // this isnt working for some reason |
268 | 268 | ||
269 | // if ( mediaPlayerState->streaming() ) { | 269 | // if ( mediaPlayerState->streaming() ) { |
270 | // qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 270 | // qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
271 | // if( !slider.isHidden()) slider.hide(); | 271 | // if( !slider.isHidden()) slider.hide(); |
272 | // disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 272 | // disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
273 | // disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 273 | // disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
274 | // } else { | 274 | // } else { |
275 | // this stops the slider from being moved, thus | 275 | // this stops the slider from being moved, thus |
276 | // does not stop stream when it reaches the end | 276 | // does not stop stream when it reaches the end |
277 | // slider.show(); | 277 | // slider.show(); |
278 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 278 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
279 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 279 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
280 | // } | 280 | // } |
281 | 281 | ||
282 | if ( view == 'a' ) { | 282 | if ( view == 'a' ) { |
283 | startTimer( 150 ); | 283 | startTimer( 150 ); |
284 | showMaximized(); | 284 | showMaximized(); |
285 | } else { | 285 | } else { |
286 | killTimers(); | 286 | killTimers(); |
287 | hide(); | 287 | hide(); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | 291 | ||
292 | static QString timeAsString( long length ) { | 292 | static QString timeAsString( long length ) { |
293 | int minutes = length / 60; | 293 | int minutes = length / 60; |
294 | int seconds = length % 60; | 294 | int seconds = length % 60; |
295 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 295 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
296 | } | 296 | } |
297 | 297 | ||
298 | void AudioWidget::updateSlider( long i, long max ) { | 298 | void AudioWidget::updateSlider( long i, long max ) { |
299 | 299 | ||
300 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 300 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
301 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 301 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
302 | 302 | ||
303 | if ( max == 0 ) { | 303 | if ( max == 0 ) { |
304 | return; | 304 | return; |
305 | } | 305 | } |
306 | // Will flicker too much if we don't do this | 306 | // Will flicker too much if we don't do this |
307 | // Scale to something reasonable | 307 | // Scale to something reasonable |
308 | int width = slider.width(); | 308 | int width = slider.width(); |
309 | int val = int((double)i * width / max); | 309 | int val = int((double)i * width / max); |
310 | if ( !audioSliderBeingMoved ) { | 310 | if ( !audioSliderBeingMoved ) { |
311 | if ( slider.value() != val ) { | 311 | if ( slider.value() != val ) { |
312 | slider.setValue( val ); | 312 | slider.setValue( val ); |
313 | } | 313 | } |
314 | 314 | ||
315 | if ( slider.maxValue() != width ) { | 315 | if ( slider.maxValue() != width ) { |
316 | slider.setMaxValue( width ); | 316 | slider.setMaxValue( width ); |
317 | } | 317 | } |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | void AudioWidget::setToggleButton( int i, bool down ) { | 322 | void AudioWidget::setToggleButton( int i, bool down ) { |
323 | if ( down != audioButtons[i].isDown ) { | 323 | if ( down != audioButtons[i].isDown ) { |
324 | toggleButton( i ); | 324 | toggleButton( i ); |
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | void AudioWidget::toggleButton( int i ) { | 329 | void AudioWidget::toggleButton( int i ) { |
330 | audioButtons[i].isDown = !audioButtons[i].isDown; | 330 | audioButtons[i].isDown = !audioButtons[i].isDown; |
331 | QPainter p(this); | 331 | QPainter p(this); |
332 | paintButton ( &p, i ); | 332 | paintButton ( &p, i ); |
333 | } | 333 | } |
334 | 334 | ||
335 | 335 | ||
336 | void AudioWidget::paintButton( QPainter *p, int i ) { | 336 | void AudioWidget::paintButton( QPainter *p, int i ) { |
337 | if ( audioButtons[i].isDown ) | 337 | if ( audioButtons[i].isDown ) |
338 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 338 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
339 | else | 339 | else |
340 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 340 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
341 | } | 341 | } |
342 | 342 | ||
343 | 343 | ||
344 | void AudioWidget::timerEvent( QTimerEvent * ) { | 344 | void AudioWidget::timerEvent( QTimerEvent * ) { |
345 | // static int frame = 0; | ||
346 | // if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { | ||
347 | // frame = frame >= 7 ? 0 : frame + 1; | ||
348 | // } | ||
349 | } | 345 | } |
350 | 346 | ||
351 | 347 | ||
352 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 348 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
353 | for ( int i = 0; i < numButtons; i++ ) { | 349 | for ( int i = 0; i < numButtons; i++ ) { |
354 | if ( event->state() == QMouseEvent::LeftButton ) { | 350 | if ( event->state() == QMouseEvent::LeftButton ) { |
355 | 351 | ||
356 | // The test to see if the mouse click is inside the button or not | 352 | // The test to see if the mouse click is inside the button or not |
357 | int x = event->pos().x() - xoff; | 353 | int x = event->pos().x() - xoff; |
358 | int y = event->pos().y() - yoff; | 354 | int y = event->pos().y() - yoff; |
359 | 355 | ||
360 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 356 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
361 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 357 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
362 | 358 | ||
363 | if ( isOnButton && i == AudioVolumeUp ) | 359 | if ( isOnButton && i == AudioVolumeUp ) |
364 | qDebug("on up"); | 360 | qDebug("on up"); |
365 | 361 | ||
366 | if ( isOnButton && !audioButtons[i].isHeld ) { | 362 | if ( isOnButton && !audioButtons[i].isHeld ) { |
367 | audioButtons[i].isHeld = TRUE; | 363 | audioButtons[i].isHeld = TRUE; |
368 | toggleButton(i); | 364 | toggleButton(i); |
369 | switch (i) { | 365 | switch (i) { |
370 | case AudioVolumeUp: | 366 | case AudioVolumeUp: |
371 | qDebug("more clicked"); | 367 | qDebug("more clicked"); |
372 | emit moreClicked(); | 368 | emit moreClicked(); |
373 | return; | 369 | return; |
374 | case AudioVolumeDown: emit lessClicked(); return; | 370 | case AudioVolumeDown: |
371 | emit lessClicked(); | ||
372 | return; | ||
375 | } | 373 | } |
376 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 374 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
377 | audioButtons[i].isHeld = FALSE; | 375 | audioButtons[i].isHeld = FALSE; |
378 | toggleButton(i); | 376 | toggleButton(i); |
379 | } | 377 | } |
380 | } else { | 378 | } else { |
381 | if ( audioButtons[i].isHeld ) { | 379 | if ( audioButtons[i].isHeld ) { |
382 | audioButtons[i].isHeld = FALSE; | 380 | audioButtons[i].isHeld = FALSE; |
383 | if ( !audioButtons[i].isToggle ) | 381 | if ( !audioButtons[i].isToggle ) { |
384 | setToggleButton( i, FALSE ); | 382 | setToggleButton( i, FALSE ); |
383 | qDebug("button toggled3 %d",i); | ||
384 | } | ||
385 | switch (i) { | 385 | switch (i) { |
386 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; | 386 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; |
387 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 387 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
388 | case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; | 388 | case AudioPause: mediaPlayerState->setPaused( audioButtons[i].isDown); return; |
389 | case AudioNext: mediaPlayerState->setNext(); return; | 389 | case AudioNext: mediaPlayerState->setNext(); return; |
390 | case AudioPrevious: mediaPlayerState->setPrev(); return; | 390 | case AudioPrevious: mediaPlayerState->setPrev(); return; |
391 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 391 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
392 | case AudioVolumeUp: emit moreReleased(); return; | 392 | case AudioVolumeUp: emit moreReleased(); return; |
393 | case AudioVolumeDown: emit lessReleased(); return; | 393 | case AudioVolumeDown: emit lessReleased(); return; |
394 | case AudioPlayList: mediaPlayerState->setList(); return; | 394 | case AudioPlayList: mediaPlayerState->setList(); return; |
395 | } | 395 | } |
396 | } | 396 | } |
397 | } | 397 | } |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 402 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
403 | mouseMoveEvent( event ); | 403 | mouseMoveEvent( event ); |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 407 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
408 | mouseMoveEvent( event ); | 408 | mouseMoveEvent( event ); |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | void AudioWidget::showEvent( QShowEvent* ) { | 412 | void AudioWidget::showEvent( QShowEvent* ) { |
413 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 413 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
414 | mouseMoveEvent( &event ); | 414 | mouseMoveEvent( &event ); |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | void AudioWidget::closeEvent( QCloseEvent* ) { | 418 | void AudioWidget::closeEvent( QCloseEvent* ) { |
419 | mediaPlayerState->setList(); | 419 | mediaPlayerState->setList(); |
420 | } | 420 | } |
421 | 421 | ||
422 | 422 | ||
423 | void AudioWidget::paintEvent( QPaintEvent * pe) { | 423 | void AudioWidget::paintEvent( QPaintEvent * pe) { |
424 | if ( !pe->erased() ) { | 424 | if ( !pe->erased() ) { |
425 | // Combine with background and double buffer | 425 | // Combine with background and double buffer |
426 | QPixmap pix( pe->rect().size() ); | 426 | QPixmap pix( pe->rect().size() ); |
427 | QPainter p( &pix ); | 427 | QPainter p( &pix ); |
428 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 428 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
429 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 429 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
430 | for ( int i = 0; i < numButtons; i++ ) | 430 | for ( int i = 0; i < numButtons; i++ ) |
431 | paintButton( &p, i ); | 431 | paintButton( &p, i ); |
432 | QPainter p2( this ); | 432 | QPainter p2( this ); |
433 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 433 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
434 | } else { | 434 | } else { |
435 | QPainter p( this ); | 435 | QPainter p( this ); |
436 | for ( int i = 0; i < numButtons; i++ ) | 436 | for ( int i = 0; i < numButtons; i++ ) |
437 | paintButton( &p, i ); | 437 | paintButton( &p, i ); |
438 | } | 438 | } |
439 | } | 439 | } |
440 | 440 | ||
441 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) | 441 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) |
442 | { | 442 | { |
443 | switch ( e->key() ) { | 443 | switch ( e->key() ) { |
444 | ////////////////////////////// Zaurus keys | 444 | ////////////////////////////// Zaurus keys |
445 | case Key_Home: | 445 | case Key_Home: |
446 | break; | 446 | break; |
447 | case Key_F9: //activity | 447 | case Key_F9: //activity |
448 | hide(); | 448 | hide(); |
449 | // qDebug("Audio F9"); | 449 | // qDebug("Audio F9"); |
450 | break; | 450 | break; |
451 | case Key_F10: //contacts | 451 | case Key_F10: //contacts |
452 | break; | 452 | break; |
453 | case Key_F11: //menu | 453 | case Key_F11: //menu |
454 | break; | 454 | break; |
455 | case Key_F12: //home | 455 | case Key_F12: //home |
456 | break; | 456 | break; |
457 | case Key_F13: //mail | 457 | case Key_F13: //mail |
458 | break; | 458 | break; |
459 | case Key_Space: { | 459 | case Key_Space: { |
460 | if(mediaPlayerState->playing()) { | 460 | if(mediaPlayerState->playing()) { |
461 | // toggleButton(1); | 461 | // toggleButton(1); |
462 | mediaPlayerState->setPlaying(FALSE); | 462 | mediaPlayerState->setPlaying(FALSE); |
463 | // toggleButton(1); | 463 | // toggleButton(1); |
464 | } else { | 464 | } else { |
465 | // toggleButton(0); | 465 | // toggleButton(0); |
466 | mediaPlayerState->setPlaying(TRUE); | 466 | mediaPlayerState->setPlaying(TRUE); |
467 | // toggleButton(0); | 467 | // toggleButton(0); |
468 | } | 468 | } |
469 | } | 469 | } |
470 | break; | 470 | break; |
471 | case Key_Down: | 471 | case Key_Down: |
472 | toggleButton(6); | 472 | toggleButton(6); |
473 | emit lessClicked(); | 473 | emit lessClicked(); |
474 | emit lessReleased(); | 474 | emit lessReleased(); |
475 | toggleButton(6); | 475 | toggleButton(6); |
476 | break; | 476 | break; |
477 | case Key_Up: | 477 | case Key_Up: |
478 | toggleButton(5); | 478 | toggleButton(5); |
479 | emit moreClicked(); | 479 | emit moreClicked(); |
480 | emit moreReleased(); | 480 | emit moreReleased(); |
481 | toggleButton(5); | 481 | toggleButton(5); |
482 | break; | 482 | break; |
483 | case Key_Right: | 483 | case Key_Right: |
484 | // toggleButton(3); | 484 | // toggleButton(3); |
485 | mediaPlayerState->setNext(); | 485 | mediaPlayerState->setNext(); |
486 | // toggleButton(3); | 486 | // toggleButton(3); |
487 | break; | 487 | break; |
488 | case Key_Left: | 488 | case Key_Left: |
489 | // toggleButton(4); | 489 | // toggleButton(4); |
490 | mediaPlayerState->setPrev(); | 490 | mediaPlayerState->setPrev(); |
491 | // toggleButton(4); | 491 | // toggleButton(4); |
492 | break; | 492 | break; |
493 | case Key_Escape: | 493 | case Key_Escape: |
494 | break; | 494 | break; |
495 | 495 | ||
496 | }; | 496 | }; |
497 | } | 497 | } |
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 5411a64..8d8e4e5 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,232 +1,238 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qpe/qlibrary.h> | 2 | #include <qpe/qlibrary.h> |
3 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | 5 | ||
6 | #include <qmainwindow.h> | 6 | #include <qmainwindow.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | #include <qwidgetstack.h> | 8 | #include <qwidgetstack.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | 10 | ||
11 | #include "mediaplayer.h" | 11 | #include "mediaplayer.h" |
12 | #include "playlistwidget.h" | 12 | #include "playlistwidget.h" |
13 | #include "audiowidget.h" | 13 | #include "audiowidget.h" |
14 | #include "volumecontrol.h" | ||
14 | 15 | ||
15 | #include "mediaplayerstate.h" | 16 | #include "mediaplayerstate.h" |
16 | 17 | ||
17 | 18 | ||
18 | 19 | ||
19 | extern AudioWidget *audioUI; | 20 | extern AudioWidget *audioUI; |
20 | extern PlayListWidget *playList; | 21 | extern PlayListWidget *playList; |
21 | extern MediaPlayerState *mediaPlayerState; | 22 | extern MediaPlayerState *mediaPlayerState; |
22 | 23 | ||
23 | 24 | ||
24 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 25 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
25 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 26 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
26 | 27 | ||
27 | 28 | ||
28 | xineControl = new XineControl(); | 29 | xineControl = new XineControl(); |
29 | // QPEApplication::grabKeyboard(); // EVIL | 30 | // QPEApplication::grabKeyboard(); // EVIL |
30 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 31 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
31 | 32 | ||
32 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 33 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
33 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 34 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
34 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 35 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
35 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 36 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
36 | 37 | ||
37 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 38 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
38 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 39 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
39 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 40 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
40 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 41 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
41 | 42 | ||
43 | volControl = new VolumeControl; | ||
44 | |||
42 | } | 45 | } |
43 | 46 | ||
44 | MediaPlayer::~MediaPlayer() { | 47 | MediaPlayer::~MediaPlayer() { |
48 | delete xineControl; | ||
49 | delete volControl; | ||
45 | } | 50 | } |
46 | 51 | ||
47 | void MediaPlayer::pauseCheck( bool b ) { | 52 | void MediaPlayer::pauseCheck( bool b ) { |
48 | // Only pause if playing | 53 | // Only pause if playing |
49 | if ( b && !mediaPlayerState->playing() ) { | 54 | if ( b && !mediaPlayerState->playing() ) { |
50 | mediaPlayerState->setPaused( FALSE ); | 55 | mediaPlayerState->setPaused( FALSE ); |
51 | } | 56 | } |
52 | } | 57 | } |
53 | 58 | ||
54 | void MediaPlayer::play() { | 59 | void MediaPlayer::play() { |
55 | mediaPlayerState->setPlaying( FALSE ); | 60 | mediaPlayerState->setPlaying( FALSE ); |
56 | mediaPlayerState->setPlaying( TRUE ); | 61 | mediaPlayerState->setPlaying( TRUE ); |
57 | } | 62 | } |
58 | 63 | ||
59 | void MediaPlayer::setPlaying( bool play ) { | 64 | void MediaPlayer::setPlaying( bool play ) { |
60 | if ( !play ) { | 65 | if ( !play ) { |
61 | mediaPlayerState->setPaused( FALSE ); | 66 | mediaPlayerState->setPaused( FALSE ); |
62 | return; | 67 | return; |
63 | } | 68 | } |
64 | 69 | ||
65 | if ( mediaPlayerState->paused() ) { | 70 | if ( mediaPlayerState->paused() ) { |
66 | mediaPlayerState->setPaused( FALSE ); | 71 | mediaPlayerState->setPaused( FALSE ); |
67 | return; | 72 | return; |
68 | } | 73 | } |
69 | 74 | ||
70 | const DocLnk *playListCurrent = playList->current(); | 75 | const DocLnk *playListCurrent = playList->current(); |
71 | if ( playListCurrent != NULL ) { | 76 | if ( playListCurrent != NULL ) { |
72 | currentFile = playListCurrent; | 77 | currentFile = playListCurrent; |
73 | } | 78 | } |
74 | 79 | ||
75 | xineControl->play( currentFile->file() ); | 80 | xineControl->play( currentFile->file() ); |
76 | 81 | ||
77 | xineControl->length(); | 82 | xineControl->length(); |
78 | long seconds = mediaPlayerState->length();// | 83 | long seconds = mediaPlayerState->length();// |
79 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 84 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
80 | qDebug(time); | 85 | qDebug(time); |
81 | 86 | ||
82 | QString tickerText; | 87 | QString tickerText; |
83 | if( currentFile->file().left(4) == "http" ) | 88 | if( currentFile->file().left(4) == "http" ) |
84 | tickerText= tr( " File: " ) + currentFile->name(); | 89 | tickerText= tr( " File: " ) + currentFile->name(); |
85 | else | 90 | else |
86 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; | 91 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; |
87 | 92 | ||
88 | // QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); | 93 | // QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); |
89 | 94 | ||
90 | // if ( !fileInfo.isEmpty() ) | 95 | // if ( !fileInfo.isEmpty() ) |
91 | // tickerText += ", " + fileInfo; | 96 | // tickerText += ", " + fileInfo; |
92 | // audioUI->setTickerText( tickerText + "." ); | 97 | // audioUI->setTickerText( tickerText + "." ); |
93 | 98 | ||
94 | audioUI->setTickerText( currentFile->file( ) ); | 99 | audioUI->setTickerText( currentFile->file( ) ); |
95 | 100 | ||
96 | } | 101 | } |
97 | 102 | ||
98 | 103 | ||
99 | void MediaPlayer::prev() { | 104 | void MediaPlayer::prev() { |
100 | if ( playList->prev() ) { | 105 | if ( playList->prev() ) { |
101 | play(); | 106 | play(); |
102 | } else if ( mediaPlayerState->looping() ) { | 107 | } else if ( mediaPlayerState->looping() ) { |
103 | if ( playList->last() ) { | 108 | if ( playList->last() ) { |
104 | play(); | 109 | play(); |
105 | } | 110 | } |
106 | } else { | 111 | } else { |
107 | mediaPlayerState->setList(); | 112 | mediaPlayerState->setList(); |
108 | } | 113 | } |
109 | } | 114 | } |
110 | 115 | ||
111 | 116 | ||
112 | void MediaPlayer::next() { | 117 | void MediaPlayer::next() { |
113 | if ( playList->next() ) { | 118 | if ( playList->next() ) { |
114 | play(); | 119 | play(); |
115 | } else if ( mediaPlayerState->looping() ) { | 120 | } else if ( mediaPlayerState->looping() ) { |
116 | if ( playList->first() ) { | 121 | if ( playList->first() ) { |
117 | play(); | 122 | play(); |
118 | } | 123 | } |
119 | } else { | 124 | } else { |
120 | mediaPlayerState->setList(); | 125 | mediaPlayerState->setList(); |
121 | } | 126 | } |
122 | } | 127 | } |
123 | 128 | ||
124 | 129 | ||
125 | void MediaPlayer::startDecreasingVolume() { | 130 | void MediaPlayer::startDecreasingVolume() { |
126 | volumeDirection = -1; | 131 | volumeDirection = -1; |
127 | startTimer( 100 ); | 132 | startTimer( 100 ); |
128 | // da kommt demnächst osound denk ich mal | 133 | volControl->decVol(2); |
129 | /////////////////////////// lets just move those change volume here | ||
130 | // AudioDevice::decreaseVolume(); | ||
131 | } | 134 | } |
132 | 135 | ||
133 | 136 | ||
134 | void MediaPlayer::startIncreasingVolume() { | 137 | void MediaPlayer::startIncreasingVolume() { |
135 | volumeDirection = +1; | 138 | volumeDirection = +1; |
136 | startTimer( 100 ); | 139 | startTimer( 100 ); |
137 | // AudioDevice::increaseVolume(); | 140 | volControl->incVol(2); |
138 | } | 141 | } |
139 | 142 | ||
140 | 143 | ||
141 | bool drawnOnScreenDisplay = FALSE; | 144 | bool drawnOnScreenDisplay = FALSE; |
142 | unsigned int onScreenDisplayVolume = 0; | 145 | unsigned int onScreenDisplayVolume = 0; |
143 | const int yoff = 110; | 146 | const int yoff = 110; |
144 | 147 | ||
145 | void MediaPlayer::stopChangingVolume() { | 148 | void MediaPlayer::stopChangingVolume() { |
146 | killTimers(); | 149 | killTimers(); |
147 | // Get rid of the on-screen display stuff | 150 | // Get rid of the on-screen display stuff |
148 | drawnOnScreenDisplay = FALSE; | 151 | drawnOnScreenDisplay = FALSE; |
149 | onScreenDisplayVolume = 0; | 152 | onScreenDisplayVolume = 0; |
150 | int w = audioUI->width(); | 153 | int w = audioUI->width(); |
151 | int h = audioUI->height(); | 154 | int h = audioUI->height(); |
152 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 155 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); |
153 | } | 156 | } |
154 | 157 | ||
155 | 158 | ||
156 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 159 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
157 | // if ( volumeDirection == +1 ) | 160 | if ( volumeDirection == +1 ) { |
158 | // AudioDevice::increaseVolume(); | 161 | volControl->incVol(2); |
159 | // else if ( volumeDirection == -1 ) | 162 | } else if ( volumeDirection == -1 ) { |
160 | // AudioDevice::decreaseVolume(); | 163 | volControl->decVol(2); |
164 | } | ||
161 | 165 | ||
162 | // Display an on-screen display volume | ||
163 | unsigned int l, r, v; bool m; | ||
164 | 166 | ||
165 | // TODO FIXME | 167 | // TODO FIXME |
166 | // AudioDevice::getVolume( l, r, m ); | 168 | int v; |
167 | // v = ((l + r) * 11) / (2*0xFFFF); | 169 | v = volControl->getVolume(); |
170 | v = v / 10; | ||
168 | 171 | ||
169 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) | 172 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
170 | return; | 173 | return; |
174 | } | ||
171 | 175 | ||
172 | int w = audioUI->width(); | 176 | int w = audioUI->width(); |
173 | int h = audioUI->height(); | 177 | int h = audioUI->height(); |
174 | 178 | ||
175 | if ( drawnOnScreenDisplay ) { | 179 | if ( drawnOnScreenDisplay ) { |
176 | if ( onScreenDisplayVolume > v ) | 180 | if ( onScreenDisplayVolume > v ) { |
177 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 181 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
182 | } | ||
178 | } | 183 | } |
179 | 184 | ||
180 | drawnOnScreenDisplay = TRUE; | 185 | drawnOnScreenDisplay = TRUE; |
181 | onScreenDisplayVolume = v; | 186 | onScreenDisplayVolume = v; |
182 | 187 | ||
183 | QPainter p( audioUI ); | 188 | QPainter p( audioUI ); |
184 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 189 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
185 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 190 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
186 | 191 | ||
187 | QFont f; | 192 | QFont f; |
188 | f.setPixelSize( 20 ); | 193 | f.setPixelSize( 20 ); |
189 | f.setBold( TRUE ); | 194 | f.setBold( TRUE ); |
190 | p.setFont( f ); | 195 | p.setFont( f ); |
191 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 196 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
192 | 197 | ||
193 | for ( unsigned int i = 0; i < 10; i++ ) { | 198 | for ( unsigned int i = 0; i < 10; i++ ) { |
194 | if ( v > i ) | 199 | if ( v > i ) { |
195 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 200 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
196 | else | 201 | } else { |
197 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 202 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
203 | } | ||
198 | } | 204 | } |
199 | } | 205 | } |
200 | 206 | ||
201 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 207 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
202 | switch ( e->key() ) { | 208 | switch ( e->key() ) { |
203 | ////////////////////////////// Zaurus keys | 209 | ////////////////////////////// Zaurus keys |
204 | case Key_Home: | 210 | case Key_Home: |
205 | break; | 211 | break; |
206 | case Key_F9: //activity | 212 | case Key_F9: //activity |
207 | break; | 213 | break; |
208 | case Key_F10: //contacts | 214 | case Key_F10: //contacts |
209 | break; | 215 | break; |
210 | case Key_F11: //menu | 216 | case Key_F11: //menu |
211 | break; | 217 | break; |
212 | case Key_F12: //home | 218 | case Key_F12: //home |
213 | qDebug("Blank here"); | 219 | qDebug("Blank here"); |
214 | break; | 220 | break; |
215 | case Key_F13: //mail | 221 | case Key_F13: //mail |
216 | break; | 222 | break; |
217 | } | 223 | } |
218 | } | 224 | } |
219 | 225 | ||
220 | void MediaPlayer::doBlank() { | 226 | void MediaPlayer::doBlank() { |
221 | 227 | ||
222 | } | 228 | } |
223 | 229 | ||
224 | void MediaPlayer::doUnblank() { | 230 | void MediaPlayer::doUnblank() { |
225 | 231 | ||
226 | } | 232 | } |
227 | 233 | ||
228 | void MediaPlayer::cleanUp() { | 234 | void MediaPlayer::cleanUp() { |
229 | // QPEApplication::grabKeyboard(); | 235 | // QPEApplication::grabKeyboard(); |
230 | // QPEApplication::ungrabKeyboard(); | 236 | // QPEApplication::ungrabKeyboard(); |
231 | 237 | ||
232 | } | 238 | } |
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h index 7b79066..16213b5 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.h +++ b/noncore/multimedia/opieplayer2/mediaplayer.h | |||
@@ -1,46 +1,46 @@ | |||
1 | 1 | ||
2 | #ifndef MEDIA_PLAYER_H | 2 | #ifndef MEDIA_PLAYER_H |
3 | #define MEDIA_PLAYER_H | 3 | #define MEDIA_PLAYER_H |
4 | 4 | ||
5 | #include <qmainwindow.h> | 5 | #include <qmainwindow.h> |
6 | #include <qframe.h> | 6 | #include <qframe.h> |
7 | #include <qpe/qlibrary.h> | 7 | #include <qpe/qlibrary.h> |
8 | #include <qpe/mediaplayerplugininterface.h> | 8 | #include <qpe/mediaplayerplugininterface.h> |
9 | 9 | ||
10 | #include "xinecontrol.h" | 10 | #include "xinecontrol.h" |
11 | 11 | ||
12 | class DocLnk; | 12 | class DocLnk; |
13 | 13 | class VolumeControl; | |
14 | 14 | ||
15 | class MediaPlayer : public QObject { | 15 | class MediaPlayer : public QObject { |
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | public: | 17 | public: |
18 | MediaPlayer( QObject *parent, const char *name ); | 18 | MediaPlayer( QObject *parent, const char *name ); |
19 | ~MediaPlayer(); | 19 | ~MediaPlayer(); |
20 | 20 | ||
21 | private slots: | 21 | private slots: |
22 | void setPlaying( bool ); | 22 | void setPlaying( bool ); |
23 | void pauseCheck( bool ); | 23 | void pauseCheck( bool ); |
24 | void play(); | 24 | void play(); |
25 | void next(); | 25 | void next(); |
26 | void prev(); | 26 | void prev(); |
27 | void startIncreasingVolume(); | 27 | void startIncreasingVolume(); |
28 | void startDecreasingVolume(); | 28 | void startDecreasingVolume(); |
29 | void stopChangingVolume(); | 29 | void stopChangingVolume(); |
30 | void cleanUp(); | 30 | void cleanUp(); |
31 | 31 | ||
32 | protected: | 32 | protected: |
33 | void timerEvent( QTimerEvent *e ); | 33 | void timerEvent( QTimerEvent *e ); |
34 | void keyReleaseEvent( QKeyEvent *e); | 34 | void keyReleaseEvent( QKeyEvent *e); |
35 | void doBlank(); | 35 | void doBlank(); |
36 | void doUnblank(); | 36 | void doUnblank(); |
37 | private: | 37 | private: |
38 | int volumeDirection; | 38 | int volumeDirection; |
39 | const DocLnk *currentFile; | 39 | const DocLnk *currentFile; |
40 | XineControl *xineControl; | 40 | XineControl *xineControl; |
41 | 41 | VolumeControl *volControl; | |
42 | }; | 42 | }; |
43 | 43 | ||
44 | 44 | ||
45 | #endif // MEDIA_PLAYER_H | 45 | #endif // MEDIA_PLAYER_H |
46 | 46 | ||
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro index fee9242..edc4624 100644 --- a/noncore/multimedia/opieplayer2/opieplayer2.pro +++ b/noncore/multimedia/opieplayer2/opieplayer2.pro | |||
@@ -1,23 +1,23 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | #release | 3 | #release |
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ | 5 | HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ |
6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ | 6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ |
7 | frame.h lib.h xinevideowidget.h \ | 7 | frame.h lib.h xinevideowidget.h volumecontrol.h\ |
8 | alphablend.h yuv2rgb.h | 8 | alphablend.h yuv2rgb.h |
9 | SOURCES = main.cpp \ | 9 | SOURCES = main.cpp \ |
10 | playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ | 10 | playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ |
11 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ | 11 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ |
12 | frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp \ | 12 | frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp\ |
13 | alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S | 13 | alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S |
14 | TARGET = opieplayer2 | 14 | TARGET = opieplayer2 |
15 | INCLUDEPATH += $(OPIEDIR)/include | 15 | INCLUDEPATH += $(OPIEDIR)/include |
16 | DEPENDPATH += $(OPIEDIR)/include | 16 | DEPENDPATH += $(OPIEDIR)/include |
17 | LIBS += -lqpe -lpthread -lopie -lxine -lxineutils | 17 | LIBS += -lqpe -lpthread -lopie -lxine -lxineutils |
18 | MOC_DIR=qpeobj | 18 | MOC_DIR=qpeobj |
19 | OBJECTS_DIR=qpeobj | 19 | OBJECTS_DIR=qpeobj |
20 | 20 | ||
21 | INCLUDEPATH += $(OPIEDIR)/include | 21 | INCLUDEPATH += $(OPIEDIR)/include |
22 | DEPENDPATH += $(OPIEDIR)/include | 22 | DEPENDPATH += $(OPIEDIR)/include |
23 | 23 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 9065d63..b43d9f7 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,935 +1,935 @@ | |||
1 | 1 | ||
2 | #define QTOPIA_INTERNAL_FSLP | 2 | #define QTOPIA_INTERNAL_FSLP |
3 | #include <qpe/qcopenvelope_qws.h> | 3 | #include <qpe/qcopenvelope_qws.h> |
4 | 4 | ||
5 | #include <qpe/qpemenubar.h> | 5 | #include <qpe/qpemenubar.h> |
6 | #include <qpe/qpetoolbar.h> | 6 | #include <qpe/qpetoolbar.h> |
7 | #include <qpe/fileselector.h> | 7 | #include <qpe/fileselector.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/lnkproperties.h> | 9 | #include <qpe/lnkproperties.h> |
10 | #include <qpe/storage.h> | 10 | #include <qpe/storage.h> |
11 | 11 | ||
12 | #include <qpe/applnk.h> | 12 | #include <qpe/applnk.h> |
13 | #include <qpe/config.h> | 13 | #include <qpe/config.h> |
14 | #include <qpe/global.h> | 14 | #include <qpe/global.h> |
15 | #include <qpe/resource.h> | 15 | #include <qpe/resource.h> |
16 | #include <qaction.h> | 16 | #include <qaction.h> |
17 | #include <qcursor.h> | 17 | #include <qcursor.h> |
18 | #include <qimage.h> | 18 | #include <qimage.h> |
19 | #include <qfile.h> | 19 | #include <qfile.h> |
20 | #include <qdir.h> | 20 | #include <qdir.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qlist.h> | 23 | #include <qlist.h> |
24 | #include <qlistbox.h> | 24 | #include <qlistbox.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qtoolbutton.h> | 27 | #include <qtoolbutton.h> |
28 | #include <qtabwidget.h> | 28 | #include <qtabwidget.h> |
29 | #include <qlistview.h> | 29 | #include <qlistview.h> |
30 | #include <qpoint.h> | 30 | #include <qpoint.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qregexp.h> | 33 | #include <qregexp.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | 35 | ||
36 | 36 | ||
37 | #include "playlistselection.h" | 37 | #include "playlistselection.h" |
38 | #include "playlistwidget.h" | 38 | #include "playlistwidget.h" |
39 | #include "mediaplayerstate.h" | 39 | #include "mediaplayerstate.h" |
40 | 40 | ||
41 | #include "inputDialog.h" | 41 | #include "inputDialog.h" |
42 | 42 | ||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | #include "audiowidget.h" | 44 | #include "audiowidget.h" |
45 | #include "videowidget.h" | 45 | #include "videowidget.h" |
46 | 46 | ||
47 | #include <unistd.h> | 47 | #include <unistd.h> |
48 | #include <sys/file.h> | 48 | #include <sys/file.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/soundcard.h> | 50 | #include <sys/soundcard.h> |
51 | 51 | ||
52 | // for setBacklight() | 52 | // for setBacklight() |
53 | #include <linux/fb.h> | 53 | #include <linux/fb.h> |
54 | #include <sys/types.h> | 54 | #include <sys/types.h> |
55 | #include <sys/stat.h> | 55 | #include <sys/stat.h> |
56 | #include <stdlib.h> | 56 | #include <stdlib.h> |
57 | 57 | ||
58 | #define BUTTONS_ON_TOOLBAR | 58 | #define BUTTONS_ON_TOOLBAR |
59 | #define SIDE_BUTTONS | 59 | #define SIDE_BUTTONS |
60 | #define CAN_SAVE_LOAD_PLAYLISTS | 60 | #define CAN_SAVE_LOAD_PLAYLISTS |
61 | 61 | ||
62 | extern MediaPlayerState *mediaPlayerState; | 62 | extern MediaPlayerState *mediaPlayerState; |
63 | 63 | ||
64 | 64 | ||
65 | class PlayListWidgetPrivate { | 65 | class PlayListWidgetPrivate { |
66 | public: | 66 | public: |
67 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 67 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
68 | QFrame *playListFrame; | 68 | QFrame *playListFrame; |
69 | FileSelector *files; | 69 | FileSelector *files; |
70 | PlayListSelection *selectedFiles; | 70 | PlayListSelection *selectedFiles; |
71 | bool setDocumentUsed; | 71 | bool setDocumentUsed; |
72 | DocLnk *current; | 72 | DocLnk *current; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | 75 | ||
76 | class ToolButton : public QToolButton { | 76 | class ToolButton : public QToolButton { |
77 | public: | 77 | public: |
78 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 78 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
79 | : QToolButton( parent, name ) { | 79 | : QToolButton( parent, name ) { |
80 | setTextLabel( name ); | 80 | setTextLabel( name ); |
81 | setPixmap( Resource::loadPixmap( icon ) ); | 81 | setPixmap( Resource::loadPixmap( icon ) ); |
82 | setAutoRaise( TRUE ); | 82 | setAutoRaise( TRUE ); |
83 | setFocusPolicy( QWidget::NoFocus ); | 83 | setFocusPolicy( QWidget::NoFocus ); |
84 | setToggleButton( t ); | 84 | setToggleButton( t ); |
85 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 85 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
86 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 86 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
87 | } | 87 | } |
88 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
91 | class MenuItem : public QAction { | 91 | class MenuItem : public QAction { |
92 | public: | 92 | public: |
93 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 93 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
94 | : QAction( text, QString::null, 0, 0 ) { | 94 | : QAction( text, QString::null, 0, 0 ) { |
95 | connect( this, SIGNAL( activated() ), handler, slot ); | 95 | connect( this, SIGNAL( activated() ), handler, slot ); |
96 | addTo( parent ); | 96 | addTo( parent ); |
97 | } | 97 | } |
98 | }; | 98 | }; |
99 | 99 | ||
100 | 100 | ||
101 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 101 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
102 | : QMainWindow( parent, name, fl ) { | 102 | : QMainWindow( parent, name, fl ) { |
103 | 103 | ||
104 | d = new PlayListWidgetPrivate; | 104 | d = new PlayListWidgetPrivate; |
105 | d->setDocumentUsed = FALSE; | 105 | d->setDocumentUsed = FALSE; |
106 | d->current = NULL; | 106 | d->current = NULL; |
107 | fromSetDocument = FALSE; | 107 | fromSetDocument = FALSE; |
108 | insanityBool=FALSE; | 108 | insanityBool=FALSE; |
109 | audioScan = FALSE; | 109 | audioScan = FALSE; |
110 | videoScan = FALSE; | 110 | videoScan = FALSE; |
111 | 111 | ||
112 | setBackgroundMode( PaletteButton ); | 112 | setBackgroundMode( PaletteButton ); |
113 | 113 | ||
114 | setCaption( tr("OpiePlayer") ); | 114 | setCaption( tr("OpiePlayer") ); |
115 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 115 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
116 | 116 | ||
117 | setToolBarsMovable( FALSE ); | 117 | setToolBarsMovable( FALSE ); |
118 | 118 | ||
119 | // Create Toolbar | 119 | // Create Toolbar |
120 | QPEToolBar *toolbar = new QPEToolBar( this ); | 120 | QPEToolBar *toolbar = new QPEToolBar( this ); |
121 | toolbar->setHorizontalStretchable( TRUE ); | 121 | toolbar->setHorizontalStretchable( TRUE ); |
122 | 122 | ||
123 | // Create Menubar | 123 | // Create Menubar |
124 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 124 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
125 | menu->setMargin( 0 ); | 125 | menu->setMargin( 0 ); |
126 | 126 | ||
127 | QPEToolBar *bar = new QPEToolBar( this ); | 127 | QPEToolBar *bar = new QPEToolBar( this ); |
128 | bar->setLabel( tr( "Play Operations" ) ); | 128 | bar->setLabel( tr( "Play Operations" ) ); |
129 | 129 | ||
130 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 130 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
131 | tbDeletePlaylist->setFlat(TRUE); | 131 | tbDeletePlaylist->setFlat(TRUE); |
132 | tbDeletePlaylist->setFixedSize(20,20); | 132 | tbDeletePlaylist->setFixedSize(20,20); |
133 | 133 | ||
134 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 134 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
135 | this , SLOT(addSelected()) ); | 135 | this , SLOT(addSelected()) ); |
136 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 136 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
137 | this , SLOT(removeSelected()) ); | 137 | this , SLOT(removeSelected()) ); |
138 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 138 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
139 | this , SLOT( btnPlay(bool) ), TRUE ); | 139 | this , SLOT( btnPlay(bool) ), TRUE ); |
140 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 140 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
141 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 141 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
142 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 142 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
143 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 143 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
144 | tbDeletePlaylist->hide(); | 144 | tbDeletePlaylist->hide(); |
145 | 145 | ||
146 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 146 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
147 | menu->insertItem( tr( "File" ), pmPlayList ); | 147 | menu->insertItem( tr( "File" ), pmPlayList ); |
148 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 148 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
149 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 149 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
150 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 150 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
151 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 151 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
152 | pmPlayList->insertSeparator(-1); | 152 | pmPlayList->insertSeparator(-1); |
153 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 153 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
154 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | 154 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); |
155 | pmPlayList->insertSeparator(-1); | 155 | pmPlayList->insertSeparator(-1); |
156 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 156 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
157 | pmPlayList->insertSeparator(-1); | 157 | pmPlayList->insertSeparator(-1); |
158 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 158 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
159 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 159 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
160 | 160 | ||
161 | QPopupMenu *pmView = new QPopupMenu( this ); | 161 | QPopupMenu *pmView = new QPopupMenu( this ); |
162 | menu->insertItem( tr( "View" ), pmView ); | 162 | menu->insertItem( tr( "View" ), pmView ); |
163 | 163 | ||
164 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 164 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
165 | fullScreenButton->addTo(pmView); | 165 | fullScreenButton->addTo(pmView); |
166 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 166 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
167 | scaleButton->addTo(pmView); | 167 | //scaleButton->addTo(pmView); |
168 | 168 | ||
169 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 169 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
170 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 170 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
171 | 171 | ||
172 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 172 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
173 | 173 | ||
174 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 174 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
175 | // tabWidget->setTabShape(QTabWidget::Triangular); | 175 | // tabWidget->setTabShape(QTabWidget::Triangular); |
176 | 176 | ||
177 | QWidget *pTab; | 177 | QWidget *pTab; |
178 | pTab = new QWidget( tabWidget, "pTab" ); | 178 | pTab = new QWidget( tabWidget, "pTab" ); |
179 | tabWidget->insertTab( pTab,"Playlist"); | 179 | tabWidget->insertTab( pTab,"Playlist"); |
180 | 180 | ||
181 | 181 | ||
182 | // Add the playlist area | 182 | // Add the playlist area |
183 | 183 | ||
184 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 184 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
185 | d->playListFrame = vbox3; | 185 | d->playListFrame = vbox3; |
186 | d->playListFrame ->setMinimumSize(235,260); | 186 | d->playListFrame ->setMinimumSize(235,260); |
187 | 187 | ||
188 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 188 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
189 | 189 | ||
190 | d->selectedFiles = new PlayListSelection( hbox2); | 190 | d->selectedFiles = new PlayListSelection( hbox2); |
191 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 191 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
192 | 192 | ||
193 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 193 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
194 | 194 | ||
195 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 195 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
196 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 196 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
197 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 197 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
198 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 198 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
199 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 199 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
200 | 200 | ||
201 | QWidget *aTab; | 201 | QWidget *aTab; |
202 | aTab = new QWidget( tabWidget, "aTab" ); | 202 | aTab = new QWidget( tabWidget, "aTab" ); |
203 | audioView = new QListView( aTab, "Audioview" ); | 203 | audioView = new QListView( aTab, "Audioview" ); |
204 | audioView->setMinimumSize(233,260); | 204 | audioView->setMinimumSize(233,260); |
205 | audioView->addColumn( tr("Title"),140); | 205 | audioView->addColumn( tr("Title"),140); |
206 | audioView->addColumn(tr("Size"), -1); | 206 | audioView->addColumn(tr("Size"), -1); |
207 | audioView->addColumn(tr("Media"),-1); | 207 | audioView->addColumn(tr("Media"),-1); |
208 | audioView->setColumnAlignment(1, Qt::AlignRight); | 208 | audioView->setColumnAlignment(1, Qt::AlignRight); |
209 | audioView->setColumnAlignment(2, Qt::AlignRight); | 209 | audioView->setColumnAlignment(2, Qt::AlignRight); |
210 | audioView->setAllColumnsShowFocus(TRUE); | 210 | audioView->setAllColumnsShowFocus(TRUE); |
211 | 211 | ||
212 | audioView->setMultiSelection( TRUE ); | 212 | audioView->setMultiSelection( TRUE ); |
213 | audioView->setSelectionMode( QListView::Extended); | 213 | audioView->setSelectionMode( QListView::Extended); |
214 | 214 | ||
215 | tabWidget->insertTab(aTab,tr("Audio")); | 215 | tabWidget->insertTab(aTab,tr("Audio")); |
216 | 216 | ||
217 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 217 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
218 | 218 | ||
219 | QWidget *vTab; | 219 | QWidget *vTab; |
220 | vTab = new QWidget( tabWidget, "vTab" ); | 220 | vTab = new QWidget( tabWidget, "vTab" ); |
221 | videoView = new QListView( vTab, "Videoview" ); | 221 | videoView = new QListView( vTab, "Videoview" ); |
222 | videoView->setMinimumSize(233,260); | 222 | videoView->setMinimumSize(233,260); |
223 | 223 | ||
224 | videoView->addColumn(tr("Title"),140); | 224 | videoView->addColumn(tr("Title"),140); |
225 | videoView->addColumn(tr("Size"),-1); | 225 | videoView->addColumn(tr("Size"),-1); |
226 | videoView->addColumn(tr("Media"),-1); | 226 | videoView->addColumn(tr("Media"),-1); |
227 | videoView->setColumnAlignment(1, Qt::AlignRight); | 227 | videoView->setColumnAlignment(1, Qt::AlignRight); |
228 | videoView->setColumnAlignment(2, Qt::AlignRight); | 228 | videoView->setColumnAlignment(2, Qt::AlignRight); |
229 | videoView->setAllColumnsShowFocus(TRUE); | 229 | videoView->setAllColumnsShowFocus(TRUE); |
230 | videoView->setMultiSelection( TRUE ); | 230 | videoView->setMultiSelection( TRUE ); |
231 | videoView->setSelectionMode( QListView::Extended); | 231 | videoView->setSelectionMode( QListView::Extended); |
232 | 232 | ||
233 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 233 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
234 | 234 | ||
235 | tabWidget->insertTab( vTab,tr("Video")); | 235 | tabWidget->insertTab( vTab,tr("Video")); |
236 | 236 | ||
237 | //playlists list | 237 | //playlists list |
238 | QWidget *LTab; | 238 | QWidget *LTab; |
239 | LTab = new QWidget( tabWidget, "LTab" ); | 239 | LTab = new QWidget( tabWidget, "LTab" ); |
240 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 240 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
241 | playLists->setMinimumSize(233,260); | 241 | playLists->setMinimumSize(233,260); |
242 | tabWidget->insertTab(LTab,tr("Lists")); | 242 | tabWidget->insertTab(LTab,tr("Lists")); |
243 | 243 | ||
244 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 244 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
245 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 245 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
246 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 246 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
247 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 247 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
248 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 248 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
249 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 249 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
251 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 251 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
252 | this,SLOT( playIt( QListViewItem *)) ); | 252 | this,SLOT( playIt( QListViewItem *)) ); |
253 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 253 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
254 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 254 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
255 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 255 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
256 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 256 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
257 | this,SLOT( playIt( QListViewItem *)) ); | 257 | this,SLOT( playIt( QListViewItem *)) ); |
258 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 258 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
259 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 259 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
260 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 260 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
261 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 261 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
262 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 262 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
263 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 263 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
264 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 264 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
265 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 265 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
266 | 266 | ||
267 | setCentralWidget( vbox5 ); | 267 | setCentralWidget( vbox5 ); |
268 | 268 | ||
269 | Config cfg( "OpiePlayer" ); | 269 | Config cfg( "OpiePlayer" ); |
270 | readConfig( cfg ); | 270 | readConfig( cfg ); |
271 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 271 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
272 | loadList(DocLnk( currentPlaylist)); | 272 | loadList(DocLnk( currentPlaylist)); |
273 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 273 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
274 | 274 | ||
275 | initializeStates(); | 275 | initializeStates(); |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
279 | PlayListWidget::~PlayListWidget() { | 279 | PlayListWidget::~PlayListWidget() { |
280 | Config cfg( "OpiePlayer" ); | 280 | Config cfg( "OpiePlayer" ); |
281 | writeConfig( cfg ); | 281 | writeConfig( cfg ); |
282 | 282 | ||
283 | if ( d->current ) { | 283 | if ( d->current ) { |
284 | delete d->current; | 284 | delete d->current; |
285 | } | 285 | } |
286 | delete d; | 286 | delete d; |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | void PlayListWidget::initializeStates() { | 290 | void PlayListWidget::initializeStates() { |
291 | 291 | ||
292 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 292 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
293 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 293 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
294 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 294 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
295 | setPlaylist( true); | 295 | setPlaylist( true); |
296 | } | 296 | } |
297 | 297 | ||
298 | 298 | ||
299 | void PlayListWidget::readConfig( Config& cfg ) { | 299 | void PlayListWidget::readConfig( Config& cfg ) { |
300 | cfg.setGroup("PlayList"); | 300 | cfg.setGroup("PlayList"); |
301 | QString currentString = cfg.readEntry("current", "" ); | 301 | QString currentString = cfg.readEntry("current", "" ); |
302 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 302 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
303 | for ( int i = 0; i < noOfFiles; i++ ) { | 303 | for ( int i = 0; i < noOfFiles; i++ ) { |
304 | QString entryName; | 304 | QString entryName; |
305 | entryName.sprintf( "File%i", i + 1 ); | 305 | entryName.sprintf( "File%i", i + 1 ); |
306 | QString linkFile = cfg.readEntry( entryName ); | 306 | QString linkFile = cfg.readEntry( entryName ); |
307 | DocLnk lnk( linkFile ); | 307 | DocLnk lnk( linkFile ); |
308 | if ( lnk.isValid() ) { | 308 | if ( lnk.isValid() ) { |
309 | d->selectedFiles->addToSelection( lnk ); | 309 | d->selectedFiles->addToSelection( lnk ); |
310 | } | 310 | } |
311 | } | 311 | } |
312 | d->selectedFiles->setSelectedItem( currentString); | 312 | d->selectedFiles->setSelectedItem( currentString); |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void PlayListWidget::writeConfig( Config& cfg ) const { | 316 | void PlayListWidget::writeConfig( Config& cfg ) const { |
317 | 317 | ||
318 | d->selectedFiles->writeCurrent( cfg); | 318 | d->selectedFiles->writeCurrent( cfg); |
319 | cfg.setGroup("PlayList"); | 319 | cfg.setGroup("PlayList"); |
320 | int noOfFiles = 0; | 320 | int noOfFiles = 0; |
321 | d->selectedFiles->first(); | 321 | d->selectedFiles->first(); |
322 | do { | 322 | do { |
323 | const DocLnk *lnk = d->selectedFiles->current(); | 323 | const DocLnk *lnk = d->selectedFiles->current(); |
324 | if ( lnk ) { | 324 | if ( lnk ) { |
325 | QString entryName; | 325 | QString entryName; |
326 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 326 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
327 | cfg.writeEntry( entryName, lnk->linkFile() ); | 327 | cfg.writeEntry( entryName, lnk->linkFile() ); |
328 | // if this link does exist, add it so we have the file | 328 | // if this link does exist, add it so we have the file |
329 | // next time... | 329 | // next time... |
330 | if ( !QFile::exists( lnk->linkFile() ) ) { | 330 | if ( !QFile::exists( lnk->linkFile() ) ) { |
331 | // the way writing lnks doesn't really check for out | 331 | // the way writing lnks doesn't really check for out |
332 | // of disk space, but check it anyway. | 332 | // of disk space, but check it anyway. |
333 | if ( !lnk->writeLink() ) { | 333 | if ( !lnk->writeLink() ) { |
334 | QMessageBox::critical( 0, tr("Out of space"), | 334 | QMessageBox::critical( 0, tr("Out of space"), |
335 | tr( "There was a problem saving " | 335 | tr( "There was a problem saving " |
336 | "the playlist.\n" | 336 | "the playlist.\n" |
337 | "Your playlist " | 337 | "Your playlist " |
338 | "may be missing some entries\n" | 338 | "may be missing some entries\n" |
339 | "the next time you start it." ) | 339 | "the next time you start it." ) |
340 | ); | 340 | ); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | noOfFiles++; | 343 | noOfFiles++; |
344 | } | 344 | } |
345 | } | 345 | } |
346 | while ( d->selectedFiles->next() ); | 346 | while ( d->selectedFiles->next() ); |
347 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 347 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
348 | } | 348 | } |
349 | 349 | ||
350 | 350 | ||
351 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 351 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
352 | d->setDocumentUsed = FALSE; | 352 | d->setDocumentUsed = FALSE; |
353 | if ( mediaPlayerState->playlist() ) { | 353 | if ( mediaPlayerState->playlist() ) { |
354 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 354 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
355 | d->selectedFiles->addToSelection( lnk ); | 355 | d->selectedFiles->addToSelection( lnk ); |
356 | } | 356 | } |
357 | else | 357 | else |
358 | mediaPlayerState->setPlaying( TRUE ); | 358 | mediaPlayerState->setPlaying( TRUE ); |
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | void PlayListWidget::clearList() { | 362 | void PlayListWidget::clearList() { |
363 | while ( first() ) { | 363 | while ( first() ) { |
364 | d->selectedFiles->removeSelected(); | 364 | d->selectedFiles->removeSelected(); |
365 | } | 365 | } |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | void PlayListWidget::addAllToList() { | 369 | void PlayListWidget::addAllToList() { |
370 | DocLnkSet filesAll; | 370 | DocLnkSet filesAll; |
371 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 371 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
372 | QListIterator<DocLnk> Adit( filesAll.children() ); | 372 | QListIterator<DocLnk> Adit( filesAll.children() ); |
373 | for ( ; Adit.current(); ++Adit ) { | 373 | for ( ; Adit.current(); ++Adit ) { |
374 | if(QFileInfo(Adit.current()->file()).exists()) { | 374 | if(QFileInfo(Adit.current()->file()).exists()) { |
375 | d->selectedFiles->addToSelection( **Adit ); | 375 | d->selectedFiles->addToSelection( **Adit ); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void PlayListWidget::addAllMusicToList() { | 381 | void PlayListWidget::addAllMusicToList() { |
382 | QListIterator<DocLnk> dit( files.children() ); | 382 | QListIterator<DocLnk> dit( files.children() ); |
383 | for ( ; dit.current(); ++dit ) { | 383 | for ( ; dit.current(); ++dit ) { |
384 | if(QFileInfo(dit.current()->file()).exists()) { | 384 | if(QFileInfo(dit.current()->file()).exists()) { |
385 | d->selectedFiles->addToSelection( **dit ); | 385 | d->selectedFiles->addToSelection( **dit ); |
386 | } | 386 | } |
387 | } | 387 | } |
388 | } | 388 | } |
389 | 389 | ||
390 | 390 | ||
391 | void PlayListWidget::addAllVideoToList() { | 391 | void PlayListWidget::addAllVideoToList() { |
392 | QListIterator<DocLnk> dit( vFiles.children() ); | 392 | QListIterator<DocLnk> dit( vFiles.children() ); |
393 | for ( ; dit.current(); ++dit ) | 393 | for ( ; dit.current(); ++dit ) |
394 | if(QFileInfo( dit.current()->file()).exists()) | 394 | if(QFileInfo( dit.current()->file()).exists()) |
395 | d->selectedFiles->addToSelection( **dit ); | 395 | d->selectedFiles->addToSelection( **dit ); |
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | void PlayListWidget::setDocument(const QString& fileref) { | 399 | void PlayListWidget::setDocument(const QString& fileref) { |
400 | qDebug(fileref); | 400 | qDebug(fileref); |
401 | fromSetDocument = TRUE; | 401 | fromSetDocument = TRUE; |
402 | if ( fileref.isNull() ) { | 402 | if ( fileref.isNull() ) { |
403 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 403 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
404 | return; | 404 | return; |
405 | } | 405 | } |
406 | 406 | ||
407 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 407 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
408 | readm3u( fileref); | 408 | readm3u( fileref); |
409 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 409 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
410 | readPls( fileref); | 410 | readPls( fileref); |
411 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 411 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
412 | clearList(); | 412 | clearList(); |
413 | loadList(DocLnk(fileref)); | 413 | loadList(DocLnk(fileref)); |
414 | d->selectedFiles->first(); | 414 | d->selectedFiles->first(); |
415 | } else { | 415 | } else { |
416 | clearList(); | 416 | clearList(); |
417 | addToSelection( DocLnk( fileref ) ); | 417 | addToSelection( DocLnk( fileref ) ); |
418 | d->setDocumentUsed = TRUE; | 418 | d->setDocumentUsed = TRUE; |
419 | mediaPlayerState->setPlaying( FALSE ); | 419 | mediaPlayerState->setPlaying( FALSE ); |
420 | qApp->processEvents(); | 420 | qApp->processEvents(); |
421 | mediaPlayerState->setPlaying( TRUE ); | 421 | mediaPlayerState->setPlaying( TRUE ); |
422 | qApp->processEvents(); | 422 | qApp->processEvents(); |
423 | setCaption(tr("OpiePlayer")); | 423 | setCaption(tr("OpiePlayer")); |
424 | } | 424 | } |
425 | } | 425 | } |
426 | 426 | ||
427 | 427 | ||
428 | void PlayListWidget::setActiveWindow() { | 428 | void PlayListWidget::setActiveWindow() { |
429 | qDebug("SETTING active window"); | 429 | qDebug("SETTING active window"); |
430 | // When we get raised we need to ensure that it switches views | 430 | // When we get raised we need to ensure that it switches views |
431 | char origView = mediaPlayerState->view(); | 431 | char origView = mediaPlayerState->view(); |
432 | mediaPlayerState->setView( 'l' ); // invalidate | 432 | mediaPlayerState->setView( 'l' ); // invalidate |
433 | mediaPlayerState->setView( origView ); // now switch back | 433 | mediaPlayerState->setView( origView ); // now switch back |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | void PlayListWidget::useSelectedDocument() { | 437 | void PlayListWidget::useSelectedDocument() { |
438 | d->setDocumentUsed = FALSE; | 438 | d->setDocumentUsed = FALSE; |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | const DocLnk *PlayListWidget::current() { // this is fugly | 442 | const DocLnk *PlayListWidget::current() { // this is fugly |
443 | 443 | ||
444 | switch (tabWidget->currentPageIndex()) { | 444 | switch (tabWidget->currentPageIndex()) { |
445 | case 0: //playlist | 445 | case 0: //playlist |
446 | { | 446 | { |
447 | qDebug("playlist"); | 447 | qDebug("playlist"); |
448 | if ( mediaPlayerState->playlist() ) { | 448 | if ( mediaPlayerState->playlist() ) { |
449 | return d->selectedFiles->current(); | 449 | return d->selectedFiles->current(); |
450 | } else if ( d->setDocumentUsed && d->current ) { | 450 | } else if ( d->setDocumentUsed && d->current ) { |
451 | return d->current; | 451 | return d->current; |
452 | } else { | 452 | } else { |
453 | return d->files->selected(); | 453 | return d->files->selected(); |
454 | } | 454 | } |
455 | } | 455 | } |
456 | break; | 456 | break; |
457 | case 1://audio | 457 | case 1://audio |
458 | { | 458 | { |
459 | qDebug("audioView"); | 459 | qDebug("audioView"); |
460 | QListIterator<DocLnk> dit( files.children() ); | 460 | QListIterator<DocLnk> dit( files.children() ); |
461 | for ( ; dit.current(); ++dit ) { | 461 | for ( ; dit.current(); ++dit ) { |
462 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 462 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
463 | qDebug("here"); | 463 | qDebug("here"); |
464 | insanityBool=TRUE; | 464 | insanityBool=TRUE; |
465 | return dit; | 465 | return dit; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | } | 468 | } |
469 | break; | 469 | break; |
470 | case 2: // video | 470 | case 2: // video |
471 | { | 471 | { |
472 | qDebug("videoView"); | 472 | qDebug("videoView"); |
473 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 473 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
474 | for ( ; Vdit.current(); ++Vdit ) { | 474 | for ( ; Vdit.current(); ++Vdit ) { |
475 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 475 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
476 | insanityBool=TRUE; | 476 | insanityBool=TRUE; |
477 | return Vdit; | 477 | return Vdit; |
478 | } | 478 | } |
479 | } | 479 | } |
480 | } | 480 | } |
481 | break; | 481 | break; |
482 | }; | 482 | }; |
483 | return 0; | 483 | return 0; |
484 | } | 484 | } |
485 | 485 | ||
486 | bool PlayListWidget::prev() { | 486 | bool PlayListWidget::prev() { |
487 | if ( mediaPlayerState->playlist() ) { | 487 | if ( mediaPlayerState->playlist() ) { |
488 | if ( mediaPlayerState->shuffled() ) { | 488 | if ( mediaPlayerState->shuffled() ) { |
489 | const DocLnk *cur = current(); | 489 | const DocLnk *cur = current(); |
490 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 490 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
491 | for ( int i = 0; i < j; i++ ) { | 491 | for ( int i = 0; i < j; i++ ) { |
492 | if ( !d->selectedFiles->next() ) | 492 | if ( !d->selectedFiles->next() ) |
493 | d->selectedFiles->first(); | 493 | d->selectedFiles->first(); |
494 | } | 494 | } |
495 | if ( cur == current() ) | 495 | if ( cur == current() ) |
496 | if ( !d->selectedFiles->next() ) | 496 | if ( !d->selectedFiles->next() ) |
497 | d->selectedFiles->first(); | 497 | d->selectedFiles->first(); |
498 | return TRUE; | 498 | return TRUE; |
499 | } else { | 499 | } else { |
500 | if ( !d->selectedFiles->prev() ) { | 500 | if ( !d->selectedFiles->prev() ) { |
501 | if ( mediaPlayerState->looping() ) { | 501 | if ( mediaPlayerState->looping() ) { |
502 | return d->selectedFiles->last(); | 502 | return d->selectedFiles->last(); |
503 | } else { | 503 | } else { |
504 | return FALSE; | 504 | return FALSE; |
505 | } | 505 | } |
506 | } | 506 | } |
507 | return TRUE; | 507 | return TRUE; |
508 | } | 508 | } |
509 | } else { | 509 | } else { |
510 | return mediaPlayerState->looping(); | 510 | return mediaPlayerState->looping(); |
511 | } | 511 | } |
512 | } | 512 | } |
513 | 513 | ||
514 | 514 | ||
515 | bool PlayListWidget::next() { | 515 | bool PlayListWidget::next() { |
516 | if ( mediaPlayerState->playlist() ) { | 516 | if ( mediaPlayerState->playlist() ) { |
517 | if ( mediaPlayerState->shuffled() ) { | 517 | if ( mediaPlayerState->shuffled() ) { |
518 | return prev(); | 518 | return prev(); |
519 | } else { | 519 | } else { |
520 | if ( !d->selectedFiles->next() ) { | 520 | if ( !d->selectedFiles->next() ) { |
521 | if ( mediaPlayerState->looping() ) { | 521 | if ( mediaPlayerState->looping() ) { |
522 | return d->selectedFiles->first(); | 522 | return d->selectedFiles->first(); |
523 | } else { | 523 | } else { |
524 | return FALSE; | 524 | return FALSE; |
525 | } | 525 | } |
526 | } | 526 | } |
527 | return TRUE; | 527 | return TRUE; |
528 | } | 528 | } |
529 | } else { | 529 | } else { |
530 | return mediaPlayerState->looping(); | 530 | return mediaPlayerState->looping(); |
531 | } | 531 | } |
532 | } | 532 | } |
533 | 533 | ||
534 | 534 | ||
535 | bool PlayListWidget::first() { | 535 | bool PlayListWidget::first() { |
536 | if ( mediaPlayerState->playlist() ) | 536 | if ( mediaPlayerState->playlist() ) |
537 | return d->selectedFiles->first(); | 537 | return d->selectedFiles->first(); |
538 | else | 538 | else |
539 | return mediaPlayerState->looping(); | 539 | return mediaPlayerState->looping(); |
540 | } | 540 | } |
541 | 541 | ||
542 | 542 | ||
543 | bool PlayListWidget::last() { | 543 | bool PlayListWidget::last() { |
544 | if ( mediaPlayerState->playlist() ) | 544 | if ( mediaPlayerState->playlist() ) |
545 | return d->selectedFiles->last(); | 545 | return d->selectedFiles->last(); |
546 | else | 546 | else |
547 | return mediaPlayerState->looping(); | 547 | return mediaPlayerState->looping(); |
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | void PlayListWidget::saveList() { | 551 | void PlayListWidget::saveList() { |
552 | 552 | ||
553 | QString filename; | 553 | QString filename; |
554 | InputDialog *fileDlg; | 554 | InputDialog *fileDlg; |
555 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 555 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
556 | fileDlg->exec(); | 556 | fileDlg->exec(); |
557 | if( fileDlg->result() == 1 ) { | 557 | if( fileDlg->result() == 1 ) { |
558 | if ( d->current ) | 558 | if ( d->current ) |
559 | delete d->current; | 559 | delete d->current; |
560 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 560 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
561 | // qDebug("saving playlist "+filename+".playlist"); | 561 | // qDebug("saving playlist "+filename+".playlist"); |
562 | Config cfg( filename +".playlist"); | 562 | Config cfg( filename +".playlist"); |
563 | writeConfig( cfg ); | 563 | writeConfig( cfg ); |
564 | 564 | ||
565 | DocLnk lnk; | 565 | DocLnk lnk; |
566 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 566 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
567 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 567 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
568 | lnk.setIcon("opieplayer/playlist2"); | 568 | lnk.setIcon("opieplayer/playlist2"); |
569 | lnk.setName( filename); //sets file name | 569 | lnk.setName( filename); //sets file name |
570 | // qDebug(filename); | 570 | // qDebug(filename); |
571 | if(!lnk.writeLink()) { | 571 | if(!lnk.writeLink()) { |
572 | qDebug("Writing doclink did not work"); | 572 | qDebug("Writing doclink did not work"); |
573 | } | 573 | } |
574 | } | 574 | } |
575 | Config config( "OpiePlayer" ); | 575 | Config config( "OpiePlayer" ); |
576 | config.writeEntry("CurrentPlaylist",filename); | 576 | config.writeEntry("CurrentPlaylist",filename); |
577 | setCaption(tr("OpiePlayer: ")+filename); | 577 | setCaption(tr("OpiePlayer: ")+filename); |
578 | d->selectedFiles->first(); | 578 | d->selectedFiles->first(); |
579 | if(fileDlg) { | 579 | if(fileDlg) { |
580 | delete fileDlg; | 580 | delete fileDlg; |
581 | } | 581 | } |
582 | } | 582 | } |
583 | 583 | ||
584 | void PlayListWidget::loadList( const DocLnk & lnk) { | 584 | void PlayListWidget::loadList( const DocLnk & lnk) { |
585 | QString name= lnk.name(); | 585 | QString name= lnk.name(); |
586 | // qDebug("currentList is "+name); | 586 | // qDebug("currentList is "+name); |
587 | if( name.length()>1) { | 587 | if( name.length()>1) { |
588 | setCaption("OpiePlayer: "+name); | 588 | setCaption("OpiePlayer: "+name); |
589 | // qDebug("load list "+ name+".playlist"); | 589 | // qDebug("load list "+ name+".playlist"); |
590 | clearList(); | 590 | clearList(); |
591 | Config cfg( name+".playlist"); | 591 | Config cfg( name+".playlist"); |
592 | readConfig(cfg); | 592 | readConfig(cfg); |
593 | 593 | ||
594 | tabWidget->setCurrentPage(0); | 594 | tabWidget->setCurrentPage(0); |
595 | 595 | ||
596 | Config config( "OpiePlayer" ); | 596 | Config config( "OpiePlayer" ); |
597 | config.writeEntry("CurrentPlaylist", name); | 597 | config.writeEntry("CurrentPlaylist", name); |
598 | // d->selectedFiles->first(); | 598 | // d->selectedFiles->first(); |
599 | } | 599 | } |
600 | 600 | ||
601 | } | 601 | } |
602 | 602 | ||
603 | void PlayListWidget::setPlaylist( bool shown ) { | 603 | void PlayListWidget::setPlaylist( bool shown ) { |
604 | if ( shown ) { | 604 | if ( shown ) { |
605 | d->playListFrame->show(); | 605 | d->playListFrame->show(); |
606 | } else { | 606 | } else { |
607 | d->playListFrame->hide(); | 607 | d->playListFrame->hide(); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | 610 | ||
611 | void PlayListWidget::setView( char view ) { | 611 | void PlayListWidget::setView( char view ) { |
612 | if ( view == 'l' ) | 612 | if ( view == 'l' ) |
613 | showMaximized(); | 613 | showMaximized(); |
614 | else | 614 | else |
615 | hide(); | 615 | hide(); |
616 | } | 616 | } |
617 | 617 | ||
618 | void PlayListWidget::addSelected() { | 618 | void PlayListWidget::addSelected() { |
619 | 619 | ||
620 | Config cfg( "OpiePlayer" ); | 620 | Config cfg( "OpiePlayer" ); |
621 | cfg.setGroup("PlayList"); | 621 | cfg.setGroup("PlayList"); |
622 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 622 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
623 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 623 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
624 | 624 | ||
625 | switch (tabWidget->currentPageIndex()) { | 625 | switch (tabWidget->currentPageIndex()) { |
626 | case 0: //playlist | 626 | case 0: //playlist |
627 | break; | 627 | break; |
628 | case 1: { //audio | 628 | case 1: { //audio |
629 | QListViewItemIterator it( audioView ); | 629 | QListViewItemIterator it( audioView ); |
630 | // iterate through all items of the listview | 630 | // iterate through all items of the listview |
631 | for ( ; it.current(); ++it ) { | 631 | for ( ; it.current(); ++it ) { |
632 | if ( it.current()->isSelected() ) { | 632 | if ( it.current()->isSelected() ) { |
633 | QListIterator<DocLnk> dit( files.children() ); | 633 | QListIterator<DocLnk> dit( files.children() ); |
634 | for ( ; dit.current(); ++dit ) { | 634 | for ( ; dit.current(); ++dit ) { |
635 | if( dit.current()->name() == it.current()->text(0) ) { | 635 | if( dit.current()->name() == it.current()->text(0) ) { |
636 | d->selectedFiles->addToSelection( **dit ); | 636 | d->selectedFiles->addToSelection( **dit ); |
637 | } | 637 | } |
638 | } | 638 | } |
639 | audioView->setSelected( it.current(),FALSE); | 639 | audioView->setSelected( it.current(),FALSE); |
640 | } | 640 | } |
641 | } | 641 | } |
642 | tabWidget->setCurrentPage(0); | 642 | tabWidget->setCurrentPage(0); |
643 | } | 643 | } |
644 | break; | 644 | break; |
645 | case 2: { // video | 645 | case 2: { // video |
646 | QListViewItemIterator it( videoView ); | 646 | QListViewItemIterator it( videoView ); |
647 | // iterate through all items of the listview | 647 | // iterate through all items of the listview |
648 | for ( ; it.current(); ++it ) { | 648 | for ( ; it.current(); ++it ) { |
649 | if ( it.current()->isSelected() ) { | 649 | if ( it.current()->isSelected() ) { |
650 | QListIterator<DocLnk> dit( vFiles.children() ); | 650 | QListIterator<DocLnk> dit( vFiles.children() ); |
651 | for ( ; dit.current(); ++dit ) { | 651 | for ( ; dit.current(); ++dit ) { |
652 | if( dit.current()->name() == it.current()->text(0) ) { | 652 | if( dit.current()->name() == it.current()->text(0) ) { |
653 | d->selectedFiles->addToSelection( **dit ); | 653 | d->selectedFiles->addToSelection( **dit ); |
654 | } | 654 | } |
655 | } | 655 | } |
656 | videoView->setSelected( it.current(),FALSE); | 656 | videoView->setSelected( it.current(),FALSE); |
657 | } | 657 | } |
658 | } | 658 | } |
659 | tabWidget->setCurrentPage(0); | 659 | tabWidget->setCurrentPage(0); |
660 | } | 660 | } |
661 | break; | 661 | break; |
662 | }; | 662 | }; |
663 | } | 663 | } |
664 | 664 | ||
665 | void PlayListWidget::removeSelected() { | 665 | void PlayListWidget::removeSelected() { |
666 | d->selectedFiles->removeSelected( ); | 666 | d->selectedFiles->removeSelected( ); |
667 | } | 667 | } |
668 | 668 | ||
669 | void PlayListWidget::playIt( QListViewItem *it) { | 669 | void PlayListWidget::playIt( QListViewItem *it) { |
670 | qDebug("playIt"); | 670 | qDebug("playIt"); |
671 | mediaPlayerState->setPlaying(FALSE); | 671 | mediaPlayerState->setPlaying(FALSE); |
672 | mediaPlayerState->setPlaying(TRUE); | 672 | mediaPlayerState->setPlaying(TRUE); |
673 | d->selectedFiles->unSelect(); | 673 | d->selectedFiles->unSelect(); |
674 | } | 674 | } |
675 | 675 | ||
676 | void PlayListWidget::addToSelection( QListViewItem *it) { | 676 | void PlayListWidget::addToSelection( QListViewItem *it) { |
677 | d->setDocumentUsed = FALSE; | 677 | d->setDocumentUsed = FALSE; |
678 | 678 | ||
679 | if(it) { | 679 | if(it) { |
680 | switch (tabWidget->currentPageIndex()) { | 680 | switch (tabWidget->currentPageIndex()) { |
681 | case 1: { | 681 | case 1: { |
682 | QListIterator<DocLnk> dit( files.children() ); | 682 | QListIterator<DocLnk> dit( files.children() ); |
683 | for ( ; dit.current(); ++dit ) { | 683 | for ( ; dit.current(); ++dit ) { |
684 | if( dit.current()->name() == it->text(0)) { | 684 | if( dit.current()->name() == it->text(0)) { |
685 | d->selectedFiles->addToSelection( **dit ); | 685 | d->selectedFiles->addToSelection( **dit ); |
686 | } | 686 | } |
687 | } | 687 | } |
688 | } | 688 | } |
689 | break; | 689 | break; |
690 | case 2: { | 690 | case 2: { |
691 | QListIterator<DocLnk> dit( vFiles.children() ); | 691 | QListIterator<DocLnk> dit( vFiles.children() ); |
692 | for ( ; dit.current(); ++dit ) { | 692 | for ( ; dit.current(); ++dit ) { |
693 | if( dit.current()->name() == it->text(0)) { | 693 | if( dit.current()->name() == it->text(0)) { |
694 | d->selectedFiles->addToSelection( **dit ); | 694 | d->selectedFiles->addToSelection( **dit ); |
695 | } | 695 | } |
696 | } | 696 | } |
697 | } | 697 | } |
698 | break; | 698 | break; |
699 | case 0: | 699 | case 0: |
700 | break; | 700 | break; |
701 | }; | 701 | }; |
702 | tabWidget->setCurrentPage(0); | 702 | tabWidget->setCurrentPage(0); |
703 | } | 703 | } |
704 | } | 704 | } |
705 | 705 | ||
706 | void PlayListWidget::tabChanged(QWidget *widg) { | 706 | void PlayListWidget::tabChanged(QWidget *widg) { |
707 | 707 | ||
708 | switch ( tabWidget->currentPageIndex()) { | 708 | switch ( tabWidget->currentPageIndex()) { |
709 | case 0: | 709 | case 0: |
710 | { | 710 | { |
711 | if( !tbDeletePlaylist->isHidden()) | 711 | if( !tbDeletePlaylist->isHidden()) |
712 | tbDeletePlaylist->hide(); | 712 | tbDeletePlaylist->hide(); |
713 | d->tbRemoveFromList->setEnabled(TRUE); | 713 | d->tbRemoveFromList->setEnabled(TRUE); |
714 | d->tbAddToList->setEnabled(FALSE); | 714 | d->tbAddToList->setEnabled(FALSE); |
715 | } | 715 | } |
716 | break; | 716 | break; |
717 | case 1: | 717 | case 1: |
718 | { | 718 | { |
719 | audioView->clear(); | 719 | audioView->clear(); |
720 | populateAudioView(); | 720 | populateAudioView(); |
721 | 721 | ||
722 | if( !tbDeletePlaylist->isHidden()) | 722 | if( !tbDeletePlaylist->isHidden()) |
723 | tbDeletePlaylist->hide(); | 723 | tbDeletePlaylist->hide(); |
724 | d->tbRemoveFromList->setEnabled(FALSE); | 724 | d->tbRemoveFromList->setEnabled(FALSE); |
725 | d->tbAddToList->setEnabled(TRUE); | 725 | d->tbAddToList->setEnabled(TRUE); |
726 | } | 726 | } |
727 | break; | 727 | break; |
728 | case 2: | 728 | case 2: |
729 | { | 729 | { |
730 | videoView->clear(); | 730 | videoView->clear(); |
731 | populateVideoView(); | 731 | populateVideoView(); |
732 | if( !tbDeletePlaylist->isHidden()) | 732 | if( !tbDeletePlaylist->isHidden()) |
733 | tbDeletePlaylist->hide(); | 733 | tbDeletePlaylist->hide(); |
734 | d->tbRemoveFromList->setEnabled(FALSE); | 734 | d->tbRemoveFromList->setEnabled(FALSE); |
735 | d->tbAddToList->setEnabled(TRUE); | 735 | d->tbAddToList->setEnabled(TRUE); |
736 | } | 736 | } |
737 | break; | 737 | break; |
738 | case 3: | 738 | case 3: |
739 | { | 739 | { |
740 | if( tbDeletePlaylist->isHidden()) | 740 | if( tbDeletePlaylist->isHidden()) |
741 | tbDeletePlaylist->show(); | 741 | tbDeletePlaylist->show(); |
742 | playLists->reread(); | 742 | playLists->reread(); |
743 | } | 743 | } |
744 | break; | 744 | break; |
745 | }; | 745 | }; |
746 | } | 746 | } |
747 | 747 | ||
748 | void PlayListWidget::btnPlay(bool b) { | 748 | void PlayListWidget::btnPlay(bool b) { |
749 | 749 | ||
750 | // mediaPlayerState->setPlaying(b); | 750 | // mediaPlayerState->setPlaying(b); |
751 | switch ( tabWidget->currentPageIndex()) { | 751 | switch ( tabWidget->currentPageIndex()) { |
752 | case 0: | 752 | case 0: |
753 | { | 753 | { |
754 | mediaPlayerState->setPlaying(b); | 754 | mediaPlayerState->setPlaying(b); |
755 | } | 755 | } |
756 | break; | 756 | break; |
757 | case 1: | 757 | case 1: |
758 | { | 758 | { |
759 | addToSelection( audioView->currentItem() ); | 759 | addToSelection( audioView->currentItem() ); |
760 | mediaPlayerState->setPlaying(b); | 760 | mediaPlayerState->setPlaying(b); |
761 | d->selectedFiles->removeSelected( ); | 761 | d->selectedFiles->removeSelected( ); |
762 | tabWidget->setCurrentPage(1); | 762 | tabWidget->setCurrentPage(1); |
763 | d->selectedFiles->unSelect(); | 763 | d->selectedFiles->unSelect(); |
764 | insanityBool=FALSE; | 764 | insanityBool=FALSE; |
765 | }// audioView->clearSelection(); | 765 | }// audioView->clearSelection(); |
766 | break; | 766 | break; |
767 | case 2: | 767 | case 2: |
768 | { | 768 | { |
769 | addToSelection( videoView->currentItem() ); | 769 | addToSelection( videoView->currentItem() ); |
770 | mediaPlayerState->setPlaying(b); | 770 | mediaPlayerState->setPlaying(b); |
771 | qApp->processEvents(); | 771 | qApp->processEvents(); |
772 | d->selectedFiles->removeSelected( ); | 772 | d->selectedFiles->removeSelected( ); |
773 | tabWidget->setCurrentPage(2); | 773 | tabWidget->setCurrentPage(2); |
774 | d->selectedFiles->unSelect(); | 774 | d->selectedFiles->unSelect(); |
775 | insanityBool=FALSE; | 775 | insanityBool=FALSE; |
776 | }// videoView->clearSelection(); | 776 | }// videoView->clearSelection(); |
777 | break; | 777 | break; |
778 | }; | 778 | }; |
779 | 779 | ||
780 | } | 780 | } |
781 | 781 | ||
782 | void PlayListWidget::deletePlaylist() { | 782 | void PlayListWidget::deletePlaylist() { |
783 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 783 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
784 | (tr("You really want to delete\nthis playlist?")), | 784 | (tr("You really want to delete\nthis playlist?")), |
785 | (tr("Yes")), (tr("No")), 0 )){ | 785 | (tr("Yes")), (tr("No")), 0 )){ |
786 | case 0: // Yes clicked, | 786 | case 0: // Yes clicked, |
787 | QFile().remove(playLists->selected()->file()); | 787 | QFile().remove(playLists->selected()->file()); |
788 | QFile().remove(playLists->selected()->linkFile()); | 788 | QFile().remove(playLists->selected()->linkFile()); |
789 | playLists->reread(); | 789 | playLists->reread(); |
790 | break; | 790 | break; |
791 | case 1: // Cancel | 791 | case 1: // Cancel |
792 | break; | 792 | break; |
793 | }; | 793 | }; |
794 | } | 794 | } |
795 | 795 | ||
796 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { | 796 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { |
797 | switch (mouse) { | 797 | switch (mouse) { |
798 | case 1: | 798 | case 1: |
799 | break; | 799 | break; |
800 | case 2:{ | 800 | case 2:{ |
801 | QPopupMenu m; | 801 | QPopupMenu m; |
802 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 802 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
803 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 803 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
804 | m.insertSeparator(); | 804 | m.insertSeparator(); |
805 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 805 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
806 | m.exec( QCursor::pos() ); | 806 | m.exec( QCursor::pos() ); |
807 | } | 807 | } |
808 | break; | 808 | break; |
809 | }; | 809 | }; |
810 | } | 810 | } |
811 | 811 | ||
812 | void PlayListWidget::playSelected() { | 812 | void PlayListWidget::playSelected() { |
813 | btnPlay( TRUE); | 813 | btnPlay( TRUE); |
814 | } | 814 | } |
815 | 815 | ||
816 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { | 816 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { |
817 | switch (mouse) { | 817 | switch (mouse) { |
818 | case 1: | 818 | case 1: |
819 | 819 | ||
820 | break; | 820 | break; |
821 | case 2: | 821 | case 2: |
822 | { | 822 | { |
823 | QPopupMenu m; | 823 | QPopupMenu m; |
824 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 824 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
825 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 825 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
826 | m.exec( QCursor::pos() ); | 826 | m.exec( QCursor::pos() ); |
827 | } | 827 | } |
828 | break; | 828 | break; |
829 | }; | 829 | }; |
830 | } | 830 | } |
831 | 831 | ||
832 | void PlayListWidget::listDelete() { | 832 | void PlayListWidget::listDelete() { |
833 | Config cfg( "OpiePlayer" ); | 833 | Config cfg( "OpiePlayer" ); |
834 | cfg.setGroup("PlayList"); | 834 | cfg.setGroup("PlayList"); |
835 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 835 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
836 | QString file; | 836 | QString file; |
837 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 837 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
838 | switch ( tabWidget->currentPageIndex()) { | 838 | switch ( tabWidget->currentPageIndex()) { |
839 | case 0: | 839 | case 0: |
840 | break; | 840 | break; |
841 | case 1: | 841 | case 1: |
842 | { | 842 | { |
843 | file = audioView->currentItem()->text(0); | 843 | file = audioView->currentItem()->text(0); |
844 | QListIterator<DocLnk> Pdit( files.children() ); | 844 | QListIterator<DocLnk> Pdit( files.children() ); |
845 | for ( ; Pdit.current(); ++Pdit ) { | 845 | for ( ; Pdit.current(); ++Pdit ) { |
846 | if( Pdit.current()->name() == file) { | 846 | if( Pdit.current()->name() == file) { |
847 | LnkProperties prop( Pdit.current() ); | 847 | LnkProperties prop( Pdit.current() ); |
848 | prop.showMaximized(); | 848 | prop.showMaximized(); |
849 | prop.exec(); | 849 | prop.exec(); |
850 | } | 850 | } |
851 | } | 851 | } |
852 | populateAudioView(); | 852 | populateAudioView(); |
853 | } | 853 | } |
854 | break; | 854 | break; |
855 | case 2: | 855 | case 2: |
856 | { | 856 | { |
857 | 857 | ||
858 | } | 858 | } |
859 | break; | 859 | break; |
860 | }; | 860 | }; |
861 | } | 861 | } |
862 | 862 | ||
863 | void PlayListWidget::scanForAudio() { | 863 | void PlayListWidget::scanForAudio() { |
864 | qDebug("scan for audio"); | 864 | qDebug("scan for audio"); |
865 | files.detachChildren(); | 865 | files.detachChildren(); |
866 | QListIterator<DocLnk> sdit( files.children() ); | 866 | QListIterator<DocLnk> sdit( files.children() ); |
867 | for ( ; sdit.current(); ++sdit ) { | 867 | for ( ; sdit.current(); ++sdit ) { |
868 | delete sdit.current(); | 868 | delete sdit.current(); |
869 | } | 869 | } |
870 | Global::findDocuments(&files, "audio/*"); | 870 | Global::findDocuments(&files, "audio/*"); |
871 | audioScan = TRUE; | 871 | audioScan = TRUE; |
872 | } | 872 | } |
873 | void PlayListWidget::scanForVideo() { | 873 | void PlayListWidget::scanForVideo() { |
874 | qDebug("scan for video"); | 874 | qDebug("scan for video"); |
875 | vFiles.detachChildren(); | 875 | vFiles.detachChildren(); |
876 | QListIterator<DocLnk> sdit( vFiles.children() ); | 876 | QListIterator<DocLnk> sdit( vFiles.children() ); |
877 | for ( ; sdit.current(); ++sdit ) { | 877 | for ( ; sdit.current(); ++sdit ) { |
878 | delete sdit.current(); | 878 | delete sdit.current(); |
879 | } | 879 | } |
880 | Global::findDocuments(&vFiles, "video/*"); | 880 | Global::findDocuments(&vFiles, "video/*"); |
881 | videoScan = TRUE; | 881 | videoScan = TRUE; |
882 | } | 882 | } |
883 | 883 | ||
884 | void PlayListWidget::populateAudioView() { | 884 | void PlayListWidget::populateAudioView() { |
885 | 885 | ||
886 | audioView->clear(); | 886 | audioView->clear(); |
887 | StorageInfo storageInfo; | 887 | StorageInfo storageInfo; |
888 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 888 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
889 | if(!audioScan) scanForAudio(); | 889 | if(!audioScan) scanForAudio(); |
890 | 890 | ||
891 | QListIterator<DocLnk> dit( files.children() ); | 891 | QListIterator<DocLnk> dit( files.children() ); |
892 | QListIterator<FileSystem> it ( fs ); | 892 | QListIterator<FileSystem> it ( fs ); |
893 | 893 | ||
894 | QString storage; | 894 | QString storage; |
895 | for ( ; dit.current(); ++dit ) { | 895 | for ( ; dit.current(); ++dit ) { |
896 | for( ; it.current(); ++it ){ | 896 | for( ; it.current(); ++it ){ |
897 | const QString name = (*it)->name(); | 897 | const QString name = (*it)->name(); |
898 | const QString path = (*it)->path(); | 898 | const QString path = (*it)->path(); |
899 | if(dit.current()->file().find(path) != -1 ) storage=name; | 899 | if(dit.current()->file().find(path) != -1 ) storage=name; |
900 | } | 900 | } |
901 | 901 | ||
902 | QListViewItem * newItem; | 902 | QListViewItem * newItem; |
903 | if ( QFile( dit.current()->file()).exists() ) { | 903 | if ( QFile( dit.current()->file()).exists() ) { |
904 | // qDebug(dit.current()->name()); | 904 | // qDebug(dit.current()->name()); |
905 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 905 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
906 | QString::number( QFile( dit.current()->file()).size() ), storage); | 906 | QString::number( QFile( dit.current()->file()).size() ), storage); |
907 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 907 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
908 | } | 908 | } |
909 | } | 909 | } |
910 | 910 | ||
911 | } | 911 | } |
912 | 912 | ||
913 | void PlayListWidget::populateVideoView() { | 913 | void PlayListWidget::populateVideoView() { |
914 | videoView->clear(); | 914 | videoView->clear(); |
915 | StorageInfo storageInfo; | 915 | StorageInfo storageInfo; |
916 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 916 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
917 | 917 | ||
918 | if(!videoScan ) scanForVideo(); | 918 | if(!videoScan ) scanForVideo(); |
919 | 919 | ||
920 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 920 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
921 | QListIterator<FileSystem> it ( fs ); | 921 | QListIterator<FileSystem> it ( fs ); |
922 | videoView->clear(); | 922 | videoView->clear(); |
923 | QString storage; | 923 | QString storage; |
924 | for ( ; Vdit.current(); ++Vdit ) { | 924 | for ( ; Vdit.current(); ++Vdit ) { |
925 | for( ; it.current(); ++it ){ | 925 | for( ; it.current(); ++it ){ |
926 | const QString name = (*it)->name(); | 926 | const QString name = (*it)->name(); |
927 | const QString path = (*it)->path(); | 927 | const QString path = (*it)->path(); |
928 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 928 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
929 | } | 929 | } |
930 | 930 | ||
931 | QListViewItem * newItem; | 931 | QListViewItem * newItem; |
932 | if ( QFile( Vdit.current()->file()).exists() ) { | 932 | if ( QFile( Vdit.current()->file()).exists() ) { |
933 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 933 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
934 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 934 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
935 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 935 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index af06079..188b18d 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,394 +1,381 @@ | |||
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/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/mediaplayerplugininterface.h> | ||
36 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
37 | 36 | ||
38 | #include <qwidget.h> | 37 | #include <qwidget.h> |
39 | #include <qpainter.h> | 38 | #include <qpainter.h> |
40 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
41 | #include <qslider.h> | 40 | #include <qslider.h> |
42 | #include <qdrawutil.h> | 41 | #include <qdrawutil.h> |
43 | #include "videowidget.h" | 42 | #include "videowidget.h" |
44 | #include "mediaplayerstate.h" | 43 | #include "mediaplayerstate.h" |
45 | 44 | ||
46 | 45 | ||
47 | #ifdef Q_WS_QWS | 46 | #ifdef Q_WS_QWS |
48 | # define USE_DIRECT_PAINTER | 47 | # define USE_DIRECT_PAINTER |
49 | # include <qdirectpainter_qws.h> | 48 | # include <qdirectpainter_qws.h> |
50 | # include <qgfxraster_qws.h> | 49 | # include <qgfxraster_qws.h> |
51 | #endif | 50 | #endif |
52 | 51 | ||
53 | 52 | ||
54 | extern MediaPlayerState *mediaPlayerState; | 53 | extern MediaPlayerState *mediaPlayerState; |
55 | 54 | ||
56 | 55 | ||
57 | static const int xo = 2; // movable x offset | 56 | static const int xo = 2; // movable x offset |
58 | static const int yo = 0; // movable y offset | 57 | static const int yo = 0; // movable y offset |
59 | 58 | ||
60 | 59 | ||
61 | struct MediaButton { | 60 | struct MediaButton { |
62 | int xPos, yPos; | 61 | int xPos, yPos; |
63 | bool isToggle, isHeld, isDown; | 62 | bool isToggle, isHeld, isDown; |
64 | int controlType; | 63 | int controlType; |
65 | }; | 64 | }; |
66 | 65 | ||
67 | 66 | ||
68 | // Layout information for the videoButtons (and if it is a toggle button or not) | 67 | // Layout information for the videoButtons (and if it is a toggle button or not) |
69 | MediaButton videoButtons[] = { | 68 | MediaButton videoButtons[] = { |
70 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous | 69 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous |
71 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop | 70 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop |
72 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play | 71 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play |
73 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause | 72 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause |
74 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next | 73 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next |
75 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist | 74 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist |
76 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen | 75 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen |
77 | }; | 76 | }; |
78 | 77 | ||
79 | 78 | ||
80 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 79 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
81 | 80 | ||
82 | 81 | ||
83 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
84 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
85 | setCaption( tr("OpiePlayer - Video") ); | 84 | setCaption( tr("OpiePlayer - Video") ); |
86 | Config cfg("OpiePlayer"); | 85 | Config cfg("OpiePlayer"); |
87 | cfg.setGroup("VideoWidget"); | 86 | cfg.setGroup("VideoWidget"); |
88 | 87 | ||
89 | QString Button0aPix, Button0bPix, controlsPix; | 88 | QString Button0aPix, Button0bPix, controlsPix; |
90 | //backgroundPix=cfg.readEntry( "backgroundPix", "opieplayer/metalFinish"); | ||
91 | Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); | 89 | Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); |
92 | Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); | 90 | Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); |
93 | controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); | 91 | controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); |
94 | 92 | ||
95 | cfg.setGroup("AudioWidget"); | 93 | cfg.setGroup("AudioWidget"); |
96 | QString skin = cfg.readEntry("Skin","default"); | 94 | QString skin = cfg.readEntry("Skin","default"); |
97 | QString skinPath = "opieplayer/skins/" + skin; | 95 | QString skinPath = "opieplayer/skins/" + skin; |
98 | backgroundPix = QString("%1/background").arg(skinPath) ; | 96 | backgroundPix = QString("%1/background").arg(skinPath) ; |
99 | 97 | ||
100 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); | 98 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); |
101 | pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); | 99 | pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); |
102 | pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); | 100 | pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); |
103 | pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); | 101 | pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); |
104 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | 102 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); |
105 | 103 | ||
106 | slider = new QSlider( Qt::Horizontal, this ); | 104 | slider = new QSlider( Qt::Horizontal, this ); |
107 | slider->setMinValue( 0 ); | 105 | slider->setMinValue( 0 ); |
108 | slider->setMaxValue( 1 ); | 106 | slider->setMaxValue( 1 ); |
109 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 107 | |
108 | slider->setBackgroundPixmap( *this->backgroundPixmap () ); //Resource::loadPixmap( backgroundPix ) ); | ||
109 | slider->setBackgroundOrigin( QWidget::ParentOrigin); | ||
110 | slider->setFocusPolicy( QWidget::NoFocus ); | 110 | slider->setFocusPolicy( QWidget::NoFocus ); |
111 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 111 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
112 | 112 | ||
113 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 113 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
114 | 114 | ||
115 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 115 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
116 | 116 | ||
117 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 117 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
118 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 118 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
119 | 119 | ||
120 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 120 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
121 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 121 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
122 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 122 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
123 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 123 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
124 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 124 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
125 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 125 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
126 | 126 | ||
127 | // Intialise state | 127 | // Intialise state |
128 | setLength( mediaPlayerState->length() ); | 128 | setLength( mediaPlayerState->length() ); |
129 | setPosition( mediaPlayerState->position() ); | 129 | setPosition( mediaPlayerState->position() ); |
130 | setFullscreen( mediaPlayerState->fullscreen() ); | 130 | setFullscreen( mediaPlayerState->fullscreen() ); |
131 | setPaused( mediaPlayerState->paused() ); | 131 | setPaused( mediaPlayerState->paused() ); |
132 | setPlaying( mediaPlayerState->playing() ); | 132 | setPlaying( mediaPlayerState->playing() ); |
133 | 133 | ||
134 | } | 134 | } |
135 | 135 | ||
136 | 136 | ||
137 | VideoWidget::~VideoWidget() { | 137 | VideoWidget::~VideoWidget() { |
138 | for ( int i = 0; i < 3; i++ ) { | 138 | for ( int i = 0; i < 3; i++ ) { |
139 | delete pixmaps[i]; | 139 | delete pixmaps[i]; |
140 | } | 140 | } |
141 | delete currentFrame; | 141 | delete currentFrame; |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | static bool videoSliderBeingMoved = FALSE; | 145 | static bool videoSliderBeingMoved = FALSE; |
146 | 146 | ||
147 | 147 | ||
148 | void VideoWidget::sliderPressed() { | 148 | void VideoWidget::sliderPressed() { |
149 | videoSliderBeingMoved = TRUE; | 149 | videoSliderBeingMoved = TRUE; |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | void VideoWidget::sliderReleased() { | 153 | void VideoWidget::sliderReleased() { |
154 | videoSliderBeingMoved = FALSE; | 154 | videoSliderBeingMoved = FALSE; |
155 | if ( slider->width() == 0 ) { | 155 | if ( slider->width() == 0 ) { |
156 | return; | 156 | return; |
157 | } | 157 | } |
158 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 158 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
159 | mediaPlayerState->setPosition( val ); | 159 | mediaPlayerState->setPosition( val ); |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | void VideoWidget::setPosition( long i ) { | 163 | void VideoWidget::setPosition( long i ) { |
164 | updateSlider( i, mediaPlayerState->length() ); | 164 | updateSlider( i, mediaPlayerState->length() ); |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | void VideoWidget::setLength( long max ) { | 168 | void VideoWidget::setLength( long max ) { |
169 | updateSlider( mediaPlayerState->position(), max ); | 169 | updateSlider( mediaPlayerState->position(), max ); |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | void VideoWidget::setView( char view ) { | 173 | void VideoWidget::setView( char view ) { |
174 | if ( view == 'v' ) { | 174 | if ( view == 'v' ) { |
175 | makeVisible(); | 175 | makeVisible(); |
176 | } else { | 176 | } else { |
177 | // Effectively blank the view next time we show it so it looks nicer | 177 | // Effectively blank the view next time we show it so it looks nicer |
178 | scaledWidth = 0; | 178 | scaledWidth = 0; |
179 | scaledHeight = 0; | 179 | scaledHeight = 0; |
180 | hide(); | 180 | hide(); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | void VideoWidget::updateSlider( long i, long max ) { | 185 | void VideoWidget::updateSlider( long i, long max ) { |
186 | // Will flicker too much if we don't do this | 186 | // Will flicker too much if we don't do this |
187 | if ( max == 0 ) { | 187 | if ( max == 0 ) { |
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | int width = slider->width(); | 190 | int width = slider->width(); |
191 | int val = int((double)i * width / max); | 191 | int val = int((double)i * width / max); |
192 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 192 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
193 | if ( slider->value() != val ) { | 193 | if ( slider->value() != val ) { |
194 | slider->setValue( val ); | 194 | slider->setValue( val ); |
195 | } | 195 | } |
196 | if ( slider->maxValue() != width ) { | 196 | if ( slider->maxValue() != width ) { |
197 | slider->setMaxValue( width ); | 197 | slider->setMaxValue( width ); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | 202 | ||
203 | void VideoWidget::setToggleButton( int i, bool down ) { | 203 | void VideoWidget::setToggleButton( int i, bool down ) { |
204 | if ( down != videoButtons[i].isDown ) { | 204 | if ( down != videoButtons[i].isDown ) { |
205 | toggleButton( i ); | 205 | toggleButton( i ); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | void VideoWidget::toggleButton( int i ) { | 210 | void VideoWidget::toggleButton( int i ) { |
211 | videoButtons[i].isDown = !videoButtons[i].isDown; | 211 | videoButtons[i].isDown = !videoButtons[i].isDown; |
212 | QPainter p(this); | 212 | QPainter p(this); |
213 | paintButton ( &p, i ); | 213 | paintButton ( &p, i ); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | void VideoWidget::paintButton( QPainter *p, int i ) { | 217 | void VideoWidget::paintButton( QPainter *p, int i ) { |
218 | int x = videoButtons[i].xPos; | 218 | int x = videoButtons[i].xPos; |
219 | int y = videoButtons[i].yPos; | 219 | int y = videoButtons[i].yPos; |
220 | int offset = 10 + videoButtons[i].isDown; | 220 | int offset = 10 + videoButtons[i].isDown; |
221 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); | 221 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); |
222 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); | 222 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 226 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
227 | for ( int i = 0; i < numButtons; i++ ) { | 227 | for ( int i = 0; i < numButtons; i++ ) { |
228 | int x = videoButtons[i].xPos; | 228 | int x = videoButtons[i].xPos; |
229 | int y = videoButtons[i].yPos; | 229 | int y = videoButtons[i].yPos; |
230 | if ( event->state() == QMouseEvent::LeftButton ) { | 230 | if ( event->state() == QMouseEvent::LeftButton ) { |
231 | // The test to see if the mouse click is inside the circular button or not | 231 | // The test to see if the mouse click is inside the circular button or not |
232 | // (compared with the radius squared to avoid a square-root of our distance) | 232 | // (compared with the radius squared to avoid a square-root of our distance) |
233 | int radius = 16; | 233 | int radius = 16; |
234 | QPoint center = QPoint( x + radius, y + radius ); | 234 | QPoint center = QPoint( x + radius, y + radius ); |
235 | QPoint dXY = center - event->pos(); | 235 | QPoint dXY = center - event->pos(); |
236 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 236 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
237 | bool isOnButton = dist <= (radius * radius); | 237 | bool isOnButton = dist <= (radius * radius); |
238 | if ( isOnButton != videoButtons[i].isHeld ) { | 238 | if ( isOnButton != videoButtons[i].isHeld ) { |
239 | videoButtons[i].isHeld = isOnButton; | 239 | videoButtons[i].isHeld = isOnButton; |
240 | toggleButton(i); | 240 | toggleButton(i); |
241 | } | 241 | } |
242 | } else { | 242 | } else { |
243 | if ( videoButtons[i].isHeld ) { | 243 | if ( videoButtons[i].isHeld ) { |
244 | videoButtons[i].isHeld = FALSE; | 244 | videoButtons[i].isHeld = FALSE; |
245 | if ( !videoButtons[i].isToggle ) | 245 | if ( !videoButtons[i].isToggle ) |
246 | setToggleButton( i, FALSE ); | 246 | setToggleButton( i, FALSE ); |
247 | qDebug("button toggled3 %d",i); | ||
247 | } | 248 | } |
249 | |||
248 | } | 250 | } |
249 | switch (i) { | 251 | switch (i) { |
250 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 252 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
251 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 253 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
252 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 254 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
253 | case VideoNext: mediaPlayerState->setNext(); return; | 255 | case VideoNext: mediaPlayerState->setNext(); return; |
254 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 256 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
255 | case VideoPlayList: mediaPlayerState->setList(); return; | 257 | case VideoPlayList: mediaPlayerState->setList(); return; |
256 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 258 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
257 | } | 259 | } |
258 | 260 | ||
259 | } | 261 | } |
260 | } | 262 | } |
261 | 263 | ||
262 | 264 | ||
263 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 265 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
264 | mouseMoveEvent( event ); | 266 | mouseMoveEvent( event ); |
265 | } | 267 | } |
266 | 268 | ||
267 | 269 | ||
268 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 270 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
269 | if ( mediaPlayerState->fullscreen() ) { | 271 | if ( mediaPlayerState->fullscreen() ) { |
270 | mediaPlayerState->setFullscreen( FALSE ); | 272 | mediaPlayerState->setFullscreen( FALSE ); |
271 | makeVisible(); | 273 | makeVisible(); |
272 | 274 | ||
273 | mouseMoveEvent( event ); | 275 | mouseMoveEvent( event ); |
274 | } | 276 | } |
275 | } | 277 | } |
276 | 278 | ||
277 | 279 | ||
278 | void VideoWidget::makeVisible() { | 280 | void VideoWidget::makeVisible() { |
279 | if ( mediaPlayerState->fullscreen() ) { | 281 | if ( mediaPlayerState->fullscreen() ) { |
280 | setBackgroundMode( QWidget::NoBackground ); | 282 | setBackgroundMode( QWidget::NoBackground ); |
281 | showFullScreen(); | 283 | showFullScreen(); |
282 | resize( qApp->desktop()->size() ); | 284 | resize( qApp->desktop()->size() ); |
283 | slider->hide(); | 285 | slider->hide(); |
284 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 286 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
285 | } else { | 287 | } else { |
286 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 288 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
287 | showNormal(); | 289 | showNormal(); |
288 | showMaximized(); | 290 | showMaximized(); |
289 | slider->show(); | 291 | slider->show(); |
290 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); | 292 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); |
291 | } | 293 | } |
292 | } | 294 | } |
293 | 295 | ||
294 | 296 | ||
295 | void VideoWidget::paintEvent( QPaintEvent * ) { | 297 | void VideoWidget::paintEvent( QPaintEvent * ) { |
296 | QPainter p( this ); | 298 | QPainter p( this ); |
297 | 299 | ||
298 | if ( mediaPlayerState->fullscreen() ) { | 300 | if ( mediaPlayerState->fullscreen() ) { |
299 | // Clear the background | 301 | // Clear the background |
300 | p.setBrush( QBrush( Qt::black ) ); | 302 | p.setBrush( QBrush( Qt::black ) ); |
301 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); | 303 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); |
302 | 304 | ||
303 | } else { | 305 | } else { |
304 | 306 | ||
305 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); | 307 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); |
306 | // draw the buttons | 308 | // draw the buttons |
307 | 309 | ||
308 | for ( int i = 0; i < numButtons; i++ ) { | 310 | for ( int i = 0; i < numButtons; i++ ) { |
309 | paintButton( &p, i ); | 311 | paintButton( &p, i ); |
310 | } | 312 | } |
311 | // draw the slider | 313 | // draw the slider |
312 | slider->repaint( TRUE ); | 314 | slider->repaint( TRUE ); |
313 | } | 315 | } |
314 | } | 316 | } |
315 | 317 | ||
316 | 318 | ||
317 | void VideoWidget::closeEvent( QCloseEvent* ) { | 319 | void VideoWidget::closeEvent( QCloseEvent* ) { |
318 | mediaPlayerState->setList(); | 320 | mediaPlayerState->setList(); |
319 | } | 321 | } |
320 | 322 | ||
321 | 323 | ||
322 | bool VideoWidget::playVideo() { | ||
323 | bool result = FALSE; | ||
324 | |||
325 | int stream = 0; | ||
326 | |||
327 | int sw = 240; | ||
328 | int sh = 320; | ||
329 | int dd = QPixmap::defaultDepth(); | ||
330 | int w = height(); | ||
331 | int h = width(); | ||
332 | |||
333 | return true; | ||
334 | } | ||
335 | |||
336 | |||
337 | 324 | ||
338 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) | 325 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) |
339 | { | 326 | { |
340 | switch ( e->key() ) { | 327 | switch ( e->key() ) { |
341 | ////////////////////////////// Zaurus keys | 328 | ////////////////////////////// Zaurus keys |
342 | case Key_Home: | 329 | case Key_Home: |
343 | break; | 330 | break; |
344 | case Key_F9: //activity | 331 | case Key_F9: //activity |
345 | break; | 332 | break; |
346 | case Key_F10: //contacts | 333 | case Key_F10: //contacts |
347 | // hide(); | 334 | // hide(); |
348 | break; | 335 | break; |
349 | case Key_F11: //menu | 336 | case Key_F11: //menu |
350 | break; | 337 | break; |
351 | case Key_F12: //home | 338 | case Key_F12: //home |
352 | break; | 339 | break; |
353 | case Key_F13: //mail | 340 | case Key_F13: //mail |
354 | break; | 341 | break; |
355 | case Key_Space: { | 342 | case Key_Space: { |
356 | if(mediaPlayerState->playing()) { | 343 | if(mediaPlayerState->playing()) { |
357 | mediaPlayerState->setPlaying(FALSE); | 344 | mediaPlayerState->setPlaying(FALSE); |
358 | } else { | 345 | } else { |
359 | mediaPlayerState->setPlaying(TRUE); | 346 | mediaPlayerState->setPlaying(TRUE); |
360 | } | 347 | } |
361 | } | 348 | } |
362 | break; | 349 | break; |
363 | case Key_Down: | 350 | case Key_Down: |
364 | // toggleButton(6); | 351 | // toggleButton(6); |
365 | // emit lessClicked(); | 352 | // emit lessClicked(); |
366 | // emit lessReleased(); | 353 | // emit lessReleased(); |
367 | // toggleButton(6); | 354 | // toggleButton(6); |
368 | break; | 355 | break; |
369 | case Key_Up: | 356 | case Key_Up: |
370 | // toggleButton(5); | 357 | // toggleButton(5); |
371 | // emit moreClicked(); | 358 | // emit moreClicked(); |
372 | // emit moreReleased(); | 359 | // emit moreReleased(); |
373 | // toggleButton(5); | 360 | // toggleButton(5); |
374 | break; | 361 | break; |
375 | case Key_Right: | 362 | case Key_Right: |
376 | mediaPlayerState->setNext(); | 363 | mediaPlayerState->setNext(); |
377 | break; | 364 | break; |
378 | case Key_Left: | 365 | case Key_Left: |
379 | mediaPlayerState->setPrev(); | 366 | mediaPlayerState->setPrev(); |
380 | break; | 367 | break; |
381 | case Key_Escape: | 368 | case Key_Escape: |
382 | break; | 369 | break; |
383 | 370 | ||
384 | }; | 371 | }; |
385 | } | 372 | } |
386 | XineVideoWidget* VideoWidget::vidWidget() { | 373 | XineVideoWidget* VideoWidget::vidWidget() { |
387 | return videoFrame; | 374 | return videoFrame; |
388 | } | 375 | } |
389 | 376 | ||
390 | 377 | ||
391 | void VideoWidget::setFullscreen ( bool b ) | 378 | void VideoWidget::setFullscreen ( bool b ) |
392 | { | 379 | { |
393 | setToggleButton( VideoFullscreen, b ); | 380 | setToggleButton( VideoFullscreen, b ); |
394 | } \ No newline at end of file | 381 | } |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index fc53f89..04e810e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -1,102 +1,101 @@ | |||
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 | class QPixmap; | 40 | class QPixmap; |
41 | class QSlider; | 41 | class QSlider; |
42 | 42 | ||
43 | enum VideoButtons { | 43 | enum VideoButtons { |
44 | VideoPrevious, | 44 | VideoPrevious, |
45 | VideoStop, | 45 | VideoStop, |
46 | VideoPlay, | 46 | VideoPlay, |
47 | VideoPause, | 47 | VideoPause, |
48 | VideoNext, | 48 | VideoNext, |
49 | VideoPlayList, | 49 | VideoPlayList, |
50 | VideoFullscreen | 50 | VideoFullscreen |
51 | }; | 51 | }; |
52 | 52 | ||
53 | class VideoWidget : public QWidget { | 53 | class VideoWidget : public QWidget { |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | public: | 55 | public: |
56 | VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 56 | VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
57 | ~VideoWidget(); | 57 | ~VideoWidget(); |
58 | 58 | ||
59 | bool playVideo(); | ||
60 | XineVideoWidget* vidWidget(); | 59 | XineVideoWidget* vidWidget(); |
61 | public slots: | 60 | public slots: |
62 | void updateSlider( long, long ); | 61 | void updateSlider( long, long ); |
63 | void sliderPressed( ); | 62 | void sliderPressed( ); |
64 | void sliderReleased( ); | 63 | void sliderReleased( ); |
65 | void setPaused( bool b) { setToggleButton( VideoPause, b ); } | 64 | void setPaused( bool b) { setToggleButton( VideoPause, b ); } |
66 | void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } | 65 | void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } |
67 | void setFullscreen( bool b ); | 66 | void setFullscreen( bool b ); |
68 | void makeVisible(); | 67 | void makeVisible(); |
69 | void setPosition( long ); | 68 | void setPosition( long ); |
70 | void setLength( long ); | 69 | void setLength( long ); |
71 | void setView( char ); | 70 | void setView( char ); |
72 | 71 | ||
73 | signals: | 72 | signals: |
74 | void sliderMoved( long ); | 73 | void sliderMoved( long ); |
75 | void videoResized ( const QSize &s ); | 74 | void videoResized ( const QSize &s ); |
76 | 75 | ||
77 | protected: | 76 | protected: |
78 | void paintEvent( QPaintEvent *pe ); | 77 | void paintEvent( QPaintEvent *pe ); |
79 | void mouseMoveEvent( QMouseEvent *event ); | 78 | void mouseMoveEvent( QMouseEvent *event ); |
80 | void mousePressEvent( QMouseEvent *event ); | 79 | void mousePressEvent( QMouseEvent *event ); |
81 | void mouseReleaseEvent( QMouseEvent *event ); | 80 | void mouseReleaseEvent( QMouseEvent *event ); |
82 | void closeEvent( QCloseEvent *event ); | 81 | void closeEvent( QCloseEvent *event ); |
83 | void keyReleaseEvent( QKeyEvent *e); | 82 | void keyReleaseEvent( QKeyEvent *e); |
84 | 83 | ||
85 | private: | 84 | private: |
86 | void paintButton( QPainter *p, int i ); | 85 | void paintButton( QPainter *p, int i ); |
87 | void toggleButton( int ); | 86 | void toggleButton( int ); |
88 | void setToggleButton( int, bool ); | 87 | void setToggleButton( int, bool ); |
89 | 88 | ||
90 | QString backgroundPix; | 89 | QString backgroundPix; |
91 | QSlider *slider; | 90 | QSlider *slider; |
92 | QPixmap *pixmaps[3]; | 91 | QPixmap *pixmaps[3]; |
93 | QImage *currentFrame; | 92 | QImage *currentFrame; |
94 | int scaledWidth; | 93 | int scaledWidth; |
95 | int scaledHeight; | 94 | int scaledHeight; |
96 | XineVideoWidget* videoFrame; | 95 | XineVideoWidget* videoFrame; |
97 | }; | 96 | }; |
98 | 97 | ||
99 | #endif // VIDEO_WIDGET_H | 98 | #endif // VIDEO_WIDGET_H |
100 | 99 | ||
101 | 100 | ||
102 | 101 | ||
diff --git a/noncore/multimedia/opieplayer2/volumecontrol.cpp b/noncore/multimedia/opieplayer2/volumecontrol.cpp new file mode 100644 index 0000000..b8ec0df --- a/dev/null +++ b/noncore/multimedia/opieplayer2/volumecontrol.cpp | |||
@@ -0,0 +1,59 @@ | |||
1 | |||
2 | #include <qpe/qpeapplication.h> | ||
3 | #include <qpe/config.h> | ||
4 | #include "qpe/qcopenvelope_qws.h" | ||
5 | #include <qmessagebox.h> | ||
6 | |||
7 | #include "volumecontrol.h" | ||
8 | |||
9 | int VolumeControl::getVolume() { | ||
10 | int volumePerc; | ||
11 | Config cfg( "qpe" ); | ||
12 | cfg. setGroup( "Volume" ); | ||
13 | volumePerc = cfg. readNumEntry( "VolumePercent", 50 ); | ||
14 | m_volumePerc = volumePerc; | ||
15 | return volumePerc; | ||
16 | } | ||
17 | |||
18 | |||
19 | void VolumeControl::setVolume( int volumePerc ) { | ||
20 | Config cfg("qpe"); | ||
21 | cfg.setGroup("Volume"); | ||
22 | |||
23 | if ( volumePerc > 100 ) { | ||
24 | volumePerc = 100; | ||
25 | } | ||
26 | if ( volumePerc < 0 ) { | ||
27 | volumePerc = 0; | ||
28 | } | ||
29 | |||
30 | m_volumePerc = volumePerc; | ||
31 | cfg.writeEntry("VolumePercent", volumePerc ); | ||
32 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; | ||
33 | } | ||
34 | |||
35 | |||
36 | void VolumeControl::incVol( int ammount ) { | ||
37 | int oldVol = getVolume(); | ||
38 | setVolume( oldVol + ammount); | ||
39 | } | ||
40 | |||
41 | void VolumeControl::decVol( int ammount ) { | ||
42 | int oldVol = getVolume(); | ||
43 | setVolume( oldVol - ammount); | ||
44 | } | ||
45 | |||
46 | |||
47 | VolumeControl::VolumeControl( ) { | ||
48 | getVolume(); | ||
49 | } | ||
50 | |||
51 | VolumeControl::~VolumeControl() { | ||
52 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; | ||
53 | } | ||
54 | |||
55 | |||
56 | |||
57 | |||
58 | |||
59 | |||
diff --git a/noncore/multimedia/opieplayer2/volumecontrol.h b/noncore/multimedia/opieplayer2/volumecontrol.h new file mode 100644 index 0000000..37be398 --- a/dev/null +++ b/noncore/multimedia/opieplayer2/volumecontrol.h | |||
@@ -0,0 +1,47 @@ | |||
1 | /************* | ||
2 | * this is only a quick hack and will be later replaced by osound | ||
3 | * | ||
4 | **********/ | ||
5 | |||
6 | |||
7 | #ifndef VOLUMECONTROL_H | ||
8 | #define VOLUMECONTROL_H | ||
9 | |||
10 | |||
11 | |||
12 | #include <qobject.h> | ||
13 | |||
14 | class VolumeControl : public QObject { | ||
15 | Q_OBJECT | ||
16 | public: | ||
17 | VolumeControl(); | ||
18 | ~VolumeControl(); | ||
19 | |||
20 | // increase by "ammount" | ||
21 | void incVol( int ammount ); | ||
22 | void decVol( int ammount ); | ||
23 | |||
24 | /** | ||
25 | * Get the volume in percent | ||
26 | * @return volume percentage | ||
27 | */ | ||
28 | int getVolume(); | ||
29 | |||
30 | public slots: | ||
31 | |||
32 | /** | ||
33 | * Set the volume in percent | ||
34 | * @value volumePerc between 0 and 100 | ||
35 | */ | ||
36 | void setVolume( int volumePerc ); | ||
37 | |||
38 | |||
39 | |||
40 | private: | ||
41 | |||
42 | int m_volumePerc; | ||
43 | |||
44 | }; | ||
45 | |||
46 | #endif | ||
47 | |||