-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 9 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 20 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/nullvideo.c | 142 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 5 |
4 files changed, 81 insertions, 95 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index e21b0b1..6ccf206 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,549 +1,554 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <opie/oticker.h> | 37 | #include <opie/oticker.h> |
38 | 38 | ||
39 | #include <qwidget.h> | 39 | #include <qwidget.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qbutton.h> | 41 | #include <qbutton.h> |
42 | #include <qpainter.h> | 42 | #include <qpainter.h> |
43 | #include <qframe.h> | 43 | #include <qframe.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | 48 | ||
49 | #include "audiowidget.h" | 49 | #include "audiowidget.h" |
50 | #include "mediaplayerstate.h" | 50 | #include "mediaplayerstate.h" |
51 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
52 | 52 | ||
53 | extern MediaPlayerState *mediaPlayerState; | 53 | extern MediaPlayerState *mediaPlayerState; |
54 | extern PlayListWidget *playList; | 54 | extern PlayListWidget *playList; |
55 | 55 | ||
56 | static const int xo = -2; // movable x offset | 56 | static const int xo = -2; // movable x offset |
57 | static const int yo = 22; // movable y offset | 57 | static const int yo = 22; // movable y offset |
58 | 58 | ||
59 | struct MediaButton { | 59 | struct MediaButton { |
60 | bool isToggle, isHeld, isDown; | 60 | bool isToggle, isHeld, isDown; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | //Layout information for the audioButtons (and if it is a toggle button or not) | 63 | //Layout information for the audioButtons (and if it is a toggle button or not) |
64 | MediaButton audioButtons[] = { | 64 | MediaButton audioButtons[] = { |
65 | { TRUE, FALSE, FALSE }, // play | 65 | { TRUE, FALSE, FALSE }, // play |
66 | { FALSE, FALSE, FALSE }, // stop | 66 | { FALSE, FALSE, FALSE }, // stop |
67 | { FALSE, FALSE, FALSE }, // next | 67 | { FALSE, FALSE, FALSE }, // next |
68 | { FALSE, FALSE, FALSE }, // previous | 68 | { FALSE, FALSE, FALSE }, // previous |
69 | { FALSE, FALSE, FALSE }, // volume up | 69 | { FALSE, FALSE, FALSE }, // volume up |
70 | { FALSE, FALSE, FALSE }, // volume down | 70 | { FALSE, FALSE, FALSE }, // volume down |
71 | { TRUE, FALSE, FALSE }, // repeat/loop | 71 | { TRUE, FALSE, FALSE }, // repeat/loop |
72 | { FALSE, FALSE, FALSE }, // playlist | 72 | { FALSE, FALSE, FALSE }, // playlist |
73 | { FALSE, FALSE, FALSE }, // forward | 73 | { FALSE, FALSE, FALSE }, // forward |
74 | { FALSE, FALSE, FALSE } // back | 74 | { FALSE, FALSE, FALSE } // back |
75 | }; | 75 | }; |
76 | 76 | ||
77 | const char *skin_mask_file_names[10] = { | 77 | const char *skin_mask_file_names[10] = { |
78 | "play", "stop", "next", "prev", "up", | 78 | "play", "stop", "next", "prev", "up", |
79 | "down", "loop", "playlist", "forward", "back" | 79 | "down", "loop", "playlist", "forward", "back" |
80 | }; | 80 | }; |
81 | 81 | ||
82 | 82 | ||
83 | static void changeTextColor( QWidget *w ) { | 83 | static void changeTextColor( QWidget *w ) { |
84 | QPalette p = w->palette(); | 84 | QPalette p = w->palette(); |
85 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 85 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
86 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 86 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
87 | w->setPalette( p ); | 87 | w->setPalette( p ); |
88 | } | 88 | } |
89 | 89 | ||
90 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 90 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
91 | 91 | ||
92 | 92 | ||
93 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 93 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
94 | 94 | ||
95 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 95 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
96 | 96 | ||
97 | setCaption( tr("OpiePlayer") ); | 97 | setCaption( tr("OpiePlayer") ); |
98 | 98 | ||
99 | Config cfg("OpiePlayer"); | 99 | Config cfg("OpiePlayer"); |
100 | cfg.setGroup("Options"); | 100 | cfg.setGroup("Options"); |
101 | skin = cfg.readEntry("Skin","default"); | 101 | skin = cfg.readEntry("Skin","default"); |
102 | //skin = "scaleTest"; | 102 | //skin = "scaleTest"; |
103 | // color of background, frame, degree of transparency | 103 | // color of background, frame, degree of transparency |
104 | 104 | ||
105 | QString skinPath = "opieplayer2/skins/" + skin; | 105 | QString skinPath = "opieplayer2/skins/" + skin; |
106 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 106 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
107 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 107 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
108 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 108 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
109 | 109 | ||
110 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 110 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
111 | imgButtonMask->fill( 0 ); | 111 | imgButtonMask->fill( 0 ); |
112 | 112 | ||
113 | for ( int i = 0; i < 10; i++ ) { | 113 | for ( int i = 0; i < 10; i++ ) { |
114 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 114 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); |
115 | masks[i] = new QBitmap( filename ); | 115 | masks[i] = new QBitmap( filename ); |
116 | 116 | ||
117 | if ( !masks[i]->isNull() ) { | 117 | if ( !masks[i]->isNull() ) { |
118 | QImage imgMask = masks[i]->convertToImage(); | 118 | QImage imgMask = masks[i]->convertToImage(); |
119 | uchar **dest = imgButtonMask->jumpTable(); | 119 | uchar **dest = imgButtonMask->jumpTable(); |
120 | for ( int y = 0; y < imgUp->height(); y++ ) { | 120 | for ( int y = 0; y < imgUp->height(); y++ ) { |
121 | uchar *line = dest[y]; | 121 | uchar *line = dest[y]; |
122 | for ( int x = 0; x < imgUp->width(); x++ ) | 122 | for ( int x = 0; x < imgUp->width(); x++ ) |
123 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 123 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
124 | line[x] = i + 1; | 124 | line[x] = i + 1; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | } | 128 | } |
129 | 129 | ||
130 | for ( int i = 0; i < 10; i++ ) { | 130 | for ( int i = 0; i < 10; i++ ) { |
131 | buttonPixUp[i] = 0l; | 131 | buttonPixUp[i] = 0l; |
132 | buttonPixDown[i] = 0l; | 132 | buttonPixDown[i] = 0l; |
133 | } | 133 | } |
134 | 134 | ||
135 | setBackgroundPixmap( *pixBg ); | 135 | setBackgroundPixmap( *pixBg ); |
136 | 136 | ||
137 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 137 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
138 | // changeTextColor( &songInfo ); | 138 | // changeTextColor( &songInfo ); |
139 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 139 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
140 | // songInfo.setFrameStyle( QFrame::NoFrame); | 140 | // songInfo.setFrameStyle( QFrame::NoFrame); |
141 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 141 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
142 | // songInfo.setForegroundColor(Qt::white); | 142 | // songInfo.setForegroundColor(Qt::white); |
143 | 143 | ||
144 | slider.setFixedHeight( 20 ); | 144 | slider.setFixedHeight( 20 ); |
145 | slider.setMinValue( 0 ); | 145 | slider.setMinValue( 0 ); |
146 | slider.setMaxValue( 1 ); | 146 | slider.setMaxValue( 1 ); |
147 | slider.setFocusPolicy( QWidget::NoFocus ); | 147 | slider.setFocusPolicy( QWidget::NoFocus ); |
148 | slider.setBackgroundPixmap( *pixBg ); | 148 | slider.setBackgroundPixmap( *pixBg ); |
149 | 149 | ||
150 | // Config cofg("qpe"); | ||
151 | // cofg.setGroup("Appearance"); | ||
152 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | ||
153 | |||
150 | time.setFocusPolicy( QWidget::NoFocus ); | 154 | time.setFocusPolicy( QWidget::NoFocus ); |
151 | time.setAlignment( Qt::AlignCenter ); | 155 | time.setAlignment( Qt::AlignCenter ); |
152 | time.setFrame(FALSE); | 156 | |
153 | changeTextColor( &time ); | 157 | // time.setFrame(FALSE); |
158 | // changeTextColor( &time ); | ||
154 | 159 | ||
155 | resizeEvent( NULL ); | 160 | resizeEvent( NULL ); |
156 | 161 | ||
157 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 162 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
158 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 163 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
159 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 164 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
160 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 165 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
161 | connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); | 166 | connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); |
162 | 167 | ||
163 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 168 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
164 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 169 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
165 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 170 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
166 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 171 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
167 | 172 | ||
168 | // Intialise state | 173 | // Intialise state |
169 | setLength( mediaPlayerState->length() ); | 174 | setLength( mediaPlayerState->length() ); |
170 | setPosition( mediaPlayerState->position() ); | 175 | setPosition( mediaPlayerState->position() ); |
171 | setLooping( mediaPlayerState->fullscreen() ); | 176 | setLooping( mediaPlayerState->fullscreen() ); |
172 | // setPaused( mediaPlayerState->paused() ); | 177 | // setPaused( mediaPlayerState->paused() ); |
173 | setPlaying( mediaPlayerState->playing() ); | 178 | setPlaying( mediaPlayerState->playing() ); |
174 | 179 | ||
175 | } | 180 | } |
176 | 181 | ||
177 | AudioWidget::~AudioWidget() { | 182 | AudioWidget::~AudioWidget() { |
178 | 183 | ||
179 | for ( int i = 0; i < 10; i++ ) { | 184 | for ( int i = 0; i < 10; i++ ) { |
180 | delete buttonPixUp[i]; | 185 | delete buttonPixUp[i]; |
181 | delete buttonPixDown[i]; | 186 | delete buttonPixDown[i]; |
182 | } | 187 | } |
183 | delete pixBg; | 188 | delete pixBg; |
184 | delete imgUp; | 189 | delete imgUp; |
185 | delete imgDn; | 190 | delete imgDn; |
186 | delete imgButtonMask; | 191 | delete imgButtonMask; |
187 | for ( int i = 0; i < 10; i++ ) { | 192 | for ( int i = 0; i < 10; i++ ) { |
188 | delete masks[i]; | 193 | delete masks[i]; |
189 | } | 194 | } |
190 | // mediaPlayerState->setPlaying(false); | 195 | // mediaPlayerState->setPlaying(false); |
191 | } | 196 | } |
192 | 197 | ||
193 | namespace { | 198 | namespace { |
194 | 199 | ||
195 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 200 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
196 | QPixmap pix( img.width(), img.height() ); | 201 | QPixmap pix( img.width(), img.height() ); |
197 | QPainter p( &pix ); | 202 | QPainter p( &pix ); |
198 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 203 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
199 | p.drawImage( 0, 0, img ); | 204 | p.drawImage( 0, 0, img ); |
200 | return new QPixmap( pix ); | 205 | return new QPixmap( pix ); |
201 | } | 206 | } |
202 | 207 | ||
203 | 208 | ||
204 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { | 209 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { |
205 | QPixmap *pixmap = new QPixmap( pix ); | 210 | QPixmap *pixmap = new QPixmap( pix ); |
206 | pixmap->setMask( mask ); | 211 | pixmap->setMask( mask ); |
207 | return pixmap; | 212 | return pixmap; |
208 | } | 213 | } |
209 | 214 | ||
210 | }; | 215 | }; |
211 | 216 | ||
212 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 217 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
213 | int h = height(); | 218 | int h = height(); |
214 | int w = width(); | 219 | int w = width(); |
215 | 220 | ||
216 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 221 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
217 | slider.setFixedWidth( w - 110 ); | 222 | slider.setFixedWidth( w - 110 ); |
218 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 223 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
219 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 224 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
220 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 225 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
221 | 226 | ||
222 | xoff = ( w - imgUp->width() ) / 2; | 227 | xoff = ( w - imgUp->width() ) / 2; |
223 | yoff = (( h - imgUp->height() ) / 2) - 10; | 228 | yoff = (( h - imgUp->height() ) / 2) - 10; |
224 | QPoint p( xoff, yoff ); | 229 | QPoint p( xoff, yoff ); |
225 | 230 | ||
226 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); | 231 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); |
227 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); | 232 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); |
228 | 233 | ||
229 | for ( int i = 0; i < 10; i++ ) { | 234 | for ( int i = 0; i < 10; i++ ) { |
230 | if ( !masks[i]->isNull() ) { | 235 | if ( !masks[i]->isNull() ) { |
231 | delete buttonPixUp[i]; | 236 | delete buttonPixUp[i]; |
232 | delete buttonPixDown[i]; | 237 | delete buttonPixDown[i]; |
233 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); | 238 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); |
234 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); | 239 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); |
235 | } | 240 | } |
236 | } | 241 | } |
237 | 242 | ||
238 | delete pixUp; | 243 | delete pixUp; |
239 | delete pixDn; | 244 | delete pixDn; |
240 | } | 245 | } |
241 | 246 | ||
242 | static bool audioSliderBeingMoved = FALSE; | 247 | static bool audioSliderBeingMoved = FALSE; |
243 | 248 | ||
244 | 249 | ||
245 | void AudioWidget::sliderPressed() { | 250 | void AudioWidget::sliderPressed() { |
246 | audioSliderBeingMoved = TRUE; | 251 | audioSliderBeingMoved = TRUE; |
247 | } | 252 | } |
248 | 253 | ||
249 | 254 | ||
250 | void AudioWidget::sliderReleased() { | 255 | void AudioWidget::sliderReleased() { |
251 | audioSliderBeingMoved = FALSE; | 256 | audioSliderBeingMoved = FALSE; |
252 | if ( slider.width() == 0 ) | 257 | if ( slider.width() == 0 ) |
253 | return; | 258 | return; |
254 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 259 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
255 | mediaPlayerState->setPosition( val ); | 260 | mediaPlayerState->setPosition( val ); |
256 | } | 261 | } |
257 | 262 | ||
258 | void AudioWidget::setPosition( long i ) { | 263 | void AudioWidget::setPosition( long i ) { |
259 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 264 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
260 | updateSlider( i, mediaPlayerState->length() ); | 265 | updateSlider( i, mediaPlayerState->length() ); |
261 | } | 266 | } |
262 | 267 | ||
263 | 268 | ||
264 | void AudioWidget::setLength( long max ) { | 269 | void AudioWidget::setLength( long max ) { |
265 | updateSlider( mediaPlayerState->position(), max ); | 270 | updateSlider( mediaPlayerState->position(), max ); |
266 | } | 271 | } |
267 | 272 | ||
268 | 273 | ||
269 | void AudioWidget::setView( char view ) { | 274 | void AudioWidget::setView( char view ) { |
270 | 275 | ||
271 | if ( view == 'a' ) { | 276 | if ( view == 'a' ) { |
272 | // startTimer( 150 ); | 277 | // startTimer( 150 ); |
273 | showMaximized(); | 278 | showMaximized(); |
274 | } else { | 279 | } else { |
275 | killTimers(); | 280 | killTimers(); |
276 | hide(); | 281 | hide(); |
277 | } | 282 | } |
278 | // qApp->processEvents(); | 283 | // qApp->processEvents(); |
279 | } | 284 | } |
280 | 285 | ||
281 | 286 | ||
282 | void AudioWidget::setSeekable( bool isSeekable ) { | 287 | void AudioWidget::setSeekable( bool isSeekable ) { |
283 | 288 | ||
284 | if ( !isSeekable ) { | 289 | if ( !isSeekable ) { |
285 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 290 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
286 | if( !slider.isHidden()) { | 291 | if( !slider.isHidden()) { |
287 | slider.hide(); | 292 | slider.hide(); |
288 | } | 293 | } |
289 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 294 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
290 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 295 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
291 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 296 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
292 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 297 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
293 | } else { | 298 | } else { |
294 | // this stops the slider from being moved, thus | 299 | // this stops the slider from being moved, thus |
295 | // does not stop stream when it reaches the end | 300 | // does not stop stream when it reaches the end |
296 | slider.show(); | 301 | slider.show(); |
297 | qDebug( " CONNECT SET POSTION " ); | 302 | qDebug( " CONNECT SET POSTION " ); |
298 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 303 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
299 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 304 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
300 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 305 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
301 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 306 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
302 | } | 307 | } |
303 | } | 308 | } |
304 | 309 | ||
305 | 310 | ||
306 | static QString timeAsString( long length ) { | 311 | static QString timeAsString( long length ) { |
307 | int minutes = length / 60; | 312 | int minutes = length / 60; |
308 | int seconds = length % 60; | 313 | int seconds = length % 60; |
309 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 314 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
310 | } | 315 | } |
311 | 316 | ||
312 | void AudioWidget::updateSlider( long i, long max ) { | 317 | void AudioWidget::updateSlider( long i, long max ) { |
313 | 318 | ||
314 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 319 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
315 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 320 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
316 | 321 | ||
317 | if ( max == 0 ) { | 322 | if ( max == 0 ) { |
318 | return; | 323 | return; |
319 | } | 324 | } |
320 | // Will flicker too much if we don't do this | 325 | // Will flicker too much if we don't do this |
321 | // Scale to something reasonable | 326 | // Scale to something reasonable |
322 | int width = slider.width(); | 327 | int width = slider.width(); |
323 | int val = int((double)i * width / max); | 328 | int val = int((double)i * width / max); |
324 | if ( !audioSliderBeingMoved ) { | 329 | if ( !audioSliderBeingMoved ) { |
325 | if ( slider.value() != val ) { | 330 | if ( slider.value() != val ) { |
326 | slider.setValue( val ); | 331 | slider.setValue( val ); |
327 | } | 332 | } |
328 | 333 | ||
329 | if ( slider.maxValue() != width ) { | 334 | if ( slider.maxValue() != width ) { |
330 | slider.setMaxValue( width ); | 335 | slider.setMaxValue( width ); |
331 | } | 336 | } |
332 | } | 337 | } |
333 | } | 338 | } |
334 | 339 | ||
335 | 340 | ||
336 | void AudioWidget::setToggleButton( int i, bool down ) { | 341 | void AudioWidget::setToggleButton( int i, bool down ) { |
337 | qDebug("setToggleButton %d", i); | 342 | qDebug("setToggleButton %d", i); |
338 | if ( down != audioButtons[i].isDown ) { | 343 | if ( down != audioButtons[i].isDown ) { |
339 | toggleButton( i ); | 344 | toggleButton( i ); |
340 | } | 345 | } |
341 | } | 346 | } |
342 | 347 | ||
343 | 348 | ||
344 | void AudioWidget::toggleButton( int i ) { | 349 | void AudioWidget::toggleButton( int i ) { |
345 | audioButtons[i].isDown = !audioButtons[i].isDown; | 350 | audioButtons[i].isDown = !audioButtons[i].isDown; |
346 | QPainter p(this); | 351 | QPainter p(this); |
347 | paintButton ( &p, i ); | 352 | paintButton ( &p, i ); |
348 | } | 353 | } |
349 | 354 | ||
350 | 355 | ||
351 | void AudioWidget::paintButton( QPainter *p, int i ) { | 356 | void AudioWidget::paintButton( QPainter *p, int i ) { |
352 | if ( audioButtons[i].isDown ) { | 357 | if ( audioButtons[i].isDown ) { |
353 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 358 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
354 | } else { | 359 | } else { |
355 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 360 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
356 | } | 361 | } |
357 | } | 362 | } |
358 | 363 | ||
359 | 364 | ||
360 | void AudioWidget::skipFor() { | 365 | void AudioWidget::skipFor() { |
361 | skipDirection = +1; | 366 | skipDirection = +1; |
362 | startTimer( 50 ); | 367 | startTimer( 50 ); |
363 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 368 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
364 | } | 369 | } |
365 | 370 | ||
366 | void AudioWidget::skipBack() { | 371 | void AudioWidget::skipBack() { |
367 | skipDirection = -1; | 372 | skipDirection = -1; |
368 | startTimer( 50 ); | 373 | startTimer( 50 ); |
369 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 374 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
370 | } | 375 | } |
371 | 376 | ||
372 | 377 | ||
373 | 378 | ||
374 | void AudioWidget::stopSkip() { | 379 | void AudioWidget::stopSkip() { |
375 | killTimers(); | 380 | killTimers(); |
376 | } | 381 | } |
377 | 382 | ||
378 | 383 | ||
379 | void AudioWidget::timerEvent( QTimerEvent * ) { | 384 | void AudioWidget::timerEvent( QTimerEvent * ) { |
380 | if ( skipDirection == +1 ) { | 385 | if ( skipDirection == +1 ) { |
381 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 386 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
382 | } else if ( skipDirection == -1 ) { | 387 | } else if ( skipDirection == -1 ) { |
383 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 388 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
384 | } | 389 | } |
385 | } | 390 | } |
386 | 391 | ||
387 | 392 | ||
388 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 393 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
389 | for ( int i = 0; i < numButtons; i++ ) { | 394 | for ( int i = 0; i < numButtons; i++ ) { |
390 | if ( event->state() == QMouseEvent::LeftButton ) { | 395 | if ( event->state() == QMouseEvent::LeftButton ) { |
391 | // The test to see if the mouse click is inside the button or not | 396 | // The test to see if the mouse click is inside the button or not |
392 | int x = event->pos().x() - xoff; | 397 | int x = event->pos().x() - xoff; |
393 | int y = event->pos().y() - yoff; | 398 | int y = event->pos().y() - yoff; |
394 | 399 | ||
395 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 400 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
396 | && y < imgButtonMask->height() | 401 | && y < imgButtonMask->height() |
397 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 402 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
398 | 403 | ||
399 | if ( isOnButton && !audioButtons[i].isHeld ) { | 404 | if ( isOnButton && !audioButtons[i].isHeld ) { |
400 | audioButtons[i].isHeld = TRUE; | 405 | audioButtons[i].isHeld = TRUE; |
401 | toggleButton(i); | 406 | toggleButton(i); |
402 | switch (i) { | 407 | switch (i) { |
403 | case AudioVolumeUp: | 408 | case AudioVolumeUp: |
404 | emit moreClicked(); | 409 | emit moreClicked(); |
405 | return; | 410 | return; |
406 | case AudioVolumeDown: | 411 | case AudioVolumeDown: |
407 | emit lessClicked(); | 412 | emit lessClicked(); |
408 | return; | 413 | return; |
409 | case AudioForward: | 414 | case AudioForward: |
410 | emit forwardClicked(); | 415 | emit forwardClicked(); |
411 | return; | 416 | return; |
412 | case AudioBack: | 417 | case AudioBack: |
413 | emit backClicked(); | 418 | emit backClicked(); |
414 | return; | 419 | return; |
415 | } | 420 | } |
416 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 421 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
417 | audioButtons[i].isHeld = FALSE; | 422 | audioButtons[i].isHeld = FALSE; |
418 | toggleButton(i); | 423 | toggleButton(i); |
419 | } | 424 | } |
420 | } else { | 425 | } else { |
421 | if ( audioButtons[i].isHeld ) { | 426 | if ( audioButtons[i].isHeld ) { |
422 | audioButtons[i].isHeld = FALSE; | 427 | audioButtons[i].isHeld = FALSE; |
423 | if ( !audioButtons[i].isToggle ) { | 428 | if ( !audioButtons[i].isToggle ) { |
424 | setToggleButton( i, FALSE ); | 429 | setToggleButton( i, FALSE ); |
425 | } | 430 | } |
426 | qDebug("mouseEvent %d", i); | 431 | qDebug("mouseEvent %d", i); |
427 | switch (i) { | 432 | switch (i) { |
428 | case AudioPlay: | 433 | case AudioPlay: |
429 | if( mediaPlayerState->isPaused ) { | 434 | if( mediaPlayerState->isPaused ) { |
430 | mediaPlayerState->setPaused( FALSE ); | 435 | mediaPlayerState->setPaused( FALSE ); |
431 | return; | 436 | return; |
432 | } else if( !mediaPlayerState->isPaused ) { | 437 | } else if( !mediaPlayerState->isPaused ) { |
433 | mediaPlayerState->setPaused( TRUE ); | 438 | mediaPlayerState->setPaused( TRUE ); |
434 | return; | 439 | return; |
435 | } | 440 | } |
436 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 441 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
437 | case AudioNext: if( playList->whichList() ==0 ) mediaPlayerState->setNext(); return; | 442 | case AudioNext: if( playList->whichList() ==0 ) mediaPlayerState->setNext(); return; |
438 | case AudioPrevious: if( playList->whichList() ==0 ) mediaPlayerState->setPrev(); return; | 443 | case AudioPrevious: if( playList->whichList() ==0 ) mediaPlayerState->setPrev(); return; |
439 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 444 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
440 | case AudioVolumeUp: emit moreReleased(); return; | 445 | case AudioVolumeUp: emit moreReleased(); return; |
441 | case AudioVolumeDown: emit lessReleased(); return; | 446 | case AudioVolumeDown: emit lessReleased(); return; |
442 | case AudioPlayList: mediaPlayerState->setList(); return; | 447 | case AudioPlayList: mediaPlayerState->setList(); return; |
443 | case AudioForward: emit forwardReleased(); return; | 448 | case AudioForward: emit forwardReleased(); return; |
444 | case AudioBack: emit backReleased(); return; | 449 | case AudioBack: emit backReleased(); return; |
445 | } | 450 | } |
446 | } | 451 | } |
447 | } | 452 | } |
448 | } | 453 | } |
449 | } | 454 | } |
450 | 455 | ||
451 | 456 | ||
452 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 457 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
453 | mouseMoveEvent( event ); | 458 | mouseMoveEvent( event ); |
454 | } | 459 | } |
455 | 460 | ||
456 | 461 | ||
457 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 462 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
458 | mouseMoveEvent( event ); | 463 | mouseMoveEvent( event ); |
459 | } | 464 | } |
460 | 465 | ||
461 | 466 | ||
462 | void AudioWidget::showEvent( QShowEvent* ) { | 467 | void AudioWidget::showEvent( QShowEvent* ) { |
463 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 468 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
464 | mouseMoveEvent( &event ); | 469 | mouseMoveEvent( &event ); |
465 | } | 470 | } |
466 | 471 | ||
467 | 472 | ||
468 | void AudioWidget::closeEvent( QCloseEvent* ) { | 473 | void AudioWidget::closeEvent( QCloseEvent* ) { |
469 | mediaPlayerState->setList(); | 474 | mediaPlayerState->setList(); |
470 | } | 475 | } |
471 | 476 | ||
472 | 477 | ||
473 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | 478 | void AudioWidget::paintEvent( QPaintEvent * pe ) { |
474 | if ( !pe->erased() ) { | 479 | if ( !pe->erased() ) { |
475 | // Combine with background and double buffer | 480 | // Combine with background and double buffer |
476 | QPixmap pix( pe->rect().size() ); | 481 | QPixmap pix( pe->rect().size() ); |
477 | QPainter p( &pix ); | 482 | QPainter p( &pix ); |
478 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 483 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
479 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 484 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
480 | for ( int i = 0; i < numButtons; i++ ) | 485 | for ( int i = 0; i < numButtons; i++ ) |
481 | paintButton( &p, i ); | 486 | paintButton( &p, i ); |
482 | QPainter p2( this ); | 487 | QPainter p2( this ); |
483 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 488 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
484 | } else { | 489 | } else { |
485 | QPainter p( this ); | 490 | QPainter p( this ); |
486 | for ( int i = 0; i < numButtons; i++ ) | 491 | for ( int i = 0; i < numButtons; i++ ) |
487 | paintButton( &p, i ); | 492 | paintButton( &p, i ); |
488 | } | 493 | } |
489 | } | 494 | } |
490 | 495 | ||
491 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 496 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
492 | switch ( e->key() ) { | 497 | switch ( e->key() ) { |
493 | ////////////////////////////// Zaurus keys | 498 | ////////////////////////////// Zaurus keys |
494 | case Key_Home: | 499 | case Key_Home: |
495 | break; | 500 | break; |
496 | case Key_F9: //activity | 501 | case Key_F9: //activity |
497 | hide(); | 502 | hide(); |
498 | // qDebug("Audio F9"); | 503 | // qDebug("Audio F9"); |
499 | break; | 504 | break; |
500 | case Key_F10: //contacts | 505 | case Key_F10: //contacts |
501 | break; | 506 | break; |
502 | case Key_F11: //menu | 507 | case Key_F11: //menu |
503 | mediaPlayerState->toggleBlank(); | 508 | mediaPlayerState->toggleBlank(); |
504 | break; | 509 | break; |
505 | case Key_F12: //home | 510 | case Key_F12: //home |
506 | break; | 511 | break; |
507 | case Key_F13: //mail | 512 | case Key_F13: //mail |
508 | mediaPlayerState->toggleBlank(); | 513 | mediaPlayerState->toggleBlank(); |
509 | break; | 514 | break; |
510 | case Key_Space: { | 515 | case Key_Space: { |
511 | if(mediaPlayerState->playing()) { | 516 | if(mediaPlayerState->playing()) { |
512 | // toggleButton(1); | 517 | // toggleButton(1); |
513 | mediaPlayerState->setPlaying(FALSE); | 518 | mediaPlayerState->setPlaying(FALSE); |
514 | // toggleButton(1); | 519 | // toggleButton(1); |
515 | } else { | 520 | } else { |
516 | // toggleButton(0); | 521 | // toggleButton(0); |
517 | mediaPlayerState->setPlaying(TRUE); | 522 | mediaPlayerState->setPlaying(TRUE); |
518 | // toggleButton(0); | 523 | // toggleButton(0); |
519 | } | 524 | } |
520 | } | 525 | } |
521 | break; | 526 | break; |
522 | case Key_Down: | 527 | case Key_Down: |
523 | // toggleButton(6); | 528 | // toggleButton(6); |
524 | emit lessClicked(); | 529 | emit lessClicked(); |
525 | emit lessReleased(); | 530 | emit lessReleased(); |
526 | // toggleButton(6); | 531 | // toggleButton(6); |
527 | break; | 532 | break; |
528 | case Key_Up: | 533 | case Key_Up: |
529 | // toggleButton(5); | 534 | // toggleButton(5); |
530 | emit moreClicked(); | 535 | emit moreClicked(); |
531 | emit moreReleased(); | 536 | emit moreReleased(); |
532 | // toggleButton(5); | 537 | // toggleButton(5); |
533 | break; | 538 | break; |
534 | case Key_Right: | 539 | case Key_Right: |
535 | // toggleButton(3); | 540 | // toggleButton(3); |
536 | mediaPlayerState->setNext(); | 541 | mediaPlayerState->setNext(); |
537 | // toggleButton(3); | 542 | // toggleButton(3); |
538 | break; | 543 | break; |
539 | case Key_Left: | 544 | case Key_Left: |
540 | // toggleButton(4); | 545 | // toggleButton(4); |
541 | mediaPlayerState->setPrev(); | 546 | mediaPlayerState->setPrev(); |
542 | // toggleButton(4); | 547 | // toggleButton(4); |
543 | break; | 548 | break; |
544 | case Key_Escape: { | 549 | case Key_Escape: { |
545 | } | 550 | } |
546 | break; | 551 | break; |
547 | 552 | ||
548 | }; | 553 | }; |
549 | } | 554 | } |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index bcd941e..7cb1d79 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -1,150 +1,134 @@ | |||
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 AUDIO_WIDGET_H | 34 | #ifndef AUDIO_WIDGET_H |
35 | #define AUDIO_WIDGET_H | 35 | #define AUDIO_WIDGET_H |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qpainter.h> | 38 | #include <qpainter.h> |
39 | #include <qdrawutil.h> | 39 | #include <qdrawutil.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qstring.h> | 41 | #include <qstring.h> |
42 | #include <qslider.h> | 42 | #include <qslider.h> |
43 | #include <qframe.h> | 43 | #include <qframe.h> |
44 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
45 | 45 | ||
46 | #include <opie/oticker.h> | ||
46 | 47 | ||
47 | class QPixmap; | 48 | class QPixmap; |
48 | 49 | ||
49 | namespace { | 50 | namespace { |
50 | 51 | ||
51 | enum AudioButtons { | 52 | enum AudioButtons { |
52 | AudioPlay=0, | 53 | AudioPlay=0, |
53 | AudioStop, | 54 | AudioStop, |
54 | AudioNext, | 55 | AudioNext, |
55 | AudioPrevious, | 56 | AudioPrevious, |
56 | AudioVolumeUp, | 57 | AudioVolumeUp, |
57 | AudioVolumeDown, | 58 | AudioVolumeDown, |
58 | AudioLoop, | 59 | AudioLoop, |
59 | AudioPlayList, | 60 | AudioPlayList, |
60 | AudioForward, | 61 | AudioForward, |
61 | AudioBack | 62 | AudioBack |
62 | }; | 63 | }; |
63 | }; | 64 | }; |
64 | 65 | ||
65 | class Ticker : public QFrame { | ||
66 | Q_OBJECT | ||
67 | |||
68 | public: | ||
69 | Ticker( QWidget* parent=0 ); | ||
70 | ~Ticker(); | ||
71 | void setText( const QString& text ) ; | ||
72 | |||
73 | protected: | ||
74 | void timerEvent( QTimerEvent * ); | ||
75 | void drawContents( QPainter *p ); | ||
76 | private: | ||
77 | QString scrollText; | ||
78 | int pos, pixelLen; | ||
79 | }; | ||
80 | |||
81 | |||
82 | class AudioWidget : public QWidget { | 66 | class AudioWidget : public QWidget { |
83 | Q_OBJECT | 67 | Q_OBJECT |
84 | public: | 68 | public: |
85 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 69 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
86 | ~AudioWidget(); | 70 | ~AudioWidget(); |
87 | void setTickerText( const QString &text ) { songInfo.setText( text ); } | 71 | void setTickerText( const QString &text ) { songInfo.setText( text ); } |
88 | public slots: | 72 | public slots: |
89 | void updateSlider( long, long ); | 73 | void updateSlider( long, long ); |
90 | void sliderPressed( ); | 74 | void sliderPressed( ); |
91 | void sliderReleased( ); | 75 | void sliderReleased( ); |
92 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } | 76 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } |
93 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } | 77 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } |
94 | void setPosition( long ); | 78 | void setPosition( long ); |
95 | void setLength( long ); | 79 | void setLength( long ); |
96 | void setSeekable( bool ); | 80 | void setSeekable( bool ); |
97 | void setView( char ); | 81 | void setView( char ); |
98 | 82 | ||
99 | signals: | 83 | signals: |
100 | void moreClicked(); | 84 | void moreClicked(); |
101 | void lessClicked(); | 85 | void lessClicked(); |
102 | void moreReleased(); | 86 | void moreReleased(); |
103 | void lessReleased(); | 87 | void lessReleased(); |
104 | void forwardClicked(); | 88 | void forwardClicked(); |
105 | void backClicked(); | 89 | void backClicked(); |
106 | void forwardReleased(); | 90 | void forwardReleased(); |
107 | void backReleased(); | 91 | void backReleased(); |
108 | void sliderMoved(long); | 92 | void sliderMoved(long); |
109 | 93 | ||
110 | protected: | 94 | protected: |
111 | void doBlank(); | 95 | void doBlank(); |
112 | void doUnblank(); | 96 | void doUnblank(); |
113 | void paintEvent( QPaintEvent *pe ); | 97 | void paintEvent( QPaintEvent *pe ); |
114 | void showEvent( QShowEvent *se ); | 98 | void showEvent( QShowEvent *se ); |
115 | void resizeEvent( QResizeEvent *re ); | 99 | void resizeEvent( QResizeEvent *re ); |
116 | void mouseMoveEvent( QMouseEvent *event ); | 100 | void mouseMoveEvent( QMouseEvent *event ); |
117 | void mousePressEvent( QMouseEvent *event ); | 101 | void mousePressEvent( QMouseEvent *event ); |
118 | void mouseReleaseEvent( QMouseEvent *event ); | 102 | void mouseReleaseEvent( QMouseEvent *event ); |
119 | void timerEvent( QTimerEvent *event ); | 103 | void timerEvent( QTimerEvent *event ); |
120 | void closeEvent( QCloseEvent *event ); | 104 | void closeEvent( QCloseEvent *event ); |
121 | void keyReleaseEvent( QKeyEvent *e); | 105 | void keyReleaseEvent( QKeyEvent *e); |
122 | private slots: | 106 | private slots: |
123 | void skipFor(); | 107 | void skipFor(); |
124 | void skipBack(); | 108 | void skipBack(); |
125 | void stopSkip(); | 109 | void stopSkip(); |
126 | private: | 110 | private: |
127 | void toggleButton( int ); | 111 | void toggleButton( int ); |
128 | void setToggleButton( int, bool ); | 112 | void setToggleButton( int, bool ); |
129 | void paintButton( QPainter *p, int i ); | 113 | void paintButton( QPainter *p, int i ); |
130 | int skipDirection; | 114 | int skipDirection; |
131 | QString skin; | 115 | QString skin; |
132 | QPixmap *pixBg; | 116 | QPixmap *pixBg; |
133 | QImage *imgUp; | 117 | QImage *imgUp; |
134 | QImage *imgDn; | 118 | QImage *imgDn; |
135 | QImage *imgButtonMask; | 119 | QImage *imgButtonMask; |
136 | QBitmap *masks[10]; | 120 | QBitmap *masks[10]; |
137 | QPixmap *buttonPixUp[10]; | 121 | QPixmap *buttonPixUp[10]; |
138 | QPixmap *buttonPixDown[10]; | 122 | QPixmap *buttonPixDown[10]; |
139 | 123 | ||
140 | QPixmap *pixmaps[4]; | 124 | QPixmap *pixmaps[4]; |
141 | Ticker songInfo; | 125 | OTicker songInfo; |
142 | QSlider slider; | 126 | QSlider slider; |
143 | QLineEdit time; | 127 | QLineEdit time; |
144 | int xoff, yoff; | 128 | int xoff, yoff; |
145 | bool isStreaming : 1; | 129 | bool isStreaming : 1; |
146 | }; | 130 | }; |
147 | 131 | ||
148 | 132 | ||
149 | #endif // AUDIO_WIDGET_H | 133 | #endif // AUDIO_WIDGET_H |
150 | 134 | ||
diff --git a/noncore/multimedia/opieplayer2/nullvideo.c b/noncore/multimedia/opieplayer2/nullvideo.c index 707efeb..9c285a0 100644 --- a/noncore/multimedia/opieplayer2/nullvideo.c +++ b/noncore/multimedia/opieplayer2/nullvideo.c | |||
@@ -1,610 +1,610 @@ | |||
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 LJP <> | 5 | Copyright (c) 2002 LJP <> |
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 <stdlib.h> | 34 | #include <stdlib.h> |
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | 36 | ||
37 | #include <math.h> | 37 | #include <math.h> |
38 | 38 | ||
39 | #include <xine.h> | 39 | #include <xine.h> |
40 | #include <xine/video_out.h> | 40 | #include <xine/video_out.h> |
41 | #include <xine/xine_internal.h> | 41 | #include <xine/xine_internal.h> |
42 | #include <xine/xineutils.h> | 42 | #include <xine/xineutils.h> |
43 | #include <xine/vo_scale.h> | 43 | #include <xine/vo_scale.h> |
44 | 44 | ||
45 | #include <pthread.h> | 45 | #include <pthread.h> |
46 | #include "alphablend.h" | 46 | #include "alphablend.h" |
47 | #include "yuv2rgb.h" | 47 | #include "yuv2rgb.h" |
48 | 48 | ||
49 | #define printf(x,...) | 49 | #define printf(x,...) |
50 | 50 | ||
51 | /* | 51 | /* |
52 | #define LOG | 52 | #define LOG |
53 | */ | 53 | */ |
54 | 54 | ||
55 | /* the caller for our event draw handler */ | 55 | /* the caller for our event draw handler */ |
56 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 56 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
57 | int width, int height,int bytes ); | 57 | int width, int height,int bytes ); |
58 | 58 | ||
59 | typedef struct null_driver_s null_driver_t; | 59 | typedef struct null_driver_s null_driver_t; |
60 | 60 | ||
61 | struct null_driver_s { | 61 | struct null_driver_s { |
62 | xine_vo_driver_t vo_driver; | 62 | xine_vo_driver_t vo_driver; |
63 | 63 | ||
64 | uint32_t m_capabilities; | 64 | uint32_t m_capabilities; |
65 | int m_show_video; | 65 | int m_show_video; |
66 | int m_video_fullscreen; | 66 | int m_video_fullscreen; |
67 | int m_is_scaling; | 67 | int m_is_scaling; |
68 | 68 | ||
69 | int depth, bpp, bytes_per_pixel; | 69 | int depth, bpp, bytes_per_pixel; |
70 | int yuv2rgb_mode; | 70 | int yuv2rgb_mode; |
71 | int yuv2rgb_swap; | 71 | int yuv2rgb_swap; |
72 | int yuv2rgb_gamma; | 72 | int yuv2rgb_gamma; |
73 | uint8_t *yuv2rgb_cmap; | 73 | uint8_t *yuv2rgb_cmap; |
74 | yuv2rgb_factory_t *yuv2rgb_factory; | 74 | yuv2rgb_factory_t *yuv2rgb_factory; |
75 | 75 | ||
76 | vo_overlay_t *overlay; | 76 | vo_overlay_t *overlay; |
77 | vo_scale_t sc; | 77 | vo_scale_t sc; |
78 | 78 | ||
79 | int gui_width; | 79 | int gui_width; |
80 | int gui_height; | 80 | int gui_height; |
81 | int gui_changed; | 81 | int gui_changed; |
82 | 82 | ||
83 | double display_ratio; | 83 | double display_ratio; |
84 | void* caller; | 84 | void* caller; |
85 | display_xine_frame_t frameDis; | 85 | display_xine_frame_t frameDis; |
86 | }; | 86 | }; |
87 | 87 | ||
88 | typedef struct opie_frame_s opie_frame_t; | 88 | typedef struct opie_frame_s opie_frame_t; |
89 | struct opie_frame_s { | 89 | struct opie_frame_s { |
90 | vo_frame_t frame; | 90 | vo_frame_t frame; |
91 | 91 | ||
92 | int format; | 92 | int format; |
93 | int flags; | 93 | int flags; |
94 | 94 | ||
95 | vo_scale_t sc; | 95 | vo_scale_t sc; |
96 | 96 | ||
97 | uint8_t *chunk[3]; | 97 | uint8_t *chunk[3]; |
98 | 98 | ||
99 | uint8_t *data; /* rgb */ | 99 | uint8_t *data; /* rgb */ |
100 | int bytes_per_line; | 100 | int bytes_per_line; |
101 | 101 | ||
102 | yuv2rgb_t *yuv2rgb; | 102 | yuv2rgb_t *yuv2rgb; |
103 | uint8_t *rgb_dst; | 103 | uint8_t *rgb_dst; |
104 | int yuv_stride; | 104 | int yuv_stride; |
105 | int stripe_height, stripe_inc; | 105 | int stripe_height, stripe_inc; |
106 | 106 | ||
107 | null_driver_t *output; | 107 | null_driver_t *output; |
108 | }; | 108 | }; |
109 | 109 | ||
110 | static uint32_t null_get_capabilities( xine_vo_driver_t *self ){ | 110 | static uint32_t null_get_capabilities( xine_vo_driver_t *self ){ |
111 | null_driver_t* this = (null_driver_t*)self; | 111 | null_driver_t* this = (null_driver_t*)self; |
112 | return this->m_capabilities; | 112 | return this->m_capabilities; |
113 | } | 113 | } |
114 | 114 | ||
115 | static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { | 115 | static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { |
116 | opie_frame_t *frame = (opie_frame_t *) vo_img ; | 116 | opie_frame_t *frame = (opie_frame_t *) vo_img ; |
117 | 117 | ||
118 | if (!frame->output->m_show_video) { | 118 | if (!frame->output->m_show_video) { |
119 | /* printf("nullvideo: no video\n"); */ | 119 | /* printf("nullvideo: no video\n"); */ |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | 122 | ||
123 | if (frame->format == XINE_IMGFMT_YV12) { | 123 | if (frame->format == XINE_IMGFMT_YV12) { |
124 | frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, | 124 | frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, |
125 | src[0], src[1], src[2]); | 125 | src[0], src[1], src[2]); |
126 | } else { | 126 | } else { |
127 | 127 | ||
128 | frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, | 128 | frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, |
129 | src[0]); | 129 | src[0]); |
130 | } | 130 | } |
131 | 131 | ||
132 | frame->rgb_dst += frame->stripe_inc; | 132 | frame->rgb_dst += frame->stripe_inc; |
133 | } | 133 | } |
134 | 134 | ||
135 | static void null_frame_field (vo_frame_t *vo_img, int which_field) { | 135 | static void null_frame_field (vo_frame_t *vo_img, int which_field) { |
136 | 136 | ||
137 | opie_frame_t *frame = (opie_frame_t *) vo_img ; | 137 | opie_frame_t *frame = (opie_frame_t *) vo_img ; |
138 | 138 | ||
139 | switch (which_field) { | 139 | switch (which_field) { |
140 | case VO_TOP_FIELD: | 140 | case VO_TOP_FIELD: |
141 | frame->rgb_dst = (uint8_t *)frame->data; | 141 | frame->rgb_dst = (uint8_t *)frame->data; |
142 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; | 142 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; |
143 | break; | 143 | break; |
144 | case VO_BOTTOM_FIELD: | 144 | case VO_BOTTOM_FIELD: |
145 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | 145 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; |
146 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; | 146 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; |
147 | break; | 147 | break; |
148 | case VO_BOTH_FIELDS: | 148 | case VO_BOTH_FIELDS: |
149 | frame->rgb_dst = (uint8_t *)frame->data; | 149 | frame->rgb_dst = (uint8_t *)frame->data; |
150 | break; | 150 | break; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | /* take care of the frame*/ | 155 | /* take care of the frame*/ |
156 | static void null_frame_dispose( vo_frame_t* vo_img){ | 156 | static void null_frame_dispose( vo_frame_t* vo_img){ |
157 | opie_frame_t* frame = (opie_frame_t*)vo_img; | 157 | opie_frame_t* frame = (opie_frame_t*)vo_img; |
158 | 158 | ||
159 | if (frame->data) | 159 | if (frame->data) |
160 | free( frame->data ); | 160 | free( frame->data ); |
161 | free (frame); | 161 | free (frame); |
162 | } | 162 | } |
163 | 163 | ||
164 | /* end take care of frames*/ | 164 | /* end take care of frames*/ |
165 | 165 | ||
166 | static vo_frame_t* null_alloc_frame( xine_vo_driver_t* self ){ | 166 | static vo_frame_t* null_alloc_frame( xine_vo_driver_t* self ){ |
167 | 167 | ||
168 | null_driver_t* this = (null_driver_t*)self; | 168 | null_driver_t* this = (null_driver_t*)self; |
169 | opie_frame_t* frame; | 169 | opie_frame_t* frame; |
170 | 170 | ||
171 | #ifdef LOG | 171 | #ifdef LOG |
172 | fprintf (stderr, "nullvideo: alloc_frame\n"); | 172 | fprintf (stderr, "nullvideo: alloc_frame\n"); |
173 | #endif | 173 | #endif |
174 | 174 | ||
175 | frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) ); | 175 | frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) ); |
176 | 176 | ||
177 | memset( frame, 0, sizeof( opie_frame_t) ); | 177 | memset( frame, 0, sizeof( opie_frame_t) ); |
178 | memcpy (&frame->sc, &this->sc, sizeof(vo_scale_t)); | 178 | memcpy (&frame->sc, &this->sc, sizeof(vo_scale_t)); |
179 | 179 | ||
180 | pthread_mutex_init (&frame->frame.mutex, NULL); | 180 | pthread_mutex_init (&frame->frame.mutex, NULL); |
181 | 181 | ||
182 | frame->output = this; | 182 | frame->output = this; |
183 | 183 | ||
184 | /* initialize the frame*/ | 184 | /* initialize the frame*/ |
185 | frame->frame.driver = self; | 185 | frame->frame.driver = self; |
186 | frame->frame.copy = null_frame_copy; | 186 | frame->frame.copy = null_frame_copy; |
187 | frame->frame.field = null_frame_field; | 187 | frame->frame.field = null_frame_field; |
188 | frame->frame.dispose = null_frame_dispose; | 188 | frame->frame.dispose = null_frame_dispose; |
189 | 189 | ||
190 | /* | 190 | /* |
191 | * colorspace converter for this frame | 191 | * colorspace converter for this frame |
192 | */ | 192 | */ |
193 | frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory); | 193 | frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory); |
194 | 194 | ||
195 | return (vo_frame_t*) frame; | 195 | return (vo_frame_t*) frame; |
196 | } | 196 | } |
197 | 197 | ||
198 | static void null_update_frame_format( xine_vo_driver_t* self, vo_frame_t* img, | 198 | static void null_update_frame_format( xine_vo_driver_t* self, vo_frame_t* img, |
199 | uint32_t width, uint32_t height, | 199 | uint32_t width, uint32_t height, |
200 | int ratio_code, int format, int flags ){ | 200 | int ratio_code, int format, int flags ){ |
201 | null_driver_t* this = (null_driver_t*) self; | 201 | null_driver_t* this = (null_driver_t*) self; |
202 | opie_frame_t* frame = (opie_frame_t*)img; | 202 | opie_frame_t* frame = (opie_frame_t*)img; |
203 | /* not needed now */ | 203 | /* not needed now */ |
204 | 204 | ||
205 | #ifdef LOG | 205 | #ifdef LOG |
206 | fprintf (stderr, "nullvideo: update_frame_format\n"); | 206 | fprintf (stderr, "nullvideo: update_frame_format\n"); |
207 | #endif | 207 | #endif |
208 | 208 | ||
209 | flags &= VO_BOTH_FIELDS; | 209 | flags &= VO_BOTH_FIELDS; |
210 | 210 | ||
211 | /* find out if we need to adapt this frame */ | 211 | /* find out if we need to adapt this frame */ |
212 | 212 | ||
213 | if ((width != frame->sc.delivered_width) | 213 | if ((width != frame->sc.delivered_width) |
214 | || (height != frame->sc.delivered_height) | 214 | || (height != frame->sc.delivered_height) |
215 | || (ratio_code != frame->sc.delivered_ratio_code) | 215 | || (ratio_code != frame->sc.delivered_ratio_code) |
216 | || (flags != frame->flags) | 216 | || (flags != frame->flags) |
217 | || (format != frame->format) | 217 | || (format != frame->format) |
218 | || (this->sc.user_ratio != frame->sc.user_ratio) | 218 | || (this->sc.user_ratio != frame->sc.user_ratio) |
219 | || (this->gui_width != frame->sc.gui_width) | 219 | || (this->gui_width != frame->sc.gui_width) |
220 | || (this->gui_height != frame->sc.gui_height)) { | 220 | || (this->gui_height != frame->sc.gui_height)) { |
221 | 221 | ||
222 | frame->sc.delivered_width = width; | 222 | frame->sc.delivered_width = width; |
223 | frame->sc.delivered_height = height; | 223 | frame->sc.delivered_height = height; |
224 | frame->sc.delivered_ratio_code = ratio_code; | 224 | frame->sc.delivered_ratio_code = ratio_code; |
225 | frame->flags = flags; | 225 | frame->flags = flags; |
226 | frame->format = format; | 226 | frame->format = format; |
227 | frame->sc.user_ratio = this->sc.user_ratio; | 227 | frame->sc.user_ratio = this->sc.user_ratio; |
228 | frame->sc.gui_width = this->gui_width; | 228 | frame->sc.gui_width = this->gui_width; |
229 | frame->sc.gui_height = this->gui_height; | 229 | frame->sc.gui_height = this->gui_height; |
230 | frame->sc.gui_pixel_aspect = 1.0; | 230 | frame->sc.gui_pixel_aspect = 1.0; |
231 | 231 | ||
232 | vo_scale_compute_ideal_size ( &frame->sc ); | 232 | vo_scale_compute_ideal_size ( &frame->sc ); |
233 | vo_scale_compute_output_size( &frame->sc ); | 233 | vo_scale_compute_output_size( &frame->sc ); |
234 | 234 | ||
235 | #ifdef LOG | 235 | #ifdef LOG |
236 | fprintf (stderr, "nullvideo: gui %dx%d delivered %dx%d output %dx%d\n", | 236 | fprintf (stderr, "nullvideo: gui %dx%d delivered %dx%d output %dx%d\n", |
237 | frame->sc.gui_width, frame->sc.gui_height, | 237 | frame->sc.gui_width, frame->sc.gui_height, |
238 | frame->sc.delivered_width, frame->sc.delivered_height, | 238 | frame->sc.delivered_width, frame->sc.delivered_height, |
239 | frame->sc.output_width, frame->sc.output_height); | 239 | frame->sc.output_width, frame->sc.output_height); |
240 | #endif | 240 | #endif |
241 | 241 | ||
242 | /* | 242 | /* |
243 | * (re-) allocate | 243 | * (re-) allocate |
244 | */ | 244 | */ |
245 | if( frame->data ) { | 245 | if( frame->data ) { |
246 | if( frame->chunk[0] ){ | 246 | if( frame->chunk[0] ){ |
247 | free( frame->chunk[0] ); | 247 | free( frame->chunk[0] ); |
248 | frame->chunk[0] = NULL; | 248 | frame->chunk[0] = NULL; |
249 | } | 249 | } |
250 | if( frame->chunk[1] ){ | 250 | if( frame->chunk[1] ){ |
251 | free ( frame->chunk[1] ); | 251 | free ( frame->chunk[1] ); |
252 | frame->chunk[1] = NULL; | 252 | frame->chunk[1] = NULL; |
253 | } | 253 | } |
254 | if( frame->chunk[2] ){ | 254 | if( frame->chunk[2] ){ |
255 | free ( frame->chunk[2] ); | 255 | free ( frame->chunk[2] ); |
256 | frame->chunk[2] = NULL; | 256 | frame->chunk[2] = NULL; |
257 | } | 257 | } |
258 | free ( frame->data ); | 258 | free ( frame->data ); |
259 | } | 259 | } |
260 | 260 | ||
261 | frame->data = xine_xmalloc (frame->sc.output_width | 261 | frame->data = xine_xmalloc (frame->sc.output_width |
262 | * frame->sc.output_height | 262 | * frame->sc.output_height |
263 | * this->bytes_per_pixel ); | 263 | * this->bytes_per_pixel ); |
264 | 264 | ||
265 | if( format == XINE_IMGFMT_YV12 ) { | 265 | if( format == XINE_IMGFMT_YV12 ) { |
266 | frame->frame.pitches[0] = 8*((width + 7) / 8); | 266 | frame->frame.pitches[0] = 8*((width + 7) / 8); |
267 | frame->frame.pitches[1] = 8*((width + 15) / 16); | 267 | frame->frame.pitches[1] = 8*((width + 15) / 16); |
268 | frame->frame.pitches[2] = 8*((width + 15) / 16); | 268 | frame->frame.pitches[2] = 8*((width + 15) / 16); |
269 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,(void **)&frame->chunk[0]); | 269 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,(void **)&frame->chunk[0]); |
270 | frame->frame.base[1] = xine_xmalloc_aligned (16, frame->frame.pitches[1] * ((height+ 1)/2), (void **)&frame->chunk[1]); | 270 | frame->frame.base[1] = xine_xmalloc_aligned (16, frame->frame.pitches[1] * ((height+ 1)/2), (void **)&frame->chunk[1]); |
271 | frame->frame.base[2] = xine_xmalloc_aligned (16, frame->frame.pitches[2] * ((height+ 1)/2), (void **)&frame->chunk[2]); | 271 | frame->frame.base[2] = xine_xmalloc_aligned (16, frame->frame.pitches[2] * ((height+ 1)/2), (void **)&frame->chunk[2]); |
272 | 272 | ||
273 | }else{ | 273 | }else{ |
274 | frame->frame.pitches[0] = 8*((width + 3) / 4); | 274 | frame->frame.pitches[0] = 8*((width + 3) / 4); |
275 | 275 | ||
276 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height, | 276 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height, |
277 | (void **)&frame->chunk[0]); | 277 | (void **)&frame->chunk[0]); |
278 | frame->chunk[1] = NULL; | 278 | frame->chunk[1] = NULL; |
279 | frame->chunk[2] = NULL; | 279 | frame->chunk[2] = NULL; |
280 | } | 280 | } |
281 | 281 | ||
282 | frame->stripe_height = 16 * frame->sc.output_height / frame->sc.delivered_height; | 282 | frame->stripe_height = 16 * frame->sc.output_height / frame->sc.delivered_height; |
283 | frame->bytes_per_line = frame->sc.output_width * this->bytes_per_pixel; | 283 | frame->bytes_per_line = frame->sc.output_width * this->bytes_per_pixel; |
284 | 284 | ||
285 | /* | 285 | /* |
286 | * set up colorspace converter | 286 | * set up colorspace converter |
287 | */ | 287 | */ |
288 | 288 | ||
289 | switch (flags) { | 289 | switch (flags) { |
290 | case VO_TOP_FIELD: | 290 | case VO_TOP_FIELD: |
291 | case VO_BOTTOM_FIELD: | 291 | case VO_BOTTOM_FIELD: |
292 | frame->yuv2rgb->configure (frame->yuv2rgb, | 292 | frame->yuv2rgb->configure (frame->yuv2rgb, |
293 | frame->sc.delivered_width, | 293 | frame->sc.delivered_width, |
294 | 16, | 294 | 16, |
295 | 2*frame->frame.pitches[0], | 295 | 2*frame->frame.pitches[0], |
296 | 2*frame->frame.pitches[1], | 296 | 2*frame->frame.pitches[1], |
297 | frame->sc.output_width, | 297 | frame->sc.output_width, |
298 | frame->stripe_height, | 298 | frame->stripe_height, |
299 | frame->bytes_per_line*2); | 299 | frame->bytes_per_line*2); |
300 | frame->yuv_stride = frame->bytes_per_line*2; | 300 | frame->yuv_stride = frame->bytes_per_line*2; |
301 | break; | 301 | break; |
302 | case VO_BOTH_FIELDS: | 302 | case VO_BOTH_FIELDS: |
303 | frame->yuv2rgb->configure (frame->yuv2rgb, | 303 | frame->yuv2rgb->configure (frame->yuv2rgb, |
304 | frame->sc.delivered_width, | 304 | frame->sc.delivered_width, |
305 | 16, | 305 | 16, |
306 | frame->frame.pitches[0], | 306 | frame->frame.pitches[0], |
307 | frame->frame.pitches[1], | 307 | frame->frame.pitches[1], |
308 | frame->sc.output_width, | 308 | frame->sc.output_width, |
309 | frame->stripe_height, | 309 | frame->stripe_height, |
310 | frame->bytes_per_line); | 310 | frame->bytes_per_line); |
311 | frame->yuv_stride = frame->bytes_per_line; | 311 | frame->yuv_stride = frame->bytes_per_line; |
312 | break; | 312 | break; |
313 | } | 313 | } |
314 | #ifdef LOG | 314 | #ifdef LOG |
315 | fprintf (stderr, "nullvideo: colorspace converter configured.\n"); | 315 | fprintf (stderr, "nullvideo: colorspace converter configured.\n"); |
316 | #endif | 316 | #endif |
317 | } | 317 | } |
318 | 318 | ||
319 | /* | 319 | /* |
320 | * reset dest pointers | 320 | * reset dest pointers |
321 | */ | 321 | */ |
322 | 322 | ||
323 | if (frame->data) { | 323 | if (frame->data) { |
324 | switch (flags) { | 324 | switch (flags) { |
325 | case VO_TOP_FIELD: | 325 | case VO_TOP_FIELD: |
326 | frame->rgb_dst = (uint8_t *)frame->data; | 326 | frame->rgb_dst = (uint8_t *)frame->data; |
327 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | 327 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; |
328 | break; | 328 | break; |
329 | case VO_BOTTOM_FIELD: | 329 | case VO_BOTTOM_FIELD: |
330 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | 330 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; |
331 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | 331 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; |
332 | break; | 332 | break; |
333 | case VO_BOTH_FIELDS: | 333 | case VO_BOTH_FIELDS: |
334 | frame->rgb_dst = (uint8_t *)frame->data; | 334 | frame->rgb_dst = (uint8_t *)frame->data; |
335 | frame->stripe_inc = frame->stripe_height * frame->bytes_per_line; | 335 | frame->stripe_inc = frame->stripe_height * frame->bytes_per_line; |
336 | break; | 336 | break; |
337 | } | 337 | } |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | static void null_display_frame( xine_vo_driver_t* self, vo_frame_t *frame_gen ){ | 341 | static void null_display_frame( xine_vo_driver_t* self, vo_frame_t *frame_gen ){ |
342 | null_driver_t* this = (null_driver_t*) self; | 342 | null_driver_t* this = (null_driver_t*) self; |
343 | opie_frame_t* frame = (opie_frame_t*)frame_gen; | 343 | opie_frame_t* frame = (opie_frame_t*)frame_gen; |
344 | display_xine_frame_t display = this->frameDis; | 344 | display_xine_frame_t display = this->frameDis; |
345 | 345 | ||
346 | if (!this->m_show_video) | 346 | if (!this->m_show_video) |
347 | return; | 347 | return; |
348 | 348 | ||
349 | if( display != NULL ) { | 349 | if( display != NULL ) { |
350 | (*display)(this->caller, frame->data, | 350 | (*display)(this->caller, frame->data, |
351 | frame->sc.output_width, frame->sc.output_height, | 351 | frame->sc.output_width, frame->sc.output_height, |
352 | frame->bytes_per_line ); | 352 | frame->bytes_per_line ); |
353 | } | 353 | } |
354 | 354 | ||
355 | frame->frame.displayed (&frame->frame); | 355 | frame->frame.displayed (&frame->frame); |
356 | } | 356 | } |
357 | 357 | ||
358 | 358 | ||
359 | /* blending related */ | 359 | /* blending related */ |
360 | static void null_overlay_clut_yuv2rgb (null_driver_t *this, | 360 | static void null_overlay_clut_yuv2rgb (null_driver_t *this, |
361 | vo_overlay_t *overlay, | 361 | vo_overlay_t *overlay, |
362 | opie_frame_t *frame) { | 362 | opie_frame_t *frame) { |
363 | int i; | 363 | int i; |
364 | clut_t* clut = (clut_t*) overlay->color; | 364 | clut_t* clut = (clut_t*) overlay->color; |
365 | if (!overlay->rgb_clut) { | 365 | if (!overlay->rgb_clut) { |
366 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { | 366 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { |
367 | *((uint32_t *)&clut[i]) = | 367 | *((uint32_t *)&clut[i]) = |
368 | frame->yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb, | 368 | frame->yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb, |
369 | clut[i].y, clut[i].cb, clut[i].cr); | 369 | clut[i].y, clut[i].cb, clut[i].cr); |
370 | } | 370 | } |
371 | overlay->rgb_clut++; | 371 | overlay->rgb_clut++; |
372 | } | 372 | } |
373 | if (!overlay->clip_rgb_clut) { | 373 | if (!overlay->clip_rgb_clut) { |
374 | clut = (clut_t*) overlay->clip_color; | 374 | clut = (clut_t*) overlay->clip_color; |
375 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { | 375 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { |
376 | *((uint32_t *)&clut[i]) = | 376 | *((uint32_t *)&clut[i]) = |
377 | frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, | 377 | frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, |
378 | clut[i].y, clut[i].cb, clut[i].cr); | 378 | clut[i].y, clut[i].cb, clut[i].cr); |
379 | } | 379 | } |
380 | overlay->clip_rgb_clut++; | 380 | overlay->clip_rgb_clut++; |
381 | } | 381 | } |
382 | } | 382 | } |
383 | 383 | ||
384 | static void null_overlay_blend ( xine_vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) { | 384 | static void null_overlay_blend ( xine_vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) { |
385 | null_driver_t *this = (null_driver_t *) this_gen; | 385 | null_driver_t *this = (null_driver_t *) this_gen; |
386 | opie_frame_t *frame = (opie_frame_t *) frame_gen; | 386 | opie_frame_t *frame = (opie_frame_t *) frame_gen; |
387 | 387 | ||
388 | if(!this->m_show_video || frame->sc.output_width == 0 | 388 | if(!this->m_show_video || frame->sc.output_width == 0 |
389 | || frame->sc.output_height== 0) | 389 | || frame->sc.output_height== 0) |
390 | return; | 390 | return; |
391 | 391 | ||
392 | /* Alpha Blend here */ | 392 | /* Alpha Blend here */ |
393 | if (overlay->rle) { | 393 | if (overlay->rle) { |
394 | if( !overlay->rgb_clut || !overlay->clip_rgb_clut) | 394 | if( !overlay->rgb_clut || !overlay->clip_rgb_clut) |
395 | null_overlay_clut_yuv2rgb(this,overlay,frame); | 395 | null_overlay_clut_yuv2rgb(this,overlay,frame); |
396 | 396 | ||
397 | switch(this->bpp) { | 397 | switch(this->bpp) { |
398 | case 16: | 398 | case 16: |
399 | blend_rgb16( (uint8_t *)frame->data, overlay, | 399 | blend_rgb16( (uint8_t *)frame->data, overlay, |
400 | frame->sc.output_width, frame->sc.output_height, | 400 | frame->sc.output_width, frame->sc.output_height, |
401 | frame->sc.delivered_width, frame->sc.delivered_height); | 401 | frame->sc.delivered_width, frame->sc.delivered_height); |
402 | break; | 402 | break; |
403 | case 24: | 403 | case 24: |
404 | blend_rgb24( (uint8_t *)frame->data, overlay, | 404 | blend_rgb24( (uint8_t *)frame->data, overlay, |
405 | frame->sc.output_width, frame->sc.output_height, | 405 | frame->sc.output_width, frame->sc.output_height, |
406 | frame->sc.delivered_width, frame->sc.delivered_height); | 406 | frame->sc.delivered_width, frame->sc.delivered_height); |
407 | break; | 407 | break; |
408 | case 32: | 408 | case 32: |
409 | blend_rgb32( (uint8_t *)frame->data, overlay, | 409 | blend_rgb32( (uint8_t *)frame->data, overlay, |
410 | frame->sc.output_width, frame->sc.output_height, | 410 | frame->sc.output_width, frame->sc.output_height, |
411 | frame->sc.delivered_width, frame->sc.delivered_height); | 411 | frame->sc.delivered_width, frame->sc.delivered_height); |
412 | break; | 412 | break; |
413 | default: | 413 | default: |
414 | /* It should never get here */ | 414 | /* It should never get here */ |
415 | break; | 415 | break; |
416 | } | 416 | } |
417 | } | 417 | } |
418 | } | 418 | } |
419 | 419 | ||
420 | 420 | ||
421 | static int null_get_property( xine_vo_driver_t* self, | 421 | static int null_get_property( xine_vo_driver_t* self, |
422 | int property ){ | 422 | int property ){ |
423 | return 0; | 423 | return 0; |
424 | } | 424 | } |
425 | static int null_set_property( xine_vo_driver_t* self, | 425 | static int null_set_property( xine_vo_driver_t* self, |
426 | int property, | 426 | int property, |
427 | int value ){ | 427 | int value ){ |
428 | return value; | 428 | return value; |
429 | } | 429 | } |
430 | static void null_get_property_min_max( xine_vo_driver_t* self, | 430 | static void null_get_property_min_max( xine_vo_driver_t* self, |
431 | int property, int *min, | 431 | int property, int *min, |
432 | int *max ){ | 432 | int *max ){ |
433 | *max = 0; | 433 | *max = 0; |
434 | *min = 0; | 434 | *min = 0; |
435 | } | 435 | } |
436 | static int null_gui_data_exchange( xine_vo_driver_t* self, | 436 | static int null_gui_data_exchange( xine_vo_driver_t* self, |
437 | int data_type, | 437 | int data_type, |
438 | void *data ){ | 438 | void *data ){ |
439 | return 0; | 439 | return 0; |
440 | } | 440 | } |
441 | 441 | ||
442 | static void null_dispose ( xine_vo_driver_t* self ){ | 442 | static void null_dispose ( xine_vo_driver_t* self ){ |
443 | null_driver_t* this = (null_driver_t*)self; | 443 | null_driver_t* this = (null_driver_t*)self; |
444 | free ( this ); | 444 | free ( this ); |
445 | } | 445 | } |
446 | static int null_redraw_needed( xine_vo_driver_t* self ){ | 446 | static int null_redraw_needed( xine_vo_driver_t* self ){ |
447 | return 0; | 447 | return 0; |
448 | } | 448 | } |
449 | 449 | ||
450 | 450 | ||
451 | xine_vo_driver_t* init_video_out_plugin( config_values_t* conf, | 451 | xine_vo_driver_t* init_video_out_plugin( config_values_t* conf, |
452 | void* video ){ | 452 | void* video ){ |
453 | null_driver_t *vo; | 453 | null_driver_t *vo; |
454 | vo = (null_driver_t*)malloc( sizeof(null_driver_t ) ); | 454 | vo = (null_driver_t*)malloc( sizeof(null_driver_t ) ); |
455 | 455 | ||
456 | /* memset? */ | 456 | /* memset? */ |
457 | memset(vo,0, sizeof(null_driver_t ) ); | 457 | memset(vo,0, sizeof(null_driver_t ) ); |
458 | 458 | ||
459 | vo_scale_init (&vo->sc, 0, 0); | 459 | vo_scale_init (&vo->sc, 0, 0); |
460 | 460 | ||
461 | vo->sc.gui_pixel_aspect = 1.0; | 461 | vo->sc.gui_pixel_aspect = 1.0; |
462 | 462 | ||
463 | vo->m_show_video = 0; // false | 463 | vo->m_show_video = 0; // false |
464 | vo->m_video_fullscreen = 0; | 464 | vo->m_video_fullscreen = 0; |
465 | vo->m_is_scaling = 0; | 465 | vo->m_is_scaling = 0; |
466 | vo->display_ratio = 1.0; | 466 | vo->display_ratio = 1.0; |
467 | vo->gui_width = 16; | 467 | vo->gui_width = 16; |
468 | vo->gui_height = 8; | 468 | vo->gui_height = 8; |
469 | vo->frameDis = NULL; | 469 | vo->frameDis = NULL; |
470 | 470 | ||
471 | /* install callback handlers*/ | 471 | /* install callback handlers*/ |
472 | vo->vo_driver.get_capabilities = null_get_capabilities; | 472 | vo->vo_driver.get_capabilities = null_get_capabilities; |
473 | vo->vo_driver.alloc_frame = null_alloc_frame; | 473 | vo->vo_driver.alloc_frame = null_alloc_frame; |
474 | vo->vo_driver.update_frame_format = null_update_frame_format; | 474 | vo->vo_driver.update_frame_format = null_update_frame_format; |
475 | vo->vo_driver.display_frame = null_display_frame; | 475 | vo->vo_driver.display_frame = null_display_frame; |
476 | vo->vo_driver.overlay_blend = null_overlay_blend; | 476 | vo->vo_driver.overlay_blend = null_overlay_blend; |
477 | vo->vo_driver.get_property = null_get_property; | 477 | vo->vo_driver.get_property = null_get_property; |
478 | vo->vo_driver.set_property = null_set_property; | 478 | vo->vo_driver.set_property = null_set_property; |
479 | vo->vo_driver.get_property_min_max = null_get_property_min_max; | 479 | vo->vo_driver.get_property_min_max = null_get_property_min_max; |
480 | vo->vo_driver.gui_data_exchange = null_gui_data_exchange; | 480 | vo->vo_driver.gui_data_exchange = null_gui_data_exchange; |
481 | vo->vo_driver.dispose = null_dispose; | 481 | vo->vo_driver.dispose = null_dispose; |
482 | vo->vo_driver.redraw_needed = null_redraw_needed; | 482 | vo->vo_driver.redraw_needed = null_redraw_needed; |
483 | 483 | ||
484 | 484 | ||
485 | /* capabilities */ | 485 | /* capabilities */ |
486 | vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12; | 486 | vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12; |
487 | vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap, | 487 | vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap, |
488 | vo->yuv2rgb_cmap); | 488 | vo->yuv2rgb_cmap); |
489 | 489 | ||
490 | return ( xine_vo_driver_t*) vo; | 490 | return ( xine_vo_driver_t*) vo; |
491 | } | 491 | } |
492 | 492 | ||
493 | #if 0 | 493 | #if 0 |
494 | static vo_info_t vo_info_null = { | 494 | static vo_info_t vo_info_null = { |
495 | 5, | 495 | 5, |
496 | XINE_VISUAL_TYPE_FB | 496 | XINE_VISUAL_TYPE_FB |
497 | }; | 497 | }; |
498 | 498 | ||
499 | vo_info_t *get_video_out_plugin_info(){ | 499 | vo_info_t *get_video_out_plugin_info(){ |
500 | vo_info_null.description = ("xine video output plugin using null device"); | 500 | vo_info_null.description = ("xine video output plugin using null device"); |
501 | return &vo_info_null; | 501 | return &vo_info_null; |
502 | } | 502 | } |
503 | 503 | ||
504 | #endif | 504 | #endif |
505 | 505 | ||
506 | /* this is special for this device */ | 506 | /* this is special for this device */ |
507 | /** | 507 | /** |
508 | * We know that we will be controled by the XINE LIB++ | 508 | * We know that we will be controled by the XINE LIB++ |
509 | */ | 509 | */ |
510 | 510 | ||
511 | /** | 511 | /** |
512 | * | 512 | * |
513 | */ | 513 | */ |
514 | int null_is_showing_video( xine_vo_driver_t* self ){ | 514 | int null_is_showing_video( xine_vo_driver_t* self ){ |
515 | null_driver_t* this = (null_driver_t*)self; | 515 | null_driver_t* this = (null_driver_t*)self; |
516 | return this->m_show_video; | 516 | return this->m_show_video; |
517 | } | 517 | } |
518 | void null_set_show_video( xine_vo_driver_t* self, int show ) { | 518 | void null_set_show_video( xine_vo_driver_t* self, int show ) { |
519 | ((null_driver_t*)self)->m_show_video = show; | 519 | ((null_driver_t*)self)->m_show_video = show; |
520 | } | 520 | } |
521 | 521 | ||
522 | int null_is_fullscreen( xine_vo_driver_t* self ){ | 522 | int null_is_fullscreen( xine_vo_driver_t* self ){ |
523 | return ((null_driver_t*)self)->m_video_fullscreen; | 523 | return ((null_driver_t*)self)->m_video_fullscreen; |
524 | } | 524 | } |
525 | void null_set_fullscreen( xine_vo_driver_t* self, int screen ){ | 525 | void null_set_fullscreen( xine_vo_driver_t* self, int screen ){ |
526 | ((null_driver_t*)self)->m_video_fullscreen = screen; | 526 | ((null_driver_t*)self)->m_video_fullscreen = screen; |
527 | } | 527 | } |
528 | int null_is_scaling( xine_vo_driver_t* self ){ | 528 | int null_is_scaling( xine_vo_driver_t* self ){ |
529 | return ((null_driver_t*)self)->m_is_scaling; | 529 | return ((null_driver_t*)self)->m_is_scaling; |
530 | } | 530 | } |
531 | 531 | ||
532 | void null_set_videoGamma( xine_vo_driver_t* self , int value ) { | 532 | void null_set_videoGamma( xine_vo_driver_t* self , int value ) { |
533 | ((null_driver_t*) self) ->yuv2rgb_gamma = value; | 533 | ((null_driver_t*) self) ->yuv2rgb_gamma = value; |
534 | ((null_driver_t*) self) ->yuv2rgb_factory->set_gamma( ((null_driver_t*) self) ->yuv2rgb_factory, value ); | 534 | ((null_driver_t*) self) ->yuv2rgb_factory->set_gamma( ((null_driver_t*) self) ->yuv2rgb_factory, value ); |
535 | } | 535 | } |
536 | 536 | ||
537 | void null_set_scaling( xine_vo_driver_t* self, int scale ) { | 537 | void null_set_scaling( xine_vo_driver_t* self, int scale ) { |
538 | ((null_driver_t*)self)->m_is_scaling = scale; | 538 | ((null_driver_t*)self)->m_is_scaling = scale; |
539 | } | 539 | } |
540 | 540 | ||
541 | void null_set_gui_width( xine_vo_driver_t* self, int width ) { | 541 | void null_set_gui_width( xine_vo_driver_t* self, int width ) { |
542 | ((null_driver_t*)self)->gui_width = width; | 542 | ((null_driver_t*)self)->gui_width = width; |
543 | } | 543 | } |
544 | void null_set_gui_height( xine_vo_driver_t* self, int height ) { | 544 | void null_set_gui_height( xine_vo_driver_t* self, int height ) { |
545 | ((null_driver_t*)self)->gui_height = height; | 545 | ((null_driver_t*)self)->gui_height = height; |
546 | } | 546 | } |
547 | 547 | ||
548 | 548 | ||
549 | void null_set_mode( xine_vo_driver_t* self, int depth, int rgb ) { | 549 | void null_set_mode( xine_vo_driver_t* self, int depth, int rgb ) { |
550 | null_driver_t* this = (null_driver_t*)self; | 550 | null_driver_t* this = (null_driver_t*)self; |
551 | 551 | ||
552 | this->bytes_per_pixel = (depth + 7 ) / 8; | 552 | this->bytes_per_pixel = (depth + 7 ) / 8; |
553 | this->bpp = this->bytes_per_pixel * 8; | 553 | this->bpp = this->bytes_per_pixel * 8; |
554 | this->depth = depth; | 554 | this->depth = depth; |
555 | printf("depth %d %d\n", depth, this->bpp); | 555 | printf("depth %d %d\n", depth, this->bpp); |
556 | printf("pixeltype %d\n", rgb ); | 556 | printf("pixeltype %d\n", rgb ); |
557 | switch ( this->depth ) { | 557 | switch ( this->depth ) { |
558 | case 32: | 558 | case 32: |
559 | if( rgb == 0 ) | 559 | if( rgb == 0 ) |
560 | this->yuv2rgb_mode = MODE_32_RGB; | 560 | this->yuv2rgb_mode = MODE_32_RGB; |
561 | else | 561 | else |
562 | this->yuv2rgb_mode = MODE_32_BGR; | 562 | this->yuv2rgb_mode = MODE_32_BGR; |
563 | case 24: | 563 | case 24: |
564 | if( this->bpp == 32 ) { | 564 | if( this->bpp == 32 ) { |
565 | if( rgb == 0 ) { | 565 | if( rgb == 0 ) { |
566 | this->yuv2rgb_mode = MODE_32_RGB; | 566 | this->yuv2rgb_mode = MODE_32_RGB; |
567 | } else { | 567 | } else { |
568 | this->yuv2rgb_mode = MODE_32_BGR; | 568 | this->yuv2rgb_mode = MODE_32_BGR; |
569 | } | 569 | } |
570 | }else{ | 570 | }else{ |
571 | if( rgb == 0 ) | 571 | if( rgb == 0 ) |
572 | this->yuv2rgb_mode = MODE_24_RGB; | 572 | this->yuv2rgb_mode = MODE_24_RGB; |
573 | else | 573 | else |
574 | this->yuv2rgb_mode = MODE_24_BGR; | 574 | this->yuv2rgb_mode = MODE_24_BGR; |
575 | }; | 575 | }; |
576 | break; | 576 | break; |
577 | case 16: | 577 | case 16: |
578 | if( rgb == 0 ) { | 578 | if( rgb == 0 ) { |
579 | this->yuv2rgb_mode = MODE_16_RGB; | 579 | this->yuv2rgb_mode = MODE_16_RGB; |
580 | } else { | 580 | } else { |
581 | this->yuv2rgb_mode = MODE_16_BGR; | 581 | this->yuv2rgb_mode = MODE_16_BGR; |
582 | } | 582 | } |
583 | break; | 583 | break; |
584 | case 15: | 584 | case 15: |
585 | if( rgb == 0 ) { | 585 | if( rgb == 0 ) { |
586 | this->yuv2rgb_mode = MODE_15_RGB; | 586 | this->yuv2rgb_mode = MODE_15_RGB; |
587 | } else { | 587 | } else { |
588 | this->yuv2rgb_mode = MODE_15_BGR; | 588 | this->yuv2rgb_mode = MODE_15_BGR; |
589 | } | 589 | } |
590 | break; | 590 | break; |
591 | case 8: | 591 | case 8: |
592 | if( rgb == 0 ) { | 592 | if( rgb == 0 ) { |
593 | this->yuv2rgb_mode = MODE_8_RGB; | 593 | this->yuv2rgb_mode = MODE_8_RGB; |
594 | } else { | 594 | } else { |
595 | this->yuv2rgb_mode = MODE_8_BGR; | 595 | this->yuv2rgb_mode = MODE_8_BGR; |
596 | } | 596 | } |
597 | break; | 597 | break; |
598 | }; | 598 | }; |
599 | //free(this->yuv2rgb_factory ); | 599 | //free(this->yuv2rgb_factory ); |
600 | // this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap, | 600 | // this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap, |
601 | // this->yuv2rgb_cmap); | 601 | // this->yuv2rgb_cmap); |
602 | }; | 602 | }; |
603 | 603 | ||
604 | void null_display_handler( xine_vo_driver_t* self, display_xine_frame_t t, | 604 | void null_display_handler( xine_vo_driver_t* self, display_xine_frame_t t, |
605 | void* user_data ) { | 605 | void* user_data ) { |
606 | null_driver_t* this = (null_driver_t*) self; | 606 | null_driver_t* this = (null_driver_t*) self; |
607 | this->caller = user_data; | 607 | this->caller = user_data; |
608 | this->frameDis = t; | 608 | this->frameDis = t; |
609 | } | 609 | } |
610 | 610 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 040ef71..8e88e9b 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -26,1061 +26,1058 @@ | |||
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = 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/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdir.h> | 41 | #include <qdir.h> |
42 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
45 | 45 | ||
46 | #include "playlistselection.h" | 46 | #include "playlistselection.h" |
47 | #include "playlistwidget.h" | 47 | #include "playlistwidget.h" |
48 | #include "mediaplayerstate.h" | 48 | #include "mediaplayerstate.h" |
49 | #include "inputDialog.h" | 49 | #include "inputDialog.h" |
50 | #include "om3u.h" | 50 | #include "om3u.h" |
51 | 51 | ||
52 | //only needed for the random play | 52 | //only needed for the random play |
53 | #include <stdlib.h> | 53 | #include <stdlib.h> |
54 | 54 | ||
55 | #include "audiowidget.h" | 55 | #include "audiowidget.h" |
56 | #include "videowidget.h" | 56 | #include "videowidget.h" |
57 | 57 | ||
58 | extern MediaPlayerState *mediaPlayerState; | 58 | extern MediaPlayerState *mediaPlayerState; |
59 | // extern AudioWidget *audioUI; | 59 | // extern AudioWidget *audioUI; |
60 | // extern VideoWidget *videoUI; | 60 | // extern VideoWidget *videoUI; |
61 | 61 | ||
62 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | 62 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; |
63 | // no m3u's here please | 63 | // no m3u's here please |
64 | 64 | ||
65 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 65 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
66 | : PlayListWidgetGui( parent, name, fl ) { | 66 | : PlayListWidgetGui( parent, name, fl ) { |
67 | 67 | ||
68 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 68 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
69 | "opieplayer2/add_to_playlist", | 69 | "opieplayer2/add_to_playlist", |
70 | this , SLOT(addSelected() ) ); | 70 | this , SLOT(addSelected() ) ); |
71 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 71 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
72 | "opieplayer2/remove_from_playlist", | 72 | "opieplayer2/remove_from_playlist", |
73 | this , SLOT(removeSelected() ) ); | 73 | this , SLOT(removeSelected() ) ); |
74 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 74 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
75 | this , SLOT( btnPlay( bool) ), TRUE ); | 75 | this , SLOT( btnPlay( bool) ), TRUE ); |
76 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 76 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
77 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 77 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
78 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 78 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
79 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 79 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
80 | 80 | ||
81 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 81 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
82 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 82 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
83 | this, SLOT( addAllMusicToList() ) ); | 83 | this, SLOT( addAllMusicToList() ) ); |
84 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
85 | this, SLOT( addAllVideoToList() ) ); | 85 | this, SLOT( addAllVideoToList() ) ); |
86 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 86 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
87 | this, SLOT( addAllToList() ) ); | 87 | this, SLOT( addAllToList() ) ); |
88 | pmPlayList->insertSeparator(-1); | 88 | pmPlayList->insertSeparator(-1); |
89 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 89 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
90 | // this, SLOT( saveList() ) ); | 90 | // this, SLOT( saveList() ) ); |
91 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
92 | this, SLOT(writem3u() ) ); | 92 | this, SLOT(writem3u() ) ); |
93 | pmPlayList->insertSeparator(-1); | 93 | pmPlayList->insertSeparator(-1); |
94 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 94 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
95 | this,SLOT( openFile() ) ); | 95 | this,SLOT( openFile() ) ); |
96 | pmPlayList->insertSeparator(-1); | 96 | pmPlayList->insertSeparator(-1); |
97 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 97 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
98 | this,SLOT( scanForAudio() ) ); | 98 | this,SLOT( scanForAudio() ) ); |
99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
100 | this,SLOT( scanForVideo() ) ); | 100 | this,SLOT( scanForVideo() ) ); |
101 | 101 | ||
102 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 102 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
103 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 103 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
104 | 104 | ||
105 | Config cfg( "OpiePlayer" ); | 105 | Config cfg( "OpiePlayer" ); |
106 | bool b= cfg.readBoolEntry("FullScreen", 0); | 106 | bool b= cfg.readBoolEntry("FullScreen", 0); |
107 | mediaPlayerState->setFullscreen( b ); | 107 | mediaPlayerState->setFullscreen( b ); |
108 | pmView->setItemChecked( -16, b ); | 108 | pmView->setItemChecked( -16, b ); |
109 | 109 | ||
110 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 110 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
111 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 111 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
112 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 112 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
113 | d->selectedFiles, SLOT(removeSelected() ) ); | 113 | d->selectedFiles, SLOT(removeSelected() ) ); |
114 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 114 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
115 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 115 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
116 | QVBox *stretch2 = new QVBox( vbox1 ); | 116 | QVBox *stretch2 = new QVBox( vbox1 ); |
117 | 117 | ||
118 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 118 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
119 | SLOT( deletePlaylist() ) ); | 119 | SLOT( deletePlaylist() ) ); |
120 | connect( pmView, SIGNAL( activated( int ) ), | 120 | connect( pmView, SIGNAL( activated( int ) ), |
121 | this, SLOT( pmViewActivated( int ) ) ); | 121 | this, SLOT( pmViewActivated( int ) ) ); |
122 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 122 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
123 | this, SLOT( skinsMenuActivated( int ) ) ); | 123 | this, SLOT( skinsMenuActivated( int ) ) ); |
124 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 124 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
125 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 125 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
126 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 126 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
128 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 128 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
129 | this,SLOT( playIt( QListViewItem *) ) ); | 129 | this,SLOT( playIt( QListViewItem *) ) ); |
130 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 130 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
131 | this, SLOT( addToSelection( QListViewItem *) ) ); | 131 | this, SLOT( addToSelection( QListViewItem *) ) ); |
132 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 132 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
133 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 133 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
134 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 134 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
135 | this,SLOT( playIt( QListViewItem *) ) ); | 135 | this,SLOT( playIt( QListViewItem *) ) ); |
136 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 136 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
137 | this, SLOT( addToSelection( QListViewItem *) ) ); | 137 | this, SLOT( addToSelection( QListViewItem *) ) ); |
138 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 138 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
139 | this, SLOT( loadList( const DocLnk & ) ) ); | 139 | this, SLOT( loadList( const DocLnk & ) ) ); |
140 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 140 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
141 | this, SLOT( tabChanged( QWidget* ) ) ); | 141 | this, SLOT( tabChanged( QWidget* ) ) ); |
142 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 142 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
143 | d->tbPlay, SLOT( setOn( bool ) ) ); | 143 | d->tbPlay, SLOT( setOn( bool ) ) ); |
144 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 144 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
145 | d->tbLoop, SLOT( setOn( bool ) ) ); | 145 | d->tbLoop, SLOT( setOn( bool ) ) ); |
146 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 146 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
147 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 147 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
148 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), | 148 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), |
149 | this, SLOT( setPlaylist( bool ) ) ); | 149 | this, SLOT( setPlaylist( bool ) ) ); |
150 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 150 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
151 | this, SLOT( playIt( QListViewItem *) ) ); | 151 | this, SLOT( playIt( QListViewItem *) ) ); |
152 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 152 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
153 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 153 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
154 | 154 | ||
155 | // see which skins are installed | 155 | // see which skins are installed |
156 | videoScan=FALSE; | 156 | videoScan=FALSE; |
157 | audioScan=FALSE; | 157 | audioScan=FALSE; |
158 | populateSkinsMenu(); | 158 | populateSkinsMenu(); |
159 | initializeStates(); | 159 | initializeStates(); |
160 | 160 | ||
161 | cfg.setGroup("PlayList"); | 161 | cfg.setGroup("PlayList"); |
162 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 162 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
163 | loadList(DocLnk( currentPlaylist ) ); | 163 | loadList(DocLnk( currentPlaylist ) ); |
164 | 164 | ||
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | PlayListWidget::~PlayListWidget() { | 168 | PlayListWidget::~PlayListWidget() { |
169 | if ( d->current ) { | 169 | if ( d->current ) { |
170 | delete d->current; | 170 | delete d->current; |
171 | } | 171 | } |
172 | delete d; | 172 | delete d; |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
176 | void PlayListWidget::initializeStates() { | 176 | void PlayListWidget::initializeStates() { |
177 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 177 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
178 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 178 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
179 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 179 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
180 | setPlaylist( true ); | 180 | setPlaylist( true ); |
181 | } | 181 | } |
182 | 182 | ||
183 | void PlayListWidget::writeDefaultPlaylist() { | 183 | void PlayListWidget::writeDefaultPlaylist() { |
184 | 184 | ||
185 | Config config( "OpiePlayer" ); | 185 | Config config( "OpiePlayer" ); |
186 | config.setGroup( "PlayList" ); | 186 | config.setGroup( "PlayList" ); |
187 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 187 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
188 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 188 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
189 | if( currentString == filename) { | 189 | if( currentString == filename) { |
190 | Om3u *m3uList; | 190 | Om3u *m3uList; |
191 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 191 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
192 | if( d->selectedFiles->first() ) { | 192 | if( d->selectedFiles->first() ) { |
193 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 193 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
194 | do { | 194 | do { |
195 | // qDebug(d->selectedFiles->current()->file()); | 195 | // qDebug(d->selectedFiles->current()->file()); |
196 | m3uList->add( d->selectedFiles->current()->file() ); | 196 | m3uList->add( d->selectedFiles->current()->file() ); |
197 | } | 197 | } |
198 | while ( d->selectedFiles->next() ); | 198 | while ( d->selectedFiles->next() ); |
199 | 199 | ||
200 | m3uList->write(); | 200 | m3uList->write(); |
201 | m3uList->close(); | 201 | m3uList->close(); |
202 | if(m3uList) delete m3uList; | 202 | if(m3uList) delete m3uList; |
203 | 203 | ||
204 | } | 204 | } |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 208 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
209 | d->setDocumentUsed = FALSE; | 209 | d->setDocumentUsed = FALSE; |
210 | if ( mediaPlayerState->playlist() ) { | 210 | if ( mediaPlayerState->playlist() ) { |
211 | if( QFileInfo( lnk.file() ).exists() || | 211 | if( QFileInfo( lnk.file() ).exists() || |
212 | lnk.file().left(4) == "http" ) | 212 | lnk.file().left(4) == "http" ) |
213 | d->selectedFiles->addToSelection( lnk ); | 213 | d->selectedFiles->addToSelection( lnk ); |
214 | // writeCurrentM3u(); | 214 | // writeCurrentM3u(); |
215 | } | 215 | } |
216 | else | 216 | else |
217 | mediaPlayerState->setPlaying( TRUE ); | 217 | mediaPlayerState->setPlaying( TRUE ); |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | void PlayListWidget::clearList() { | 221 | void PlayListWidget::clearList() { |
222 | while ( first() ) { | 222 | while ( first() ) { |
223 | d->selectedFiles->removeSelected(); | 223 | d->selectedFiles->removeSelected(); |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 227 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
228 | switch (mouse) { | 228 | switch (mouse) { |
229 | case 1: | 229 | case 1: |
230 | break; | 230 | break; |
231 | case 2: | 231 | case 2: |
232 | { | 232 | { |
233 | QPopupMenu m; | 233 | QPopupMenu m; |
234 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 234 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
235 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 235 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
236 | m.exec( QCursor::pos() ); | 236 | m.exec( QCursor::pos() ); |
237 | } | 237 | } |
238 | break; | 238 | break; |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | 242 | ||
243 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 243 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
244 | switch (mouse) { | 244 | switch (mouse) { |
245 | case 1: | 245 | case 1: |
246 | break; | 246 | break; |
247 | case 2: | 247 | case 2: |
248 | { | 248 | { |
249 | QPopupMenu m; | 249 | QPopupMenu m; |
250 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 250 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
251 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 251 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
252 | m.exec( QCursor::pos() ); | 252 | m.exec( QCursor::pos() ); |
253 | } | 253 | } |
254 | break; | 254 | break; |
255 | } | 255 | } |
256 | } | 256 | } |
257 | 257 | ||
258 | 258 | ||
259 | void PlayListWidget::addAllToList() { | 259 | void PlayListWidget::addAllToList() { |
260 | DocLnkSet filesAll; | 260 | DocLnkSet filesAll; |
261 | Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 261 | Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
262 | QListIterator<DocLnk> Adit( filesAll.children() ); | 262 | QListIterator<DocLnk> Adit( filesAll.children() ); |
263 | for ( ; Adit.current(); ++Adit ) { | 263 | for ( ; Adit.current(); ++Adit ) { |
264 | if( QFileInfo( Adit.current()->file() ).exists() ) { | 264 | if( QFileInfo( Adit.current()->file() ).exists() ) { |
265 | d->selectedFiles->addToSelection( **Adit ); | 265 | d->selectedFiles->addToSelection( **Adit ); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | writeCurrentM3u(); | 268 | writeCurrentM3u(); |
269 | } | 269 | } |
270 | 270 | ||
271 | 271 | ||
272 | void PlayListWidget::addAllMusicToList() { | 272 | void PlayListWidget::addAllMusicToList() { |
273 | if(!audioScan) | 273 | if(!audioScan) |
274 | scanForAudio(); | 274 | scanForAudio(); |
275 | QListIterator<DocLnk> dit( files.children() ); | 275 | QListIterator<DocLnk> dit( files.children() ); |
276 | for ( ; dit.current(); ++dit ) { | 276 | for ( ; dit.current(); ++dit ) { |
277 | if( QFileInfo(dit.current()->file() ).exists() ) { | 277 | if( QFileInfo(dit.current()->file() ).exists() ) { |
278 | d->selectedFiles->addToSelection( **dit ); | 278 | d->selectedFiles->addToSelection( **dit ); |
279 | } | 279 | } |
280 | } | 280 | } |
281 | writeCurrentM3u(); | 281 | writeCurrentM3u(); |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | void PlayListWidget::addAllVideoToList() { | 285 | void PlayListWidget::addAllVideoToList() { |
286 | if(!videoScan) | 286 | if(!videoScan) |
287 | scanForVideo(); | 287 | scanForVideo(); |
288 | QListIterator<DocLnk> dit( vFiles.children() ); | 288 | QListIterator<DocLnk> dit( vFiles.children() ); |
289 | for ( ; dit.current(); ++dit ) { | 289 | for ( ; dit.current(); ++dit ) { |
290 | if( QFileInfo( dit.current()->file() ).exists() ) { | 290 | if( QFileInfo( dit.current()->file() ).exists() ) { |
291 | d->selectedFiles->addToSelection( **dit ); | 291 | d->selectedFiles->addToSelection( **dit ); |
292 | } | 292 | } |
293 | } | 293 | } |
294 | writeCurrentM3u(); | 294 | writeCurrentM3u(); |
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | void PlayListWidget::setDocument( const QString& fileref ) { | 298 | void PlayListWidget::setDocument( const QString& fileref ) { |
299 | qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 299 | qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
300 | fromSetDocument = TRUE; | 300 | fromSetDocument = TRUE; |
301 | if ( fileref.isNull() ) { | 301 | if ( fileref.isNull() ) { |
302 | QMessageBox::warning( this, tr( "Invalid File" ), | 302 | QMessageBox::warning( this, tr( "Invalid File" ), |
303 | tr( "There was a problem in getting the file." ) ); | 303 | tr( "There was a problem in getting the file." ) ); |
304 | return; | 304 | return; |
305 | } | 305 | } |
306 | 306 | ||
307 | clearList(); | 307 | clearList(); |
308 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 308 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
309 | readm3u( fileref ); | 309 | readm3u( fileref ); |
310 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 310 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
311 | readm3u( DocLnk( fileref).file() ); | 311 | readm3u( DocLnk( fileref).file() ); |
312 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 312 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
313 | readPls( fileref ); | 313 | readPls( fileref ); |
314 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 314 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
315 | readPls( DocLnk( fileref).file() ); | 315 | readPls( DocLnk( fileref).file() ); |
316 | } else { | 316 | } else { |
317 | clearList(); | 317 | clearList(); |
318 | addToSelection( DocLnk( fileref ) ); | 318 | addToSelection( DocLnk( fileref ) ); |
319 | writeCurrentM3u(); | 319 | writeCurrentM3u(); |
320 | 320 | ||
321 | d->setDocumentUsed = TRUE; | 321 | d->setDocumentUsed = TRUE; |
322 | mediaPlayerState->setPlaying( FALSE ); | 322 | mediaPlayerState->setPlaying( FALSE ); |
323 | mediaPlayerState->setPlaying( TRUE ); | 323 | mediaPlayerState->setPlaying( TRUE ); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | void PlayListWidget::useSelectedDocument() { | 328 | void PlayListWidget::useSelectedDocument() { |
329 | d->setDocumentUsed = FALSE; | 329 | d->setDocumentUsed = FALSE; |
330 | } | 330 | } |
331 | 331 | ||
332 | 332 | ||
333 | const DocLnk *PlayListWidget::current() { // this is fugly | 333 | const DocLnk *PlayListWidget::current() { // this is fugly |
334 | switch ( whichList() ) { | 334 | switch ( whichList() ) { |
335 | case 0: //playlist | 335 | case 0: //playlist |
336 | { | 336 | { |
337 | // qDebug("playlist"); | 337 | // qDebug("playlist"); |
338 | if ( mediaPlayerState->playlist() ) { | 338 | if ( mediaPlayerState->playlist() ) { |
339 | return d->selectedFiles->current(); | 339 | return d->selectedFiles->current(); |
340 | } else if ( d->setDocumentUsed && d->current ) { | 340 | } else if ( d->setDocumentUsed && d->current ) { |
341 | return d->current; | 341 | return d->current; |
342 | } else { | 342 | } else { |
343 | return &(d->files->selectedDocument()); | 343 | return &(d->files->selectedDocument()); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | break; | 346 | break; |
347 | }; | 347 | }; |
348 | return 0; | 348 | return 0; |
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | bool PlayListWidget::prev() { | 352 | bool PlayListWidget::prev() { |
353 | if ( mediaPlayerState->playlist() ) { | 353 | if ( mediaPlayerState->playlist() ) { |
354 | if ( mediaPlayerState->shuffled() ) { | 354 | if ( mediaPlayerState->shuffled() ) { |
355 | const DocLnk *cur = current(); | 355 | const DocLnk *cur = current(); |
356 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 356 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
357 | for ( int i = 0; i < j; i++ ) { | 357 | for ( int i = 0; i < j; i++ ) { |
358 | if ( !d->selectedFiles->next() ) | 358 | if ( !d->selectedFiles->next() ) |
359 | d->selectedFiles->first(); | 359 | d->selectedFiles->first(); |
360 | } | 360 | } |
361 | if ( cur == current() ) | 361 | if ( cur == current() ) |
362 | if ( !d->selectedFiles->next() ) { | 362 | if ( !d->selectedFiles->next() ) { |
363 | d->selectedFiles->first(); | 363 | d->selectedFiles->first(); |
364 | } | 364 | } |
365 | return TRUE; | 365 | return TRUE; |
366 | } else { | 366 | } else { |
367 | if ( !d->selectedFiles->prev() ) { | 367 | if ( !d->selectedFiles->prev() ) { |
368 | if ( mediaPlayerState->looping() ) { | 368 | if ( mediaPlayerState->looping() ) { |
369 | return d->selectedFiles->last(); | 369 | return d->selectedFiles->last(); |
370 | } else { | 370 | } else { |
371 | return FALSE; | 371 | return FALSE; |
372 | } | 372 | } |
373 | } | 373 | } |
374 | return TRUE; | 374 | return TRUE; |
375 | } | 375 | } |
376 | } else { | 376 | } else { |
377 | return mediaPlayerState->looping(); | 377 | return mediaPlayerState->looping(); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | 381 | ||
382 | bool PlayListWidget::next() { | 382 | bool PlayListWidget::next() { |
383 | //qDebug("<<<<<<<<<<<<next()"); | 383 | //qDebug("<<<<<<<<<<<<next()"); |
384 | if ( mediaPlayerState->playlist() ) { | 384 | if ( mediaPlayerState->playlist() ) { |
385 | if ( mediaPlayerState->shuffled() ) { | 385 | if ( mediaPlayerState->shuffled() ) { |
386 | return prev(); | 386 | return prev(); |
387 | } else { | 387 | } else { |
388 | if ( !d->selectedFiles->next() ) { | 388 | if ( !d->selectedFiles->next() ) { |
389 | if ( mediaPlayerState->looping() ) { | 389 | if ( mediaPlayerState->looping() ) { |
390 | return d->selectedFiles->first(); | 390 | return d->selectedFiles->first(); |
391 | } else { | 391 | } else { |
392 | return FALSE; | 392 | return FALSE; |
393 | } | 393 | } |
394 | } | 394 | } |
395 | return TRUE; | 395 | return TRUE; |
396 | } | 396 | } |
397 | } else { | 397 | } else { |
398 | return mediaPlayerState->looping(); | 398 | return mediaPlayerState->looping(); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
402 | 402 | ||
403 | bool PlayListWidget::first() { | 403 | bool PlayListWidget::first() { |
404 | if ( mediaPlayerState->playlist() ) | 404 | if ( mediaPlayerState->playlist() ) |
405 | return d->selectedFiles->first(); | 405 | return d->selectedFiles->first(); |
406 | else | 406 | else |
407 | return mediaPlayerState->looping(); | 407 | return mediaPlayerState->looping(); |
408 | } | 408 | } |
409 | 409 | ||
410 | 410 | ||
411 | bool PlayListWidget::last() { | 411 | bool PlayListWidget::last() { |
412 | if ( mediaPlayerState->playlist() ) | 412 | if ( mediaPlayerState->playlist() ) |
413 | return d->selectedFiles->last(); | 413 | return d->selectedFiles->last(); |
414 | else | 414 | else |
415 | return mediaPlayerState->looping(); | 415 | return mediaPlayerState->looping(); |
416 | } | 416 | } |
417 | 417 | ||
418 | 418 | ||
419 | void PlayListWidget::saveList() { | 419 | void PlayListWidget::saveList() { |
420 | writem3u(); | 420 | writem3u(); |
421 | } | 421 | } |
422 | 422 | ||
423 | 423 | ||
424 | void PlayListWidget::loadList( const DocLnk & lnk) { | 424 | void PlayListWidget::loadList( const DocLnk & lnk) { |
425 | QString name = lnk.name(); | 425 | QString name = lnk.name(); |
426 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 426 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
427 | 427 | ||
428 | if( name.length()>0) { | 428 | if( name.length()>0) { |
429 | setCaption("OpiePlayer: "+name); | 429 | setCaption("OpiePlayer: "+name); |
430 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 430 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
431 | clearList(); | 431 | clearList(); |
432 | readm3u(lnk.file()); | 432 | readm3u(lnk.file()); |
433 | tabWidget->setCurrentPage(0); | 433 | tabWidget->setCurrentPage(0); |
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
437 | 437 | ||
438 | void PlayListWidget::setPlaylist( bool shown ) { | 438 | void PlayListWidget::setPlaylist( bool shown ) { |
439 | if ( shown ) { | 439 | if ( shown ) { |
440 | d->playListFrame->show(); | 440 | d->playListFrame->show(); |
441 | } else { | 441 | } else { |
442 | d->playListFrame->hide(); | 442 | d->playListFrame->hide(); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | void PlayListWidget::addSelected() { | 447 | void PlayListWidget::addSelected() { |
448 | qDebug("addSelected"); | 448 | qDebug("addSelected"); |
449 | switch (whichList()) { | 449 | switch (whichList()) { |
450 | case 0: //playlist | 450 | case 0: //playlist |
451 | break; | 451 | break; |
452 | case 1: { //audio | 452 | case 1: { //audio |
453 | QListViewItemIterator it( audioView ); | 453 | QListViewItemIterator it( audioView ); |
454 | // iterate through all items of the listview | 454 | // iterate through all items of the listview |
455 | for ( ; it.current(); ++it ) { | 455 | for ( ; it.current(); ++it ) { |
456 | if ( it.current()->isSelected() ) { | 456 | if ( it.current()->isSelected() ) { |
457 | QListIterator<DocLnk> dit( files.children() ); | 457 | QListIterator<DocLnk> dit( files.children() ); |
458 | for ( ; dit.current(); ++dit ) { | 458 | for ( ; dit.current(); ++dit ) { |
459 | if( dit.current()->name() == it.current()->text(0) ) { | 459 | if( dit.current()->name() == it.current()->text(0) ) { |
460 | if( QFileInfo( dit.current()->file()).exists()) { | 460 | if( QFileInfo( dit.current()->file()).exists()) { |
461 | d->selectedFiles->addToSelection( **dit ); | 461 | d->selectedFiles->addToSelection( **dit ); |
462 | audioView->setSelected( it.current(),FALSE); | 462 | audioView->setSelected( it.current(),FALSE); |
463 | } | 463 | } |
464 | } | 464 | } |
465 | } | 465 | } |
466 | } | 466 | } |
467 | } | 467 | } |
468 | // tabWidget->setCurrentPage(0); | 468 | // tabWidget->setCurrentPage(0); |
469 | writeCurrentM3u(); | 469 | writeCurrentM3u(); |
470 | d->selectedFiles->next(); | 470 | d->selectedFiles->next(); |
471 | } | 471 | } |
472 | break; | 472 | break; |
473 | case 2: { // video | 473 | case 2: { // video |
474 | QListViewItemIterator it( videoView ); | 474 | QListViewItemIterator it( videoView ); |
475 | // iterate through all items of the listview | 475 | // iterate through all items of the listview |
476 | for ( ; it.current(); ++it ) { | 476 | for ( ; it.current(); ++it ) { |
477 | if ( it.current()->isSelected() ) { | 477 | if ( it.current()->isSelected() ) { |
478 | QListIterator<DocLnk> dit( vFiles.children() ); | 478 | QListIterator<DocLnk> dit( vFiles.children() ); |
479 | for ( ; dit.current(); ++dit ) { | 479 | for ( ; dit.current(); ++dit ) { |
480 | if( dit.current()->name() == it.current()->text(0) ) { | 480 | if( dit.current()->name() == it.current()->text(0) ) { |
481 | if(QFileInfo( dit.current()->file()).exists()) { | 481 | if(QFileInfo( dit.current()->file()).exists()) { |
482 | d->selectedFiles->addToSelection( **dit ); | 482 | d->selectedFiles->addToSelection( **dit ); |
483 | videoView->setSelected( it.current(),FALSE); | 483 | videoView->setSelected( it.current(),FALSE); |
484 | } | 484 | } |
485 | } | 485 | } |
486 | } | 486 | } |
487 | } | 487 | } |
488 | } | 488 | } |
489 | // tabWidget->setCurrentPage(0); | 489 | // tabWidget->setCurrentPage(0); |
490 | writeCurrentM3u(); | 490 | writeCurrentM3u(); |
491 | 491 | ||
492 | } | 492 | } |
493 | break; | 493 | break; |
494 | }; | 494 | }; |
495 | } | 495 | } |
496 | 496 | ||
497 | 497 | ||
498 | void PlayListWidget::removeSelected() { | 498 | void PlayListWidget::removeSelected() { |
499 | d->selectedFiles->removeSelected( ); | 499 | d->selectedFiles->removeSelected( ); |
500 | writeCurrentM3u(); | 500 | writeCurrentM3u(); |
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | void PlayListWidget::playIt( QListViewItem *it) { | 504 | void PlayListWidget::playIt( QListViewItem *it) { |
505 | if(!it) return; | 505 | if(!it) return; |
506 | mediaPlayerState->setPlaying(FALSE); | 506 | mediaPlayerState->setPlaying(FALSE); |
507 | mediaPlayerState->setPlaying(TRUE); | 507 | mediaPlayerState->setPlaying(TRUE); |
508 | d->selectedFiles->unSelect(); | 508 | d->selectedFiles->unSelect(); |
509 | } | 509 | } |
510 | 510 | ||
511 | 511 | ||
512 | void PlayListWidget::addToSelection( QListViewItem *it) { | 512 | void PlayListWidget::addToSelection( QListViewItem *it) { |
513 | d->setDocumentUsed = FALSE; | 513 | d->setDocumentUsed = FALSE; |
514 | 514 | ||
515 | if(it) { | 515 | if(it) { |
516 | switch ( whichList()) { | 516 | switch ( whichList()) { |
517 | case 1: { | 517 | case 1: { |
518 | QListIterator<DocLnk> dit( files.children() ); | 518 | QListIterator<DocLnk> dit( files.children() ); |
519 | for ( ; dit.current(); ++dit ) { | 519 | for ( ; dit.current(); ++dit ) { |
520 | if( dit.current()->name() == it->text(0)) { | 520 | if( dit.current()->name() == it->text(0)) { |
521 | if(QFileInfo( dit.current()->file()).exists()) { | 521 | if(QFileInfo( dit.current()->file()).exists()) { |
522 | d->selectedFiles->addToSelection( **dit ); | 522 | d->selectedFiles->addToSelection( **dit ); |
523 | // qDebug("blah "+ dit.current()->name()); | 523 | // qDebug("blah "+ dit.current()->name()); |
524 | // d->selectedFiles->setSelectedItem( dit.current()->name()); | 524 | // d->selectedFiles->setSelectedItem( dit.current()->name()); |
525 | } | 525 | } |
526 | } | 526 | } |
527 | } | 527 | } |
528 | writeCurrentM3u(); | 528 | writeCurrentM3u(); |
529 | } | 529 | } |
530 | break; | 530 | break; |
531 | case 2: { | 531 | case 2: { |
532 | QListIterator<DocLnk> dit( vFiles.children() ); | 532 | QListIterator<DocLnk> dit( vFiles.children() ); |
533 | for ( ; dit.current(); ++dit ) { | 533 | for ( ; dit.current(); ++dit ) { |
534 | if( dit.current()->name() == it->text(0)) { | 534 | if( dit.current()->name() == it->text(0)) { |
535 | if( QFileInfo( dit.current()->file()).exists() ) { | 535 | if( QFileInfo( dit.current()->file()).exists() ) { |
536 | d->selectedFiles->addToSelection( **dit ); | 536 | d->selectedFiles->addToSelection( **dit ); |
537 | // qDebug("blah "+ dit.current()->name()); | 537 | // qDebug("blah "+ dit.current()->name()); |
538 | // d->selectedFiles->setSelectedItem( dit.current()->name()); | 538 | // d->selectedFiles->setSelectedItem( dit.current()->name()); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | } | 541 | } |
542 | writeCurrentM3u(); | 542 | writeCurrentM3u(); |
543 | 543 | ||
544 | } | 544 | } |
545 | break; | 545 | break; |
546 | case 0: | 546 | case 0: |
547 | break; | 547 | break; |
548 | }; | 548 | }; |
549 | tabWidget->setCurrentPage(0); | 549 | tabWidget->setCurrentPage(0); |
550 | 550 | ||
551 | } | 551 | } |
552 | } | 552 | } |
553 | 553 | ||
554 | 554 | ||
555 | void PlayListWidget::tabChanged(QWidget *) { | 555 | void PlayListWidget::tabChanged(QWidget *) { |
556 | 556 | ||
557 | switch ( whichList()) { | 557 | switch ( whichList()) { |
558 | case 0: | 558 | case 0: |
559 | { | 559 | { |
560 | if( !tbDeletePlaylist->isHidden() ) { | 560 | if( !tbDeletePlaylist->isHidden() ) { |
561 | tbDeletePlaylist->hide(); | 561 | tbDeletePlaylist->hide(); |
562 | } | 562 | } |
563 | d->tbRemoveFromList->setEnabled(TRUE); | 563 | d->tbRemoveFromList->setEnabled(TRUE); |
564 | d->tbAddToList->setEnabled(FALSE); | 564 | d->tbAddToList->setEnabled(FALSE); |
565 | } | 565 | } |
566 | break; | 566 | break; |
567 | case 1: | 567 | case 1: |
568 | { | 568 | { |
569 | audioView->clear(); | 569 | audioView->clear(); |
570 | populateAudioView(); | 570 | populateAudioView(); |
571 | 571 | ||
572 | if( !tbDeletePlaylist->isHidden() ) { | 572 | if( !tbDeletePlaylist->isHidden() ) { |
573 | tbDeletePlaylist->hide(); | 573 | tbDeletePlaylist->hide(); |
574 | } | 574 | } |
575 | d->tbRemoveFromList->setEnabled(FALSE); | 575 | d->tbRemoveFromList->setEnabled(FALSE); |
576 | d->tbAddToList->setEnabled(TRUE); | 576 | d->tbAddToList->setEnabled(TRUE); |
577 | } | 577 | } |
578 | break; | 578 | break; |
579 | case 2: | 579 | case 2: |
580 | { | 580 | { |
581 | videoView->clear(); | 581 | videoView->clear(); |
582 | populateVideoView(); | 582 | populateVideoView(); |
583 | if( !tbDeletePlaylist->isHidden() ) { | 583 | if( !tbDeletePlaylist->isHidden() ) { |
584 | tbDeletePlaylist->hide(); | 584 | tbDeletePlaylist->hide(); |
585 | } | 585 | } |
586 | d->tbRemoveFromList->setEnabled(FALSE); | 586 | d->tbRemoveFromList->setEnabled(FALSE); |
587 | d->tbAddToList->setEnabled(TRUE); | 587 | d->tbAddToList->setEnabled(TRUE); |
588 | } | 588 | } |
589 | break; | 589 | break; |
590 | case 3: | 590 | case 3: |
591 | { | 591 | { |
592 | if( tbDeletePlaylist->isHidden() ) { | 592 | if( tbDeletePlaylist->isHidden() ) { |
593 | tbDeletePlaylist->show(); | 593 | tbDeletePlaylist->show(); |
594 | } | 594 | } |
595 | playLists->reread(); | 595 | playLists->reread(); |
596 | } | 596 | } |
597 | break; | 597 | break; |
598 | }; | 598 | }; |
599 | } | 599 | } |
600 | 600 | ||
601 | 601 | ||
602 | void PlayListWidget::btnPlay(bool b) { | 602 | void PlayListWidget::btnPlay(bool b) { |
603 | // mediaPlayerState->setPlaying(false); | 603 | // mediaPlayerState->setPlaying(false); |
604 | mediaPlayerState->setPlaying(b); | 604 | mediaPlayerState->setPlaying(b); |
605 | insanityBool=FALSE; | 605 | insanityBool=FALSE; |
606 | } | 606 | } |
607 | 607 | ||
608 | void PlayListWidget::deletePlaylist() { | 608 | void PlayListWidget::deletePlaylist() { |
609 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 609 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
610 | (tr("You really want to delete\nthis playlist?")), | 610 | (tr("You really want to delete\nthis playlist?")), |
611 | (tr("Yes")), (tr("No")), 0 )){ | 611 | (tr("Yes")), (tr("No")), 0 )){ |
612 | case 0: // Yes clicked, | 612 | case 0: // Yes clicked, |
613 | QFile().remove(playLists->selectedDocument().file()); | 613 | QFile().remove(playLists->selectedDocument().file()); |
614 | QFile().remove(playLists->selectedDocument().linkFile()); | 614 | QFile().remove(playLists->selectedDocument().linkFile()); |
615 | playLists->reread(); | 615 | playLists->reread(); |
616 | break; | 616 | break; |
617 | case 1: // Cancel | 617 | case 1: // Cancel |
618 | break; | 618 | break; |
619 | }; | 619 | }; |
620 | } | 620 | } |
621 | 621 | ||
622 | 622 | ||
623 | void PlayListWidget::playSelected() { | 623 | void PlayListWidget::playSelected() { |
624 | btnPlay( TRUE); | 624 | btnPlay( TRUE); |
625 | } | 625 | } |
626 | 626 | ||
627 | 627 | ||
628 | void PlayListWidget::scanForAudio() { | 628 | void PlayListWidget::scanForAudio() { |
629 | // qDebug("scan for audio"); | 629 | // qDebug("scan for audio"); |
630 | files.detachChildren(); | 630 | files.detachChildren(); |
631 | QListIterator<DocLnk> sdit( files.children() ); | 631 | QListIterator<DocLnk> sdit( files.children() ); |
632 | for ( ; sdit.current(); ++sdit ) { | 632 | for ( ; sdit.current(); ++sdit ) { |
633 | delete sdit.current(); | 633 | delete sdit.current(); |
634 | } | 634 | } |
635 | // Global::findDocuments( &files, "audio/*"); | 635 | // Global::findDocuments( &files, "audio/*"); |
636 | Global::findDocuments( &files, audioMimes); | 636 | Global::findDocuments( &files, audioMimes); |
637 | audioScan = TRUE; | 637 | audioScan = TRUE; |
638 | } | 638 | } |
639 | 639 | ||
640 | void PlayListWidget::scanForVideo() { | 640 | void PlayListWidget::scanForVideo() { |
641 | // qDebug("scan for video"); | 641 | // qDebug("scan for video"); |
642 | vFiles.detachChildren(); | 642 | vFiles.detachChildren(); |
643 | QListIterator<DocLnk> sdit( vFiles.children() ); | 643 | QListIterator<DocLnk> sdit( vFiles.children() ); |
644 | for ( ; sdit.current(); ++sdit ) { | 644 | for ( ; sdit.current(); ++sdit ) { |
645 | delete sdit.current(); | 645 | delete sdit.current(); |
646 | } | 646 | } |
647 | Global::findDocuments(&vFiles, "video/*"); | 647 | Global::findDocuments(&vFiles, "video/*"); |
648 | videoScan = TRUE; | 648 | videoScan = TRUE; |
649 | } | 649 | } |
650 | 650 | ||
651 | void PlayListWidget::populateAudioView() { | 651 | void PlayListWidget::populateAudioView() { |
652 | audioView->clear(); | 652 | audioView->clear(); |
653 | StorageInfo storageInfo; | 653 | StorageInfo storageInfo; |
654 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 654 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
655 | if(!audioScan) { | 655 | if(!audioScan) { |
656 | scanForAudio(); | 656 | scanForAudio(); |
657 | } | 657 | } |
658 | 658 | ||
659 | QListIterator<DocLnk> dit( files.children() ); | 659 | QListIterator<DocLnk> dit( files.children() ); |
660 | QListIterator<FileSystem> it ( fs ); | 660 | QListIterator<FileSystem> it ( fs ); |
661 | 661 | ||
662 | QString storage; | 662 | QString storage; |
663 | for ( ; dit.current(); ++dit ) { | 663 | for ( ; dit.current(); ++dit ) { |
664 | for( ; it.current(); ++it ){ | 664 | for( ; it.current(); ++it ){ |
665 | const QString name = (*it)->name(); | 665 | const QString name = (*it)->name(); |
666 | const QString path = (*it)->path(); | 666 | const QString path = (*it)->path(); |
667 | if(dit.current()->file().find(path) != -1 ) { | 667 | if(dit.current()->file().find(path) != -1 ) { |
668 | storage = name; | 668 | storage = name; |
669 | } | 669 | } |
670 | } | 670 | } |
671 | 671 | ||
672 | QListViewItem * newItem; | 672 | QListViewItem * newItem; |
673 | if ( QFile( dit.current()->file()).exists() || | 673 | if ( QFile( dit.current()->file()).exists() || |
674 | dit.current()->file().left(4) == "http" ) { | 674 | dit.current()->file().left(4) == "http" ) { |
675 | long size; | 675 | long size; |
676 | if( dit.current()->file().left(4) == "http" ) | 676 | if( dit.current()->file().left(4) == "http" ) |
677 | size=0; | 677 | size=0; |
678 | else | 678 | else |
679 | size = QFile( dit.current()->file() ).size(); | 679 | size = QFile( dit.current()->file() ).size(); |
680 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 680 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
681 | QString::number(size ), storage, dit.current()->file()); | 681 | QString::number(size ), storage, dit.current()->file()); |
682 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 682 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
683 | } | 683 | } |
684 | } | 684 | } |
685 | } | 685 | } |
686 | 686 | ||
687 | 687 | ||
688 | void PlayListWidget::populateVideoView() { | 688 | void PlayListWidget::populateVideoView() { |
689 | videoView->clear(); | 689 | videoView->clear(); |
690 | StorageInfo storageInfo; | 690 | StorageInfo storageInfo; |
691 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 691 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
692 | 692 | ||
693 | if(!videoScan ) { | 693 | if(!videoScan ) { |
694 | scanForVideo(); | 694 | scanForVideo(); |
695 | } | 695 | } |
696 | 696 | ||
697 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 697 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
698 | QListIterator<FileSystem> it ( fs ); | 698 | QListIterator<FileSystem> it ( fs ); |
699 | videoView->clear(); | 699 | videoView->clear(); |
700 | QString storage, pathName; | 700 | QString storage, pathName; |
701 | for ( ; Vdit.current(); ++Vdit ) { | 701 | for ( ; Vdit.current(); ++Vdit ) { |
702 | for( ; it.current(); ++it ) { | 702 | for( ; it.current(); ++it ) { |
703 | const QString name = (*it)->name(); | 703 | const QString name = (*it)->name(); |
704 | const QString path = (*it)->path(); | 704 | const QString path = (*it)->path(); |
705 | if( Vdit.current()->file().find(path) != -1 ) { | 705 | if( Vdit.current()->file().find(path) != -1 ) { |
706 | storage=name; | 706 | storage=name; |
707 | pathName=path; | 707 | pathName=path; |
708 | } | 708 | } |
709 | } | 709 | } |
710 | 710 | ||
711 | QListViewItem * newItem; | 711 | QListViewItem * newItem; |
712 | if ( QFile( Vdit.current()->file() ).exists() ) { | 712 | if ( QFile( Vdit.current()->file() ).exists() ) { |
713 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 713 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
714 | QString::number( QFile( Vdit.current()->file() ).size() ), | 714 | QString::number( QFile( Vdit.current()->file() ).size() ), |
715 | storage, Vdit.current()->file()); | 715 | storage, Vdit.current()->file()); |
716 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 716 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
717 | } | 717 | } |
718 | } | 718 | } |
719 | } | 719 | } |
720 | 720 | ||
721 | 721 | ||
722 | void PlayListWidget::openFile() { | 722 | void PlayListWidget::openFile() { |
723 | // http://66.28.164.33:2080 | 723 | // http://66.28.164.33:2080 |
724 | // http://somafm.com/star0242.m3u | 724 | // http://somafm.com/star0242.m3u |
725 | QString filename, name; | 725 | QString filename, name; |
726 | InputDialog *fileDlg; | 726 | InputDialog *fileDlg; |
727 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 727 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
728 | fileDlg->exec(); | 728 | fileDlg->exec(); |
729 | if( fileDlg->result() == 1 ) { | 729 | if( fileDlg->result() == 1 ) { |
730 | filename = fileDlg->text(); | 730 | filename = fileDlg->text(); |
731 | qDebug( "Selected filename is " + filename ); | 731 | qDebug( "Selected filename is " + filename ); |
732 | Om3u *m3uList; | 732 | Om3u *m3uList; |
733 | DocLnk lnk; | 733 | DocLnk lnk; |
734 | Config cfg( "OpiePlayer" ); | 734 | Config cfg( "OpiePlayer" ); |
735 | cfg.setGroup("PlayList"); | 735 | cfg.setGroup("PlayList"); |
736 | 736 | ||
737 | if(filename.left(4) == "http") { | 737 | if(filename.left(4) == "http") { |
738 | QString m3uFile, m3uFilePath; | 738 | QString m3uFile, m3uFilePath; |
739 | if(filename.find(":",8,TRUE) != -1) { //found a port | 739 | if(filename.find(":",8,TRUE) != -1) { //found a port |
740 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 740 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
741 | m3uFile = m3uFile.right( 7); | 741 | m3uFile = m3uFile.right( 7); |
742 | } else if(filename.left(4) == "http"){ | 742 | } else if(filename.left(4) == "http"){ |
743 | m3uFile=filename; | 743 | m3uFile=filename; |
744 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 744 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
745 | } else{ | 745 | } else{ |
746 | m3uFile=filename; | 746 | m3uFile=filename; |
747 | } | 747 | } |
748 | 748 | ||
749 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 749 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
750 | lnk.setName( filename ); //sets name | 750 | lnk.setName( filename ); //sets name |
751 | lnk.setFile( filename ); //sets file name | 751 | lnk.setFile( filename ); //sets file name |
752 | 752 | ||
753 | // lnk.setIcon("opieplayer2/musicfile"); | 753 | // lnk.setIcon("opieplayer2/musicfile"); |
754 | 754 | ||
755 | d->selectedFiles->addToSelection( lnk ); | 755 | d->selectedFiles->addToSelection( lnk ); |
756 | writeCurrentM3u(); | 756 | writeCurrentM3u(); |
757 | d->selectedFiles->setSelectedItem( lnk.name()); | 757 | d->selectedFiles->setSelectedItem( lnk.name()); |
758 | } | 758 | } |
759 | else if( filename.right( 3) == "m3u" ) { | 759 | else if( filename.right( 3) == "m3u" ) { |
760 | readm3u( filename ); | 760 | readm3u( filename ); |
761 | 761 | ||
762 | } else if( filename.right(3) == "pls" ) { | 762 | } else if( filename.right(3) == "pls" ) { |
763 | readPls( filename ); | 763 | readPls( filename ); |
764 | } else { | 764 | } else { |
765 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 765 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
766 | lnk.setFile( filename ); //sets file name | 766 | lnk.setFile( filename ); //sets file name |
767 | d->selectedFiles->addToSelection( lnk); | 767 | d->selectedFiles->addToSelection( lnk); |
768 | writeCurrentM3u(); | 768 | writeCurrentM3u(); |
769 | d->selectedFiles->setSelectedItem( lnk.name()); | 769 | d->selectedFiles->setSelectedItem( lnk.name()); |
770 | } | 770 | } |
771 | } | 771 | } |
772 | 772 | ||
773 | if( fileDlg ) { | 773 | if( fileDlg ) { |
774 | delete fileDlg; | 774 | delete fileDlg; |
775 | } | 775 | } |
776 | } | 776 | } |
777 | 777 | ||
778 | /* | 778 | /* |
779 | reads m3u and shows files/urls to playlist widget */ | 779 | reads m3u and shows files/urls to playlist widget */ |
780 | void PlayListWidget::readm3u( const QString &filename ) { | 780 | void PlayListWidget::readm3u( const QString &filename ) { |
781 | qDebug( "read m3u filename " + filename ); | 781 | qDebug( "read m3u filename " + filename ); |
782 | 782 | ||
783 | Om3u *m3uList; | 783 | Om3u *m3uList; |
784 | QString s, name; | 784 | QString s, name; |
785 | m3uList = new Om3u( filename, IO_ReadOnly ); | 785 | m3uList = new Om3u( filename, IO_ReadOnly ); |
786 | m3uList->readM3u(); | 786 | m3uList->readM3u(); |
787 | DocLnk lnk; | 787 | DocLnk lnk; |
788 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 788 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
789 | s = *it; | 789 | s = *it; |
790 | // qDebug("reading "+ s); | 790 | // qDebug("reading "+ s); |
791 | if(s.left(4)=="http") { | 791 | if(s.left(4)=="http") { |
792 | lnk.setName( s ); //sets file name | 792 | lnk.setName( s ); //sets file name |
793 | lnk.setIcon("opieplayer2/musicfile"); | 793 | lnk.setIcon("opieplayer2/musicfile"); |
794 | // if(s.right(4) != '.' || s.right(5) != '.') | 794 | lnk.setFile( s ); //sets file name |
795 | // lnk.setFile( s+"/"); //if url with no extension | ||
796 | // else | ||
797 | lnk.setFile( s ); //sets file name | ||
798 | 795 | ||
799 | } else { | 796 | } else { |
800 | // if( QFileInfo( s ).exists() ) { | 797 | // if( QFileInfo( s ).exists() ) { |
801 | lnk.setName( QFileInfo(s).baseName()); | 798 | lnk.setName( QFileInfo(s).baseName()); |
802 | // if(s.right(4) == '.') {//if regular file | 799 | // if(s.right(4) == '.') {//if regular file |
803 | if(s.left(1) != "/") { | 800 | if(s.left(1) != "/") { |
804 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 801 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
805 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 802 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
806 | // lnk.setIcon(MimeType(s).pixmap() ); | 803 | // lnk.setIcon(MimeType(s).pixmap() ); |
807 | // lnk.setIcon("SoundPlayer"); | 804 | // lnk.setIcon("SoundPlayer"); |
808 | } else { | 805 | } else { |
809 | // qDebug("set link2 "+s); | 806 | // qDebug("set link2 "+s); |
810 | lnk.setFile( s); | 807 | lnk.setFile( s); |
811 | // lnk.setIcon(MimeType(s).pixmap() ); | 808 | // lnk.setIcon(MimeType(s).pixmap() ); |
812 | // lnk.setIcon("SoundPlayer"); | 809 | // lnk.setIcon("SoundPlayer"); |
813 | } | 810 | } |
814 | } | 811 | } |
815 | d->selectedFiles->addToSelection( lnk ); | 812 | d->selectedFiles->addToSelection( lnk ); |
816 | } | 813 | } |
817 | Config config( "OpiePlayer" ); | 814 | Config config( "OpiePlayer" ); |
818 | config.setGroup( "PlayList" ); | 815 | config.setGroup( "PlayList" ); |
819 | 816 | ||
820 | config.writeEntry("CurrentPlaylist",filename); | 817 | config.writeEntry("CurrentPlaylist",filename); |
821 | config.write(); | 818 | config.write(); |
822 | currentPlayList=filename; | 819 | currentPlayList=filename; |
823 | 820 | ||
824 | // m3uList->write(); | 821 | // m3uList->write(); |
825 | m3uList->close(); | 822 | m3uList->close(); |
826 | if(m3uList) delete m3uList; | 823 | if(m3uList) delete m3uList; |
827 | 824 | ||
828 | d->selectedFiles->setSelectedItem( s); | 825 | d->selectedFiles->setSelectedItem( s); |
829 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 826 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
830 | 827 | ||
831 | } | 828 | } |
832 | 829 | ||
833 | /* | 830 | /* |
834 | reads pls and adds files/urls to playlist */ | 831 | reads pls and adds files/urls to playlist */ |
835 | void PlayListWidget::readPls( const QString &filename ) { | 832 | void PlayListWidget::readPls( const QString &filename ) { |
836 | 833 | ||
837 | qDebug( "pls filename is " + filename ); | 834 | qDebug( "pls filename is " + filename ); |
838 | Om3u *m3uList; | 835 | Om3u *m3uList; |
839 | QString s, name; | 836 | QString s, name; |
840 | m3uList = new Om3u( filename, IO_ReadOnly ); | 837 | m3uList = new Om3u( filename, IO_ReadOnly ); |
841 | m3uList->readPls(); | 838 | m3uList->readPls(); |
842 | 839 | ||
843 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 840 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
844 | s = *it; | 841 | s = *it; |
845 | // s.replace( QRegExp( "%20" )," " ); | 842 | // s.replace( QRegExp( "%20" )," " ); |
846 | DocLnk lnk( s ); | 843 | DocLnk lnk( s ); |
847 | QFileInfo f( s ); | 844 | QFileInfo f( s ); |
848 | QString name = f.baseName(); | 845 | QString name = f.baseName(); |
849 | 846 | ||
850 | if( name.left( 4 ) == "http" ) { | 847 | if( name.left( 4 ) == "http" ) { |
851 | name = s.right( s.length() - 7); | 848 | name = s.right( s.length() - 7); |
852 | } else { | 849 | } else { |
853 | name = s; | 850 | name = s; |
854 | } | 851 | } |
855 | 852 | ||
856 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 853 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
857 | 854 | ||
858 | lnk.setName( name ); | 855 | lnk.setName( name ); |
859 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 856 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
860 | lnk.setFile( s ); | 857 | lnk.setFile( s ); |
861 | } else { //if its a url | 858 | } else { //if its a url |
862 | // if( name.right( 1 ).find( '/' ) == -1) { | 859 | // if( name.right( 1 ).find( '/' ) == -1) { |
863 | // s += "/"; | 860 | // s += "/"; |
864 | // } | 861 | // } |
865 | lnk.setFile( s ); | 862 | lnk.setFile( s ); |
866 | } | 863 | } |
867 | lnk.setType( "audio/x-mpegurl" ); | 864 | lnk.setType( "audio/x-mpegurl" ); |
868 | 865 | ||
869 | lnk.writeLink(); | 866 | lnk.writeLink(); |
870 | d->selectedFiles->addToSelection( lnk ); | 867 | d->selectedFiles->addToSelection( lnk ); |
871 | } | 868 | } |
872 | 869 | ||
873 | m3uList->close(); | 870 | m3uList->close(); |
874 | if(m3uList) delete m3uList; | 871 | if(m3uList) delete m3uList; |
875 | } | 872 | } |
876 | 873 | ||
877 | /* | 874 | /* |
878 | writes current playlist to current m3u file */ | 875 | writes current playlist to current m3u file */ |
879 | void PlayListWidget::writeCurrentM3u() { | 876 | void PlayListWidget::writeCurrentM3u() { |
880 | qDebug("writing to current m3u"); | 877 | qDebug("writing to current m3u"); |
881 | Config cfg( "OpiePlayer" ); | 878 | Config cfg( "OpiePlayer" ); |
882 | cfg.setGroup("PlayList"); | 879 | cfg.setGroup("PlayList"); |
883 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 880 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
884 | 881 | ||
885 | Om3u *m3uList; | 882 | Om3u *m3uList; |
886 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 883 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
887 | if( d->selectedFiles->first()) { | 884 | if( d->selectedFiles->first()) { |
888 | 885 | ||
889 | do { | 886 | do { |
890 | qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 887 | qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
891 | m3uList->add( d->selectedFiles->current()->file() ); | 888 | m3uList->add( d->selectedFiles->current()->file() ); |
892 | } | 889 | } |
893 | while ( d->selectedFiles->next() ); | 890 | while ( d->selectedFiles->next() ); |
894 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 891 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
895 | m3uList->write(); | 892 | m3uList->write(); |
896 | m3uList->close(); | 893 | m3uList->close(); |
897 | 894 | ||
898 | if(m3uList) delete m3uList; | 895 | if(m3uList) delete m3uList; |
899 | } | 896 | } |
900 | 897 | ||
901 | } | 898 | } |
902 | 899 | ||
903 | /* | 900 | /* |
904 | writes current playlist to m3u file */ | 901 | writes current playlist to m3u file */ |
905 | void PlayListWidget::writem3u() { | 902 | void PlayListWidget::writem3u() { |
906 | InputDialog *fileDlg; | 903 | InputDialog *fileDlg; |
907 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 904 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
908 | fileDlg->exec(); | 905 | fileDlg->exec(); |
909 | QString name, filename, list; | 906 | QString name, filename, list; |
910 | Om3u *m3uList; | 907 | Om3u *m3uList; |
911 | 908 | ||
912 | if( fileDlg->result() == 1 ) { | 909 | if( fileDlg->result() == 1 ) { |
913 | name = fileDlg->text(); | 910 | name = fileDlg->text(); |
914 | // qDebug( filename ); | 911 | // qDebug( filename ); |
915 | 912 | ||
916 | if( name.left( 1) != "/" ) { | 913 | if( name.left( 1) != "/" ) { |
917 | filename = QPEApplication::documentDir() + "/" + name; | 914 | filename = QPEApplication::documentDir() + "/" + name; |
918 | } | 915 | } |
919 | 916 | ||
920 | if( name.right( 3 ) != "m3u" ) { | 917 | if( name.right( 3 ) != "m3u" ) { |
921 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 918 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
922 | } | 919 | } |
923 | 920 | ||
924 | if( d->selectedFiles->first()) { | 921 | if( d->selectedFiles->first()) { |
925 | m3uList = new Om3u(filename, IO_ReadWrite); | 922 | m3uList = new Om3u(filename, IO_ReadWrite); |
926 | 923 | ||
927 | do { | 924 | do { |
928 | m3uList->add( d->selectedFiles->current()->file()); | 925 | m3uList->add( d->selectedFiles->current()->file()); |
929 | } | 926 | } |
930 | while ( d->selectedFiles->next() ); | 927 | while ( d->selectedFiles->next() ); |
931 | // qDebug( list ); | 928 | // qDebug( list ); |
932 | m3uList->write(); | 929 | m3uList->write(); |
933 | m3uList->close(); | 930 | m3uList->close(); |
934 | if(m3uList) delete m3uList; | 931 | if(m3uList) delete m3uList; |
935 | 932 | ||
936 | if(fileDlg) delete fileDlg; | 933 | if(fileDlg) delete fileDlg; |
937 | 934 | ||
938 | DocLnk lnk; | 935 | DocLnk lnk; |
939 | lnk.setFile( filename); | 936 | lnk.setFile( filename); |
940 | // lnk.setIcon("opieplayer2/playlist2"); | 937 | // lnk.setIcon("opieplayer2/playlist2"); |
941 | lnk.setName( name); //sets file name | 938 | lnk.setName( name); //sets file name |
942 | 939 | ||
943 | // qDebug(filename); | 940 | // qDebug(filename); |
944 | Config config( "OpiePlayer" ); | 941 | Config config( "OpiePlayer" ); |
945 | config.setGroup( "PlayList" ); | 942 | config.setGroup( "PlayList" ); |
946 | 943 | ||
947 | config.writeEntry("CurrentPlaylist",filename); | 944 | config.writeEntry("CurrentPlaylist",filename); |
948 | currentPlayList=filename; | 945 | currentPlayList=filename; |
949 | 946 | ||
950 | if(!lnk.writeLink()) { | 947 | if(!lnk.writeLink()) { |
951 | qDebug("Writing doclink did not work"); | 948 | qDebug("Writing doclink did not work"); |
952 | } | 949 | } |
953 | 950 | ||
954 | setCaption(tr("OpiePlayer: ") + name); | 951 | setCaption(tr("OpiePlayer: ") + name); |
955 | } | 952 | } |
956 | } | 953 | } |
957 | } | 954 | } |
958 | 955 | ||
959 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 956 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
960 | switch ( e->key() ) { | 957 | switch ( e->key() ) { |
961 | ////////////////////////////// Zaurus keys | 958 | ////////////////////////////// Zaurus keys |
962 | case Key_F9: //activity | 959 | case Key_F9: //activity |
963 | // if(audioUI->isHidden()) | 960 | // if(audioUI->isHidden()) |
964 | // audioUI->showMaximized(); | 961 | // audioUI->showMaximized(); |
965 | break; | 962 | break; |
966 | case Key_F10: //contacts | 963 | case Key_F10: //contacts |
967 | // if( videoUI->isHidden()) | 964 | // if( videoUI->isHidden()) |
968 | // videoUI->showMaximized(); | 965 | // videoUI->showMaximized(); |
969 | break; | 966 | break; |
970 | case Key_F11: //menu | 967 | case Key_F11: //menu |
971 | break; | 968 | break; |
972 | case Key_F12: //home | 969 | case Key_F12: //home |
973 | // doBlank(); | 970 | // doBlank(); |
974 | break; | 971 | break; |
975 | case Key_F13: //mail | 972 | case Key_F13: //mail |
976 | // doUnblank(); | 973 | // doUnblank(); |
977 | break; | 974 | break; |
978 | case Key_Q: //add to playlist | 975 | case Key_Q: //add to playlist |
979 | addSelected(); | 976 | addSelected(); |
980 | break; | 977 | break; |
981 | case Key_R: //remove from playlist | 978 | case Key_R: //remove from playlist |
982 | removeSelected(); | 979 | removeSelected(); |
983 | break; | 980 | break; |
984 | // case Key_P: //play | 981 | // case Key_P: //play |
985 | // qDebug("Play"); | 982 | // qDebug("Play"); |
986 | // playSelected(); | 983 | // playSelected(); |
987 | // break; | 984 | // break; |
988 | case Key_Space: | 985 | case Key_Space: |
989 | // playSelected(); puh | 986 | // playSelected(); puh |
990 | break; | 987 | break; |
991 | case Key_1: | 988 | case Key_1: |
992 | tabWidget->setCurrentPage( 0 ); | 989 | tabWidget->setCurrentPage( 0 ); |
993 | break; | 990 | break; |
994 | case Key_2: | 991 | case Key_2: |
995 | tabWidget->setCurrentPage( 1 ); | 992 | tabWidget->setCurrentPage( 1 ); |
996 | break; | 993 | break; |
997 | case Key_3: | 994 | case Key_3: |
998 | tabWidget->setCurrentPage( 2 ); | 995 | tabWidget->setCurrentPage( 2 ); |
999 | break; | 996 | break; |
1000 | case Key_4: | 997 | case Key_4: |
1001 | tabWidget->setCurrentPage( 3 ); | 998 | tabWidget->setCurrentPage( 3 ); |
1002 | break; | 999 | break; |
1003 | case Key_Down: | 1000 | case Key_Down: |
1004 | if ( !d->selectedFiles->next() ) | 1001 | if ( !d->selectedFiles->next() ) |
1005 | d->selectedFiles->first(); | 1002 | d->selectedFiles->first(); |
1006 | break; | 1003 | break; |
1007 | case Key_Up: | 1004 | case Key_Up: |
1008 | if ( !d->selectedFiles->prev() ) | 1005 | if ( !d->selectedFiles->prev() ) |
1009 | // d->selectedFiles->last(); | 1006 | // d->selectedFiles->last(); |
1010 | break; | 1007 | break; |
1011 | } | 1008 | } |
1012 | } | 1009 | } |
1013 | 1010 | ||
1014 | void PlayListWidget::pmViewActivated(int index) { | 1011 | void PlayListWidget::pmViewActivated(int index) { |
1015 | // qDebug("%d", index); | 1012 | // qDebug("%d", index); |
1016 | switch(index) { | 1013 | switch(index) { |
1017 | case -16: | 1014 | case -16: |
1018 | { | 1015 | { |
1019 | mediaPlayerState->toggleFullscreen(); | 1016 | mediaPlayerState->toggleFullscreen(); |
1020 | bool b=mediaPlayerState->fullscreen(); | 1017 | bool b=mediaPlayerState->fullscreen(); |
1021 | pmView->setItemChecked( index, b); | 1018 | pmView->setItemChecked( index, b); |
1022 | Config cfg( "OpiePlayer" ); | 1019 | Config cfg( "OpiePlayer" ); |
1023 | cfg.writeEntry( "FullScreen", b ); | 1020 | cfg.writeEntry( "FullScreen", b ); |
1024 | } | 1021 | } |
1025 | break; | 1022 | break; |
1026 | }; | 1023 | }; |
1027 | } | 1024 | } |
1028 | 1025 | ||
1029 | void PlayListWidget::populateSkinsMenu() { | 1026 | void PlayListWidget::populateSkinsMenu() { |
1030 | int item = 0; | 1027 | int item = 0; |
1031 | defaultSkinIndex = 0; | 1028 | defaultSkinIndex = 0; |
1032 | QString skinName; | 1029 | QString skinName; |
1033 | Config cfg( "OpiePlayer" ); | 1030 | Config cfg( "OpiePlayer" ); |
1034 | cfg.setGroup("Options" ); | 1031 | cfg.setGroup("Options" ); |
1035 | QString skin = cfg.readEntry( "Skin", "default" ); | 1032 | QString skin = cfg.readEntry( "Skin", "default" ); |
1036 | 1033 | ||
1037 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1034 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1038 | skinsDir.setFilter( QDir::Dirs ); | 1035 | skinsDir.setFilter( QDir::Dirs ); |
1039 | skinsDir.setSorting(QDir::Name ); | 1036 | skinsDir.setSorting(QDir::Name ); |
1040 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1037 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1041 | QFileInfoListIterator it( *skinslist ); | 1038 | QFileInfoListIterator it( *skinslist ); |
1042 | QFileInfo *fi; | 1039 | QFileInfo *fi; |
1043 | while ( ( fi = it.current() ) ) { | 1040 | while ( ( fi = it.current() ) ) { |
1044 | skinName = fi->fileName(); | 1041 | skinName = fi->fileName(); |
1045 | // qDebug( fi->fileName() ); | 1042 | // qDebug( fi->fileName() ); |
1046 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1043 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1047 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1044 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1048 | } | 1045 | } |
1049 | if( skinName == "default" ) { | 1046 | if( skinName == "default" ) { |
1050 | defaultSkinIndex = item; | 1047 | defaultSkinIndex = item; |
1051 | } | 1048 | } |
1052 | if( skinName == skin ) { | 1049 | if( skinName == skin ) { |
1053 | skinsMenu->setItemChecked( item, TRUE ); | 1050 | skinsMenu->setItemChecked( item, TRUE ); |
1054 | } | 1051 | } |
1055 | ++it; | 1052 | ++it; |
1056 | } | 1053 | } |
1057 | } | 1054 | } |
1058 | 1055 | ||
1059 | void PlayListWidget::skinsMenuActivated( int item ) { | 1056 | void PlayListWidget::skinsMenuActivated( int item ) { |
1060 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1057 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1061 | skinsMenu->setItemChecked( i, FALSE ); | 1058 | skinsMenu->setItemChecked( i, FALSE ); |
1062 | } | 1059 | } |
1063 | skinsMenu->setItemChecked( item, TRUE ); | 1060 | skinsMenu->setItemChecked( item, TRUE ); |
1064 | 1061 | ||
1065 | Config cfg( "OpiePlayer" ); | 1062 | Config cfg( "OpiePlayer" ); |
1066 | cfg.setGroup("Options"); | 1063 | cfg.setGroup("Options"); |
1067 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1064 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1068 | QMessageBox::warning( this, tr( "OpiePlayer" ), | 1065 | QMessageBox::warning( this, tr( "OpiePlayer" ), |
1069 | tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); | 1066 | tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); |
1070 | } | 1067 | } |
1071 | 1068 | ||
1072 | int PlayListWidget::whichList() { | 1069 | int PlayListWidget::whichList() { |
1073 | return tabWidget->currentPageIndex(); | 1070 | return tabWidget->currentPageIndex(); |
1074 | } | 1071 | } |
1075 | 1072 | ||
1076 | QString PlayListWidget::currentFileListPathName() { | 1073 | QString PlayListWidget::currentFileListPathName() { |
1077 | switch (whichList()) { | 1074 | switch (whichList()) { |
1078 | case 1: | 1075 | case 1: |
1079 | return audioView->currentItem()->text(3); | 1076 | return audioView->currentItem()->text(3); |
1080 | break; | 1077 | break; |
1081 | case 2: | 1078 | case 2: |
1082 | return videoView->currentItem()->text(3); | 1079 | return videoView->currentItem()->text(3); |
1083 | break; | 1080 | break; |
1084 | }; | 1081 | }; |
1085 | return ""; | 1082 | return ""; |
1086 | } | 1083 | } |