summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp20
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp48
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h5
3 files changed, 63 insertions, 10 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index 896da91..d20d560 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -3,259 +3,259 @@
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qpixmap.h> 25#include <qpixmap.h>
26#include <qbutton.h> 26#include <qbutton.h>
27#include <qpainter.h> 27#include <qpainter.h>
28#include <qframe.h> 28#include <qframe.h>
29#include <qlayout.h> 29#include <qlayout.h>
30 30
31#include "audiowidget.h" 31#include "audiowidget.h"
32#include "mediaplayerstate.h" 32#include "mediaplayerstate.h"
33 33
34#include <stdlib.h> 34#include <stdlib.h>
35#include <stdio.h> 35#include <stdio.h>
36 36
37extern MediaPlayerState *mediaPlayerState; 37extern MediaPlayerState *mediaPlayerState;
38 38
39 39
40static const int xo = -2; // movable x offset 40static const int xo = -2; // movable x offset
41static const int yo = 22; // movable y offset 41static const int yo = 22; // movable y offset
42 42
43struct MediaButton { 43struct MediaButton {
44 bool isToggle, isHeld, isDown; 44 bool isToggle, isHeld, isDown;
45}; 45};
46 46
47//Layout information for the audioButtons (and if it is a toggle button or not) 47//Layout information for the audioButtons (and if it is a toggle button or not)
48MediaButton audioButtons[] = { 48MediaButton audioButtons[] = {
49 { TRUE, FALSE, FALSE }, // play 49 { TRUE, FALSE, FALSE }, // play
50 { FALSE, FALSE, FALSE }, // stop 50 { FALSE, FALSE, FALSE }, // stop
51 { TRUE, FALSE, FALSE }, // pause
52 { FALSE, FALSE, FALSE }, // next 51 { FALSE, FALSE, FALSE }, // next
53 { FALSE, FALSE, FALSE }, // previous 52 { FALSE, FALSE, FALSE }, // previous
54 { FALSE, FALSE, FALSE }, // volume up 53 { FALSE, FALSE, FALSE }, // volume up
55 { FALSE, FALSE, FALSE }, // volume down 54 { FALSE, FALSE, FALSE }, // volume down
56 { TRUE, FALSE, FALSE }, // repeat/loop 55 { TRUE, FALSE, FALSE }, // repeat/loop
57 { FALSE, FALSE, FALSE }, // playlist 56 { FALSE, FALSE, FALSE }, // playlist
58 { FALSE, FALSE, FALSE }, // forward 57 { FALSE, FALSE, FALSE }, // forward
59 { FALSE, FALSE, FALSE } // back 58 { FALSE, FALSE, FALSE } // back
60}; 59};
61 60
62const char *skin_mask_file_names[11] = { 61const char *skin_mask_file_names[10] = {
63 "play", "stop", "pause", "next", "prev", "up", 62 "play", "stop", "next", "prev", "up",
64 "down", "loop", "playlist", "forward", "back" 63 "down", "loop", "playlist", "forward", "back"
65}; 64};
66 65
67
68static void changeTextColor( QWidget *w ) { 66static void changeTextColor( QWidget *w ) {
69 QPalette p = w->palette(); 67 QPalette p = w->palette();
70 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 68 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
71 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 69 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
72 w->setPalette( p ); 70 w->setPalette( p );
73} 71}
74 72
75static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 73static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
76 74
77AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 75AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
78 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) 76 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
79{ 77{
80 setCaption( tr("OpiePlayer") ); 78 setCaption( tr("OpiePlayer") );
81 qDebug("<<<<<audioWidget"); 79 qDebug("<<<<<audioWidget");
82 80
83 Config cfg("OpiePlayer"); 81 Config cfg("OpiePlayer");
84 cfg.setGroup("AudioWidget"); 82 cfg.setGroup("Options");
85 skin = cfg.readEntry("Skin","default"); 83 skin = cfg.readEntry("Skin","default");
86 //skin = "scaleTest"; 84 //skin = "scaleTest";
87// color of background, frame, degree of transparency 85// color of background, frame, degree of transparency
88 86
89 QString skinPath = "opieplayer2/skins/" + skin; 87 QString skinPath = "opieplayer2/skins/" + skin;
88 qDebug("skin path "+skinPath);
89
90 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 90 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
91 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 91 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
92 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 92 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
93 93
94 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 94 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
95 imgButtonMask->fill( 0 ); 95 imgButtonMask->fill( 0 );
96 96
97 for ( int i = 0; i < 11; i++ ) { 97 for ( int i = 0; i < 10; i++ ) {
98 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 98 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
99 masks[i] = new QBitmap( filename ); 99 masks[i] = new QBitmap( filename );
100 100
101 if ( !masks[i]->isNull() ) { 101 if ( !masks[i]->isNull() ) {
102 QImage imgMask = masks[i]->convertToImage(); 102 QImage imgMask = masks[i]->convertToImage();
103 uchar **dest = imgButtonMask->jumpTable(); 103 uchar **dest = imgButtonMask->jumpTable();
104 for ( int y = 0; y < imgUp->height(); y++ ) { 104 for ( int y = 0; y < imgUp->height(); y++ ) {
105 uchar *line = dest[y]; 105 uchar *line = dest[y];
106 for ( int x = 0; x < imgUp->width(); x++ ) 106 for ( int x = 0; x < imgUp->width(); x++ )
107 if ( !qRed( imgMask.pixel( x, y ) ) ) 107 if ( !qRed( imgMask.pixel( x, y ) ) )
108 line[x] = i + 1; 108 line[x] = i + 1;
109 } 109 }
110 } 110 }
111 111
112 } 112 }
113 113
114 for ( int i = 0; i < 11; i++ ) { 114 for ( int i = 0; i < 11; i++ ) {
115 buttonPixUp[i] = NULL; 115 buttonPixUp[i] = NULL;
116 buttonPixDown[i] = NULL; 116 buttonPixDown[i] = NULL;
117 } 117 }
118 118
119 setBackgroundPixmap( *pixBg ); 119 setBackgroundPixmap( *pixBg );
120 120
121 songInfo.setFocusPolicy( QWidget::NoFocus ); 121 songInfo.setFocusPolicy( QWidget::NoFocus );
122 122
123 changeTextColor( &songInfo ); 123 changeTextColor( &songInfo );
124 songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 124 songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
125 songInfo.setFrameStyle( QFrame::NoFrame); 125 songInfo.setFrameStyle( QFrame::NoFrame);
126// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 126// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
127 //NoFrame 127 //NoFrame
128// songInfo.setForegroundColor(Qt::white); 128// songInfo.setForegroundColor(Qt::white);
129 129
130 slider.setFixedHeight( 20 ); 130 slider.setFixedHeight( 20 );
131 slider.setMinValue( 0 ); 131 slider.setMinValue( 0 );
132 slider.setMaxValue( 1 ); 132 slider.setMaxValue( 1 );
133 slider.setFocusPolicy( QWidget::NoFocus ); 133 slider.setFocusPolicy( QWidget::NoFocus );
134 slider.setBackgroundPixmap( *pixBg ); 134 slider.setBackgroundPixmap( *pixBg );
135 135
136 time.setFocusPolicy( QWidget::NoFocus ); 136 time.setFocusPolicy( QWidget::NoFocus );
137 time.setAlignment( Qt::AlignCenter ); 137 time.setAlignment( Qt::AlignCenter );
138 time.setFrame(FALSE); 138 time.setFrame(FALSE);
139 changeTextColor( &time ); 139 changeTextColor( &time );
140 140
141 resizeEvent( NULL ); 141 resizeEvent( NULL );
142 142
143 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 143 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
144 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 144 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
145 145
146 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 146 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
147 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 147 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
148 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 148 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
149 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 149 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
150 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 150 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
151 151
152 // Intialise state 152 // Intialise state
153 setLength( mediaPlayerState->length() ); 153 setLength( mediaPlayerState->length() );
154 setPosition( mediaPlayerState->position() ); 154 setPosition( mediaPlayerState->position() );
155 setLooping( mediaPlayerState->fullscreen() ); 155 setLooping( mediaPlayerState->fullscreen() );
156 setPaused( mediaPlayerState->paused() ); 156 setPaused( mediaPlayerState->paused() );
157 setPlaying( mediaPlayerState->playing() ); 157 setPlaying( mediaPlayerState->playing() );
158 158
159} 159}
160 160
161 161
162AudioWidget::~AudioWidget() { 162AudioWidget::~AudioWidget() {
163 163
164 for ( int i = 0; i < 11; i++ ) { 164 for ( int i = 0; i < 10; i++ ) {
165 delete buttonPixUp[i]; 165 delete buttonPixUp[i];
166 delete buttonPixDown[i]; 166 delete buttonPixDown[i];
167 } 167 }
168 delete pixBg; 168 delete pixBg;
169 delete imgUp; 169 delete imgUp;
170 delete imgDn; 170 delete imgDn;
171 delete imgButtonMask; 171 delete imgButtonMask;
172 for ( int i = 0; i < 11; i++ ) { 172 for ( int i = 0; i < 10; i++ ) {
173 delete masks[i]; 173 delete masks[i];
174 } 174 }
175} 175}
176 176
177 177
178QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 178QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
179 QPixmap pix( img.width(), img.height() ); 179 QPixmap pix( img.width(), img.height() );
180 QPainter p( &pix ); 180 QPainter p( &pix );
181 p.drawTiledPixmap( pix.rect(), bg, offset ); 181 p.drawTiledPixmap( pix.rect(), bg, offset );
182 p.drawImage( 0, 0, img ); 182 p.drawImage( 0, 0, img );
183 return new QPixmap( pix ); 183 return new QPixmap( pix );
184} 184}
185 185
186 186
187QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 187QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
188{ 188{
189 QPixmap *pixmap = new QPixmap( pix ); 189 QPixmap *pixmap = new QPixmap( pix );
190 pixmap->setMask( mask ); 190 pixmap->setMask( mask );
191 return pixmap; 191 return pixmap;
192} 192}
193 193
194 194
195 195
196void AudioWidget::resizeEvent( QResizeEvent * ) { 196void AudioWidget::resizeEvent( QResizeEvent * ) {
197 int h = height(); 197 int h = height();
198 int w = width(); 198 int w = width();
199 199
200 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 200 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
201 slider.setFixedWidth( w - 110 ); 201 slider.setFixedWidth( w - 110 );
202 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 202 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
203 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 203 slider.setBackgroundOrigin( QWidget::ParentOrigin );
204 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 204 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
205 205
206 xoff = ( w - imgUp->width() ) / 2; 206 xoff = ( w - imgUp->width() ) / 2;
207 yoff = (( h - imgUp->height() ) / 2) - 10; 207 yoff = (( h - imgUp->height() ) / 2) - 10;
208 QPoint p( xoff, yoff ); 208 QPoint p( xoff, yoff );
209 209
210 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 210 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
211 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 211 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
212 212
213 for ( int i = 0; i < 11; i++ ) { 213 for ( int i = 0; i < 10; i++ ) {
214 if ( !masks[i]->isNull() ) { 214 if ( !masks[i]->isNull() ) {
215 delete buttonPixUp[i]; 215 delete buttonPixUp[i];
216 delete buttonPixDown[i]; 216 delete buttonPixDown[i];
217 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 217 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
218 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 218 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
219 } 219 }
220 } 220 }
221 221
222 delete pixUp; 222 delete pixUp;
223 delete pixDn; 223 delete pixDn;
224} 224}
225 225
226 226
227static bool audioSliderBeingMoved = FALSE; 227static bool audioSliderBeingMoved = FALSE;
228 228
229void AudioWidget::sliderPressed() { 229void AudioWidget::sliderPressed() {
230 audioSliderBeingMoved = TRUE; 230 audioSliderBeingMoved = TRUE;
231} 231}
232 232
233 233
234void AudioWidget::sliderReleased() { 234void AudioWidget::sliderReleased() {
235 audioSliderBeingMoved = FALSE; 235 audioSliderBeingMoved = FALSE;
236 if ( slider.width() == 0 ) 236 if ( slider.width() == 0 )
237 return; 237 return;
238 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 238 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
239 mediaPlayerState->setPosition( val ); 239 mediaPlayerState->setPosition( val );
240} 240}
241 241
242 242
243void AudioWidget::setPosition( long i ) { 243void AudioWidget::setPosition( long i ) {
244// qDebug("set position %d",i); 244// qDebug("set position %d",i);
245 long length = mediaPlayerState->length(); 245 long length = mediaPlayerState->length();
246 updateSlider( i, length ); 246 updateSlider( i, length );
247} 247}
248 248
249 249
250void AudioWidget::setLength( long max ) { 250void AudioWidget::setLength( long max ) {
251 updateSlider( mediaPlayerState->position(), max ); 251 updateSlider( mediaPlayerState->position(), max );
252} 252}
253 253
254 254
255void AudioWidget::setView( char view ) { 255void AudioWidget::setView( char view ) {
256 256
257 if (mediaPlayerState->isStreaming) { 257 if (mediaPlayerState->isStreaming) {
258 if( !slider.isHidden()) slider.hide(); 258 if( !slider.isHidden()) slider.hide();
259 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 259 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
260 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 260 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
261 } else { 261 } else {
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 6580a88..a937d7c 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -148,96 +148,104 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
148 toolbar->setHorizontalStretchable( TRUE ); 148 toolbar->setHorizontalStretchable( TRUE );
149 149
150 // Create Menubar 150 // Create Menubar
151 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 151 QPEMenuBar *menu = new QPEMenuBar( toolbar );
152 menu->setMargin( 0 ); 152 menu->setMargin( 0 );
153 153
154 QPEToolBar *bar = new QPEToolBar( this ); 154 QPEToolBar *bar = new QPEToolBar( this );
155 bar->setLabel( tr( "Play Operations" ) ); 155 bar->setLabel( tr( "Play Operations" ) );
156// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 156// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
157// this , SLOT( addSelected()) ); 157// this , SLOT( addSelected()) );
158 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 158 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
159 tbDeletePlaylist->setFlat(TRUE); 159 tbDeletePlaylist->setFlat(TRUE);
160 tbDeletePlaylist->setFixedSize(20,20); 160 tbDeletePlaylist->setFixedSize(20,20);
161 161
162 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 162 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
163 this , SLOT(addSelected()) ); 163 this , SLOT(addSelected()) );
164 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 164 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
165 this , SLOT(removeSelected()) ); 165 this , SLOT(removeSelected()) );
166// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 166// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
167 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 167 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
168 this , SLOT( btnPlay(bool) ), TRUE ); 168 this , SLOT( btnPlay(bool) ), TRUE );
169 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 169 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
170 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 170 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
171 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 171 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
172 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 172 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
173 tbDeletePlaylist->hide(); 173 tbDeletePlaylist->hide();
174 174
175 QPopupMenu *pmPlayList = new QPopupMenu( this ); 175 QPopupMenu *pmPlayList = new QPopupMenu( this );
176 menu->insertItem( tr( "File" ), pmPlayList ); 176 menu->insertItem( tr( "File" ), pmPlayList );
177 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 177 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
178 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 178 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
179 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 179 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
180 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 180 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
181 pmPlayList->insertSeparator(-1); 181 pmPlayList->insertSeparator(-1);
182 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 182 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
183 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 183 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
184 pmPlayList->insertSeparator(-1); 184 pmPlayList->insertSeparator(-1);
185 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 185 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
186 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 186 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
187 187
188 QPopupMenu *pmView = new QPopupMenu( this ); 188 QPopupMenu *pmView = new QPopupMenu( this );
189 menu->insertItem( tr( "View" ), pmView ); 189 menu->insertItem( tr( "View" ), pmView );
190 190
191 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 191 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
192 fullScreenButton->addTo(pmView); 192 fullScreenButton->addTo(pmView);
193 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 193 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
194 scaleButton->addTo(pmView); 194 scaleButton->addTo(pmView);
195 195
196
197 skinsMenu = new QPopupMenu( this );
198 menu->insertItem( tr( "Skins" ), skinsMenu );
199 skinsMenu->isCheckable();
200 connect( skinsMenu, SIGNAL( activated( int ) ) ,
201 this, SLOT( skinsMenuActivated( int ) ) );
202 populateSkinsMenu();
203
196 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 204 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
197 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 205 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
198 206
199 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 207 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
200 208
201 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 209 tabWidget = new QTabWidget( hbox6, "tabWidget" );
202 tabWidget->setTabShape(QTabWidget::Triangular); 210 tabWidget->setTabShape(QTabWidget::Triangular);
203 211
204 QWidget *pTab; 212 QWidget *pTab;
205 pTab = new QWidget( tabWidget, "pTab" ); 213 pTab = new QWidget( tabWidget, "pTab" );
206// playlistView = new QListView( pTab, "playlistview" ); 214// playlistView = new QListView( pTab, "playlistview" );
207// playlistView->setMinimumSize(236,260); 215// playlistView->setMinimumSize(236,260);
208 tabWidget->insertTab( pTab,"Playlist"); 216 tabWidget->insertTab( pTab,"Playlist");
209 217
210 218
211 // Add the playlist area 219 // Add the playlist area
212 220
213 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 221 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
214 d->playListFrame = vbox3; 222 d->playListFrame = vbox3;
215 d->playListFrame ->setMinimumSize(235,260); 223 d->playListFrame ->setMinimumSize(235,260);
216 224
217 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 225 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
218 226
219 d->selectedFiles = new PlayListSelection( hbox2); 227 d->selectedFiles = new PlayListSelection( hbox2);
220 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 228 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
221 229
222 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 230 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
223 231
224 232
225 233
226 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 234 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
227 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 235 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
228 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 236 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
229 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 237 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
230 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 238 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
231 239
232 QWidget *aTab; 240 QWidget *aTab;
233 aTab = new QWidget( tabWidget, "aTab" ); 241 aTab = new QWidget( tabWidget, "aTab" );
234 audioView = new QListView( aTab, "Audioview" ); 242 audioView = new QListView( aTab, "Audioview" );
235 audioView->setMinimumSize(233,260); 243 audioView->setMinimumSize(233,260);
236 audioView->addColumn( tr("Title"),140); 244 audioView->addColumn( tr("Title"),140);
237 audioView->addColumn(tr("Size"), -1); 245 audioView->addColumn(tr("Size"), -1);
238 audioView->addColumn(tr("Media"),-1); 246 audioView->addColumn(tr("Media"),-1);
239 audioView->setColumnAlignment(1, Qt::AlignRight); 247 audioView->setColumnAlignment(1, Qt::AlignRight);
240 audioView->setColumnAlignment(2, Qt::AlignRight); 248 audioView->setColumnAlignment(2, Qt::AlignRight);
241 audioView->setAllColumnsShowFocus(TRUE); 249 audioView->setAllColumnsShowFocus(TRUE);
242 250
243 audioView->setMultiSelection( TRUE ); 251 audioView->setMultiSelection( TRUE );
@@ -1305,48 +1313,88 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1305 } 1313 }
1306} 1314}
1307 1315
1308void PlayListWidget::keyPressEvent( QKeyEvent *) 1316void PlayListWidget::keyPressEvent( QKeyEvent *)
1309{ 1317{
1310// qDebug("Key press"); 1318// qDebug("Key press");
1311// switch ( e->key() ) { 1319// switch ( e->key() ) {
1312// ////////////////////////////// Zaurus keys 1320// ////////////////////////////// Zaurus keys
1313// case Key_A: //add to playlist 1321// case Key_A: //add to playlist
1314// qDebug("Add"); 1322// qDebug("Add");
1315// addSelected(); 1323// addSelected();
1316// break; 1324// break;
1317// case Key_R: //remove from playlist 1325// case Key_R: //remove from playlist
1318// removeSelected(); 1326// removeSelected();
1319// break; 1327// break;
1320// case Key_P: //play 1328// case Key_P: //play
1321// qDebug("Play"); 1329// qDebug("Play");
1322// playSelected(); 1330// playSelected();
1323// break; 1331// break;
1324// case Key_Space: 1332// case Key_Space:
1325// qDebug("Play"); 1333// qDebug("Play");
1326// playSelected(); 1334// playSelected();
1327// break; 1335// break;
1328// } 1336// }
1329} 1337}
1330 1338
1331void PlayListWidget::doBlank() { 1339void PlayListWidget::doBlank() {
1332 qDebug("do blanking"); 1340 qDebug("do blanking");
1333 fd=open("/dev/fb0",O_RDWR); 1341 fd=open("/dev/fb0",O_RDWR);
1334 if (fd != -1) { 1342 if (fd != -1) {
1335 ioctl(fd,FBIOBLANK,1); 1343 ioctl(fd,FBIOBLANK,1);
1336// close(fd); 1344// close(fd);
1337 } 1345 }
1338} 1346}
1339 1347
1340void PlayListWidget::doUnblank() { 1348void PlayListWidget::doUnblank() {
1341 // this crashes opieplayer with a segfault 1349 // this crashes opieplayer with a segfault
1342// int fd; 1350// int fd;
1343// fd=open("/dev/fb0",O_RDWR); 1351// fd=open("/dev/fb0",O_RDWR);
1344 qDebug("do unblanking"); 1352 qDebug("do unblanking");
1345 if (fd != -1) { 1353 if (fd != -1) {
1346 ioctl(fd,FBIOBLANK,0); 1354 ioctl(fd,FBIOBLANK,0);
1347 close(fd); 1355 close(fd);
1348 } 1356 }
1349 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1357 QCopEnvelope h("QPE/System", "setBacklight(int)");
1350 h <<-3;// v[1]; // -3 Force on 1358 h <<-3;// v[1]; // -3 Force on
1351} 1359}
1352 1360
1361void PlayListWidget::populateSkinsMenu() {
1362 int item = 0;
1363 defaultSkinIndex = 0;
1364 QString skinName;
1365 Config cfg( "OpiePlayer" );
1366 cfg.setGroup("Options" );
1367 QString skin = cfg.readEntry( "Skin", "default" );
1368
1369 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1370 skinsDir.setFilter( QDir::Dirs );
1371 skinsDir.setSorting(QDir::Name );
1372 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1373 QFileInfoListIterator it( *skinslist );
1374 QFileInfo *fi;
1375 while ( ( fi = it.current() ) ) {
1376 skinName = fi->fileName();
1377// qDebug( fi->fileName() );
1378 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1379 item = skinsMenu->insertItem( fi->fileName() ) ;
1380 }
1381 if( skinName == "default" ) {
1382 defaultSkinIndex = item;
1383 }
1384 if( skinName == skin ) {
1385 skinsMenu->setItemChecked( item, TRUE );
1386 }
1387 ++it;
1388 }
1389}
1390
1391void PlayListWidget::skinsMenuActivated( int item ) {
1392 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1393 skinsMenu->setItemChecked( i, FALSE );
1394 }
1395 skinsMenu->setItemChecked( item, TRUE );
1396
1397 Config cfg( "OpiePlayer" );
1398 cfg.setGroup("Options");
1399 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1400}
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 1be5a15..1118b76 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -1,128 +1,133 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef PLAY_LIST_WIDGET_H 20#ifndef PLAY_LIST_WIDGET_H
21#define PLAY_LIST_WIDGET_H 21#define PLAY_LIST_WIDGET_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qtabwidget.h> 25#include <qtabwidget.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28 28
29#include "om3u.h" 29#include "om3u.h"
30/* #include <qtimer.h> */ 30/* #include <qtimer.h> */
31 31
32 32
33class PlayListWidgetPrivate; 33class PlayListWidgetPrivate;
34class Config; 34class Config;
35class QListViewItem; 35class QListViewItem;
36class QListView; 36class QListView;
37class QPoint; 37class QPoint;
38class QAction; 38class QAction;
39class QLabel; 39class QLabel;
40class QPopupMenu;
40 41
41class PlayListWidget : public QMainWindow { 42class PlayListWidget : public QMainWindow {
42 Q_OBJECT 43 Q_OBJECT
43public: 44public:
44 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 45 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
45 ~PlayListWidget(); 46 ~PlayListWidget();
46 QTabWidget * tabWidget; 47 QTabWidget * tabWidget;
47 QAction *fullScreenButton, *scaleButton; 48 QAction *fullScreenButton, *scaleButton;
48 DocLnkSet files; 49 DocLnkSet files;
49 DocLnkSet vFiles; 50 DocLnkSet vFiles;
50 QListView *audioView, *videoView, *playlistView; 51 QListView *audioView, *videoView, *playlistView;
51 QLabel *libString; 52 QLabel *libString;
52 bool fromSetDocument; 53 bool fromSetDocument;
53 bool insanityBool; 54 bool insanityBool;
54 QString setDocFileRef, currentPlayList; 55 QString setDocFileRef, currentPlayList;
55 // retrieve the current playlist entry (media file link) 56 // retrieve the current playlist entry (media file link)
56 const DocLnk *current(); 57 const DocLnk *current();
57 void useSelectedDocument(); 58 void useSelectedDocument();
58/* QTimer * menuTimer; */ 59/* QTimer * menuTimer; */
59 FileSelector* playLists; 60 FileSelector* playLists;
60 QPushButton *tbDeletePlaylist; 61 QPushButton *tbDeletePlaylist;
61 int fd, selected; 62 int fd, selected;
62public slots: 63public slots:
63 bool first(); 64 bool first();
64 bool last(); 65 bool last();
65 bool next(); 66 bool next();
66 bool prev(); 67 bool prev();
67/* void setFullScreen(); */ 68/* void setFullScreen(); */
68/* void setScaled(); */ 69/* void setScaled(); */
69protected: 70protected:
71 QPopupMenu *skinsMenu;
70/* void contentsMousePressEvent( QMouseEvent * e ); */ 72/* void contentsMousePressEvent( QMouseEvent * e ); */
71/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ 73/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
72void keyReleaseEvent( QKeyEvent *e); 74void keyReleaseEvent( QKeyEvent *e);
73void keyPressEvent( QKeyEvent *e); 75void keyPressEvent( QKeyEvent *e);
74private: 76private:
77 int defaultSkinIndex;
75 bool audioScan, videoScan; 78 bool audioScan, videoScan;
76 void doBlank(); 79 void doBlank();
77 void doUnblank(); 80 void doUnblank();
78 void readm3u(const QString &); 81 void readm3u(const QString &);
79 void readPls(const QString &); 82 void readPls(const QString &);
80 83
81 84
82 void initializeStates(); 85 void initializeStates();
83 void readConfig( Config& cfg ); 86 void readConfig( Config& cfg );
84 void writeConfig( Config& cfg ) const; 87 void writeConfig( Config& cfg ) const;
85 PlayListWidgetPrivate *d; // Private implementation data 88 PlayListWidgetPrivate *d; // Private implementation data
86 void populateAudioView(); 89 void populateAudioView();
87 void populateVideoView(); 90 void populateVideoView();
88private slots: 91private slots:
89 92
93 void populateSkinsMenu();
94 void skinsMenuActivated(int);
90 void writem3u(); 95 void writem3u();
91 void writeCurrentM3u(); 96 void writeCurrentM3u();
92 void scanForAudio(); 97 void scanForAudio();
93 void scanForVideo(); 98 void scanForVideo();
94 void openFile(); 99 void openFile();
95 void setDocument( const QString& fileref ); 100 void setDocument( const QString& fileref );
96 void addToSelection( const DocLnk& ); // Add a media file to the playlist 101 void addToSelection( const DocLnk& ); // Add a media file to the playlist
97 void addToSelection( QListViewItem* ); // Add a media file to the playlist 102 void addToSelection( QListViewItem* ); // Add a media file to the playlist
98 void setActiveWindow(); // need to handle this to show the right view 103 void setActiveWindow(); // need to handle this to show the right view
99 void setPlaylist( bool ); // Show/Hide the playlist 104 void setPlaylist( bool ); // Show/Hide the playlist
100 void setView( char ); 105 void setView( char );
101 void clearList(); 106 void clearList();
102 void addAllToList(); 107 void addAllToList();
103 void addAllMusicToList(); 108 void addAllMusicToList();
104 void addAllVideoToList(); 109 void addAllVideoToList();
105 void saveList(); // Save the playlist 110 void saveList(); // Save the playlist
106 void loadList( const DocLnk &); // Load a playlist 111 void loadList( const DocLnk &); // Load a playlist
107 void playIt( QListViewItem *); 112 void playIt( QListViewItem *);
108 113
109 void btnPlay(bool); 114 void btnPlay(bool);
110 void deletePlaylist(); 115 void deletePlaylist();
111 void addSelected(); 116 void addSelected();
112 void removeSelected(); 117 void removeSelected();
113 void tabChanged(QWidget*); 118 void tabChanged(QWidget*);
114 void viewPressed( int, QListViewItem *, const QPoint&, int); 119 void viewPressed( int, QListViewItem *, const QPoint&, int);
115 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 120 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
116 void playSelected(); 121 void playSelected();
117 void listDelete(); 122 void listDelete();
118 123
119protected slots: 124protected slots:
120/* void cancelMenuTimer(); */ 125/* void cancelMenuTimer(); */
121/* void showFileMenu(); */ 126/* void showFileMenu(); */
122 127
123 128
124}; 129};
125 130
126 131
127#endif // PLAY_LIST_WIDGET_H 132#endif // PLAY_LIST_WIDGET_H
128 133