-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 49 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.h | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.h | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 35 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 10 |
7 files changed, 58 insertions, 65 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 442864f..56203e0 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,588 +1,589 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | #include <qwidget.h> | 38 | #include <qwidget.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include <qbutton.h> | 40 | #include <qbutton.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | #include <qframe.h> | 42 | #include <qframe.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | 44 | ||
45 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | #include <stdio.h> | 46 | #include <stdio.h> |
47 | 47 | ||
48 | #include "audiowidget.h" | 48 | #include "audiowidget.h" |
49 | #include "mediaplayerstate.h" | 49 | #include "mediaplayerstate.h" |
50 | 50 | ||
51 | extern MediaPlayerState *mediaPlayerState; | 51 | extern MediaPlayerState *mediaPlayerState; |
52 | 52 | ||
53 | static const int xo = -2; // movable x offset | 53 | static const int xo = -2; // movable x offset |
54 | static const int yo = 22; // movable y offset | 54 | static const int yo = 22; // movable y offset |
55 | 55 | ||
56 | 56 | ||
57 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { | 57 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { |
58 | setFrameStyle( WinPanel | Sunken ); | 58 | setFrameStyle( WinPanel | Sunken ); |
59 | setText( "No Song" ); | 59 | setText( "No Song" ); |
60 | } | 60 | } |
61 | 61 | ||
62 | Ticker::~Ticker() { | 62 | Ticker::~Ticker() { |
63 | } | 63 | } |
64 | 64 | ||
65 | void Ticker::setText( const QString& text ) { | 65 | void Ticker::setText( const QString& text ) { |
66 | pos = 0; // reset it everytime the text is changed | 66 | pos = 0; // reset it everytime the text is changed |
67 | scrollText = text; | 67 | scrollText = text; |
68 | pixelLen = fontMetrics().width( scrollText ); | 68 | pixelLen = fontMetrics().width( scrollText ); |
69 | killTimers(); | 69 | killTimers(); |
70 | if ( pixelLen > width() ) { | 70 | if ( pixelLen > width() ) { |
71 | startTimer( 50 ); | 71 | startTimer( 50 ); |
72 | } | 72 | } |
73 | update(); | 73 | update(); |
74 | } | 74 | } |
75 | 75 | ||
76 | 76 | ||
77 | void Ticker::timerEvent( QTimerEvent * ) { | 77 | void Ticker::timerEvent( QTimerEvent * ) { |
78 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | 78 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; |
79 | scroll( -1, 0, contentsRect() ); | 79 | scroll( -1, 0, contentsRect() ); |
80 | repaint( FALSE ); | 80 | repaint( FALSE ); |
81 | } | 81 | } |
82 | 82 | ||
83 | void Ticker::drawContents( QPainter *p ) { | 83 | void Ticker::drawContents( QPainter *p ) { |
84 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | 84 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) |
85 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 85 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
86 | QPixmap pm( width(), height() ); | 86 | QPixmap pm( width(), height() ); |
87 | pm.fill( colorGroup().base() ); | 87 | pm.fill( colorGroup().base() ); |
88 | QPainter pmp( &pm ); | 88 | QPainter pmp( &pm ); |
89 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | 89 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { |
90 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 90 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
91 | } | 91 | } |
92 | p->drawPixmap( 0, 0, pm ); | 92 | p->drawPixmap( 0, 0, pm ); |
93 | } | 93 | } |
94 | 94 | ||
95 | struct MediaButton { | 95 | struct MediaButton { |
96 | bool isToggle, isHeld, isDown; | 96 | bool isToggle, isHeld, isDown; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | //Layout information for the audioButtons (and if it is a toggle button or not) | 99 | //Layout information for the audioButtons (and if it is a toggle button or not) |
100 | MediaButton audioButtons[] = { | 100 | MediaButton audioButtons[] = { |
101 | { TRUE, FALSE, FALSE }, // play | 101 | { TRUE, FALSE, FALSE }, // play |
102 | { FALSE, FALSE, FALSE }, // stop | 102 | { FALSE, FALSE, FALSE }, // stop |
103 | { FALSE, FALSE, FALSE }, // next | 103 | { FALSE, FALSE, FALSE }, // next |
104 | { FALSE, FALSE, FALSE }, // previous | 104 | { FALSE, FALSE, FALSE }, // previous |
105 | { FALSE, FALSE, FALSE }, // volume up | 105 | { FALSE, FALSE, FALSE }, // volume up |
106 | { FALSE, FALSE, FALSE }, // volume down | 106 | { FALSE, FALSE, FALSE }, // volume down |
107 | { TRUE, FALSE, FALSE }, // repeat/loop | 107 | { TRUE, FALSE, FALSE }, // repeat/loop |
108 | { FALSE, FALSE, FALSE }, // playlist | 108 | { FALSE, FALSE, FALSE }, // playlist |
109 | { FALSE, FALSE, FALSE }, // forward | 109 | { FALSE, FALSE, FALSE }, // forward |
110 | { FALSE, FALSE, FALSE } // back | 110 | { FALSE, FALSE, FALSE } // back |
111 | }; | 111 | }; |
112 | 112 | ||
113 | const char *skin_mask_file_names[10] = { | 113 | const char *skin_mask_file_names[10] = { |
114 | "play", "stop", "next", "prev", "up", | 114 | "play", "stop", "next", "prev", "up", |
115 | "down", "loop", "playlist", "forward", "back" | 115 | "down", "loop", "playlist", "forward", "back" |
116 | }; | 116 | }; |
117 | 117 | ||
118 | 118 | ||
119 | static void changeTextColor( QWidget *w ) { | 119 | static void changeTextColor( QWidget *w ) { |
120 | QPalette p = w->palette(); | 120 | QPalette p = w->palette(); |
121 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 121 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
122 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 122 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
123 | w->setPalette( p ); | 123 | w->setPalette( p ); |
124 | } | 124 | } |
125 | 125 | ||
126 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 126 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
127 | 127 | ||
128 | 128 | ||
129 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 129 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
130 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 130 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
131 | setCaption( tr("OpiePlayer") ); | 131 | setCaption( tr("OpiePlayer") ); |
132 | 132 | ||
133 | Config cfg("OpiePlayer"); | 133 | Config cfg("OpiePlayer"); |
134 | cfg.setGroup("Options"); | 134 | cfg.setGroup("Options"); |
135 | skin = cfg.readEntry("Skin","default"); | 135 | skin = cfg.readEntry("Skin","default"); |
136 | //skin = "scaleTest"; | 136 | //skin = "scaleTest"; |
137 | // color of background, frame, degree of transparency | 137 | // color of background, frame, degree of transparency |
138 | 138 | ||
139 | QString skinPath = "opieplayer2/skins/" + skin; | 139 | QString skinPath = "opieplayer2/skins/" + skin; |
140 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 140 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
141 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 141 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
142 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 142 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
143 | 143 | ||
144 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 144 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
145 | imgButtonMask->fill( 0 ); | 145 | imgButtonMask->fill( 0 ); |
146 | 146 | ||
147 | for ( int i = 0; i < 10; i++ ) { | 147 | for ( int i = 0; i < 10; i++ ) { |
148 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; | 148 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; |
149 | masks[i] = new QBitmap( filename ); | 149 | masks[i] = new QBitmap( filename ); |
150 | 150 | ||
151 | if ( !masks[i]->isNull() ) { | 151 | if ( !masks[i]->isNull() ) { |
152 | QImage imgMask = masks[i]->convertToImage(); | 152 | QImage imgMask = masks[i]->convertToImage(); |
153 | uchar **dest = imgButtonMask->jumpTable(); | 153 | uchar **dest = imgButtonMask->jumpTable(); |
154 | for ( int y = 0; y < imgUp->height(); y++ ) { | 154 | for ( int y = 0; y < imgUp->height(); y++ ) { |
155 | uchar *line = dest[y]; | 155 | uchar *line = dest[y]; |
156 | for ( int x = 0; x < imgUp->width(); x++ ) | 156 | for ( int x = 0; x < imgUp->width(); x++ ) |
157 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 157 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
158 | line[x] = i + 1; | 158 | line[x] = i + 1; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | } | 162 | } |
163 | 163 | ||
164 | for ( int i = 0; i < 10; i++ ) { | 164 | for ( int i = 0; i < 10; i++ ) { |
165 | buttonPixUp[i] = NULL; | 165 | buttonPixUp[i] = NULL; |
166 | buttonPixDown[i] = NULL; | 166 | buttonPixDown[i] = NULL; |
167 | } | 167 | } |
168 | 168 | ||
169 | setBackgroundPixmap( *pixBg ); | 169 | setBackgroundPixmap( *pixBg ); |
170 | 170 | ||
171 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 171 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
172 | changeTextColor( &songInfo ); | 172 | changeTextColor( &songInfo ); |
173 | 173 | ||
174 | slider.setFixedHeight( 20 ); | 174 | slider.setFixedHeight( 20 ); |
175 | slider.setMinValue( 0 ); | 175 | slider.setMinValue( 0 ); |
176 | slider.setMaxValue( 1 ); | 176 | slider.setMaxValue( 1 ); |
177 | slider.setFocusPolicy( QWidget::NoFocus ); | 177 | slider.setFocusPolicy( QWidget::NoFocus ); |
178 | slider.setBackgroundPixmap( *pixBg ); | 178 | slider.setBackgroundPixmap( *pixBg ); |
179 | 179 | ||
180 | time.setFocusPolicy( QWidget::NoFocus ); | 180 | time.setFocusPolicy( QWidget::NoFocus ); |
181 | time.setAlignment( Qt::AlignCenter ); | 181 | time.setAlignment( Qt::AlignCenter ); |
182 | time.setFrame(FALSE); | 182 | time.setFrame(FALSE); |
183 | changeTextColor( &time ); | 183 | changeTextColor( &time ); |
184 | 184 | ||
185 | resizeEvent( NULL ); | 185 | resizeEvent( NULL ); |
186 | 186 | ||
187 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 187 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
188 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 188 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
189 | 189 | ||
190 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 190 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
191 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 191 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
192 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 192 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
193 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 193 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
194 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 194 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
195 | 195 | ||
196 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 196 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
197 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 197 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
198 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 198 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
199 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 199 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
200 | 200 | ||
201 | 201 | ||
202 | 202 | ||
203 | // Intialise state | 203 | // Intialise state |
204 | setLength( mediaPlayerState->length() ); | 204 | setLength( mediaPlayerState->length() ); |
205 | setPosition( mediaPlayerState->position() ); | 205 | setPosition( mediaPlayerState->position() ); |
206 | setLooping( mediaPlayerState->fullscreen() ); | 206 | setLooping( mediaPlayerState->fullscreen() ); |
207 | // setPaused( mediaPlayerState->paused() ); | 207 | // setPaused( mediaPlayerState->paused() ); |
208 | setPlaying( mediaPlayerState->playing() ); | 208 | setPlaying( mediaPlayerState->playing() ); |
209 | 209 | ||
210 | } | 210 | } |
211 | 211 | ||
212 | AudioWidget::~AudioWidget() { | 212 | AudioWidget::~AudioWidget() { |
213 | 213 | ||
214 | for ( int i = 0; i < 10; i++ ) { | 214 | for ( int i = 0; i < 10; i++ ) { |
215 | delete buttonPixUp[i]; | 215 | delete buttonPixUp[i]; |
216 | delete buttonPixDown[i]; | 216 | delete buttonPixDown[i]; |
217 | } | 217 | } |
218 | delete pixBg; | 218 | delete pixBg; |
219 | delete imgUp; | 219 | delete imgUp; |
220 | delete imgDn; | 220 | delete imgDn; |
221 | delete imgButtonMask; | 221 | delete imgButtonMask; |
222 | for ( int i = 0; i < 10; i++ ) { | 222 | for ( int i = 0; i < 10; i++ ) { |
223 | delete masks[i]; | 223 | delete masks[i]; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 227 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
228 | QPixmap pix( img.width(), img.height() ); | 228 | QPixmap pix( img.width(), img.height() ); |
229 | QPainter p( &pix ); | 229 | QPainter p( &pix ); |
230 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 230 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
231 | p.drawImage( 0, 0, img ); | 231 | p.drawImage( 0, 0, img ); |
232 | return new QPixmap( pix ); | 232 | return new QPixmap( pix ); |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) | 236 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) |
237 | { | 237 | { |
238 | QPixmap *pixmap = new QPixmap( pix ); | 238 | QPixmap *pixmap = new QPixmap( pix ); |
239 | pixmap->setMask( mask ); | 239 | pixmap->setMask( mask ); |
240 | return pixmap; | 240 | return pixmap; |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | 244 | ||
245 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 245 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
246 | int h = height(); | 246 | int h = height(); |
247 | int w = width(); | 247 | int w = width(); |
248 | 248 | ||
249 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | 249 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); |
250 | slider.setFixedWidth( w - 110 ); | 250 | slider.setFixedWidth( w - 110 ); |
251 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 251 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
252 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 252 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
253 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 253 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
254 | 254 | ||
255 | xoff = ( w - imgUp->width() ) / 2; | 255 | xoff = ( w - imgUp->width() ) / 2; |
256 | yoff = (( h - imgUp->height() ) / 2) - 10; | 256 | yoff = (( h - imgUp->height() ) / 2) - 10; |
257 | QPoint p( xoff, yoff ); | 257 | QPoint p( xoff, yoff ); |
258 | 258 | ||
259 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); | 259 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); |
260 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); | 260 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); |
261 | 261 | ||
262 | for ( int i = 0; i < 10; i++ ) { | 262 | for ( int i = 0; i < 10; i++ ) { |
263 | if ( !masks[i]->isNull() ) { | 263 | if ( !masks[i]->isNull() ) { |
264 | delete buttonPixUp[i]; | 264 | delete buttonPixUp[i]; |
265 | delete buttonPixDown[i]; | 265 | delete buttonPixDown[i]; |
266 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); | 266 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); |
267 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); | 267 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); |
268 | } | 268 | } |
269 | } | 269 | } |
270 | 270 | ||
271 | delete pixUp; | 271 | delete pixUp; |
272 | delete pixDn; | 272 | delete pixDn; |
273 | } | 273 | } |
274 | 274 | ||
275 | static bool audioSliderBeingMoved = FALSE; | 275 | static bool audioSliderBeingMoved = FALSE; |
276 | 276 | ||
277 | 277 | ||
278 | void AudioWidget::sliderPressed() { | 278 | void AudioWidget::sliderPressed() { |
279 | audioSliderBeingMoved = TRUE; | 279 | audioSliderBeingMoved = TRUE; |
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | void AudioWidget::sliderReleased() { | 283 | void AudioWidget::sliderReleased() { |
284 | audioSliderBeingMoved = FALSE; | 284 | audioSliderBeingMoved = FALSE; |
285 | if ( slider.width() == 0 ) | 285 | if ( slider.width() == 0 ) |
286 | return; | 286 | return; |
287 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 287 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
288 | mediaPlayerState->setPosition( val ); | 288 | mediaPlayerState->setPosition( val ); |
289 | } | 289 | } |
290 | 290 | ||
291 | void AudioWidget::setPosition( long i ) { | 291 | void AudioWidget::setPosition( long i ) { |
292 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 292 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
293 | updateSlider( i, mediaPlayerState->length() ); | 293 | updateSlider( i, mediaPlayerState->length() ); |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | void AudioWidget::setLength( long max ) { | 297 | void AudioWidget::setLength( long max ) { |
298 | updateSlider( mediaPlayerState->position(), max ); | 298 | updateSlider( mediaPlayerState->position(), max ); |
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | void AudioWidget::setView( char view ) { | 302 | void AudioWidget::setView( char view ) { |
303 | 303 | ||
304 | // this isnt working for some reason | 304 | // this isnt working for some reason |
305 | 305 | ||
306 | if ( mediaPlayerState->streaming() ) { | 306 | if ( mediaPlayerState->streaming() ) { |
307 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 307 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
308 | if( !slider.isHidden()) { | 308 | if( !slider.isHidden()) { |
309 | slider.hide(); | 309 | slider.hide(); |
310 | } | 310 | } |
311 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 311 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
312 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 312 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
313 | } else { | 313 | } else { |
314 | // this stops the slider from being moved, thus | 314 | // this stops the slider from being moved, thus |
315 | // does not stop stream when it reaches the end | 315 | // does not stop stream when it reaches the end |
316 | slider.show(); | 316 | slider.show(); |
317 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 317 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
318 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 318 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
319 | } | 319 | } |
320 | 320 | ||
321 | if ( view == 'a' ) { | 321 | if ( view == 'a' ) { |
322 | // startTimer( 150 ); | 322 | // startTimer( 150 ); |
323 | showMaximized(); | 323 | showMaximized(); |
324 | } else { | 324 | } else { |
325 | killTimers(); | 325 | killTimers(); |
326 | hide(); | 326 | hide(); |
327 | } | 327 | } |
328 | qApp->processEvents(); | 328 | qApp->processEvents(); |
329 | } | 329 | } |
330 | 330 | ||
331 | 331 | ||
332 | static QString timeAsString( long length ) { | 332 | static QString timeAsString( long length ) { |
333 | int minutes = length / 60; | 333 | int minutes = length / 60; |
334 | int seconds = length % 60; | 334 | int seconds = length % 60; |
335 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 335 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
336 | } | 336 | } |
337 | 337 | ||
338 | void AudioWidget::updateSlider( long i, long max ) { | 338 | void AudioWidget::updateSlider( long i, long max ) { |
339 | 339 | ||
340 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 340 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
341 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 341 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
342 | 342 | ||
343 | if ( max == 0 ) { | 343 | if ( max == 0 ) { |
344 | return; | 344 | return; |
345 | } | 345 | } |
346 | // Will flicker too much if we don't do this | 346 | // Will flicker too much if we don't do this |
347 | // Scale to something reasonable | 347 | // Scale to something reasonable |
348 | int width = slider.width(); | 348 | int width = slider.width(); |
349 | int val = int((double)i * width / max); | 349 | int val = int((double)i * width / max); |
350 | if ( !audioSliderBeingMoved ) { | 350 | if ( !audioSliderBeingMoved ) { |
351 | if ( slider.value() != val ) { | 351 | if ( slider.value() != val ) { |
352 | slider.setValue( val ); | 352 | slider.setValue( val ); |
353 | } | 353 | } |
354 | 354 | ||
355 | if ( slider.maxValue() != width ) { | 355 | if ( slider.maxValue() != width ) { |
356 | slider.setMaxValue( width ); | 356 | slider.setMaxValue( width ); |
357 | } | 357 | } |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | void AudioWidget::setToggleButton( int i, bool down ) { | 362 | void AudioWidget::setToggleButton( int i, bool down ) { |
363 | qDebug("setToggleButton %d", i); | 363 | qDebug("setToggleButton %d", i); |
364 | if ( down != audioButtons[i].isDown ) { | 364 | if ( down != audioButtons[i].isDown ) { |
365 | toggleButton( i ); | 365 | toggleButton( i ); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | void AudioWidget::toggleButton( int i ) { | 370 | void AudioWidget::toggleButton( int i ) { |
371 | audioButtons[i].isDown = !audioButtons[i].isDown; | 371 | audioButtons[i].isDown = !audioButtons[i].isDown; |
372 | QPainter p(this); | 372 | QPainter p(this); |
373 | paintButton ( &p, i ); | 373 | paintButton ( &p, i ); |
374 | } | 374 | } |
375 | 375 | ||
376 | 376 | ||
377 | void AudioWidget::paintButton( QPainter *p, int i ) { | 377 | void AudioWidget::paintButton( QPainter *p, int i ) { |
378 | if ( audioButtons[i].isDown ) { | 378 | if ( audioButtons[i].isDown ) { |
379 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 379 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
380 | } else { | 380 | } else { |
381 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 381 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | 385 | ||
386 | void AudioWidget::skipFor() { | 386 | void AudioWidget::skipFor() { |
387 | skipDirection = +1; | 387 | skipDirection = +1; |
388 | startTimer( 50 ); | 388 | startTimer( 50 ); |
389 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 389 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
390 | } | 390 | } |
391 | 391 | ||
392 | void AudioWidget::skipBack() { | 392 | void AudioWidget::skipBack() { |
393 | skipDirection = -1; | 393 | skipDirection = -1; |
394 | startTimer( 50 ); | 394 | startTimer( 50 ); |
395 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 395 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | 399 | ||
400 | void AudioWidget::stopSkip() { | 400 | void AudioWidget::stopSkip() { |
401 | killTimers(); | 401 | killTimers(); |
402 | } | 402 | } |
403 | 403 | ||
404 | 404 | ||
405 | void AudioWidget::timerEvent( QTimerEvent * ) { | 405 | void AudioWidget::timerEvent( QTimerEvent * ) { |
406 | if ( skipDirection == +1 ) { | 406 | if ( skipDirection == +1 ) { |
407 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 407 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
408 | } else if ( skipDirection == -1 ) { | 408 | } else if ( skipDirection == -1 ) { |
409 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 409 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
410 | } | 410 | } |
411 | } | 411 | } |
412 | 412 | ||
413 | 413 | ||
414 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 414 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
415 | for ( int i = 0; i < numButtons; i++ ) { | 415 | for ( int i = 0; i < numButtons; i++ ) { |
416 | if ( event->state() == QMouseEvent::LeftButton ) { | 416 | if ( event->state() == QMouseEvent::LeftButton ) { |
417 | // The test to see if the mouse click is inside the button or not | 417 | // The test to see if the mouse click is inside the button or not |
418 | int x = event->pos().x() - xoff; | 418 | int x = event->pos().x() - xoff; |
419 | int y = event->pos().y() - yoff; | 419 | int y = event->pos().y() - yoff; |
420 | 420 | ||
421 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 421 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
422 | && y < imgButtonMask->height() | 422 | && y < imgButtonMask->height() |
423 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 423 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
424 | 424 | ||
425 | if ( isOnButton && !audioButtons[i].isHeld ) { | 425 | if ( isOnButton && !audioButtons[i].isHeld ) { |
426 | audioButtons[i].isHeld = TRUE; | 426 | audioButtons[i].isHeld = TRUE; |
427 | toggleButton(i); | 427 | toggleButton(i); |
428 | switch (i) { | 428 | switch (i) { |
429 | case AudioVolumeUp: | 429 | case AudioVolumeUp: |
430 | emit moreClicked(); | 430 | emit moreClicked(); |
431 | return; | 431 | return; |
432 | case AudioVolumeDown: | 432 | case AudioVolumeDown: |
433 | emit lessClicked(); | 433 | emit lessClicked(); |
434 | return; | 434 | return; |
435 | case AudioForward: | 435 | case AudioForward: |
436 | emit forwardClicked(); | 436 | emit forwardClicked(); |
437 | return; | 437 | return; |
438 | case AudioBack: | 438 | case AudioBack: |
439 | emit backClicked(); | 439 | emit backClicked(); |
440 | return; | 440 | return; |
441 | } | 441 | } |
442 | } | 442 | } |
443 | else if ( !isOnButton && audioButtons[i].isHeld ) { | 443 | else if ( !isOnButton && audioButtons[i].isHeld ) { |
444 | audioButtons[i].isHeld = FALSE; | 444 | audioButtons[i].isHeld = FALSE; |
445 | toggleButton(i); | 445 | toggleButton(i); |
446 | } | 446 | } |
447 | } else { | 447 | } else { |
448 | if ( audioButtons[i].isHeld ) { | 448 | if ( audioButtons[i].isHeld ) { |
449 | audioButtons[i].isHeld = FALSE; | 449 | audioButtons[i].isHeld = FALSE; |
450 | if ( !audioButtons[i].isToggle ) { | 450 | if ( !audioButtons[i].isToggle ) { |
451 | setToggleButton( i, FALSE ); | 451 | setToggleButton( i, FALSE ); |
452 | } | 452 | } |
453 | switch (i) { | 453 | switch (i) { |
454 | case AudioPlay: | 454 | case AudioPlay: |
455 | if( mediaPlayerState->isPaused ) { | 455 | if( mediaPlayerState->isPaused ) { |
456 | // setToggleButton( i, FALSE ); | 456 | // setToggleButton( i, FALSE ); |
457 | mediaPlayerState->setPaused( FALSE ); | 457 | mediaPlayerState->setPaused( FALSE ); |
458 | return; | 458 | return; |
459 | } else if( !mediaPlayerState->isPaused ) { | 459 | } else if( !mediaPlayerState->isPaused ) { |
460 | // setToggleButton( i, TRUE ); | 460 | // setToggleButton( i, TRUE ); |
461 | mediaPlayerState->setPaused( TRUE ); | 461 | mediaPlayerState->setPaused( TRUE ); |
462 | return; | 462 | return; |
463 | } else { | 463 | } else { |
464 | // setToggleButton( i, TRUE ); | 464 | // setToggleButton( i, TRUE ); |
465 | // mediaPlayerState->setPlaying( videoButtons[i].isDown ); | 465 | // mediaPlayerState->setPlaying( videoButtons[i].isDown ); |
466 | } | 466 | } |
467 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 467 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
468 | case AudioNext: mediaPlayerState->setNext(); return; | 468 | case AudioNext: mediaPlayerState->setNext(); return; |
469 | case AudioPrevious: mediaPlayerState->setPrev(); return; | 469 | case AudioPrevious: mediaPlayerState->setPrev(); return; |
470 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 470 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
471 | case AudioVolumeUp: emit moreReleased(); return; | 471 | case AudioVolumeUp: emit moreReleased(); return; |
472 | case AudioVolumeDown: emit lessReleased(); return; | 472 | case AudioVolumeDown: emit lessReleased(); return; |
473 | case AudioPlayList: mediaPlayerState->setList(); return; | 473 | case AudioPlayList: mediaPlayerState->setList(); return; |
474 | case AudioForward: emit forwardReleased(); return; | 474 | case AudioForward: emit forwardReleased(); return; |
475 | case AudioBack: emit backReleased(); return; | 475 | case AudioBack: emit backReleased(); return; |
476 | } | 476 | } |
477 | } | 477 | } |
478 | } | 478 | } |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 483 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
484 | mouseMoveEvent( event ); | 484 | mouseMoveEvent( event ); |
485 | } | 485 | } |
486 | 486 | ||
487 | 487 | ||
488 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 488 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
489 | mouseMoveEvent( event ); | 489 | mouseMoveEvent( event ); |
490 | } | 490 | } |
491 | 491 | ||
492 | 492 | ||
493 | void AudioWidget::showEvent( QShowEvent* ) { | 493 | void AudioWidget::showEvent( QShowEvent* ) { |
494 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 494 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
495 | mouseMoveEvent( &event ); | 495 | mouseMoveEvent( &event ); |
496 | } | 496 | } |
497 | 497 | ||
498 | 498 | ||
499 | void AudioWidget::closeEvent( QCloseEvent* ) { | 499 | void AudioWidget::closeEvent( QCloseEvent* ) { |
500 | mediaPlayerState->setList(); | 500 | mediaPlayerState->setList(); |
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | void AudioWidget::paintEvent( QPaintEvent * pe) { | 504 | void AudioWidget::paintEvent( QPaintEvent * pe) { |
505 | if ( !pe->erased() ) { | 505 | if ( !pe->erased() ) { |
506 | // Combine with background and double buffer | 506 | // Combine with background and double buffer |
507 | QPixmap pix( pe->rect().size() ); | 507 | QPixmap pix( pe->rect().size() ); |
508 | QPainter p( &pix ); | 508 | QPainter p( &pix ); |
509 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 509 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
510 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 510 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
511 | for ( int i = 0; i < numButtons; i++ ) | 511 | for ( int i = 0; i < numButtons; i++ ) |
512 | paintButton( &p, i ); | 512 | paintButton( &p, i ); |
513 | QPainter p2( this ); | 513 | QPainter p2( this ); |
514 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 514 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
515 | } else { | 515 | } else { |
516 | QPainter p( this ); | 516 | QPainter p( this ); |
517 | for ( int i = 0; i < numButtons; i++ ) | 517 | for ( int i = 0; i < numButtons; i++ ) |
518 | paintButton( &p, i ); | 518 | paintButton( &p, i ); |
519 | } | 519 | } |
520 | } | 520 | } |
521 | 521 | ||
522 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) | 522 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) |
523 | { | 523 | { |
524 | switch ( e->key() ) { | 524 | switch ( e->key() ) { |
525 | ////////////////////////////// Zaurus keys | 525 | ////////////////////////////// Zaurus keys |
526 | case Key_Home: | 526 | case Key_Home: |
527 | break; | 527 | break; |
528 | case Key_F9: //activity | 528 | case Key_F9: //activity |
529 | hide(); | 529 | hide(); |
530 | // qDebug("Audio F9"); | 530 | // qDebug("Audio F9"); |
531 | break; | 531 | break; |
532 | case Key_F10: //contacts | 532 | case Key_F10: //contacts |
533 | break; | 533 | break; |
534 | case Key_F11: //menu | 534 | case Key_F11: //menu |
535 | break; | 535 | break; |
536 | case Key_F12: //home | 536 | case Key_F12: //home |
537 | break; | 537 | break; |
538 | case Key_F13: //mail | 538 | case Key_F13: //mail |
539 | mediaPlayerState->toggleBlank(); | ||
539 | break; | 540 | break; |
540 | case Key_Space: { | 541 | case Key_Space: { |
541 | if(mediaPlayerState->playing()) { | 542 | if(mediaPlayerState->playing()) { |
542 | // toggleButton(1); | 543 | // toggleButton(1); |
543 | mediaPlayerState->setPlaying(FALSE); | 544 | mediaPlayerState->setPlaying(FALSE); |
544 | // toggleButton(1); | 545 | // toggleButton(1); |
545 | } else { | 546 | } else { |
546 | // toggleButton(0); | 547 | // toggleButton(0); |
547 | mediaPlayerState->setPlaying(TRUE); | 548 | mediaPlayerState->setPlaying(TRUE); |
548 | // toggleButton(0); | 549 | // toggleButton(0); |
549 | } | 550 | } |
550 | } | 551 | } |
551 | break; | 552 | break; |
552 | case Key_Down: | 553 | case Key_Down: |
553 | // toggleButton(6); | 554 | // toggleButton(6); |
554 | emit lessClicked(); | 555 | emit lessClicked(); |
555 | emit lessReleased(); | 556 | emit lessReleased(); |
556 | // toggleButton(6); | 557 | // toggleButton(6); |
557 | break; | 558 | break; |
558 | case Key_Up: | 559 | case Key_Up: |
559 | // toggleButton(5); | 560 | // toggleButton(5); |
560 | emit moreClicked(); | 561 | emit moreClicked(); |
561 | emit moreReleased(); | 562 | emit moreReleased(); |
562 | // toggleButton(5); | 563 | // toggleButton(5); |
563 | break; | 564 | break; |
564 | case Key_Right: | 565 | case Key_Right: |
565 | // toggleButton(3); | 566 | // toggleButton(3); |
566 | mediaPlayerState->setNext(); | 567 | mediaPlayerState->setNext(); |
567 | // toggleButton(3); | 568 | // toggleButton(3); |
568 | break; | 569 | break; |
569 | case Key_Left: | 570 | case Key_Left: |
570 | // toggleButton(4); | 571 | // toggleButton(4); |
571 | mediaPlayerState->setPrev(); | 572 | mediaPlayerState->setPrev(); |
572 | // toggleButton(4); | 573 | // toggleButton(4); |
573 | break; | 574 | break; |
574 | case Key_Escape: { | 575 | case Key_Escape: { |
575 | #if defined(QT_QWS_IPAQ) | 576 | #if defined(QT_QWS_IPAQ) |
576 | if( mediaPlayerState->isPaused ) { | 577 | if( mediaPlayerState->isPaused ) { |
577 | setToggleButton( i, FALSE ); | 578 | setToggleButton( i, FALSE ); |
578 | mediaPlayerState->setPaused( FALSE ); | 579 | mediaPlayerState->setPaused( FALSE ); |
579 | } else if( !mediaPlayerState->isPaused ) { | 580 | } else if( !mediaPlayerState->isPaused ) { |
580 | setToggleButton( i, TRUE ); | 581 | setToggleButton( i, TRUE ); |
581 | mediaPlayerState->setPaused( TRUE ); | 582 | mediaPlayerState->setPaused( TRUE ); |
582 | } | 583 | } |
583 | #endif | 584 | #endif |
584 | } | 585 | } |
585 | break; | 586 | break; |
586 | 587 | ||
587 | }; | 588 | }; |
588 | } | 589 | } |
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 8dadf96..858b51f 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,283 +1,294 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qpe/qlibrary.h> | 2 | #include <qpe/qlibrary.h> |
3 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | #include <qpe/qcopenvelope_qws.h> | ||
5 | 6 | ||
6 | #include <qmainwindow.h> | 7 | #include <qmainwindow.h> |
7 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
8 | #include <qwidgetstack.h> | 9 | #include <qwidgetstack.h> |
9 | #include <qfile.h> | 10 | #include <qfile.h> |
10 | 11 | ||
11 | #include "mediaplayer.h" | 12 | #include "mediaplayer.h" |
12 | #include "playlistwidget.h" | 13 | #include "playlistwidget.h" |
13 | #include "audiowidget.h" | 14 | #include "audiowidget.h" |
14 | #include "videowidget.h" | 15 | #include "videowidget.h" |
15 | #include "volumecontrol.h" | 16 | #include "volumecontrol.h" |
16 | 17 | ||
17 | #include "mediaplayerstate.h" | 18 | #include "mediaplayerstate.h" |
18 | 19 | ||
20 | // for setBacklight() | ||
21 | #include <linux/fb.h> | ||
22 | #include <sys/file.h> | ||
23 | #include <sys/ioctl.h> | ||
19 | 24 | ||
20 | 25 | ||
21 | extern AudioWidget *audioUI; | 26 | extern AudioWidget *audioUI; |
22 | extern VideoWidget *videoUI; | 27 | extern VideoWidget *videoUI; |
23 | extern PlayListWidget *playList; | 28 | extern PlayListWidget *playList; |
24 | extern MediaPlayerState *mediaPlayerState; | 29 | extern MediaPlayerState *mediaPlayerState; |
25 | 30 | ||
26 | 31 | ||
27 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 32 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
28 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 33 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
29 | 34 | ||
30 | 35 | ||
31 | xineControl = new XineControl(); | 36 | // xineControl = new XineControl(); |
32 | // QPEApplication::grabKeyboard(); // EVIL | 37 | // QPEApplication::grabKeyboard(); // EVIL |
33 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 38 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
34 | 39 | ||
35 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 40 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
36 | 41 | ||
37 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 42 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
38 | 43 | ||
39 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 44 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
40 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 45 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
46 | connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | ||
41 | 47 | ||
42 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 48 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
43 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 49 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
44 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 50 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
45 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 51 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
46 | 52 | ||
47 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 53 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
48 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 54 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
49 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 55 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
50 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 56 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
51 | 57 | ||
52 | volControl = new VolumeControl; | 58 | volControl = new VolumeControl; |
53 | 59 | xineControl = new XineControl(); | |
54 | } | 60 | } |
55 | 61 | ||
56 | MediaPlayer::~MediaPlayer() { | 62 | MediaPlayer::~MediaPlayer() { |
57 | delete xineControl; | 63 | delete xineControl; |
58 | delete volControl; | 64 | delete volControl; |
59 | } | 65 | } |
60 | 66 | ||
61 | void MediaPlayer::pauseCheck( bool b ) { | 67 | void MediaPlayer::pauseCheck( bool b ) { |
62 | if ( b && !mediaPlayerState->playing() ) { | 68 | if ( b && !mediaPlayerState->playing() ) { |
63 | mediaPlayerState->setPaused( FALSE ); | 69 | mediaPlayerState->setPaused( FALSE ); |
64 | } | 70 | } |
65 | } | 71 | } |
66 | 72 | ||
67 | void MediaPlayer::play() { | 73 | void MediaPlayer::play() { |
68 | mediaPlayerState->setPlaying( FALSE ); | 74 | mediaPlayerState->setPlaying( FALSE ); |
69 | mediaPlayerState->setPlaying( TRUE ); | 75 | mediaPlayerState->setPlaying( TRUE ); |
70 | } | 76 | } |
71 | 77 | ||
72 | void MediaPlayer::setPlaying( bool play ) { | 78 | void MediaPlayer::setPlaying( bool play ) { |
73 | if ( !play ) { | 79 | if ( !play ) { |
74 | // mediaPlayerState->setPaused( FALSE ); | ||
75 | return; | 80 | return; |
76 | } | 81 | } |
77 | 82 | ||
78 | if ( mediaPlayerState->paused() ) { | 83 | if ( mediaPlayerState->paused() ) { |
79 | mediaPlayerState->setPaused( FALSE ); | 84 | mediaPlayerState->setPaused( FALSE ); |
80 | return; | 85 | return; |
81 | } | 86 | } |
82 | 87 | ||
83 | const DocLnk *playListCurrent = playList->current(); | 88 | const DocLnk *playListCurrent = playList->current(); |
84 | if ( playListCurrent != NULL ) { | 89 | if ( playListCurrent != NULL ) { |
85 | currentFile = playListCurrent; | 90 | currentFile = playListCurrent; |
86 | } | 91 | } |
87 | 92 | ||
88 | xineControl->play( currentFile->file() ); | 93 | xineControl->play( currentFile->file() ); |
89 | 94 | ||
90 | xineControl->length(); | 95 | xineControl->length(); |
91 | long seconds = mediaPlayerState->length();// | 96 | long seconds = mediaPlayerState->length();// |
92 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 97 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
93 | qDebug(time); | 98 | qDebug(time); |
94 | 99 | ||
95 | QString tickerText; | 100 | QString tickerText; |
96 | if( currentFile->file().left(4) == "http" ) | 101 | if( currentFile->file().left(4) == "http" ) |
97 | tickerText= tr( " File: " ) + currentFile->name(); | 102 | tickerText= tr( " File: " ) + currentFile->name(); |
98 | else | 103 | else |
99 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; | 104 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; |
100 | 105 | ||
101 | // QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); | ||
102 | |||
103 | // if ( !fileInfo.isEmpty() ) | ||
104 | // tickerText += ", " + fileInfo; | ||
105 | // audioUI->setTickerText( tickerText + "." ); | ||
106 | |||
107 | audioUI->setTickerText( currentFile->file( ) ); | 106 | audioUI->setTickerText( currentFile->file( ) ); |
108 | 107 | ||
109 | } | 108 | } |
110 | 109 | ||
111 | 110 | ||
112 | void MediaPlayer::prev() { | 111 | void MediaPlayer::prev() { |
113 | if ( playList->prev() ) { | 112 | if ( playList->prev() ) { |
114 | play(); | 113 | play(); |
115 | } else if ( mediaPlayerState->looping() ) { | 114 | } else if ( mediaPlayerState->looping() ) { |
116 | if ( playList->last() ) { | 115 | if ( playList->last() ) { |
117 | play(); | 116 | play(); |
118 | } | 117 | } |
119 | } else { | 118 | } else { |
120 | mediaPlayerState->setList(); | 119 | mediaPlayerState->setList(); |
121 | } | 120 | } |
122 | } | 121 | } |
123 | 122 | ||
124 | 123 | ||
125 | void MediaPlayer::next() { | 124 | void MediaPlayer::next() { |
126 | if ( playList->next() ) { | 125 | if ( playList->next() ) { |
127 | play(); | 126 | play(); |
128 | } else if ( mediaPlayerState->looping() ) { | 127 | } else if ( mediaPlayerState->looping() ) { |
129 | if ( playList->first() ) { | 128 | if ( playList->first() ) { |
130 | play(); | 129 | play(); |
131 | } | 130 | } |
132 | } else { | 131 | } else { |
133 | mediaPlayerState->setList(); | 132 | mediaPlayerState->setList(); |
134 | } | 133 | } |
135 | } | 134 | } |
136 | 135 | ||
137 | 136 | ||
138 | void MediaPlayer::startDecreasingVolume() { | 137 | void MediaPlayer::startDecreasingVolume() { |
139 | volumeDirection = -1; | 138 | volumeDirection = -1; |
140 | startTimer( 100 ); | 139 | startTimer( 100 ); |
141 | volControl->decVol(2); | 140 | volControl->decVol(2); |
142 | } | 141 | } |
143 | 142 | ||
144 | 143 | ||
145 | void MediaPlayer::startIncreasingVolume() { | 144 | void MediaPlayer::startIncreasingVolume() { |
146 | volumeDirection = +1; | 145 | volumeDirection = +1; |
147 | startTimer( 100 ); | 146 | startTimer( 100 ); |
148 | volControl->incVol(2); | 147 | volControl->incVol(2); |
149 | } | 148 | } |
150 | 149 | ||
151 | 150 | ||
152 | bool drawnOnScreenDisplay = FALSE; | 151 | bool drawnOnScreenDisplay = FALSE; |
153 | unsigned int onScreenDisplayVolume = 0; | 152 | unsigned int onScreenDisplayVolume = 0; |
154 | const int yoff = 110; | 153 | const int yoff = 110; |
155 | 154 | ||
156 | void MediaPlayer::stopChangingVolume() { | 155 | void MediaPlayer::stopChangingVolume() { |
157 | killTimers(); | 156 | killTimers(); |
158 | // Get rid of the on-screen display stuff | 157 | // Get rid of the on-screen display stuff |
159 | drawnOnScreenDisplay = FALSE; | 158 | drawnOnScreenDisplay = FALSE; |
160 | onScreenDisplayVolume = 0; | 159 | onScreenDisplayVolume = 0; |
161 | int w=0; | 160 | int w=0; |
162 | int h=0; | 161 | int h=0; |
163 | if( !xineControl->hasVideo()) { | 162 | if( !xineControl->hasVideo()) { |
164 | w = audioUI->width(); | 163 | w = audioUI->width(); |
165 | h = audioUI->height(); | 164 | h = audioUI->height(); |
166 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 165 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); |
167 | } else { | 166 | } else { |
168 | w = videoUI->width(); | 167 | w = videoUI->width(); |
169 | h = videoUI->height(); | 168 | h = videoUI->height(); |
170 | videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 169 | videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); |
171 | } | 170 | } |
172 | } | 171 | } |
173 | 172 | ||
174 | 173 | ||
175 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 174 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
176 | if ( volumeDirection == +1 ) { | 175 | if ( volumeDirection == +1 ) { |
177 | volControl->incVol(2); | 176 | volControl->incVol(2); |
178 | } else if ( volumeDirection == -1 ) { | 177 | } else if ( volumeDirection == -1 ) { |
179 | volControl->decVol(2); | 178 | volControl->decVol(2); |
180 | } | 179 | } |
181 | 180 | ||
182 | 181 | ||
183 | // TODO FIXME | 182 | // TODO FIXME |
184 | unsigned int v; | 183 | unsigned int v; |
185 | v = volControl->getVolume(); | 184 | v = volControl->getVolume(); |
186 | v = v / 10; | 185 | v = v / 10; |
187 | 186 | ||
188 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 187 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
189 | return; | 188 | return; |
190 | } | 189 | } |
191 | 190 | ||
192 | int w=0; int h=0; | 191 | int w=0; int h=0; |
193 | if( !xineControl->hasVideo()) { | 192 | if( !xineControl->hasVideo()) { |
194 | w = audioUI->width(); | 193 | w = audioUI->width(); |
195 | h = audioUI->height(); | 194 | h = audioUI->height(); |
196 | 195 | ||
197 | if ( drawnOnScreenDisplay ) { | 196 | if ( drawnOnScreenDisplay ) { |
198 | if ( onScreenDisplayVolume > v ) { | 197 | if ( onScreenDisplayVolume > v ) { |
199 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 198 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
200 | } | 199 | } |
201 | } | 200 | } |
202 | drawnOnScreenDisplay = TRUE; | 201 | drawnOnScreenDisplay = TRUE; |
203 | onScreenDisplayVolume = v; | 202 | onScreenDisplayVolume = v; |
204 | QPainter p( audioUI ); | 203 | QPainter p( audioUI ); |
205 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 204 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
206 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 205 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
207 | 206 | ||
208 | QFont f; | 207 | QFont f; |
209 | f.setPixelSize( 20 ); | 208 | f.setPixelSize( 20 ); |
210 | f.setBold( TRUE ); | 209 | f.setBold( TRUE ); |
211 | p.setFont( f ); | 210 | p.setFont( f ); |
212 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 211 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
213 | 212 | ||
214 | for ( unsigned int i = 0; i < 10; i++ ) { | 213 | for ( unsigned int i = 0; i < 10; i++ ) { |
215 | if ( v > i ) { | 214 | if ( v > i ) { |
216 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 215 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
217 | } else { | 216 | } else { |
218 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 217 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
219 | } | 218 | } |
220 | } | 219 | } |
221 | } else { | 220 | } else { |
222 | w = videoUI->width(); | 221 | w = videoUI->width(); |
223 | h = videoUI->height(); | 222 | h = videoUI->height(); |
224 | 223 | ||
225 | if ( drawnOnScreenDisplay ) { | 224 | if ( drawnOnScreenDisplay ) { |
226 | if ( onScreenDisplayVolume > v ) { | 225 | if ( onScreenDisplayVolume > v ) { |
227 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 226 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
228 | } | 227 | } |
229 | } | 228 | } |
230 | drawnOnScreenDisplay = TRUE; | 229 | drawnOnScreenDisplay = TRUE; |
231 | onScreenDisplayVolume = v; | 230 | onScreenDisplayVolume = v; |
232 | QPainter p( videoUI ); | 231 | QPainter p( videoUI ); |
233 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 232 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
234 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 233 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
235 | 234 | ||
236 | QFont f; | 235 | QFont f; |
237 | f.setPixelSize( 20 ); | 236 | f.setPixelSize( 20 ); |
238 | f.setBold( TRUE ); | 237 | f.setBold( TRUE ); |
239 | p.setFont( f ); | 238 | p.setFont( f ); |
240 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 239 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
241 | 240 | ||
242 | for ( unsigned int i = 0; i < 10; i++ ) { | 241 | for ( unsigned int i = 0; i < 10; i++ ) { |
243 | if ( v > i ) { | 242 | if ( v > i ) { |
244 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 243 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
245 | } else { | 244 | } else { |
246 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 245 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
247 | } | 246 | } |
248 | } | 247 | } |
249 | } | 248 | } |
250 | } | 249 | } |
251 | 250 | ||
251 | |||
252 | void MediaPlayer::blank( bool b ) { | ||
253 | fd=open("/dev/fb0",O_RDWR); | ||
254 | if (fd != -1) { | ||
255 | |||
256 | if ( !b ) { | ||
257 | qDebug("do blanking"); | ||
258 | ioctl( fd, FBIOBLANK, 3 ); | ||
259 | isBlanked = TRUE; | ||
260 | } else { | ||
261 | qDebug("do unblanking"); | ||
262 | ioctl( fd, FBIOBLANK, 0); | ||
263 | isBlanked = FALSE; | ||
264 | } | ||
265 | close( fd ); | ||
266 | } | ||
267 | } | ||
268 | |||
252 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 269 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
253 | switch ( e->key() ) { | 270 | switch ( e->key() ) { |
254 | ////////////////////////////// Zaurus keys | 271 | ////////////////////////////// Zaurus keys |
255 | case Key_Home: | 272 | case Key_Home: |
256 | break; | 273 | break; |
257 | case Key_F9: //activity | 274 | case Key_F9: //activity |
258 | break; | 275 | break; |
259 | case Key_F10: //contacts | 276 | case Key_F10: //contacts |
260 | break; | 277 | break; |
261 | case Key_F11: //menu | 278 | case Key_F11: //menu |
262 | break; | 279 | break; |
263 | case Key_F12: //home | 280 | case Key_F12: //home |
264 | qDebug("Blank here"); | 281 | qDebug("Blank here"); |
282 | // mediaPlayerState->toggleBlank(); | ||
265 | break; | 283 | break; |
266 | case Key_F13: //mail | 284 | case Key_F13: //mail |
267 | break; | 285 | qDebug("Blank here"); |
286 | // mediaPlayerState->toggleBlank(); | ||
287 | break; | ||
268 | } | 288 | } |
269 | } | 289 | } |
270 | 290 | ||
271 | void MediaPlayer::doBlank() { | ||
272 | |||
273 | } | ||
274 | |||
275 | void MediaPlayer::doUnblank() { | ||
276 | |||
277 | } | ||
278 | |||
279 | void MediaPlayer::cleanUp() { | 291 | void MediaPlayer::cleanUp() { |
280 | // QPEApplication::grabKeyboard(); | 292 | // QPEApplication::grabKeyboard(); |
281 | // QPEApplication::ungrabKeyboard(); | 293 | // QPEApplication::ungrabKeyboard(); |
282 | |||
283 | } | 294 | } |
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h index 16213b5..81fab88 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.h +++ b/noncore/multimedia/opieplayer2/mediaplayer.h | |||
@@ -1,46 +1,47 @@ | |||
1 | 1 | ||
2 | #ifndef MEDIA_PLAYER_H | 2 | #ifndef MEDIA_PLAYER_H |
3 | #define MEDIA_PLAYER_H | 3 | #define MEDIA_PLAYER_H |
4 | 4 | ||
5 | #include <qmainwindow.h> | 5 | #include <qmainwindow.h> |
6 | #include <qframe.h> | 6 | #include <qframe.h> |
7 | #include <qpe/qlibrary.h> | 7 | #include <qpe/qlibrary.h> |
8 | #include <qpe/mediaplayerplugininterface.h> | 8 | #include <qpe/mediaplayerplugininterface.h> |
9 | 9 | ||
10 | #include "xinecontrol.h" | 10 | #include "xinecontrol.h" |
11 | 11 | ||
12 | class DocLnk; | 12 | class DocLnk; |
13 | class VolumeControl; | 13 | class VolumeControl; |
14 | 14 | ||
15 | class MediaPlayer : public QObject { | 15 | class MediaPlayer : public QObject { |
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | public: | 17 | public: |
18 | MediaPlayer( QObject *parent, const char *name ); | 18 | MediaPlayer( QObject *parent, const char *name ); |
19 | ~MediaPlayer(); | 19 | ~MediaPlayer(); |
20 | 20 | ||
21 | private slots: | 21 | private slots: |
22 | void setPlaying( bool ); | 22 | void setPlaying( bool ); |
23 | void pauseCheck( bool ); | 23 | void pauseCheck( bool ); |
24 | void play(); | 24 | void play(); |
25 | void next(); | 25 | void next(); |
26 | void prev(); | 26 | void prev(); |
27 | void startIncreasingVolume(); | 27 | void startIncreasingVolume(); |
28 | void startDecreasingVolume(); | 28 | void startDecreasingVolume(); |
29 | void stopChangingVolume(); | 29 | void stopChangingVolume(); |
30 | void cleanUp(); | 30 | void cleanUp(); |
31 | void blank( bool ); | ||
31 | 32 | ||
32 | protected: | 33 | protected: |
33 | void timerEvent( QTimerEvent *e ); | 34 | void timerEvent( QTimerEvent *e ); |
34 | void keyReleaseEvent( QKeyEvent *e); | 35 | void keyReleaseEvent( QKeyEvent *e); |
35 | void doBlank(); | ||
36 | void doUnblank(); | ||
37 | private: | 36 | private: |
37 | bool isBlanked; | ||
38 | int fd; | ||
38 | int volumeDirection; | 39 | int volumeDirection; |
39 | const DocLnk *currentFile; | 40 | const DocLnk *currentFile; |
40 | XineControl *xineControl; | 41 | XineControl *xineControl; |
41 | VolumeControl *volControl; | 42 | VolumeControl *volControl; |
42 | }; | 43 | }; |
43 | 44 | ||
44 | 45 | ||
45 | #endif // MEDIA_PLAYER_H | 46 | #endif // MEDIA_PLAYER_H |
46 | 47 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index bb8d905..6aafb88 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp | |||
@@ -1,269 +1,281 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qpe/qlibrary.h> | 2 | #include <qpe/qlibrary.h> |
3 | #include <qpe/config.h> | 3 | #include <qpe/config.h> |
4 | #include <qvaluelist.h> | 4 | #include <qvaluelist.h> |
5 | #include <qobject.h> | 5 | #include <qobject.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | #include "mediaplayerstate.h" | 7 | #include "mediaplayerstate.h" |
8 | 8 | ||
9 | 9 | ||
10 | 10 | ||
11 | //#define MediaPlayerDebug(x) qDebug x | 11 | //#define MediaPlayerDebug(x) qDebug x |
12 | #define MediaPlayerDebug(x) | 12 | #define MediaPlayerDebug(x) |
13 | 13 | ||
14 | 14 | ||
15 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 15 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
16 | : QObject( parent, name ) { | 16 | : QObject( parent, name ) { |
17 | Config cfg( "OpiePlayer" ); | 17 | Config cfg( "OpiePlayer" ); |
18 | readConfig( cfg ); | 18 | readConfig( cfg ); |
19 | 19 | ||
20 | } | 20 | } |
21 | 21 | ||
22 | 22 | ||
23 | MediaPlayerState::~MediaPlayerState() { | 23 | MediaPlayerState::~MediaPlayerState() { |
24 | Config cfg( "OpiePlayer" ); | 24 | Config cfg( "OpiePlayer" ); |
25 | writeConfig( cfg ); | 25 | writeConfig( cfg ); |
26 | 26 | ||
27 | } | 27 | } |
28 | 28 | ||
29 | 29 | ||
30 | void MediaPlayerState::readConfig( Config& cfg ) { | 30 | void MediaPlayerState::readConfig( Config& cfg ) { |
31 | cfg.setGroup("Options"); | 31 | cfg.setGroup("Options"); |
32 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); | 32 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); |
33 | isScaled = cfg.readBoolEntry( "Scaling" ); | 33 | isScaled = cfg.readBoolEntry( "Scaling" ); |
34 | isLooping = cfg.readBoolEntry( "Looping" ); | 34 | isLooping = cfg.readBoolEntry( "Looping" ); |
35 | isShuffled = cfg.readBoolEntry( "Shuffle" ); | 35 | isShuffled = cfg.readBoolEntry( "Shuffle" ); |
36 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); | 36 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); |
37 | usePlaylist = TRUE; | 37 | usePlaylist = TRUE; |
38 | isPlaying = FALSE; | 38 | isPlaying = FALSE; |
39 | isPaused = FALSE; | 39 | isPaused = FALSE; |
40 | curPosition = 0; | 40 | curPosition = 0; |
41 | curLength = 0; | 41 | curLength = 0; |
42 | curView = 'l'; | 42 | curView = 'l'; |
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
46 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 46 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
47 | cfg.setGroup("Options"); | 47 | cfg.setGroup("Options"); |
48 | cfg.writeEntry("FullScreen", isFullscreen ); | 48 | cfg.writeEntry("FullScreen", isFullscreen ); |
49 | cfg.writeEntry("Scaling", isScaled ); | 49 | cfg.writeEntry("Scaling", isScaled ); |
50 | cfg.writeEntry("Looping", isLooping ); | 50 | cfg.writeEntry("Looping", isLooping ); |
51 | cfg.writeEntry("Shuffle", isShuffled ); | 51 | cfg.writeEntry("Shuffle", isShuffled ); |
52 | cfg.writeEntry("UsePlayList", usePlaylist ); | 52 | cfg.writeEntry("UsePlayList", usePlaylist ); |
53 | } | 53 | } |
54 | 54 | ||
55 | 55 | ||
56 | // public stuff | 56 | // public stuff |
57 | 57 | ||
58 | 58 | ||
59 | bool MediaPlayerState::streaming() { | 59 | bool MediaPlayerState::streaming() { |
60 | return isStreaming; | 60 | return isStreaming; |
61 | } | 61 | } |
62 | 62 | ||
63 | bool MediaPlayerState::fullscreen() { | 63 | bool MediaPlayerState::fullscreen() { |
64 | return isFullscreen; | 64 | return isFullscreen; |
65 | } | 65 | } |
66 | 66 | ||
67 | bool MediaPlayerState::scaled() { | 67 | bool MediaPlayerState::scaled() { |
68 | return isScaled; | 68 | return isScaled; |
69 | } | 69 | } |
70 | 70 | ||
71 | bool MediaPlayerState::looping() { | 71 | bool MediaPlayerState::looping() { |
72 | return isLooping; | 72 | return isLooping; |
73 | } | 73 | } |
74 | 74 | ||
75 | bool MediaPlayerState::shuffled() { | 75 | bool MediaPlayerState::shuffled() { |
76 | return isShuffled; | 76 | return isShuffled; |
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | bool MediaPlayerState:: playlist() { | 80 | bool MediaPlayerState:: playlist() { |
81 | return usePlaylist; | 81 | return usePlaylist; |
82 | } | 82 | } |
83 | 83 | ||
84 | bool MediaPlayerState::paused() { | 84 | bool MediaPlayerState::paused() { |
85 | return isPaused; | 85 | return isPaused; |
86 | } | 86 | } |
87 | 87 | ||
88 | bool MediaPlayerState::playing() { | 88 | bool MediaPlayerState::playing() { |
89 | return isPlaying; | 89 | return isPlaying; |
90 | } | 90 | } |
91 | 91 | ||
92 | bool MediaPlayerState::stop() { | 92 | bool MediaPlayerState::stop() { |
93 | return isStoped; | 93 | return isStoped; |
94 | } | 94 | } |
95 | 95 | ||
96 | long MediaPlayerState::position() { | 96 | long MediaPlayerState::position() { |
97 | return curPosition; | 97 | return curPosition; |
98 | } | 98 | } |
99 | 99 | ||
100 | long MediaPlayerState::length() { | 100 | long MediaPlayerState::length() { |
101 | return curLength; | 101 | return curLength; |
102 | } | 102 | } |
103 | 103 | ||
104 | char MediaPlayerState::view() { | 104 | char MediaPlayerState::view() { |
105 | return curView; | 105 | return curView; |
106 | } | 106 | } |
107 | 107 | ||
108 | // slots | 108 | // slots |
109 | void MediaPlayerState::setIsStreaming( bool b ) { | 109 | void MediaPlayerState::setIsStreaming( bool b ) { |
110 | 110 | ||
111 | if ( isStreaming == b ) { | 111 | if ( isStreaming == b ) { |
112 | return; | 112 | return; |
113 | } | 113 | } |
114 | isStreaming = b; | 114 | isStreaming = b; |
115 | } | 115 | } |
116 | 116 | ||
117 | 117 | ||
118 | void MediaPlayerState::setFullscreen( bool b ) { | 118 | void MediaPlayerState::setBlank( bool b ) { |
119 | if ( isFullscreen == b ) { | 119 | if ( isFullscreen == b ) { |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | isFullscreen = b; | 122 | isFullscreen = b; |
123 | emit fullscreenToggled(b); | 123 | emit fullscreenToggled(b); |
124 | } | 124 | } |
125 | 125 | ||
126 | 126 | ||
127 | void MediaPlayerState::setFullscreen( bool b ) { | ||
128 | if ( isBlanked == b ) { | ||
129 | return; | ||
130 | } | ||
131 | isBlanked = b; | ||
132 | emit blankToggled(b); | ||
133 | } | ||
134 | |||
135 | |||
127 | void MediaPlayerState::setScaled( bool b ) { | 136 | void MediaPlayerState::setScaled( bool b ) { |
128 | if ( isScaled == b ) { | 137 | if ( isScaled == b ) { |
129 | return; | 138 | return; |
130 | } | 139 | } |
131 | isScaled = b; | 140 | isScaled = b; |
132 | emit scaledToggled(b); | 141 | emit scaledToggled(b); |
133 | } | 142 | } |
134 | 143 | ||
135 | void MediaPlayerState::setLooping( bool b ) { | 144 | void MediaPlayerState::setLooping( bool b ) { |
136 | if ( isLooping == b ) { | 145 | if ( isLooping == b ) { |
137 | return; | 146 | return; |
138 | } | 147 | } |
139 | isLooping = b; | 148 | isLooping = b; |
140 | emit loopingToggled(b); | 149 | emit loopingToggled(b); |
141 | } | 150 | } |
142 | 151 | ||
143 | void MediaPlayerState::setShuffled( bool b ) { | 152 | void MediaPlayerState::setShuffled( bool b ) { |
144 | if ( isShuffled == b ) { | 153 | if ( isShuffled == b ) { |
145 | return; | 154 | return; |
146 | } | 155 | } |
147 | isShuffled = b; | 156 | isShuffled = b; |
148 | emit shuffledToggled(b); | 157 | emit shuffledToggled(b); |
149 | } | 158 | } |
150 | 159 | ||
151 | void MediaPlayerState::setPlaylist( bool b ) { | 160 | void MediaPlayerState::setPlaylist( bool b ) { |
152 | if ( usePlaylist == b ) { | 161 | if ( usePlaylist == b ) { |
153 | return; | 162 | return; |
154 | } | 163 | } |
155 | usePlaylist = b; | 164 | usePlaylist = b; |
156 | emit playlistToggled(b); | 165 | emit playlistToggled(b); |
157 | } | 166 | } |
158 | 167 | ||
159 | void MediaPlayerState::setPaused( bool b ) { | 168 | void MediaPlayerState::setPaused( bool b ) { |
160 | if ( isPaused == b ) { | 169 | if ( isPaused == b ) { |
161 | isPaused = FALSE; | 170 | isPaused = FALSE; |
162 | emit pausedToggled(FALSE); | 171 | emit pausedToggled(FALSE); |
163 | return; | 172 | return; |
164 | } | 173 | } |
165 | isPaused = b; | 174 | isPaused = b; |
166 | emit pausedToggled(b); | 175 | emit pausedToggled(b); |
167 | } | 176 | } |
168 | 177 | ||
169 | void MediaPlayerState::setPlaying( bool b ) { | 178 | void MediaPlayerState::setPlaying( bool b ) { |
170 | if ( isPlaying == b ) { | 179 | if ( isPlaying == b ) { |
171 | return; | 180 | return; |
172 | } | 181 | } |
173 | isPlaying = b; | 182 | isPlaying = b; |
174 | isStoped = !b; | 183 | isStoped = !b; |
175 | emit playingToggled(b); | 184 | emit playingToggled(b); |
176 | } | 185 | } |
177 | 186 | ||
178 | void MediaPlayerState::setStop( bool b ) { | 187 | void MediaPlayerState::setStop( bool b ) { |
179 | if ( isStoped == b ) { | 188 | if ( isStoped == b ) { |
180 | return; | 189 | return; |
181 | } | 190 | } |
182 | isStoped = b; | 191 | isStoped = b; |
183 | emit stopToggled(b); | 192 | emit stopToggled(b); |
184 | } | 193 | } |
185 | 194 | ||
186 | void MediaPlayerState::setPosition( long p ) { | 195 | void MediaPlayerState::setPosition( long p ) { |
187 | if ( curPosition == p ) { | 196 | if ( curPosition == p ) { |
188 | return; | 197 | return; |
189 | } | 198 | } |
190 | curPosition = p; | 199 | curPosition = p; |
191 | emit positionChanged(p); | 200 | emit positionChanged(p); |
192 | } | 201 | } |
193 | 202 | ||
194 | void MediaPlayerState::updatePosition( long p ){ | 203 | void MediaPlayerState::updatePosition( long p ){ |
195 | if ( curPosition == p ) { | 204 | if ( curPosition == p ) { |
196 | return; | 205 | return; |
197 | } | 206 | } |
198 | curPosition = p; | 207 | curPosition = p; |
199 | emit positionUpdated(p); | 208 | emit positionUpdated(p); |
200 | } | 209 | } |
201 | 210 | ||
202 | void MediaPlayerState::setLength( long l ) { | 211 | void MediaPlayerState::setLength( long l ) { |
203 | if ( curLength == l ) { | 212 | if ( curLength == l ) { |
204 | return; | 213 | return; |
205 | } | 214 | } |
206 | curLength = l; | 215 | curLength = l; |
207 | emit lengthChanged(l); | 216 | emit lengthChanged(l); |
208 | } | 217 | } |
209 | 218 | ||
210 | void MediaPlayerState::setView( char v ) { | 219 | void MediaPlayerState::setView( char v ) { |
211 | if ( curView == v ) { | 220 | if ( curView == v ) { |
212 | return; | 221 | return; |
213 | } | 222 | } |
214 | curView = v; | 223 | curView = v; |
215 | emit viewChanged(v); | 224 | emit viewChanged(v); |
216 | } | 225 | } |
217 | 226 | ||
218 | void MediaPlayerState::setPrev(){ | 227 | void MediaPlayerState::setPrev(){ |
219 | emit prev(); | 228 | emit prev(); |
220 | } | 229 | } |
221 | 230 | ||
222 | void MediaPlayerState::setNext() { | 231 | void MediaPlayerState::setNext() { |
223 | emit next(); | 232 | emit next(); |
224 | } | 233 | } |
225 | 234 | ||
226 | void MediaPlayerState::setList() { | 235 | void MediaPlayerState::setList() { |
227 | setPlaying( FALSE ); | 236 | setPlaying( FALSE ); |
228 | setView('l'); | 237 | setView('l'); |
229 | } | 238 | } |
230 | 239 | ||
231 | void MediaPlayerState::setVideo() { | 240 | void MediaPlayerState::setVideo() { |
232 | setView('v'); | 241 | setView('v'); |
233 | } | 242 | } |
234 | 243 | ||
235 | void MediaPlayerState::setAudio() { | 244 | void MediaPlayerState::setAudio() { |
236 | setView('a'); | 245 | setView('a'); |
237 | } | 246 | } |
238 | 247 | ||
239 | void MediaPlayerState::toggleFullscreen() { | 248 | void MediaPlayerState::toggleFullscreen() { |
240 | setFullscreen( !isFullscreen ); | 249 | setFullscreen( !isFullscreen ); |
241 | } | 250 | } |
242 | 251 | ||
243 | void MediaPlayerState::toggleScaled() { | 252 | void MediaPlayerState::toggleScaled() { |
244 | setScaled( !isScaled); | 253 | setScaled( !isScaled); |
245 | } | 254 | } |
246 | 255 | ||
247 | void MediaPlayerState::toggleLooping() { | 256 | void MediaPlayerState::toggleLooping() { |
248 | setLooping( !isLooping); | 257 | setLooping( !isLooping); |
249 | } | 258 | } |
250 | 259 | ||
251 | void MediaPlayerState::toggleShuffled() { | 260 | void MediaPlayerState::toggleShuffled() { |
252 | setShuffled( !isShuffled); | 261 | setShuffled( !isShuffled); |
253 | } | 262 | } |
254 | 263 | ||
255 | void MediaPlayerState::togglePlaylist() { | 264 | void MediaPlayerState::togglePlaylist() { |
256 | setPlaylist( !usePlaylist); | 265 | setPlaylist( !usePlaylist); |
257 | } | 266 | } |
258 | 267 | ||
259 | void MediaPlayerState::togglePaused() { | 268 | void MediaPlayerState::togglePaused() { |
260 | setPaused( !isPaused); | 269 | setPaused( !isPaused); |
261 | } | 270 | } |
262 | 271 | ||
263 | void MediaPlayerState::togglePlaying() { | 272 | void MediaPlayerState::togglePlaying() { |
264 | setPlaying( !isPlaying); | 273 | setPlaying( !isPlaying); |
265 | } | 274 | } |
266 | 275 | ||
276 | void MediaPlayerState::toggleBlank() { | ||
277 | setBlank( !isBlanked); | ||
278 | } | ||
267 | 279 | ||
268 | 280 | ||
269 | 281 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h index 887c527..3baffd3 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.h +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h | |||
@@ -1,132 +1,135 @@ | |||
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 MEDIA_PLAYER_STATE_H | 34 | #ifndef MEDIA_PLAYER_STATE_H |
35 | #define MEDIA_PLAYER_STATE_H | 35 | #define MEDIA_PLAYER_STATE_H |
36 | 36 | ||
37 | 37 | ||
38 | #include <qobject.h> | 38 | #include <qobject.h> |
39 | 39 | ||
40 | 40 | ||
41 | class MediaPlayerDecoder; | 41 | class MediaPlayerDecoder; |
42 | class Config; | 42 | class Config; |
43 | 43 | ||
44 | 44 | ||
45 | class MediaPlayerState : public QObject { | 45 | class MediaPlayerState : public QObject { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | public: | 47 | public: |
48 | MediaPlayerState( QObject *parent, const char *name ); | 48 | MediaPlayerState( QObject *parent, const char *name ); |
49 | ~MediaPlayerState(); | 49 | ~MediaPlayerState(); |
50 | 50 | ||
51 | bool isPaused; | 51 | bool isPaused; |
52 | bool isPlaying; | 52 | bool isPlaying; |
53 | bool isStoped; | 53 | bool isStoped; |
54 | bool streaming(); | 54 | bool streaming(); |
55 | bool fullscreen(); | 55 | bool fullscreen(); |
56 | bool scaled(); | 56 | bool scaled(); |
57 | bool looping(); | 57 | bool looping(); |
58 | bool shuffled(); | 58 | bool shuffled(); |
59 | bool playlist(); | 59 | bool playlist(); |
60 | bool paused(); | 60 | bool paused(); |
61 | bool playing(); | 61 | bool playing(); |
62 | bool stop(); | 62 | bool stop(); |
63 | long position(); | 63 | long position(); |
64 | long length(); | 64 | long length(); |
65 | char view(); | 65 | char view(); |
66 | 66 | ||
67 | public slots: | 67 | public slots: |
68 | void setIsStreaming( bool b ); | 68 | void setIsStreaming( bool b ); |
69 | void setFullscreen( bool b ); | 69 | void setFullscreen( bool b ); |
70 | void setScaled( bool b ); | 70 | void setScaled( bool b ); |
71 | void setLooping( bool b ); | 71 | void setLooping( bool b ); |
72 | void setShuffled( bool b ); | 72 | void setShuffled( bool b ); |
73 | void setPlaylist( bool b ); | 73 | void setPlaylist( bool b ); |
74 | void setPaused( bool b ); | 74 | void setPaused( bool b ); |
75 | void setPlaying( bool b ); | 75 | void setPlaying( bool b ); |
76 | void setStop( bool b ); | 76 | void setStop( bool b ); |
77 | void setPosition( long p ); | 77 | void setPosition( long p ); |
78 | void updatePosition( long p ); | 78 | void updatePosition( long p ); |
79 | void setLength( long l ); | 79 | void setLength( long l ); |
80 | void setView( char v ); | 80 | void setView( char v ); |
81 | void setBlank( bool b ); | ||
81 | 82 | ||
82 | void setPrev(); | 83 | void setPrev(); |
83 | void setNext(); | 84 | void setNext(); |
84 | void setList(); | 85 | void setList(); |
85 | void setVideo(); | 86 | void setVideo(); |
86 | void setAudio(); | 87 | void setAudio(); |
87 | 88 | ||
88 | void toggleFullscreen(); | 89 | void toggleFullscreen(); |
89 | void toggleScaled(); | 90 | void toggleScaled(); |
90 | void toggleLooping(); | 91 | void toggleLooping(); |
91 | void toggleShuffled(); | 92 | void toggleShuffled(); |
92 | void togglePlaylist(); | 93 | void togglePlaylist(); |
93 | void togglePaused(); | 94 | void togglePaused(); |
94 | void togglePlaying(); | 95 | void togglePlaying(); |
96 | void toggleBlank(); | ||
95 | 97 | ||
96 | signals: | 98 | signals: |
97 | void fullscreenToggled( bool ); | 99 | void fullscreenToggled( bool ); |
98 | void scaledToggled( bool ); | 100 | void scaledToggled( bool ); |
99 | void loopingToggled( bool ); | 101 | void loopingToggled( bool ); |
100 | void shuffledToggled( bool ); | 102 | void shuffledToggled( bool ); |
101 | void playlistToggled( bool ); | 103 | void playlistToggled( bool ); |
102 | void pausedToggled( bool ); | 104 | void pausedToggled( bool ); |
103 | void playingToggled( bool ); | 105 | void playingToggled( bool ); |
104 | void stopToggled( bool ); | 106 | void stopToggled( bool ); |
105 | void positionChanged( long ); // When the slider is moved | 107 | void positionChanged( long ); // When the slider is moved |
106 | void positionUpdated( long ); // When the media file progresses | 108 | void positionUpdated( long ); // When the media file progresses |
107 | void lengthChanged( long ); | 109 | void lengthChanged( long ); |
108 | void viewChanged( char ); | 110 | void viewChanged( char ); |
109 | 111 | void blankToggled( bool ); | |
110 | void prev(); | 112 | void prev(); |
111 | void next(); | 113 | void next(); |
112 | 114 | ||
113 | private: | 115 | private: |
114 | bool isStreaming; | 116 | bool isStreaming; |
115 | bool isFullscreen; | 117 | bool isFullscreen; |
116 | bool isScaled; | 118 | bool isScaled; |
119 | bool isBlanked; | ||
117 | bool isLooping; | 120 | bool isLooping; |
118 | bool isShuffled; | 121 | bool isShuffled; |
119 | bool usePlaylist; | 122 | bool usePlaylist; |
120 | long curPosition; | 123 | long curPosition; |
121 | long curLength; | 124 | long curLength; |
122 | char curView; | 125 | char curView; |
123 | 126 | ||
124 | void readConfig( Config& cfg ); | 127 | void readConfig( Config& cfg ); |
125 | void writeConfig( Config& cfg ) const; | 128 | void writeConfig( Config& cfg ) const; |
126 | 129 | ||
127 | 130 | ||
128 | }; | 131 | }; |
129 | 132 | ||
130 | 133 | ||
131 | #endif // MEDIA_PLAYER_STATE_H | 134 | #endif // MEDIA_PLAYER_STATE_H |
132 | 135 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 6dcc842..0cfd720 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1293 +1,1260 @@ | |||
1 | 1 | ||
2 | #define QTOPIA_INTERNAL_FSLP | 2 | #define QTOPIA_INTERNAL_FSLP |
3 | #include <qpe/qcopenvelope_qws.h> | ||
4 | |||
5 | #include <qpe/qpemenubar.h> | 3 | #include <qpe/qpemenubar.h> |
6 | #include <qpe/qpetoolbar.h> | 4 | #include <qpe/qpetoolbar.h> |
7 | #include <qpe/fileselector.h> | 5 | #include <qpe/fileselector.h> |
8 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/lnkproperties.h> | 7 | #include <qpe/lnkproperties.h> |
10 | #include <qpe/storage.h> | 8 | #include <qpe/storage.h> |
11 | 9 | ||
12 | #include <qpe/applnk.h> | 10 | #include <qpe/applnk.h> |
13 | #include <qpopupmenu.h> | 11 | #include <qpopupmenu.h> |
14 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
15 | #include <qpe/global.h> | 13 | #include <qpe/global.h> |
16 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
17 | #include <qaction.h> | 15 | #include <qaction.h> |
18 | #include <qcursor.h> | 16 | #include <qcursor.h> |
19 | #include <qimage.h> | 17 | #include <qimage.h> |
20 | #include <qfile.h> | 18 | #include <qfile.h> |
21 | #include <qdir.h> | 19 | #include <qdir.h> |
22 | #include <qlayout.h> | 20 | #include <qlayout.h> |
23 | #include <qlabel.h> | 21 | #include <qlabel.h> |
24 | #include <qlist.h> | 22 | #include <qlist.h> |
25 | #include <qlistbox.h> | 23 | #include <qlistbox.h> |
26 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
27 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
28 | #include <qtoolbutton.h> | 26 | #include <qtoolbutton.h> |
29 | #include <qtabwidget.h> | 27 | #include <qtabwidget.h> |
30 | #include <qlistview.h> | 28 | #include <qlistview.h> |
31 | #include <qpoint.h> | 29 | #include <qpoint.h> |
32 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
34 | #include <qregexp.h> | 32 | #include <qregexp.h> |
35 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
36 | 34 | ||
37 | 35 | ||
38 | #include "playlistselection.h" | 36 | #include "playlistselection.h" |
39 | #include "playlistwidget.h" | 37 | #include "playlistwidget.h" |
40 | #include "mediaplayerstate.h" | 38 | #include "mediaplayerstate.h" |
41 | 39 | ||
42 | #include "inputDialog.h" | 40 | #include "inputDialog.h" |
43 | 41 | ||
44 | #include <stdlib.h> | 42 | #include <stdlib.h> |
45 | #include "audiowidget.h" | 43 | #include "audiowidget.h" |
46 | #include "videowidget.h" | 44 | #include "videowidget.h" |
47 | 45 | ||
48 | #include <unistd.h> | ||
49 | #include <sys/file.h> | ||
50 | #include <sys/ioctl.h> | ||
51 | #include <sys/soundcard.h> | ||
52 | |||
53 | // for setBacklight() | ||
54 | #include <linux/fb.h> | ||
55 | #include <sys/types.h> | ||
56 | #include <sys/stat.h> | ||
57 | #include <stdlib.h> | ||
58 | |||
59 | #define BUTTONS_ON_TOOLBAR | 46 | #define BUTTONS_ON_TOOLBAR |
60 | #define SIDE_BUTTONS | 47 | #define SIDE_BUTTONS |
61 | #define CAN_SAVE_LOAD_PLAYLISTS | 48 | #define CAN_SAVE_LOAD_PLAYLISTS |
62 | 49 | ||
63 | extern MediaPlayerState *mediaPlayerState; | 50 | extern MediaPlayerState *mediaPlayerState; |
64 | 51 | ||
65 | 52 | ||
66 | class PlayListWidgetPrivate { | 53 | class PlayListWidgetPrivate { |
67 | public: | 54 | public: |
68 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 55 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
69 | QFrame *playListFrame; | 56 | QFrame *playListFrame; |
70 | FileSelector *files; | 57 | FileSelector *files; |
71 | PlayListSelection *selectedFiles; | 58 | PlayListSelection *selectedFiles; |
72 | bool setDocumentUsed; | 59 | bool setDocumentUsed; |
73 | DocLnk *current; | 60 | DocLnk *current; |
74 | }; | 61 | }; |
75 | 62 | ||
76 | 63 | ||
77 | class ToolButton : public QToolButton { | 64 | class ToolButton : public QToolButton { |
78 | public: | 65 | public: |
79 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 66 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
80 | : QToolButton( parent, name ) { | 67 | : QToolButton( parent, name ) { |
81 | setTextLabel( name ); | 68 | setTextLabel( name ); |
82 | setPixmap( Resource::loadPixmap( icon ) ); | 69 | setPixmap( Resource::loadPixmap( icon ) ); |
83 | setAutoRaise( TRUE ); | 70 | setAutoRaise( TRUE ); |
84 | setFocusPolicy( QWidget::NoFocus ); | 71 | setFocusPolicy( QWidget::NoFocus ); |
85 | setToggleButton( t ); | 72 | setToggleButton( t ); |
86 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 73 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
87 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 74 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
88 | } | 75 | } |
89 | }; | 76 | }; |
90 | 77 | ||
91 | 78 | ||
92 | class MenuItem : public QAction { | 79 | class MenuItem : public QAction { |
93 | public: | 80 | public: |
94 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 81 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
95 | : QAction( text, QString::null, 0, 0 ) { | 82 | : QAction( text, QString::null, 0, 0 ) { |
96 | connect( this, SIGNAL( activated() ), handler, slot ); | 83 | connect( this, SIGNAL( activated() ), handler, slot ); |
97 | addTo( parent ); | 84 | addTo( parent ); |
98 | } | 85 | } |
99 | }; | 86 | }; |
100 | 87 | ||
101 | 88 | ||
102 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 89 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
103 | : QMainWindow( parent, name, fl ) { | 90 | : QMainWindow( parent, name, fl ) { |
104 | 91 | ||
105 | d = new PlayListWidgetPrivate; | 92 | d = new PlayListWidgetPrivate; |
106 | d->setDocumentUsed = FALSE; | 93 | d->setDocumentUsed = FALSE; |
107 | d->current = NULL; | 94 | d->current = NULL; |
108 | fromSetDocument = FALSE; | 95 | fromSetDocument = FALSE; |
109 | insanityBool=FALSE; | 96 | insanityBool=FALSE; |
110 | audioScan = FALSE; | 97 | audioScan = FALSE; |
111 | videoScan = FALSE; | 98 | videoScan = FALSE; |
112 | 99 | ||
113 | setBackgroundMode( PaletteButton ); | 100 | setBackgroundMode( PaletteButton ); |
114 | 101 | ||
115 | setCaption( tr("OpiePlayer") ); | 102 | setCaption( tr("OpiePlayer") ); |
116 | setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) ); | 103 | setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) ); |
117 | 104 | ||
118 | setToolBarsMovable( FALSE ); | 105 | setToolBarsMovable( FALSE ); |
119 | 106 | ||
120 | // Create Toolbar | 107 | // Create Toolbar |
121 | QPEToolBar *toolbar = new QPEToolBar( this ); | 108 | QPEToolBar *toolbar = new QPEToolBar( this ); |
122 | toolbar->setHorizontalStretchable( TRUE ); | 109 | toolbar->setHorizontalStretchable( TRUE ); |
123 | 110 | ||
124 | // Create Menubar | 111 | // Create Menubar |
125 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 112 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
126 | menu->setMargin( 0 ); | 113 | menu->setMargin( 0 ); |
127 | 114 | ||
128 | QPEToolBar *bar = new QPEToolBar( this ); | 115 | QPEToolBar *bar = new QPEToolBar( this ); |
129 | bar->setLabel( tr( "Play Operations" ) ); | 116 | bar->setLabel( tr( "Play Operations" ) ); |
130 | 117 | ||
131 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 118 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
132 | tbDeletePlaylist->setFlat(TRUE); | 119 | tbDeletePlaylist->setFlat(TRUE); |
133 | tbDeletePlaylist->setFixedSize(20,20); | 120 | tbDeletePlaylist->setFixedSize(20,20); |
134 | 121 | ||
135 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", | 122 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", |
136 | this , SLOT(addSelected()) ); | 123 | this , SLOT(addSelected()) ); |
137 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", | 124 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", |
138 | this , SLOT(removeSelected()) ); | 125 | this , SLOT(removeSelected()) ); |
139 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 126 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
140 | this , SLOT( btnPlay(bool) ), TRUE ); | 127 | this , SLOT( btnPlay(bool) ), TRUE ); |
141 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 128 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
142 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 129 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
143 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", | 130 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", |
144 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 131 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
145 | tbDeletePlaylist->hide(); | 132 | tbDeletePlaylist->hide(); |
146 | 133 | ||
147 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 134 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
148 | menu->insertItem( tr( "File" ), pmPlayList ); | 135 | menu->insertItem( tr( "File" ), pmPlayList ); |
149 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 136 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
150 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 137 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
151 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 138 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
152 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 139 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
153 | pmPlayList->insertSeparator(-1); | 140 | pmPlayList->insertSeparator(-1); |
154 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 141 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
155 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | 142 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); |
156 | pmPlayList->insertSeparator(-1); | 143 | pmPlayList->insertSeparator(-1); |
157 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 144 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
158 | pmPlayList->insertSeparator(-1); | 145 | pmPlayList->insertSeparator(-1); |
159 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 146 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
160 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 147 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
161 | 148 | ||
162 | 149 | ||
163 | pmView = new QPopupMenu( this ); | 150 | pmView = new QPopupMenu( this ); |
164 | menu->insertItem( tr( "View" ), pmView ); | 151 | menu->insertItem( tr( "View" ), pmView ); |
165 | pmView->isCheckable(); | 152 | pmView->isCheckable(); |
166 | 153 | ||
167 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); | 154 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); |
168 | 155 | ||
169 | Config cfg( "OpiePlayer" ); | 156 | Config cfg( "OpiePlayer" ); |
170 | bool b= cfg.readBoolEntry("FullScreen", 0); | 157 | bool b= cfg.readBoolEntry("FullScreen", 0); |
171 | mediaPlayerState->setFullscreen( b ); | 158 | mediaPlayerState->setFullscreen( b ); |
172 | pmView->setItemChecked( -16, b ); | 159 | pmView->setItemChecked( -16, b ); |
173 | 160 | ||
174 | // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); | 161 | // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); |
175 | 162 | ||
176 | pmView->insertSeparator(-1); | 163 | pmView->insertSeparator(-1); |
177 | 164 | ||
178 | skinsMenu = new QPopupMenu( this ); | 165 | skinsMenu = new QPopupMenu( this ); |
179 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | 166 | pmView->insertItem( tr( "Skins" ), skinsMenu ); |
180 | skinsMenu->isCheckable(); | 167 | skinsMenu->isCheckable(); |
181 | populateSkinsMenu(); | 168 | populateSkinsMenu(); |
182 | 169 | ||
183 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 170 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
184 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 171 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
185 | 172 | ||
186 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 173 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
187 | 174 | ||
188 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 175 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
189 | // tabWidget->setTabShape(QTabWidget::Triangular); | 176 | // tabWidget->setTabShape(QTabWidget::Triangular); |
190 | 177 | ||
191 | QWidget *pTab; | 178 | QWidget *pTab; |
192 | pTab = new QWidget( tabWidget, "pTab" ); | 179 | pTab = new QWidget( tabWidget, "pTab" ); |
193 | tabWidget->insertTab( pTab,"Playlist"); | 180 | tabWidget->insertTab( pTab,"Playlist"); |
194 | 181 | ||
195 | 182 | ||
196 | // Add the playlist area | 183 | // Add the playlist area |
197 | 184 | ||
198 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 185 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
199 | d->playListFrame = vbox3; | 186 | d->playListFrame = vbox3; |
200 | d->playListFrame ->setMinimumSize(235,250); | 187 | d->playListFrame ->setMinimumSize(235,250); |
201 | 188 | ||
202 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 189 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
203 | 190 | ||
204 | d->selectedFiles = new PlayListSelection( hbox2); | 191 | d->selectedFiles = new PlayListSelection( hbox2); |
205 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 192 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
206 | 193 | ||
207 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 194 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
208 | 195 | ||
209 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 196 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
210 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 197 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
211 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); | 198 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); |
212 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 199 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
213 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 200 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
214 | 201 | ||
215 | QWidget *aTab; | 202 | QWidget *aTab; |
216 | aTab = new QWidget( tabWidget, "aTab" ); | 203 | aTab = new QWidget( tabWidget, "aTab" ); |
217 | audioView = new QListView( aTab, "Audioview" ); | 204 | audioView = new QListView( aTab, "Audioview" ); |
218 | audioView->setMinimumSize(233,250); | 205 | audioView->setMinimumSize(233,250); |
219 | audioView->addColumn( tr("Title"),140); | 206 | audioView->addColumn( tr("Title"),140); |
220 | audioView->addColumn(tr("Size"), -1); | 207 | audioView->addColumn(tr("Size"), -1); |
221 | audioView->addColumn(tr("Media"),-1); | 208 | audioView->addColumn(tr("Media"),-1); |
222 | audioView->setColumnAlignment(1, Qt::AlignRight); | 209 | audioView->setColumnAlignment(1, Qt::AlignRight); |
223 | audioView->setColumnAlignment(2, Qt::AlignRight); | 210 | audioView->setColumnAlignment(2, Qt::AlignRight); |
224 | audioView->setAllColumnsShowFocus(TRUE); | 211 | audioView->setAllColumnsShowFocus(TRUE); |
225 | 212 | ||
226 | audioView->setMultiSelection( TRUE ); | 213 | audioView->setMultiSelection( TRUE ); |
227 | audioView->setSelectionMode( QListView::Extended); | 214 | audioView->setSelectionMode( QListView::Extended); |
228 | 215 | ||
229 | tabWidget->insertTab(aTab,tr("Audio")); | 216 | tabWidget->insertTab(aTab,tr("Audio")); |
230 | 217 | ||
231 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 218 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
232 | 219 | ||
233 | QWidget *vTab; | 220 | QWidget *vTab; |
234 | vTab = new QWidget( tabWidget, "vTab" ); | 221 | vTab = new QWidget( tabWidget, "vTab" ); |
235 | videoView = new QListView( vTab, "Videoview" ); | 222 | videoView = new QListView( vTab, "Videoview" ); |
236 | videoView->setMinimumSize(233,250); | 223 | videoView->setMinimumSize(233,250); |
237 | 224 | ||
238 | videoView->addColumn(tr("Title"),140); | 225 | videoView->addColumn(tr("Title"),140); |
239 | videoView->addColumn(tr("Size"),-1); | 226 | videoView->addColumn(tr("Size"),-1); |
240 | videoView->addColumn(tr("Media"),-1); | 227 | videoView->addColumn(tr("Media"),-1); |
241 | videoView->setColumnAlignment(1, Qt::AlignRight); | 228 | videoView->setColumnAlignment(1, Qt::AlignRight); |
242 | videoView->setColumnAlignment(2, Qt::AlignRight); | 229 | videoView->setColumnAlignment(2, Qt::AlignRight); |
243 | videoView->setAllColumnsShowFocus(TRUE); | 230 | videoView->setAllColumnsShowFocus(TRUE); |
244 | videoView->setMultiSelection( TRUE ); | 231 | videoView->setMultiSelection( TRUE ); |
245 | videoView->setSelectionMode( QListView::Extended); | 232 | videoView->setSelectionMode( QListView::Extended); |
246 | 233 | ||
247 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 234 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
248 | 235 | ||
249 | tabWidget->insertTab( vTab,tr("Video")); | 236 | tabWidget->insertTab( vTab,tr("Video")); |
250 | 237 | ||
251 | //playlists list | 238 | //playlists list |
252 | QWidget *LTab; | 239 | QWidget *LTab; |
253 | LTab = new QWidget( tabWidget, "LTab" ); | 240 | LTab = new QWidget( tabWidget, "LTab" ); |
254 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 241 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
255 | playLists->setMinimumSize(233,260); | 242 | playLists->setMinimumSize(233,260); |
256 | tabWidget->insertTab(LTab,tr("Lists")); | 243 | tabWidget->insertTab(LTab,tr("Lists")); |
257 | 244 | ||
258 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 245 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
259 | 246 | ||
260 | connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); | 247 | connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); |
261 | 248 | ||
262 | connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); | 249 | connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); |
263 | 250 | ||
264 | // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); | 251 | // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); |
265 | 252 | ||
266 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 253 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
267 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 254 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
268 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 255 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
269 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 256 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
270 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 257 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
271 | this,SLOT( playIt( QListViewItem *)) ); | 258 | this,SLOT( playIt( QListViewItem *)) ); |
272 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 259 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
273 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 260 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
274 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 261 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
275 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 262 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
276 | this,SLOT( playIt( QListViewItem *)) ); | 263 | this,SLOT( playIt( QListViewItem *)) ); |
277 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 264 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
278 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 265 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
279 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 266 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
280 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 267 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
281 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 268 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
282 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 269 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
283 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 270 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
284 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 271 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
285 | 272 | ||
286 | setCentralWidget( vbox5 ); | 273 | setCentralWidget( vbox5 ); |
287 | 274 | ||
288 | readConfig( cfg ); | 275 | readConfig( cfg ); |
289 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 276 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
290 | loadList(DocLnk( currentPlaylist)); | 277 | loadList(DocLnk( currentPlaylist)); |
291 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 278 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
292 | 279 | ||
293 | initializeStates(); | 280 | initializeStates(); |
294 | } | 281 | } |
295 | 282 | ||
296 | 283 | ||
297 | PlayListWidget::~PlayListWidget() { | 284 | PlayListWidget::~PlayListWidget() { |
298 | Config cfg( "OpiePlayer" ); | 285 | Config cfg( "OpiePlayer" ); |
299 | writeConfig( cfg ); | 286 | writeConfig( cfg ); |
300 | 287 | ||
301 | if ( d->current ) { | 288 | if ( d->current ) { |
302 | delete d->current; | 289 | delete d->current; |
303 | } | 290 | } |
304 | delete d; | 291 | delete d; |
305 | } | 292 | } |
306 | 293 | ||
307 | 294 | ||
308 | void PlayListWidget::initializeStates() { | 295 | void PlayListWidget::initializeStates() { |
309 | 296 | ||
310 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 297 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
311 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 298 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
312 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 299 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
313 | setPlaylist( true); | 300 | setPlaylist( true); |
314 | } | 301 | } |
315 | 302 | ||
316 | 303 | ||
317 | void PlayListWidget::readConfig( Config& cfg ) { | 304 | void PlayListWidget::readConfig( Config& cfg ) { |
318 | cfg.setGroup("PlayList"); | 305 | cfg.setGroup("PlayList"); |
319 | QString currentString = cfg.readEntry("current", "" ); | 306 | QString currentString = cfg.readEntry("current", "" ); |
320 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 307 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
321 | for ( int i = 0; i < noOfFiles; i++ ) { | 308 | for ( int i = 0; i < noOfFiles; i++ ) { |
322 | QString entryName; | 309 | QString entryName; |
323 | entryName.sprintf( "File%i", i + 1 ); | 310 | entryName.sprintf( "File%i", i + 1 ); |
324 | QString linkFile = cfg.readEntry( entryName ); | 311 | QString linkFile = cfg.readEntry( entryName ); |
325 | if(QFileInfo( linkFile).exists() ) { | 312 | if(QFileInfo( linkFile).exists() ) { |
326 | DocLnk lnk( linkFile ); | 313 | DocLnk lnk( linkFile ); |
327 | if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { | 314 | if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { |
328 | d->selectedFiles->addToSelection( lnk ); | 315 | d->selectedFiles->addToSelection( lnk ); |
329 | } | 316 | } |
330 | } | 317 | } |
331 | } | 318 | } |
332 | d->selectedFiles->setSelectedItem( currentString); | 319 | d->selectedFiles->setSelectedItem( currentString); |
333 | } | 320 | } |
334 | 321 | ||
335 | 322 | ||
336 | void PlayListWidget::writeConfig( Config& cfg ) const { | 323 | void PlayListWidget::writeConfig( Config& cfg ) const { |
337 | 324 | ||
338 | d->selectedFiles->writeCurrent( cfg); | 325 | d->selectedFiles->writeCurrent( cfg); |
339 | cfg.setGroup("PlayList"); | 326 | cfg.setGroup("PlayList"); |
340 | int noOfFiles = 0; | 327 | int noOfFiles = 0; |
341 | d->selectedFiles->first(); | 328 | d->selectedFiles->first(); |
342 | do { | 329 | do { |
343 | const DocLnk *lnk = d->selectedFiles->current(); | 330 | const DocLnk *lnk = d->selectedFiles->current(); |
344 | if ( lnk ) { | 331 | if ( lnk ) { |
345 | QString entryName; | 332 | QString entryName; |
346 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 333 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
347 | cfg.writeEntry( entryName, lnk->linkFile() ); | 334 | cfg.writeEntry( entryName, lnk->linkFile() ); |
348 | // if this link does exist, add it so we have the file | 335 | // if this link does exist, add it so we have the file |
349 | // next time... | 336 | // next time... |
350 | if ( !QFile::exists( lnk->linkFile() ) ) { | 337 | if ( !QFile::exists( lnk->linkFile() ) ) { |
351 | // the way writing lnks doesn't really check for out | 338 | // the way writing lnks doesn't really check for out |
352 | // of disk space, but check it anyway. | 339 | // of disk space, but check it anyway. |
353 | if ( !lnk->writeLink() ) { | 340 | if ( !lnk->writeLink() ) { |
354 | QMessageBox::critical( 0, tr("Out of space"), | 341 | QMessageBox::critical( 0, tr("Out of space"), |
355 | tr( "There was a problem saving " | 342 | tr( "There was a problem saving " |
356 | "the playlist.\n" | 343 | "the playlist.\n" |
357 | "Your playlist " | 344 | "Your playlist " |
358 | "may be missing some entries\n" | 345 | "may be missing some entries\n" |
359 | "the next time you start it." ) | 346 | "the next time you start it." ) |
360 | ); | 347 | ); |
361 | } | 348 | } |
362 | } | 349 | } |
363 | noOfFiles++; | 350 | noOfFiles++; |
364 | } | 351 | } |
365 | } | 352 | } |
366 | while ( d->selectedFiles->next() ); | 353 | while ( d->selectedFiles->next() ); |
367 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 354 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
368 | } | 355 | } |
369 | 356 | ||
370 | 357 | ||
371 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 358 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
372 | d->setDocumentUsed = FALSE; | 359 | d->setDocumentUsed = FALSE; |
373 | if ( mediaPlayerState->playlist() ) { | 360 | if ( mediaPlayerState->playlist() ) { |
374 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 361 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
375 | d->selectedFiles->addToSelection( lnk ); | 362 | d->selectedFiles->addToSelection( lnk ); |
376 | } | 363 | } |
377 | else | 364 | else |
378 | mediaPlayerState->setPlaying( TRUE ); | 365 | mediaPlayerState->setPlaying( TRUE ); |
379 | } | 366 | } |
380 | 367 | ||
381 | 368 | ||
382 | void PlayListWidget::clearList() { | 369 | void PlayListWidget::clearList() { |
383 | while ( first() ) { | 370 | while ( first() ) { |
384 | d->selectedFiles->removeSelected(); | 371 | d->selectedFiles->removeSelected(); |
385 | } | 372 | } |
386 | } | 373 | } |
387 | 374 | ||
388 | 375 | ||
389 | void PlayListWidget::addAllToList() { | 376 | void PlayListWidget::addAllToList() { |
390 | DocLnkSet filesAll; | 377 | DocLnkSet filesAll; |
391 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 378 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
392 | QListIterator<DocLnk> Adit( filesAll.children() ); | 379 | QListIterator<DocLnk> Adit( filesAll.children() ); |
393 | for ( ; Adit.current(); ++Adit ) { | 380 | for ( ; Adit.current(); ++Adit ) { |
394 | if(QFileInfo(Adit.current()->file()).exists()) { | 381 | if(QFileInfo(Adit.current()->file()).exists()) { |
395 | d->selectedFiles->addToSelection( **Adit ); | 382 | d->selectedFiles->addToSelection( **Adit ); |
396 | } | 383 | } |
397 | } | 384 | } |
398 | } | 385 | } |
399 | 386 | ||
400 | 387 | ||
401 | void PlayListWidget::addAllMusicToList() { | 388 | void PlayListWidget::addAllMusicToList() { |
402 | QListIterator<DocLnk> dit( files.children() ); | 389 | QListIterator<DocLnk> dit( files.children() ); |
403 | for ( ; dit.current(); ++dit ) { | 390 | for ( ; dit.current(); ++dit ) { |
404 | if(QFileInfo(dit.current()->file()).exists()) { | 391 | if(QFileInfo(dit.current()->file()).exists()) { |
405 | d->selectedFiles->addToSelection( **dit ); | 392 | d->selectedFiles->addToSelection( **dit ); |
406 | } | 393 | } |
407 | } | 394 | } |
408 | } | 395 | } |
409 | 396 | ||
410 | 397 | ||
411 | void PlayListWidget::addAllVideoToList() { | 398 | void PlayListWidget::addAllVideoToList() { |
412 | QListIterator<DocLnk> dit( vFiles.children() ); | 399 | QListIterator<DocLnk> dit( vFiles.children() ); |
413 | for ( ; dit.current(); ++dit ) | 400 | for ( ; dit.current(); ++dit ) |
414 | if(QFileInfo( dit.current()->file()).exists()) | 401 | if(QFileInfo( dit.current()->file()).exists()) |
415 | d->selectedFiles->addToSelection( **dit ); | 402 | d->selectedFiles->addToSelection( **dit ); |
416 | } | 403 | } |
417 | 404 | ||
418 | 405 | ||
419 | void PlayListWidget::setDocument(const QString& fileref) { | 406 | void PlayListWidget::setDocument(const QString& fileref) { |
420 | qDebug(fileref); | 407 | qDebug(fileref); |
421 | fromSetDocument = TRUE; | 408 | fromSetDocument = TRUE; |
422 | if ( fileref.isNull() ) { | 409 | if ( fileref.isNull() ) { |
423 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 410 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
424 | return; | 411 | return; |
425 | } | 412 | } |
426 | 413 | ||
427 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 414 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
428 | readm3u( fileref); | 415 | readm3u( fileref); |
429 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 416 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
430 | readPls( fileref); | 417 | readPls( fileref); |
431 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 418 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
432 | clearList(); | 419 | clearList(); |
433 | loadList(DocLnk(fileref)); | 420 | loadList(DocLnk(fileref)); |
434 | d->selectedFiles->first(); | 421 | d->selectedFiles->first(); |
435 | } else { | 422 | } else { |
436 | clearList(); | 423 | clearList(); |
437 | addToSelection( DocLnk( fileref ) ); | 424 | addToSelection( DocLnk( fileref ) ); |
438 | d->setDocumentUsed = TRUE; | 425 | d->setDocumentUsed = TRUE; |
439 | mediaPlayerState->setPlaying( FALSE ); | 426 | mediaPlayerState->setPlaying( FALSE ); |
440 | qApp->processEvents(); | 427 | qApp->processEvents(); |
441 | mediaPlayerState->setPlaying( TRUE ); | 428 | mediaPlayerState->setPlaying( TRUE ); |
442 | qApp->processEvents(); | 429 | qApp->processEvents(); |
443 | setCaption(tr("OpiePlayer")); | 430 | setCaption(tr("OpiePlayer")); |
444 | } | 431 | } |
445 | } | 432 | } |
446 | 433 | ||
447 | 434 | ||
448 | void PlayListWidget::setActiveWindow() { | 435 | void PlayListWidget::setActiveWindow() { |
449 | qDebug("SETTING active window"); | 436 | qDebug("SETTING active window"); |
450 | // When we get raised we need to ensure that it switches views | 437 | // When we get raised we need to ensure that it switches views |
451 | char origView = mediaPlayerState->view(); | 438 | char origView = mediaPlayerState->view(); |
452 | mediaPlayerState->setView( 'l' ); // invalidate | 439 | mediaPlayerState->setView( 'l' ); // invalidate |
453 | mediaPlayerState->setView( origView ); // now switch back | 440 | mediaPlayerState->setView( origView ); // now switch back |
454 | } | 441 | } |
455 | 442 | ||
456 | 443 | ||
457 | void PlayListWidget::useSelectedDocument() { | 444 | void PlayListWidget::useSelectedDocument() { |
458 | d->setDocumentUsed = FALSE; | 445 | d->setDocumentUsed = FALSE; |
459 | } | 446 | } |
460 | 447 | ||
461 | 448 | ||
462 | const DocLnk *PlayListWidget::current() { // this is fugly | 449 | const DocLnk *PlayListWidget::current() { // this is fugly |
463 | 450 | ||
464 | switch (tabWidget->currentPageIndex()) { | 451 | switch (tabWidget->currentPageIndex()) { |
465 | case 0: //playlist | 452 | case 0: //playlist |
466 | { | 453 | { |
467 | qDebug("playlist"); | 454 | qDebug("playlist"); |
468 | if ( mediaPlayerState->playlist() ) { | 455 | if ( mediaPlayerState->playlist() ) { |
469 | return d->selectedFiles->current(); | 456 | return d->selectedFiles->current(); |
470 | } else if ( d->setDocumentUsed && d->current ) { | 457 | } else if ( d->setDocumentUsed && d->current ) { |
471 | return d->current; | 458 | return d->current; |
472 | } else { | 459 | } else { |
473 | return d->files->selected(); | 460 | return d->files->selected(); |
474 | } | 461 | } |
475 | } | 462 | } |
476 | break; | 463 | break; |
477 | case 1://audio | 464 | case 1://audio |
478 | { | 465 | { |
479 | qDebug("audioView"); | 466 | qDebug("audioView"); |
480 | QListIterator<DocLnk> dit( files.children() ); | 467 | QListIterator<DocLnk> dit( files.children() ); |
481 | for ( ; dit.current(); ++dit ) { | 468 | for ( ; dit.current(); ++dit ) { |
482 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 469 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
483 | qDebug("here"); | 470 | qDebug("here"); |
484 | insanityBool=TRUE; | 471 | insanityBool=TRUE; |
485 | return dit; | 472 | return dit; |
486 | } | 473 | } |
487 | } | 474 | } |
488 | } | 475 | } |
489 | break; | 476 | break; |
490 | case 2: // video | 477 | case 2: // video |
491 | { | 478 | { |
492 | qDebug("videoView"); | 479 | qDebug("videoView"); |
493 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 480 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
494 | for ( ; Vdit.current(); ++Vdit ) { | 481 | for ( ; Vdit.current(); ++Vdit ) { |
495 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 482 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
496 | insanityBool=TRUE; | 483 | insanityBool=TRUE; |
497 | return Vdit; | 484 | return Vdit; |
498 | } | 485 | } |
499 | } | 486 | } |
500 | } | 487 | } |
501 | break; | 488 | break; |
502 | }; | 489 | }; |
503 | return 0; | 490 | return 0; |
504 | } | 491 | } |
505 | 492 | ||
506 | bool PlayListWidget::prev() { | 493 | bool PlayListWidget::prev() { |
507 | if ( mediaPlayerState->playlist() ) { | 494 | if ( mediaPlayerState->playlist() ) { |
508 | if ( mediaPlayerState->shuffled() ) { | 495 | if ( mediaPlayerState->shuffled() ) { |
509 | const DocLnk *cur = current(); | 496 | const DocLnk *cur = current(); |
510 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 497 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
511 | for ( int i = 0; i < j; i++ ) { | 498 | for ( int i = 0; i < j; i++ ) { |
512 | if ( !d->selectedFiles->next() ) | 499 | if ( !d->selectedFiles->next() ) |
513 | d->selectedFiles->first(); | 500 | d->selectedFiles->first(); |
514 | } | 501 | } |
515 | if ( cur == current() ) | 502 | if ( cur == current() ) |
516 | if ( !d->selectedFiles->next() ) | 503 | if ( !d->selectedFiles->next() ) |
517 | d->selectedFiles->first(); | 504 | d->selectedFiles->first(); |
518 | return TRUE; | 505 | return TRUE; |
519 | } else { | 506 | } else { |
520 | if ( !d->selectedFiles->prev() ) { | 507 | if ( !d->selectedFiles->prev() ) { |
521 | if ( mediaPlayerState->looping() ) { | 508 | if ( mediaPlayerState->looping() ) { |
522 | return d->selectedFiles->last(); | 509 | return d->selectedFiles->last(); |
523 | } else { | 510 | } else { |
524 | return FALSE; | 511 | return FALSE; |
525 | } | 512 | } |
526 | } | 513 | } |
527 | return TRUE; | 514 | return TRUE; |
528 | } | 515 | } |
529 | } else { | 516 | } else { |
530 | return mediaPlayerState->looping(); | 517 | return mediaPlayerState->looping(); |
531 | } | 518 | } |
532 | } | 519 | } |
533 | 520 | ||
534 | 521 | ||
535 | bool PlayListWidget::next() { | 522 | bool PlayListWidget::next() { |
536 | if ( mediaPlayerState->playlist() ) { | 523 | if ( mediaPlayerState->playlist() ) { |
537 | if ( mediaPlayerState->shuffled() ) { | 524 | if ( mediaPlayerState->shuffled() ) { |
538 | return prev(); | 525 | return prev(); |
539 | } else { | 526 | } else { |
540 | if ( !d->selectedFiles->next() ) { | 527 | if ( !d->selectedFiles->next() ) { |
541 | if ( mediaPlayerState->looping() ) { | 528 | if ( mediaPlayerState->looping() ) { |
542 | return d->selectedFiles->first(); | 529 | return d->selectedFiles->first(); |
543 | } else { | 530 | } else { |
544 | return FALSE; | 531 | return FALSE; |
545 | } | 532 | } |
546 | } | 533 | } |
547 | return TRUE; | 534 | return TRUE; |
548 | } | 535 | } |
549 | } else { | 536 | } else { |
550 | return mediaPlayerState->looping(); | 537 | return mediaPlayerState->looping(); |
551 | } | 538 | } |
552 | } | 539 | } |
553 | 540 | ||
554 | 541 | ||
555 | bool PlayListWidget::first() { | 542 | bool PlayListWidget::first() { |
556 | if ( mediaPlayerState->playlist() ) | 543 | if ( mediaPlayerState->playlist() ) |
557 | return d->selectedFiles->first(); | 544 | return d->selectedFiles->first(); |
558 | else | 545 | else |
559 | return mediaPlayerState->looping(); | 546 | return mediaPlayerState->looping(); |
560 | } | 547 | } |
561 | 548 | ||
562 | 549 | ||
563 | bool PlayListWidget::last() { | 550 | bool PlayListWidget::last() { |
564 | if ( mediaPlayerState->playlist() ) | 551 | if ( mediaPlayerState->playlist() ) |
565 | return d->selectedFiles->last(); | 552 | return d->selectedFiles->last(); |
566 | else | 553 | else |
567 | return mediaPlayerState->looping(); | 554 | return mediaPlayerState->looping(); |
568 | } | 555 | } |
569 | 556 | ||
570 | 557 | ||
571 | void PlayListWidget::saveList() { | 558 | void PlayListWidget::saveList() { |
572 | 559 | ||
573 | QString filename; | 560 | QString filename; |
574 | InputDialog *fileDlg; | 561 | InputDialog *fileDlg; |
575 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 562 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
576 | fileDlg->exec(); | 563 | fileDlg->exec(); |
577 | if( fileDlg->result() == 1 ) { | 564 | if( fileDlg->result() == 1 ) { |
578 | if ( d->current ) | 565 | if ( d->current ) |
579 | delete d->current; | 566 | delete d->current; |
580 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 567 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
581 | // qDebug("saving playlist "+filename+".playlist"); | 568 | // qDebug("saving playlist "+filename+".playlist"); |
582 | Config cfg( filename +".playlist"); | 569 | Config cfg( filename +".playlist"); |
583 | writeConfig( cfg ); | 570 | writeConfig( cfg ); |
584 | 571 | ||
585 | DocLnk lnk; | 572 | DocLnk lnk; |
586 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 573 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
587 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 574 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
588 | lnk.setIcon("opieplayer2/playlist2"); | 575 | lnk.setIcon("opieplayer2/playlist2"); |
589 | lnk.setName( filename); //sets file name | 576 | lnk.setName( filename); //sets file name |
590 | // qDebug(filename); | 577 | // qDebug(filename); |
591 | if(!lnk.writeLink()) { | 578 | if(!lnk.writeLink()) { |
592 | qDebug("Writing doclink did not work"); | 579 | qDebug("Writing doclink did not work"); |
593 | } | 580 | } |
594 | } | 581 | } |
595 | Config config( "OpiePlayer" ); | 582 | Config config( "OpiePlayer" ); |
596 | config.writeEntry("CurrentPlaylist",filename); | 583 | config.writeEntry("CurrentPlaylist",filename); |
597 | setCaption(tr("OpiePlayer: ")+filename); | 584 | setCaption(tr("OpiePlayer: ")+filename); |
598 | d->selectedFiles->first(); | 585 | d->selectedFiles->first(); |
599 | if(fileDlg) { | 586 | if(fileDlg) { |
600 | delete fileDlg; | 587 | delete fileDlg; |
601 | } | 588 | } |
602 | } | 589 | } |
603 | 590 | ||
604 | void PlayListWidget::loadList( const DocLnk & lnk) { | 591 | void PlayListWidget::loadList( const DocLnk & lnk) { |
605 | QString name= lnk.name(); | 592 | QString name= lnk.name(); |
606 | // qDebug("currentList is "+name); | 593 | // qDebug("currentList is "+name); |
607 | if( name.length()>1) { | 594 | if( name.length()>1) { |
608 | setCaption("OpiePlayer: "+name); | 595 | setCaption("OpiePlayer: "+name); |
609 | // qDebug("load list "+ name+".playlist"); | 596 | // qDebug("load list "+ name+".playlist"); |
610 | clearList(); | 597 | clearList(); |
611 | Config cfg( name+".playlist"); | 598 | Config cfg( name+".playlist"); |
612 | readConfig(cfg); | 599 | readConfig(cfg); |
613 | 600 | ||
614 | tabWidget->setCurrentPage(0); | 601 | tabWidget->setCurrentPage(0); |
615 | 602 | ||
616 | Config config( "OpiePlayer" ); | 603 | Config config( "OpiePlayer" ); |
617 | config.writeEntry("CurrentPlaylist", name); | 604 | config.writeEntry("CurrentPlaylist", name); |
618 | // d->selectedFiles->first(); | 605 | // d->selectedFiles->first(); |
619 | } | 606 | } |
620 | 607 | ||
621 | } | 608 | } |
622 | 609 | ||
623 | void PlayListWidget::setPlaylist( bool shown ) { | 610 | void PlayListWidget::setPlaylist( bool shown ) { |
624 | if ( shown ) { | 611 | if ( shown ) { |
625 | d->playListFrame->show(); | 612 | d->playListFrame->show(); |
626 | } else { | 613 | } else { |
627 | d->playListFrame->hide(); | 614 | d->playListFrame->hide(); |
628 | } | 615 | } |
629 | } | 616 | } |
630 | 617 | ||
631 | void PlayListWidget::setView( char view ) { | 618 | void PlayListWidget::setView( char view ) { |
632 | if ( view == 'l' ) | 619 | if ( view == 'l' ) |
633 | showMaximized(); | 620 | showMaximized(); |
634 | else | 621 | else |
635 | hide(); | 622 | hide(); |
636 | } | 623 | } |
637 | 624 | ||
638 | void PlayListWidget::addSelected() { | 625 | void PlayListWidget::addSelected() { |
639 | 626 | ||
640 | Config cfg( "OpiePlayer" ); | 627 | Config cfg( "OpiePlayer" ); |
641 | cfg.setGroup("PlayList"); | 628 | cfg.setGroup("PlayList"); |
642 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 629 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
643 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 630 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
644 | 631 | ||
645 | switch (tabWidget->currentPageIndex()) { | 632 | switch (tabWidget->currentPageIndex()) { |
646 | case 0: //playlist | 633 | case 0: //playlist |
647 | break; | 634 | break; |
648 | case 1: { //audio | 635 | case 1: { //audio |
649 | QListViewItemIterator it( audioView ); | 636 | QListViewItemIterator it( audioView ); |
650 | // iterate through all items of the listview | 637 | // iterate through all items of the listview |
651 | for ( ; it.current(); ++it ) { | 638 | for ( ; it.current(); ++it ) { |
652 | if ( it.current()->isSelected() ) { | 639 | if ( it.current()->isSelected() ) { |
653 | QListIterator<DocLnk> dit( files.children() ); | 640 | QListIterator<DocLnk> dit( files.children() ); |
654 | for ( ; dit.current(); ++dit ) { | 641 | for ( ; dit.current(); ++dit ) { |
655 | if( dit.current()->name() == it.current()->text(0) ) { | 642 | if( dit.current()->name() == it.current()->text(0) ) { |
656 | if(QFileInfo( dit.current()->file()).exists()) | 643 | if(QFileInfo( dit.current()->file()).exists()) |
657 | d->selectedFiles->addToSelection( **dit ); | 644 | d->selectedFiles->addToSelection( **dit ); |
658 | } | 645 | } |
659 | } | 646 | } |
660 | audioView->setSelected( it.current(),FALSE); | 647 | audioView->setSelected( it.current(),FALSE); |
661 | } | 648 | } |
662 | } | 649 | } |
663 | tabWidget->setCurrentPage(0); | 650 | tabWidget->setCurrentPage(0); |
664 | } | 651 | } |
665 | break; | 652 | break; |
666 | case 2: { // video | 653 | case 2: { // video |
667 | QListViewItemIterator it( videoView ); | 654 | QListViewItemIterator it( videoView ); |
668 | // iterate through all items of the listview | 655 | // iterate through all items of the listview |
669 | for ( ; it.current(); ++it ) { | 656 | for ( ; it.current(); ++it ) { |
670 | if ( it.current()->isSelected() ) { | 657 | if ( it.current()->isSelected() ) { |
671 | QListIterator<DocLnk> dit( vFiles.children() ); | 658 | QListIterator<DocLnk> dit( vFiles.children() ); |
672 | for ( ; dit.current(); ++dit ) { | 659 | for ( ; dit.current(); ++dit ) { |
673 | if( dit.current()->name() == it.current()->text(0) ) { | 660 | if( dit.current()->name() == it.current()->text(0) ) { |
674 | if(QFileInfo( dit.current()->file()).exists()) | 661 | if(QFileInfo( dit.current()->file()).exists()) |
675 | d->selectedFiles->addToSelection( **dit ); | 662 | d->selectedFiles->addToSelection( **dit ); |
676 | } | 663 | } |
677 | } | 664 | } |
678 | videoView->setSelected( it.current(),FALSE); | 665 | videoView->setSelected( it.current(),FALSE); |
679 | } | 666 | } |
680 | } | 667 | } |
681 | tabWidget->setCurrentPage(0); | 668 | tabWidget->setCurrentPage(0); |
682 | } | 669 | } |
683 | break; | 670 | break; |
684 | }; | 671 | }; |
685 | } | 672 | } |
686 | 673 | ||
687 | void PlayListWidget::removeSelected() { | 674 | void PlayListWidget::removeSelected() { |
688 | d->selectedFiles->removeSelected( ); | 675 | d->selectedFiles->removeSelected( ); |
689 | } | 676 | } |
690 | 677 | ||
691 | void PlayListWidget::playIt( QListViewItem *it) { | 678 | void PlayListWidget::playIt( QListViewItem *it) { |
692 | // if(it==NULL) return; | 679 | // if(it==NULL) return; |
693 | qDebug("playIt"); | 680 | qDebug("playIt"); |
694 | mediaPlayerState->setPlaying(FALSE); | 681 | mediaPlayerState->setPlaying(FALSE); |
695 | mediaPlayerState->setPlaying(TRUE); | 682 | mediaPlayerState->setPlaying(TRUE); |
696 | d->selectedFiles->unSelect(); | 683 | d->selectedFiles->unSelect(); |
697 | } | 684 | } |
698 | 685 | ||
699 | void PlayListWidget::addToSelection( QListViewItem *it) { | 686 | void PlayListWidget::addToSelection( QListViewItem *it) { |
700 | d->setDocumentUsed = FALSE; | 687 | d->setDocumentUsed = FALSE; |
701 | 688 | ||
702 | if(it) { | 689 | if(it) { |
703 | switch (tabWidget->currentPageIndex()) { | 690 | switch (tabWidget->currentPageIndex()) { |
704 | case 1: { | 691 | case 1: { |
705 | QListIterator<DocLnk> dit( files.children() ); | 692 | QListIterator<DocLnk> dit( files.children() ); |
706 | for ( ; dit.current(); ++dit ) { | 693 | for ( ; dit.current(); ++dit ) { |
707 | if( dit.current()->name() == it->text(0)) { | 694 | if( dit.current()->name() == it->text(0)) { |
708 | if(QFileInfo( dit.current()->file()).exists()) | 695 | if(QFileInfo( dit.current()->file()).exists()) |
709 | d->selectedFiles->addToSelection( **dit ); | 696 | d->selectedFiles->addToSelection( **dit ); |
710 | } | 697 | } |
711 | } | 698 | } |
712 | } | 699 | } |
713 | break; | 700 | break; |
714 | case 2: { | 701 | case 2: { |
715 | QListIterator<DocLnk> dit( vFiles.children() ); | 702 | QListIterator<DocLnk> dit( vFiles.children() ); |
716 | for ( ; dit.current(); ++dit ) { | 703 | for ( ; dit.current(); ++dit ) { |
717 | if( dit.current()->name() == it->text(0)) { | 704 | if( dit.current()->name() == it->text(0)) { |
718 | if(QFileInfo( dit.current()->file()).exists()) | 705 | if(QFileInfo( dit.current()->file()).exists()) |
719 | d->selectedFiles->addToSelection( **dit ); | 706 | d->selectedFiles->addToSelection( **dit ); |
720 | } | 707 | } |
721 | } | 708 | } |
722 | } | 709 | } |
723 | break; | 710 | break; |
724 | case 0: | 711 | case 0: |
725 | break; | 712 | break; |
726 | }; | 713 | }; |
727 | tabWidget->setCurrentPage(0); | 714 | tabWidget->setCurrentPage(0); |
728 | } | 715 | } |
729 | } | 716 | } |
730 | 717 | ||
731 | void PlayListWidget::tabChanged(QWidget *) { | 718 | void PlayListWidget::tabChanged(QWidget *) { |
732 | 719 | ||
733 | switch ( tabWidget->currentPageIndex()) { | 720 | switch ( tabWidget->currentPageIndex()) { |
734 | case 0: | 721 | case 0: |
735 | { | 722 | { |
736 | if( !tbDeletePlaylist->isHidden()) | 723 | if( !tbDeletePlaylist->isHidden()) |
737 | tbDeletePlaylist->hide(); | 724 | tbDeletePlaylist->hide(); |
738 | d->tbRemoveFromList->setEnabled(TRUE); | 725 | d->tbRemoveFromList->setEnabled(TRUE); |
739 | d->tbAddToList->setEnabled(FALSE); | 726 | d->tbAddToList->setEnabled(FALSE); |
740 | } | 727 | } |
741 | break; | 728 | break; |
742 | case 1: | 729 | case 1: |
743 | { | 730 | { |
744 | audioView->clear(); | 731 | audioView->clear(); |
745 | populateAudioView(); | 732 | populateAudioView(); |
746 | 733 | ||
747 | if( !tbDeletePlaylist->isHidden()) | 734 | if( !tbDeletePlaylist->isHidden()) |
748 | tbDeletePlaylist->hide(); | 735 | tbDeletePlaylist->hide(); |
749 | d->tbRemoveFromList->setEnabled(FALSE); | 736 | d->tbRemoveFromList->setEnabled(FALSE); |
750 | d->tbAddToList->setEnabled(TRUE); | 737 | d->tbAddToList->setEnabled(TRUE); |
751 | } | 738 | } |
752 | break; | 739 | break; |
753 | case 2: | 740 | case 2: |
754 | { | 741 | { |
755 | videoView->clear(); | 742 | videoView->clear(); |
756 | populateVideoView(); | 743 | populateVideoView(); |
757 | if( !tbDeletePlaylist->isHidden()) | 744 | if( !tbDeletePlaylist->isHidden()) |
758 | tbDeletePlaylist->hide(); | 745 | tbDeletePlaylist->hide(); |
759 | d->tbRemoveFromList->setEnabled(FALSE); | 746 | d->tbRemoveFromList->setEnabled(FALSE); |
760 | d->tbAddToList->setEnabled(TRUE); | 747 | d->tbAddToList->setEnabled(TRUE); |
761 | } | 748 | } |
762 | break; | 749 | break; |
763 | case 3: | 750 | case 3: |
764 | { | 751 | { |
765 | if( tbDeletePlaylist->isHidden()) | 752 | if( tbDeletePlaylist->isHidden()) |
766 | tbDeletePlaylist->show(); | 753 | tbDeletePlaylist->show(); |
767 | playLists->reread(); | 754 | playLists->reread(); |
768 | } | 755 | } |
769 | break; | 756 | break; |
770 | }; | 757 | }; |
771 | } | 758 | } |
772 | 759 | ||
773 | void PlayListWidget::btnPlay(bool b) { | 760 | void PlayListWidget::btnPlay(bool b) { |
774 | 761 | ||
775 | // mediaPlayerState->setPlaying(b); | 762 | // mediaPlayerState->setPlaying(b); |
776 | switch ( tabWidget->currentPageIndex()) { | 763 | switch ( tabWidget->currentPageIndex()) { |
777 | case 0: | 764 | case 0: |
778 | { | 765 | { |
779 | mediaPlayerState->setPlaying(b); | 766 | mediaPlayerState->setPlaying(b); |
780 | } | 767 | } |
781 | break; | 768 | break; |
782 | case 1: | 769 | case 1: |
783 | { | 770 | { |
784 | addToSelection( audioView->currentItem() ); | 771 | addToSelection( audioView->currentItem() ); |
785 | mediaPlayerState->setPlaying(b); | 772 | mediaPlayerState->setPlaying(b); |
786 | d->selectedFiles->removeSelected( ); | 773 | d->selectedFiles->removeSelected( ); |
787 | tabWidget->setCurrentPage(1); | 774 | tabWidget->setCurrentPage(1); |
788 | d->selectedFiles->unSelect(); | 775 | d->selectedFiles->unSelect(); |
789 | insanityBool=FALSE; | 776 | insanityBool=FALSE; |
790 | }// audioView->clearSelection(); | 777 | }// audioView->clearSelection(); |
791 | break; | 778 | break; |
792 | case 2: | 779 | case 2: |
793 | { | 780 | { |
794 | addToSelection( videoView->currentItem() ); | 781 | addToSelection( videoView->currentItem() ); |
795 | mediaPlayerState->setPlaying(b); | 782 | mediaPlayerState->setPlaying(b); |
796 | qApp->processEvents(); | 783 | qApp->processEvents(); |
797 | d->selectedFiles->removeSelected( ); | 784 | d->selectedFiles->removeSelected( ); |
798 | tabWidget->setCurrentPage(2); | 785 | tabWidget->setCurrentPage(2); |
799 | d->selectedFiles->unSelect(); | 786 | d->selectedFiles->unSelect(); |
800 | insanityBool=FALSE; | 787 | insanityBool=FALSE; |
801 | }// videoView->clearSelection(); | 788 | }// videoView->clearSelection(); |
802 | break; | 789 | break; |
803 | }; | 790 | }; |
804 | 791 | ||
805 | } | 792 | } |
806 | 793 | ||
807 | void PlayListWidget::deletePlaylist() { | 794 | void PlayListWidget::deletePlaylist() { |
808 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 795 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
809 | (tr("You really want to delete\nthis playlist?")), | 796 | (tr("You really want to delete\nthis playlist?")), |
810 | (tr("Yes")), (tr("No")), 0 )){ | 797 | (tr("Yes")), (tr("No")), 0 )){ |
811 | case 0: // Yes clicked, | 798 | case 0: // Yes clicked, |
812 | QFile().remove(playLists->selected()->file()); | 799 | QFile().remove(playLists->selected()->file()); |
813 | QFile().remove(playLists->selected()->linkFile()); | 800 | QFile().remove(playLists->selected()->linkFile()); |
814 | playLists->reread(); | 801 | playLists->reread(); |
815 | break; | 802 | break; |
816 | case 1: // Cancel | 803 | case 1: // Cancel |
817 | break; | 804 | break; |
818 | }; | 805 | }; |
819 | } | 806 | } |
820 | 807 | ||
821 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 808 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
822 | switch (mouse) { | 809 | switch (mouse) { |
823 | case 1: | 810 | case 1: |
824 | break; | 811 | break; |
825 | case 2:{ | 812 | case 2:{ |
826 | QPopupMenu m; | 813 | QPopupMenu m; |
827 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 814 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
828 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 815 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
829 | m.insertSeparator(); | 816 | m.insertSeparator(); |
830 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 817 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
831 | m.exec( QCursor::pos() ); | 818 | m.exec( QCursor::pos() ); |
832 | } | 819 | } |
833 | break; | 820 | break; |
834 | }; | 821 | }; |
835 | } | 822 | } |
836 | 823 | ||
837 | void PlayListWidget::playSelected() { | 824 | void PlayListWidget::playSelected() { |
838 | btnPlay( TRUE); | 825 | btnPlay( TRUE); |
839 | } | 826 | } |
840 | 827 | ||
841 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 828 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
842 | switch (mouse) { | 829 | switch (mouse) { |
843 | case 1: | 830 | case 1: |
844 | 831 | ||
845 | break; | 832 | break; |
846 | case 2: | 833 | case 2: |
847 | { | 834 | { |
848 | QPopupMenu m; | 835 | QPopupMenu m; |
849 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 836 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
850 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 837 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
851 | m.exec( QCursor::pos() ); | 838 | m.exec( QCursor::pos() ); |
852 | } | 839 | } |
853 | break; | 840 | break; |
854 | }; | 841 | }; |
855 | } | 842 | } |
856 | 843 | ||
857 | void PlayListWidget::listDelete() { | 844 | void PlayListWidget::listDelete() { |
858 | Config cfg( "OpiePlayer" ); | 845 | Config cfg( "OpiePlayer" ); |
859 | cfg.setGroup("PlayList"); | 846 | cfg.setGroup("PlayList"); |
860 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 847 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
861 | QString file; | 848 | QString file; |
862 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 849 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
863 | switch ( tabWidget->currentPageIndex()) { | 850 | switch ( tabWidget->currentPageIndex()) { |
864 | case 0: | 851 | case 0: |
865 | break; | 852 | break; |
866 | case 1: | 853 | case 1: |
867 | { | 854 | { |
868 | file = audioView->currentItem()->text(0); | 855 | file = audioView->currentItem()->text(0); |
869 | QListIterator<DocLnk> Pdit( files.children() ); | 856 | QListIterator<DocLnk> Pdit( files.children() ); |
870 | for ( ; Pdit.current(); ++Pdit ) { | 857 | for ( ; Pdit.current(); ++Pdit ) { |
871 | if( Pdit.current()->name() == file) { | 858 | if( Pdit.current()->name() == file) { |
872 | LnkProperties prop( Pdit.current() ); | 859 | LnkProperties prop( Pdit.current() ); |
873 | prop.showMaximized(); | 860 | prop.showMaximized(); |
874 | prop.exec(); | 861 | prop.exec(); |
875 | } | 862 | } |
876 | } | 863 | } |
877 | populateAudioView(); | 864 | populateAudioView(); |
878 | } | 865 | } |
879 | break; | 866 | break; |
880 | case 2: | 867 | case 2: |
881 | { | 868 | { |
882 | 869 | ||
883 | } | 870 | } |
884 | break; | 871 | break; |
885 | }; | 872 | }; |
886 | } | 873 | } |
887 | 874 | ||
888 | void PlayListWidget::scanForAudio() { | 875 | void PlayListWidget::scanForAudio() { |
889 | qDebug("scan for audio"); | 876 | qDebug("scan for audio"); |
890 | files.detachChildren(); | 877 | files.detachChildren(); |
891 | QListIterator<DocLnk> sdit( files.children() ); | 878 | QListIterator<DocLnk> sdit( files.children() ); |
892 | for ( ; sdit.current(); ++sdit ) { | 879 | for ( ; sdit.current(); ++sdit ) { |
893 | delete sdit.current(); | 880 | delete sdit.current(); |
894 | } | 881 | } |
895 | Global::findDocuments(&files, "audio/*"); | 882 | Global::findDocuments(&files, "audio/*"); |
896 | audioScan = TRUE; | 883 | audioScan = TRUE; |
897 | } | 884 | } |
898 | void PlayListWidget::scanForVideo() { | 885 | void PlayListWidget::scanForVideo() { |
899 | qDebug("scan for video"); | 886 | qDebug("scan for video"); |
900 | vFiles.detachChildren(); | 887 | vFiles.detachChildren(); |
901 | QListIterator<DocLnk> sdit( vFiles.children() ); | 888 | QListIterator<DocLnk> sdit( vFiles.children() ); |
902 | for ( ; sdit.current(); ++sdit ) { | 889 | for ( ; sdit.current(); ++sdit ) { |
903 | delete sdit.current(); | 890 | delete sdit.current(); |
904 | } | 891 | } |
905 | Global::findDocuments(&vFiles, "video/*"); | 892 | Global::findDocuments(&vFiles, "video/*"); |
906 | videoScan = TRUE; | 893 | videoScan = TRUE; |
907 | } | 894 | } |
908 | 895 | ||
909 | void PlayListWidget::populateAudioView() { | 896 | void PlayListWidget::populateAudioView() { |
910 | 897 | ||
911 | audioView->clear(); | 898 | audioView->clear(); |
912 | StorageInfo storageInfo; | 899 | StorageInfo storageInfo; |
913 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 900 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
914 | if(!audioScan) scanForAudio(); | 901 | if(!audioScan) scanForAudio(); |
915 | 902 | ||
916 | QListIterator<DocLnk> dit( files.children() ); | 903 | QListIterator<DocLnk> dit( files.children() ); |
917 | QListIterator<FileSystem> it ( fs ); | 904 | QListIterator<FileSystem> it ( fs ); |
918 | 905 | ||
919 | QString storage; | 906 | QString storage; |
920 | for ( ; dit.current(); ++dit ) { | 907 | for ( ; dit.current(); ++dit ) { |
921 | for( ; it.current(); ++it ){ | 908 | for( ; it.current(); ++it ){ |
922 | const QString name = (*it)->name(); | 909 | const QString name = (*it)->name(); |
923 | const QString path = (*it)->path(); | 910 | const QString path = (*it)->path(); |
924 | if(dit.current()->file().find(path) != -1 ) storage=name; | 911 | if(dit.current()->file().find(path) != -1 ) storage=name; |
925 | } | 912 | } |
926 | 913 | ||
927 | QListViewItem * newItem; | 914 | QListViewItem * newItem; |
928 | if ( QFile( dit.current()->file()).exists() ) { | 915 | if ( QFile( dit.current()->file()).exists() ) { |
929 | // qDebug(dit.current()->name()); | 916 | // qDebug(dit.current()->name()); |
930 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 917 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
931 | QString::number( QFile( dit.current()->file()).size() ), storage); | 918 | QString::number( QFile( dit.current()->file()).size() ), storage); |
932 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); | 919 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); |
933 | } | 920 | } |
934 | } | 921 | } |
935 | 922 | ||
936 | } | 923 | } |
937 | 924 | ||
938 | void PlayListWidget::populateVideoView() { | 925 | void PlayListWidget::populateVideoView() { |
939 | videoView->clear(); | 926 | videoView->clear(); |
940 | StorageInfo storageInfo; | 927 | StorageInfo storageInfo; |
941 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 928 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
942 | 929 | ||
943 | if(!videoScan ) scanForVideo(); | 930 | if(!videoScan ) scanForVideo(); |
944 | 931 | ||
945 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 932 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
946 | QListIterator<FileSystem> it ( fs ); | 933 | QListIterator<FileSystem> it ( fs ); |
947 | videoView->clear(); | 934 | videoView->clear(); |
948 | QString storage; | 935 | QString storage; |
949 | for ( ; Vdit.current(); ++Vdit ) { | 936 | for ( ; Vdit.current(); ++Vdit ) { |
950 | for( ; it.current(); ++it ){ | 937 | for( ; it.current(); ++it ){ |
951 | const QString name = (*it)->name(); | 938 | const QString name = (*it)->name(); |
952 | const QString path = (*it)->path(); | 939 | const QString path = (*it)->path(); |
953 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 940 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
954 | } | 941 | } |
955 | 942 | ||
956 | QListViewItem * newItem; | 943 | QListViewItem * newItem; |
957 | if ( QFile( Vdit.current()->file()).exists() ) { | 944 | if ( QFile( Vdit.current()->file()).exists() ) { |
958 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 945 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
959 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 946 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
960 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); | 947 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); |
961 | } | 948 | } |
962 | } | 949 | } |
963 | } | 950 | } |
964 | 951 | ||
965 | void PlayListWidget::openFile() { | 952 | void PlayListWidget::openFile() { |
966 | QString filename, name; | 953 | QString filename, name; |
967 | InputDialog *fileDlg; | 954 | InputDialog *fileDlg; |
968 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 955 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
969 | fileDlg->exec(); | 956 | fileDlg->exec(); |
970 | if( fileDlg->result() == 1 ) { | 957 | if( fileDlg->result() == 1 ) { |
971 | filename = fileDlg->LineEdit1->text(); | 958 | filename = fileDlg->LineEdit1->text(); |
972 | 959 | ||
973 | qDebug("Selected filename is "+filename); | 960 | qDebug("Selected filename is "+filename); |
974 | if(filename.right(3) == "m3u") { | 961 | if(filename.right(3) == "m3u") { |
975 | readm3u( filename ); | 962 | readm3u( filename ); |
976 | } else if(filename.right(3) == "pls") { | 963 | } else if(filename.right(3) == "pls") { |
977 | readPls( filename ); | 964 | readPls( filename ); |
978 | } else { | 965 | } else { |
979 | DocLnk lnk; | 966 | DocLnk lnk; |
980 | 967 | ||
981 | lnk.setName(filename); //sets file name | 968 | lnk.setName(filename); //sets file name |
982 | lnk.setFile(filename); //sets File property | 969 | lnk.setFile(filename); //sets File property |
983 | lnk.setType("audio/x-mpegurl"); | 970 | lnk.setType("audio/x-mpegurl"); |
984 | lnk.setExec("opieplayer"); | 971 | lnk.setExec("opieplayer"); |
985 | lnk.setIcon("opieplayer2/MPEGPlayer"); | 972 | lnk.setIcon("opieplayer2/MPEGPlayer"); |
986 | 973 | ||
987 | if(!lnk.writeLink()) { | 974 | if(!lnk.writeLink()) { |
988 | qDebug("Writing doclink did not work"); | 975 | qDebug("Writing doclink did not work"); |
989 | } | 976 | } |
990 | d->selectedFiles->addToSelection( lnk); | 977 | d->selectedFiles->addToSelection( lnk); |
991 | } | 978 | } |
992 | } | 979 | } |
993 | if(fileDlg) { | 980 | if(fileDlg) { |
994 | delete fileDlg; | 981 | delete fileDlg; |
995 | } | 982 | } |
996 | } | 983 | } |
997 | 984 | ||
998 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 985 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
999 | { | 986 | { |
1000 | switch ( e->key() ) { | 987 | switch ( e->key() ) { |
1001 | ////////////////////////////// Zaurus keys | 988 | ////////////////////////////// Zaurus keys |
1002 | case Key_F9: //activity | 989 | case Key_F9: //activity |
1003 | // if(audioUI->isHidden()) | 990 | // if(audioUI->isHidden()) |
1004 | // audioUI->showMaximized(); | 991 | // audioUI->showMaximized(); |
1005 | break; | 992 | break; |
1006 | case Key_F10: //contacts | 993 | case Key_F10: //contacts |
1007 | // if( videoUI->isHidden()) | 994 | // if( videoUI->isHidden()) |
1008 | // videoUI->showMaximized(); | 995 | // videoUI->showMaximized(); |
1009 | break; | 996 | break; |
1010 | case Key_F11: //menu | 997 | case Key_F11: //menu |
1011 | break; | 998 | break; |
1012 | case Key_F12: //home | 999 | case Key_F12: //home |
1013 | // doBlank(); | 1000 | // doBlank(); |
1014 | break; | 1001 | break; |
1015 | case Key_F13: //mail | 1002 | case Key_F13: //mail |
1016 | // doUnblank(); | 1003 | // doUnblank(); |
1017 | break; | 1004 | break; |
1018 | case Key_Q: //add to playlist | 1005 | case Key_Q: //add to playlist |
1019 | qDebug("Add"); | 1006 | qDebug("Add"); |
1020 | addSelected(); | 1007 | addSelected(); |
1021 | break; | 1008 | break; |
1022 | case Key_R: //remove from playlist | 1009 | case Key_R: //remove from playlist |
1023 | removeSelected(); | 1010 | removeSelected(); |
1024 | break; | 1011 | break; |
1025 | // case Key_P: //play | 1012 | // case Key_P: //play |
1026 | // qDebug("Play"); | 1013 | // qDebug("Play"); |
1027 | // playSelected(); | 1014 | // playSelected(); |
1028 | // break; | 1015 | // break; |
1029 | case Key_Space: | 1016 | case Key_Space: |
1030 | qDebug("Play"); | 1017 | qDebug("Play"); |
1031 | // playSelected(); puh | 1018 | // playSelected(); puh |
1032 | break; | 1019 | break; |
1033 | case Key_1: | 1020 | case Key_1: |
1034 | tabWidget->setCurrentPage(0); | 1021 | tabWidget->setCurrentPage(0); |
1035 | break; | 1022 | break; |
1036 | case Key_2: | 1023 | case Key_2: |
1037 | tabWidget->setCurrentPage(1); | 1024 | tabWidget->setCurrentPage(1); |
1038 | break; | 1025 | break; |
1039 | case Key_3: | 1026 | case Key_3: |
1040 | tabWidget->setCurrentPage(2); | 1027 | tabWidget->setCurrentPage(2); |
1041 | break; | 1028 | break; |
1042 | case Key_4: | 1029 | case Key_4: |
1043 | tabWidget->setCurrentPage(3); | 1030 | tabWidget->setCurrentPage(3); |
1044 | break; | 1031 | break; |
1045 | case Key_Down: | 1032 | case Key_Down: |
1046 | if ( !d->selectedFiles->next() ) | 1033 | if ( !d->selectedFiles->next() ) |
1047 | d->selectedFiles->first(); | 1034 | d->selectedFiles->first(); |
1048 | 1035 | ||
1049 | break; | 1036 | break; |
1050 | case Key_Up: | 1037 | case Key_Up: |
1051 | if ( !d->selectedFiles->prev() ) | 1038 | if ( !d->selectedFiles->prev() ) |
1052 | // d->selectedFiles->last(); | 1039 | // d->selectedFiles->last(); |
1053 | 1040 | ||
1054 | break; | 1041 | break; |
1055 | 1042 | ||
1056 | } | 1043 | } |
1057 | } | 1044 | } |
1058 | 1045 | ||
1059 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1046 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1060 | { | 1047 | { |
1061 | // qDebug("Key press"); | 1048 | // qDebug("Key press"); |
1062 | // switch ( e->key() ) { | 1049 | // switch ( e->key() ) { |
1063 | // ////////////////////////////// Zaurus keys | 1050 | // ////////////////////////////// Zaurus keys |
1064 | // case Key_A: //add to playlist | 1051 | // case Key_A: //add to playlist |
1065 | // qDebug("Add"); | 1052 | // qDebug("Add"); |
1066 | // addSelected(); | 1053 | // addSelected(); |
1067 | // break; | 1054 | // break; |
1068 | // case Key_R: //remove from playlist | 1055 | // case Key_R: //remove from playlist |
1069 | // removeSelected(); | 1056 | // removeSelected(); |
1070 | // break; | 1057 | // break; |
1071 | // case Key_P: //play | 1058 | // case Key_P: //play |
1072 | // qDebug("Play"); | 1059 | // qDebug("Play"); |
1073 | // playSelected(); | 1060 | // playSelected(); |
1074 | // break; | 1061 | // break; |
1075 | // case Key_Space: | 1062 | // case Key_Space: |
1076 | // qDebug("Play"); | 1063 | // qDebug("Play"); |
1077 | // playSelected(); | 1064 | // playSelected(); |
1078 | // break; | 1065 | // break; |
1079 | // } | 1066 | // } |
1080 | } | 1067 | } |
1081 | 1068 | ||
1082 | void PlayListWidget::doBlank() { | ||
1083 | qDebug("do blanking"); | ||
1084 | fd=open("/dev/fb0",O_RDWR); | ||
1085 | if (fd != -1) { | ||
1086 | ioctl(fd,FBIOBLANK,1); | ||
1087 | // close(fd); | ||
1088 | } | ||
1089 | } | ||
1090 | 1069 | ||
1091 | void PlayListWidget::doUnblank() { | ||
1092 | // this crashes opieplayer with a segfault | ||
1093 | // int fd; | ||
1094 | // fd=open("/dev/fb0",O_RDWR); | ||
1095 | qDebug("do unblanking"); | ||
1096 | if (fd != -1) { | ||
1097 | ioctl(fd,FBIOBLANK,0); | ||
1098 | close(fd); | ||
1099 | } | ||
1100 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | ||
1101 | h <<-3;// v[1]; // -3 Force on | ||
1102 | } | ||
1103 | 1070 | ||
1104 | void PlayListWidget::readm3u(const QString &filename) { | 1071 | void PlayListWidget::readm3u(const QString &filename) { |
1105 | 1072 | ||
1106 | qDebug("m3u filename is "+filename); | 1073 | qDebug("m3u filename is "+filename); |
1107 | QFile f(filename); | 1074 | QFile f(filename); |
1108 | 1075 | ||
1109 | if(f.open(IO_ReadOnly)) { | 1076 | if(f.open(IO_ReadOnly)) { |
1110 | QTextStream t(&f); | 1077 | QTextStream t(&f); |
1111 | QString s;//, first, second; | 1078 | QString s;//, first, second; |
1112 | int i=0; | 1079 | int i=0; |
1113 | while ( !t.atEnd()) { | 1080 | while ( !t.atEnd()) { |
1114 | s=t.readLine(); | 1081 | s=t.readLine(); |
1115 | 1082 | ||
1116 | if(s.find("#",0,TRUE) == -1) { | 1083 | if(s.find("#",0,TRUE) == -1) { |
1117 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1084 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1118 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1085 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1119 | s=s.right(s.length()-2); | 1086 | s=s.right(s.length()-2); |
1120 | if(QFile(s).exists()) { | 1087 | if(QFile(s).exists()) { |
1121 | DocLnk lnk( s ); | 1088 | DocLnk lnk( s ); |
1122 | QFileInfo f(s); | 1089 | QFileInfo f(s); |
1123 | QString name = f.baseName(); | 1090 | QString name = f.baseName(); |
1124 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 1091 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
1125 | lnk.setName( name ); | 1092 | lnk.setName( name ); |
1126 | s=s.replace( QRegExp("\\"),"/"); | 1093 | s=s.replace( QRegExp("\\"),"/"); |
1127 | lnk.setFile( s ); | 1094 | lnk.setFile( s ); |
1128 | lnk.writeLink(); | 1095 | lnk.writeLink(); |
1129 | qDebug("add "+name); | 1096 | qDebug("add "+name); |
1130 | d->selectedFiles->addToSelection( lnk); | 1097 | d->selectedFiles->addToSelection( lnk); |
1131 | } | 1098 | } |
1132 | } else { // is url | 1099 | } else { // is url |
1133 | s.replace(QRegExp("%20")," "); | 1100 | s.replace(QRegExp("%20")," "); |
1134 | DocLnk lnk( s ); | 1101 | DocLnk lnk( s ); |
1135 | QString name; | 1102 | QString name; |
1136 | if(name.left(4)=="http") { | 1103 | if(name.left(4)=="http") { |
1137 | name = s.right( s.length() - 7); | 1104 | name = s.right( s.length() - 7); |
1138 | } else { | 1105 | } else { |
1139 | name = s; | 1106 | name = s; |
1140 | } | 1107 | } |
1141 | lnk.setName(name); | 1108 | lnk.setName(name); |
1142 | if(s.at(s.length()-4) == '.') { | 1109 | if(s.at(s.length()-4) == '.') { |
1143 | lnk.setFile( s); | 1110 | lnk.setFile( s); |
1144 | } else { | 1111 | } else { |
1145 | lnk.setFile( s+"/"); | 1112 | lnk.setFile( s+"/"); |
1146 | } | 1113 | } |
1147 | lnk.setType("audio/x-mpegurl"); | 1114 | lnk.setType("audio/x-mpegurl"); |
1148 | lnk.writeLink(); | 1115 | lnk.writeLink(); |
1149 | d->selectedFiles->addToSelection( lnk); | 1116 | d->selectedFiles->addToSelection( lnk); |
1150 | } | 1117 | } |
1151 | i++; | 1118 | i++; |
1152 | } | 1119 | } |
1153 | } | 1120 | } |
1154 | } | 1121 | } |
1155 | } | 1122 | } |
1156 | f.close(); | 1123 | f.close(); |
1157 | } | 1124 | } |
1158 | 1125 | ||
1159 | void PlayListWidget::writem3u() { | 1126 | void PlayListWidget::writem3u() { |
1160 | 1127 | ||
1161 | InputDialog *fileDlg; | 1128 | InputDialog *fileDlg; |
1162 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | 1129 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); |
1163 | fileDlg->exec(); | 1130 | fileDlg->exec(); |
1164 | QString filename,list; | 1131 | QString filename,list; |
1165 | if( fileDlg->result() == 1 ) { | 1132 | if( fileDlg->result() == 1 ) { |
1166 | filename = fileDlg->LineEdit1->text(); | 1133 | filename = fileDlg->LineEdit1->text(); |
1167 | qDebug(filename); | 1134 | qDebug(filename); |
1168 | int noOfFiles = 0; | 1135 | int noOfFiles = 0; |
1169 | d->selectedFiles->first(); | 1136 | d->selectedFiles->first(); |
1170 | do { | 1137 | do { |
1171 | // we dont check for existance because of url's | 1138 | // we dont check for existance because of url's |
1172 | // qDebug(d->selectedFiles->current()->file()); | 1139 | // qDebug(d->selectedFiles->current()->file()); |
1173 | list += d->selectedFiles->current()->file()+"\n"; | 1140 | list += d->selectedFiles->current()->file()+"\n"; |
1174 | noOfFiles++; | 1141 | noOfFiles++; |
1175 | } | 1142 | } |
1176 | while ( d->selectedFiles->next() ); | 1143 | while ( d->selectedFiles->next() ); |
1177 | qDebug(list); | 1144 | qDebug(list); |
1178 | if(filename.left(1) != "/") | 1145 | if(filename.left(1) != "/") |
1179 | filename=QPEApplication::documentDir()+"/"+filename; | 1146 | filename=QPEApplication::documentDir()+"/"+filename; |
1180 | if(filename.right(3) != "m3u") | 1147 | if(filename.right(3) != "m3u") |
1181 | filename=filename+".m3u"; | 1148 | filename=filename+".m3u"; |
1182 | 1149 | ||
1183 | QFile f(filename); | 1150 | QFile f(filename); |
1184 | f.open(IO_WriteOnly); | 1151 | f.open(IO_WriteOnly); |
1185 | f.writeBlock(list, list.length()); | 1152 | f.writeBlock(list, list.length()); |
1186 | f.close(); | 1153 | f.close(); |
1187 | } | 1154 | } |
1188 | if(fileDlg) delete fileDlg; | 1155 | if(fileDlg) delete fileDlg; |
1189 | } | 1156 | } |
1190 | 1157 | ||
1191 | void PlayListWidget::readPls(const QString &filename) { | 1158 | void PlayListWidget::readPls(const QString &filename) { |
1192 | 1159 | ||
1193 | qDebug("pls filename is "+filename); | 1160 | qDebug("pls filename is "+filename); |
1194 | QFile f(filename); | 1161 | QFile f(filename); |
1195 | 1162 | ||
1196 | if(f.open(IO_ReadOnly)) { | 1163 | if(f.open(IO_ReadOnly)) { |
1197 | QTextStream t(&f); | 1164 | QTextStream t(&f); |
1198 | QString s;//, first, second; | 1165 | QString s;//, first, second; |
1199 | int i=0; | 1166 | int i=0; |
1200 | while ( !t.atEnd()) { | 1167 | while ( !t.atEnd()) { |
1201 | s=t.readLine(); | 1168 | s=t.readLine(); |
1202 | if(s.left(4) == "File") { | 1169 | if(s.left(4) == "File") { |
1203 | s=s.right(s.length() - 6); | 1170 | s=s.right(s.length() - 6); |
1204 | s.replace(QRegExp("%20")," "); | 1171 | s.replace(QRegExp("%20")," "); |
1205 | qDebug("adding "+s+" to playlist"); | 1172 | qDebug("adding "+s+" to playlist"); |
1206 | // numberofentries=2 | 1173 | // numberofentries=2 |
1207 | // File1=http | 1174 | // File1=http |
1208 | // Title | 1175 | // Title |
1209 | // Length | 1176 | // Length |
1210 | // Version | 1177 | // Version |
1211 | // File2=http | 1178 | // File2=http |
1212 | s=s.replace( QRegExp("\\"),"/"); | 1179 | s=s.replace( QRegExp("\\"),"/"); |
1213 | DocLnk lnk( s ); | 1180 | DocLnk lnk( s ); |
1214 | QFileInfo f(s); | 1181 | QFileInfo f(s); |
1215 | QString name = f.baseName(); | 1182 | QString name = f.baseName(); |
1216 | if(name.left(4)=="http") | 1183 | if(name.left(4)=="http") |
1217 | name = s.right( s.length() - 7); | 1184 | name = s.right( s.length() - 7); |
1218 | else | 1185 | else |
1219 | name=s; | 1186 | name=s; |
1220 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1187 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1221 | lnk.setName( name); | 1188 | lnk.setName( name); |
1222 | if(s.at(s.length()-4) == '.') // if this is probably a file | 1189 | if(s.at(s.length()-4) == '.') // if this is probably a file |
1223 | lnk.setFile( s); | 1190 | lnk.setFile( s); |
1224 | else { //if its a url | 1191 | else { //if its a url |
1225 | if( name.right(1).find('/') == -1) | 1192 | if( name.right(1).find('/') == -1) |
1226 | s+="/"; | 1193 | s+="/"; |
1227 | lnk.setFile( s); | 1194 | lnk.setFile( s); |
1228 | } | 1195 | } |
1229 | lnk.setType("audio/x-mpegurl"); | 1196 | lnk.setType("audio/x-mpegurl"); |
1230 | 1197 | ||
1231 | qDebug("DocLnk add "+name); | 1198 | qDebug("DocLnk add "+name); |
1232 | d->selectedFiles->addToSelection( lnk); | 1199 | d->selectedFiles->addToSelection( lnk); |
1233 | } | 1200 | } |
1234 | } | 1201 | } |
1235 | i++; | 1202 | i++; |
1236 | } | 1203 | } |
1237 | } | 1204 | } |
1238 | 1205 | ||
1239 | void PlayListWidget::pmViewActivated(int index) { | 1206 | void PlayListWidget::pmViewActivated(int index) { |
1240 | qDebug("%d", index); | 1207 | qDebug("%d", index); |
1241 | switch(index) { | 1208 | switch(index) { |
1242 | case -16: | 1209 | case -16: |
1243 | { | 1210 | { |
1244 | 1211 | ||
1245 | mediaPlayerState->toggleFullscreen(); | 1212 | mediaPlayerState->toggleFullscreen(); |
1246 | bool b=mediaPlayerState->fullscreen(); | 1213 | bool b=mediaPlayerState->fullscreen(); |
1247 | pmView->setItemChecked( index,b); | 1214 | pmView->setItemChecked( index,b); |
1248 | Config cfg( "OpiePlayer" ); | 1215 | Config cfg( "OpiePlayer" ); |
1249 | cfg.writeEntry("FullScreen", b); | 1216 | cfg.writeEntry("FullScreen", b); |
1250 | 1217 | ||
1251 | } | 1218 | } |
1252 | break; | 1219 | break; |
1253 | }; | 1220 | }; |
1254 | } | 1221 | } |
1255 | 1222 | ||
1256 | void PlayListWidget::populateSkinsMenu() { | 1223 | void PlayListWidget::populateSkinsMenu() { |
1257 | int item=0; | 1224 | int item=0; |
1258 | defaultSkinIndex=0; | 1225 | defaultSkinIndex=0; |
1259 | QString skinName; | 1226 | QString skinName; |
1260 | Config cfg( "OpiePlayer" ); | 1227 | Config cfg( "OpiePlayer" ); |
1261 | cfg.setGroup("Options"); | 1228 | cfg.setGroup("Options"); |
1262 | QString skin = cfg.readEntry("Skin","default"); | 1229 | QString skin = cfg.readEntry("Skin","default"); |
1263 | 1230 | ||
1264 | QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins"); | 1231 | QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins"); |
1265 | skinsDir.setFilter( QDir::Dirs); | 1232 | skinsDir.setFilter( QDir::Dirs); |
1266 | skinsDir.setSorting(QDir::Name); | 1233 | skinsDir.setSorting(QDir::Name); |
1267 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1234 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1268 | QFileInfoListIterator it( *skinslist ); | 1235 | QFileInfoListIterator it( *skinslist ); |
1269 | QFileInfo *fi; | 1236 | QFileInfo *fi; |
1270 | while ( (fi=it.current()) ) { | 1237 | while ( (fi=it.current()) ) { |
1271 | skinName = fi->fileName(); | 1238 | skinName = fi->fileName(); |
1272 | qDebug( fi->fileName()); | 1239 | qDebug( fi->fileName()); |
1273 | if( skinName != "." && skinName != ".." && skinName !="CVS") | 1240 | if( skinName != "." && skinName != ".." && skinName !="CVS") |
1274 | item = skinsMenu->insertItem( fi->fileName()); | 1241 | item = skinsMenu->insertItem( fi->fileName()); |
1275 | if( skinName == "default") | 1242 | if( skinName == "default") |
1276 | defaultSkinIndex = item; | 1243 | defaultSkinIndex = item; |
1277 | if( skinName == skin) | 1244 | if( skinName == skin) |
1278 | skinsMenu->setItemChecked( item, TRUE); | 1245 | skinsMenu->setItemChecked( item, TRUE); |
1279 | 1246 | ||
1280 | ++it; | 1247 | ++it; |
1281 | } | 1248 | } |
1282 | } | 1249 | } |
1283 | 1250 | ||
1284 | void PlayListWidget::skinsMenuActivated(int item) { | 1251 | void PlayListWidget::skinsMenuActivated(int item) { |
1285 | for(int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) { | 1252 | for(int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) { |
1286 | skinsMenu->setItemChecked( i, FALSE); | 1253 | skinsMenu->setItemChecked( i, FALSE); |
1287 | } | 1254 | } |
1288 | skinsMenu->setItemChecked( item, TRUE); | 1255 | skinsMenu->setItemChecked( item, TRUE); |
1289 | 1256 | ||
1290 | Config cfg( "OpiePlayer" ); | 1257 | Config cfg( "OpiePlayer" ); |
1291 | cfg.setGroup("Options"); | 1258 | cfg.setGroup("Options"); |
1292 | cfg.writeEntry("Skin", skinsMenu->text( item)); | 1259 | cfg.writeEntry("Skin", skinsMenu->text( item)); |
1293 | } | 1260 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index 67a85a8..dd4bee0 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -1,114 +1,112 @@ | |||
1 | 1 | ||
2 | #ifndef PLAY_LIST_WIDGET_H | 2 | #ifndef PLAY_LIST_WIDGET_H |
3 | #define PLAY_LIST_WIDGET_H | 3 | #define PLAY_LIST_WIDGET_H |
4 | 4 | ||
5 | #include <qmainwindow.h> | 5 | #include <qmainwindow.h> |
6 | #include <qpe/applnk.h> | 6 | #include <qpe/applnk.h> |
7 | #include <qtabwidget.h> | 7 | #include <qtabwidget.h> |
8 | #include <qpe/fileselector.h> | 8 | #include <qpe/fileselector.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qpopupmenu.h> | 10 | #include <qpopupmenu.h> |
11 | 11 | ||
12 | /* #include <qtimer.h> */ | 12 | /* #include <qtimer.h> */ |
13 | 13 | ||
14 | 14 | ||
15 | class PlayListWidgetPrivate; | 15 | class PlayListWidgetPrivate; |
16 | class Config; | 16 | class Config; |
17 | class QListViewItem; | 17 | class QListViewItem; |
18 | class QListView; | 18 | class QListView; |
19 | class QPoint; | 19 | class QPoint; |
20 | class QAction; | 20 | class QAction; |
21 | class QLabel; | 21 | class QLabel; |
22 | 22 | ||
23 | class PlayListWidget : public QMainWindow { | 23 | class PlayListWidget : public QMainWindow { |
24 | Q_OBJECT | 24 | Q_OBJECT |
25 | public: | 25 | public: |
26 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 26 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
27 | ~PlayListWidget(); | 27 | ~PlayListWidget(); |
28 | QTabWidget * tabWidget; | 28 | QTabWidget * tabWidget; |
29 | // MenuItem *fullScreenButton, *scaleButton; | 29 | // MenuItem *fullScreenButton, *scaleButton; |
30 | // QAction *fullScreenButton, *scaleButton; | 30 | // QAction *fullScreenButton, *scaleButton; |
31 | DocLnkSet files; | 31 | DocLnkSet files; |
32 | DocLnkSet vFiles; | 32 | DocLnkSet vFiles; |
33 | QListView *audioView, *videoView, *playlistView; | 33 | QListView *audioView, *videoView, *playlistView; |
34 | QLabel *libString; | 34 | QLabel *libString; |
35 | QPopupMenu *pmView ; | 35 | QPopupMenu *pmView ; |
36 | bool fromSetDocument; | 36 | bool fromSetDocument; |
37 | bool insanityBool; | 37 | bool insanityBool; |
38 | QString setDocFileRef; | 38 | QString setDocFileRef; |
39 | // retrieve the current playlist entry (media file link) | 39 | // retrieve the current playlist entry (media file link) |
40 | const DocLnk *current(); | 40 | const DocLnk *current(); |
41 | void useSelectedDocument(); | 41 | void useSelectedDocument(); |
42 | /* QTimer * menuTimer; */ | 42 | /* QTimer * menuTimer; */ |
43 | FileSelector* playLists; | 43 | FileSelector* playLists; |
44 | QPushButton *tbDeletePlaylist; | 44 | QPushButton *tbDeletePlaylist; |
45 | int fd, selected; | 45 | int selected; |
46 | public slots: | 46 | public slots: |
47 | bool first(); | 47 | bool first(); |
48 | bool last(); | 48 | bool last(); |
49 | bool next(); | 49 | bool next(); |
50 | bool prev(); | 50 | bool prev(); |
51 | /* void setFullScreen(); */ | 51 | /* void setFullScreen(); */ |
52 | /* void setScaled(); */ | 52 | /* void setScaled(); */ |
53 | protected: | 53 | protected: |
54 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | 54 | /* void contentsMousePressEvent( QMouseEvent * e ); */ |
55 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | 55 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ |
56 | void keyReleaseEvent( QKeyEvent *e); | 56 | void keyReleaseEvent( QKeyEvent *e); |
57 | void keyPressEvent( QKeyEvent *e); | 57 | void keyPressEvent( QKeyEvent *e); |
58 | private: | 58 | private: |
59 | int defaultSkinIndex; | 59 | int defaultSkinIndex; |
60 | QPopupMenu *skinsMenu; | 60 | QPopupMenu *skinsMenu; |
61 | bool audioScan, videoScan; | 61 | bool audioScan, videoScan; |
62 | void doBlank(); | ||
63 | void doUnblank(); | ||
64 | void readm3u(const QString &); | 62 | void readm3u(const QString &); |
65 | void readPls(const QString &); | 63 | void readPls(const QString &); |
66 | 64 | ||
67 | void initializeStates(); | 65 | void initializeStates(); |
68 | void readConfig( Config& cfg ); | 66 | void readConfig( Config& cfg ); |
69 | void writeConfig( Config& cfg ) const; | 67 | void writeConfig( Config& cfg ) const; |
70 | PlayListWidgetPrivate *d; // Private implementation data | 68 | PlayListWidgetPrivate *d; // Private implementation data |
71 | void populateAudioView(); | 69 | void populateAudioView(); |
72 | void populateVideoView(); | 70 | void populateVideoView(); |
73 | private slots: | 71 | private slots: |
74 | void populateSkinsMenu(); | 72 | void populateSkinsMenu(); |
75 | void skinsMenuActivated(int); | 73 | void skinsMenuActivated(int); |
76 | void pmViewActivated(int); | 74 | void pmViewActivated(int); |
77 | void writem3u(); | 75 | void writem3u(); |
78 | void scanForAudio(); | 76 | void scanForAudio(); |
79 | void scanForVideo(); | 77 | void scanForVideo(); |
80 | void openFile(); | 78 | void openFile(); |
81 | void setDocument( const QString& fileref ); | 79 | void setDocument( const QString& fileref ); |
82 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 80 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
83 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 81 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
84 | void setActiveWindow(); // need to handle this to show the right view | 82 | void setActiveWindow(); // need to handle this to show the right view |
85 | void setPlaylist( bool ); // Show/Hide the playlist | 83 | void setPlaylist( bool ); // Show/Hide the playlist |
86 | void setView( char ); | 84 | void setView( char ); |
87 | void clearList(); | 85 | void clearList(); |
88 | void addAllToList(); | 86 | void addAllToList(); |
89 | void addAllMusicToList(); | 87 | void addAllMusicToList(); |
90 | void addAllVideoToList(); | 88 | void addAllVideoToList(); |
91 | void saveList(); // Save the playlist | 89 | void saveList(); // Save the playlist |
92 | void loadList( const DocLnk &); // Load a playlist | 90 | void loadList( const DocLnk &); // Load a playlist |
93 | void playIt( QListViewItem *); | 91 | void playIt( QListViewItem *); |
94 | 92 | ||
95 | void btnPlay(bool); | 93 | void btnPlay(bool); |
96 | void deletePlaylist(); | 94 | void deletePlaylist(); |
97 | void addSelected(); | 95 | void addSelected(); |
98 | void removeSelected(); | 96 | void removeSelected(); |
99 | void tabChanged(QWidget*); | 97 | void tabChanged(QWidget*); |
100 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 98 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
101 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 99 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
102 | void playSelected(); | 100 | void playSelected(); |
103 | void listDelete(); | 101 | void listDelete(); |
104 | 102 | ||
105 | protected slots: | 103 | protected slots: |
106 | /* void cancelMenuTimer(); */ | 104 | /* void cancelMenuTimer(); */ |
107 | /* void showFileMenu(); */ | 105 | /* void showFileMenu(); */ |
108 | 106 | ||
109 | 107 | ||
110 | }; | 108 | }; |
111 | 109 | ||
112 | 110 | ||
113 | #endif // PLAY_LIST_WIDGET_H | 111 | #endif // PLAY_LIST_WIDGET_H |
114 | 112 | ||