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