summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer
authorllornkcor <llornkcor>2002-11-03 23:41:56 (UTC)
committer llornkcor <llornkcor>2002-11-03 23:41:56 (UTC)
commit829eeff0374389891aa88b12fcafffb55f480797 (patch) (unidiff)
treebdef672d653e386535647ef82e291d95b520ef78 /core/multimedia/opieplayer
parentbf62b8f48d08f5a5e92681e1487a5f43d5c7a231 (diff)
downloadopie-829eeff0374389891aa88b12fcafffb55f480797.zip
opie-829eeff0374389891aa88b12fcafffb55f480797.tar.gz
opie-829eeff0374389891aa88b12fcafffb55f480797.tar.bz2
finish audio skin
Diffstat (limited to 'core/multimedia/opieplayer') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp18
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp48
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h5
3 files changed, 62 insertions, 9 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
@@ -39,71 +39,71 @@ extern MediaPlayerState *mediaPlayerState;
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 }
@@ -152,33 +152,33 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
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}
@@ -201,25 +201,25 @@ void AudioWidget::resizeEvent( QResizeEvent * ) {
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
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
@@ -184,24 +184,32 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
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);
@@ -1341,12 +1349,52 @@ void 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
@@ -28,24 +28,25 @@
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;
@@ -58,44 +59,48 @@ public:
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();