author | llornkcor <llornkcor> | 2002-11-03 23:41:56 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-03 23:41:56 (UTC) |
commit | 829eeff0374389891aa88b12fcafffb55f480797 (patch) (side-by-side diff) | |
tree | bdef672d653e386535647ef82e291d95b520ef78 /core | |
parent | bf62b8f48d08f5a5e92681e1487a5f43d5c7a231 (diff) | |
download | opie-829eeff0374389891aa88b12fcafffb55f480797.zip opie-829eeff0374389891aa88b12fcafffb55f480797.tar.gz opie-829eeff0374389891aa88b12fcafffb55f480797.tar.bz2 |
finish audio skin
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 20 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 48 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 5 |
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 @@ ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qwidget.h> #include <qpixmap.h> #include <qbutton.h> #include <qpainter.h> #include <qframe.h> #include <qlayout.h> #include "audiowidget.h" #include "mediaplayerstate.h" #include <stdlib.h> #include <stdio.h> extern MediaPlayerState *mediaPlayerState; static const int xo = -2; // movable x offset static const int yo = 22; // movable y offset struct MediaButton { bool isToggle, isHeld, isDown; }; //Layout information for the audioButtons (and if it is a toggle button or not) MediaButton audioButtons[] = { { TRUE, FALSE, FALSE }, // play { FALSE, FALSE, FALSE }, // stop - { TRUE, FALSE, FALSE }, // pause { FALSE, FALSE, FALSE }, // next { FALSE, FALSE, FALSE }, // previous { FALSE, FALSE, FALSE }, // volume up { FALSE, FALSE, FALSE }, // volume down { TRUE, FALSE, FALSE }, // repeat/loop { FALSE, FALSE, FALSE }, // playlist { FALSE, FALSE, FALSE }, // forward - { FALSE, FALSE, FALSE } // back + { FALSE, FALSE, FALSE } // back }; -const char *skin_mask_file_names[11] = { - "play", "stop", "pause", "next", "prev", "up", +const char *skin_mask_file_names[10] = { + "play", "stop", "next", "prev", "up", "down", "loop", "playlist", "forward", "back" }; - static void changeTextColor( QWidget *w ) { QPalette p = w->palette(); p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); w->setPalette( p ); } static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { setCaption( tr("OpiePlayer") ); qDebug("<<<<<audioWidget"); Config cfg("OpiePlayer"); - cfg.setGroup("AudioWidget"); + cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); //skin = "scaleTest"; // color of background, frame, degree of transparency QString skinPath = "opieplayer2/skins/" + skin; + qDebug("skin path "+skinPath); + pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); imgButtonMask->fill( 0 ); - for ( int i = 0; i < 11; i++ ) { + for ( int i = 0; i < 10; i++ ) { QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; masks[i] = new QBitmap( filename ); if ( !masks[i]->isNull() ) { QImage imgMask = masks[i]->convertToImage(); uchar **dest = imgButtonMask->jumpTable(); for ( int y = 0; y < imgUp->height(); y++ ) { uchar *line = dest[y]; for ( int x = 0; x < imgUp->width(); x++ ) if ( !qRed( imgMask.pixel( x, y ) ) ) line[x] = i + 1; } } } for ( int i = 0; i < 11; i++ ) { buttonPixUp[i] = NULL; buttonPixDown[i] = NULL; } setBackgroundPixmap( *pixBg ); songInfo.setFocusPolicy( QWidget::NoFocus ); changeTextColor( &songInfo ); songInfo.setBackgroundColor( QColor( 167, 212, 167 )); songInfo.setFrameStyle( QFrame::NoFrame); // songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); //NoFrame // songInfo.setForegroundColor(Qt::white); slider.setFixedHeight( 20 ); slider.setMinValue( 0 ); slider.setMaxValue( 1 ); slider.setFocusPolicy( QWidget::NoFocus ); slider.setBackgroundPixmap( *pixBg ); time.setFocusPolicy( QWidget::NoFocus ); time.setAlignment( Qt::AlignCenter ); time.setFrame(FALSE); changeTextColor( &time ); resizeEvent( NULL ); connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); // Intialise state setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); setLooping( mediaPlayerState->fullscreen() ); setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); } AudioWidget::~AudioWidget() { - for ( int i = 0; i < 11; i++ ) { + for ( int i = 0; i < 10; i++ ) { delete buttonPixUp[i]; delete buttonPixDown[i]; } delete pixBg; delete imgUp; delete imgDn; delete imgButtonMask; - for ( int i = 0; i < 11; i++ ) { + for ( int i = 0; i < 10; i++ ) { delete masks[i]; } } QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { QPixmap pix( img.width(), img.height() ); QPainter p( &pix ); p.drawTiledPixmap( pix.rect(), bg, offset ); p.drawImage( 0, 0, img ); return new QPixmap( pix ); } QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { QPixmap *pixmap = new QPixmap( pix ); pixmap->setMask( mask ); return pixmap; } void AudioWidget::resizeEvent( QResizeEvent * ) { int h = height(); int w = width(); songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); slider.setFixedWidth( w - 110 ); slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); slider.setBackgroundOrigin( QWidget::ParentOrigin ); time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); xoff = ( w - imgUp->width() ) / 2; yoff = (( h - imgUp->height() ) / 2) - 10; QPoint p( xoff, yoff ); QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); - for ( int i = 0; i < 11; i++ ) { + for ( int i = 0; i < 10; i++ ) { if ( !masks[i]->isNull() ) { delete buttonPixUp[i]; delete buttonPixDown[i]; buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); } } delete pixUp; delete pixDn; } static bool audioSliderBeingMoved = FALSE; void AudioWidget::sliderPressed() { audioSliderBeingMoved = TRUE; } void AudioWidget::sliderReleased() { audioSliderBeingMoved = FALSE; if ( slider.width() == 0 ) return; long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); mediaPlayerState->setPosition( val ); } void AudioWidget::setPosition( long i ) { // qDebug("set position %d",i); long length = mediaPlayerState->length(); updateSlider( i, length ); } void AudioWidget::setLength( long max ) { updateSlider( mediaPlayerState->position(), max ); } void AudioWidget::setView( char view ) { if (mediaPlayerState->isStreaming) { if( !slider.isHidden()) slider.hide(); disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); } 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 ) toolbar->setHorizontalStretchable( TRUE ); // Create Menubar QPEMenuBar *menu = new QPEMenuBar( toolbar ); menu->setMargin( 0 ); QPEToolBar *bar = new QPEToolBar( this ); bar->setLabel( tr( "Play Operations" ) ); // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", // this , SLOT( addSelected()) ); tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); tbDeletePlaylist->setFlat(TRUE); tbDeletePlaylist->setFixedSize(20,20); d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", this , SLOT(addSelected()) ); d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", this , SLOT(removeSelected()) ); // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", this , SLOT( btnPlay(bool) ), TRUE ); d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); tbDeletePlaylist->hide(); QPopupMenu *pmPlayList = new QPopupMenu( this ); menu->insertItem( tr( "File" ), pmPlayList ); new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); pmPlayList->insertSeparator(-1); new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); pmPlayList->insertSeparator(-1); new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); QPopupMenu *pmView = new QPopupMenu( this ); menu->insertItem( tr( "View" ), pmView ); fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); fullScreenButton->addTo(pmView); scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); scaleButton->addTo(pmView); + + skinsMenu = new QPopupMenu( this ); + menu->insertItem( tr( "Skins" ), skinsMenu ); + skinsMenu->isCheckable(); + connect( skinsMenu, SIGNAL( activated( int ) ) , + this, SLOT( skinsMenuActivated( int ) ) ); + populateSkinsMenu(); + QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); tabWidget = new QTabWidget( hbox6, "tabWidget" ); tabWidget->setTabShape(QTabWidget::Triangular); QWidget *pTab; pTab = new QWidget( tabWidget, "pTab" ); // playlistView = new QListView( pTab, "playlistview" ); // playlistView->setMinimumSize(236,260); tabWidget->insertTab( pTab,"Playlist"); // Add the playlist area QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); d->playListFrame = vbox3; d->playListFrame ->setMinimumSize(235,260); QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); d->selectedFiles = new PlayListSelection( hbox2); QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch QWidget *aTab; aTab = new QWidget( tabWidget, "aTab" ); audioView = new QListView( aTab, "Audioview" ); audioView->setMinimumSize(233,260); audioView->addColumn( tr("Title"),140); audioView->addColumn(tr("Size"), -1); audioView->addColumn(tr("Media"),-1); audioView->setColumnAlignment(1, Qt::AlignRight); audioView->setColumnAlignment(2, Qt::AlignRight); audioView->setAllColumnsShowFocus(TRUE); audioView->setMultiSelection( TRUE ); @@ -1305,48 +1313,88 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) } } void PlayListWidget::keyPressEvent( QKeyEvent *) { // qDebug("Key press"); // switch ( e->key() ) { // ////////////////////////////// Zaurus keys // case Key_A: //add to playlist // qDebug("Add"); // addSelected(); // break; // case Key_R: //remove from playlist // removeSelected(); // break; // case Key_P: //play // qDebug("Play"); // playSelected(); // break; // case Key_Space: // qDebug("Play"); // playSelected(); // break; // } } void PlayListWidget::doBlank() { qDebug("do blanking"); fd=open("/dev/fb0",O_RDWR); if (fd != -1) { ioctl(fd,FBIOBLANK,1); // close(fd); } } void PlayListWidget::doUnblank() { // this crashes opieplayer with a segfault // int fd; // fd=open("/dev/fb0",O_RDWR); qDebug("do unblanking"); if (fd != -1) { ioctl(fd,FBIOBLANK,0); close(fd); } QCopEnvelope h("QPE/System", "setBacklight(int)"); h <<-3;// v[1]; // -3 Force on } +void PlayListWidget::populateSkinsMenu() { + int item = 0; + defaultSkinIndex = 0; + QString skinName; + Config cfg( "OpiePlayer" ); + cfg.setGroup("Options" ); + QString skin = cfg.readEntry( "Skin", "default" ); + + QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); + skinsDir.setFilter( QDir::Dirs ); + skinsDir.setSorting(QDir::Name ); + const QFileInfoList *skinslist = skinsDir.entryInfoList(); + QFileInfoListIterator it( *skinslist ); + QFileInfo *fi; + while ( ( fi = it.current() ) ) { + skinName = fi->fileName(); +// qDebug( fi->fileName() ); + if( skinName != "." && skinName != ".." && skinName !="CVS" ) { + item = skinsMenu->insertItem( fi->fileName() ) ; + } + if( skinName == "default" ) { + defaultSkinIndex = item; + } + if( skinName == skin ) { + skinsMenu->setItemChecked( item, TRUE ); + } + ++it; + } +} + +void PlayListWidget::skinsMenuActivated( int item ) { + for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { + skinsMenu->setItemChecked( i, FALSE ); + } + skinsMenu->setItemChecked( item, TRUE ); + + Config cfg( "OpiePlayer" ); + cfg.setGroup("Options"); + cfg.writeEntry("Skin", skinsMenu->text( item ) ); +} 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 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef PLAY_LIST_WIDGET_H #define PLAY_LIST_WIDGET_H #include <qmainwindow.h> #include <qpe/applnk.h> #include <qtabwidget.h> #include <qpe/fileselector.h> #include <qpushbutton.h> #include "om3u.h" /* #include <qtimer.h> */ class PlayListWidgetPrivate; class Config; class QListViewItem; class QListView; class QPoint; class QAction; class QLabel; +class QPopupMenu; class PlayListWidget : public QMainWindow { Q_OBJECT public: PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); ~PlayListWidget(); QTabWidget * tabWidget; QAction *fullScreenButton, *scaleButton; DocLnkSet files; DocLnkSet vFiles; QListView *audioView, *videoView, *playlistView; QLabel *libString; bool fromSetDocument; bool insanityBool; QString setDocFileRef, currentPlayList; // retrieve the current playlist entry (media file link) const DocLnk *current(); void useSelectedDocument(); /* QTimer * menuTimer; */ FileSelector* playLists; QPushButton *tbDeletePlaylist; int fd, selected; public slots: bool first(); bool last(); bool next(); bool prev(); /* void setFullScreen(); */ /* void setScaled(); */ protected: + QPopupMenu *skinsMenu; /* void contentsMousePressEvent( QMouseEvent * e ); */ /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ void keyReleaseEvent( QKeyEvent *e); void keyPressEvent( QKeyEvent *e); private: + int defaultSkinIndex; bool audioScan, videoScan; void doBlank(); void doUnblank(); void readm3u(const QString &); void readPls(const QString &); void initializeStates(); void readConfig( Config& cfg ); void writeConfig( Config& cfg ) const; PlayListWidgetPrivate *d; // Private implementation data void populateAudioView(); void populateVideoView(); private slots: + void populateSkinsMenu(); + void skinsMenuActivated(int); void writem3u(); void writeCurrentM3u(); void scanForAudio(); void scanForVideo(); void openFile(); void setDocument( const QString& fileref ); void addToSelection( const DocLnk& ); // Add a media file to the playlist void addToSelection( QListViewItem* ); // Add a media file to the playlist void setActiveWindow(); // need to handle this to show the right view void setPlaylist( bool ); // Show/Hide the playlist void setView( char ); void clearList(); void addAllToList(); void addAllMusicToList(); void addAllVideoToList(); void saveList(); // Save the playlist void loadList( const DocLnk &); // Load a playlist void playIt( QListViewItem *); void btnPlay(bool); void deletePlaylist(); void addSelected(); void removeSelected(); void tabChanged(QWidget*); void viewPressed( int, QListViewItem *, const QPoint&, int); void playlistViewPressed( int, QListViewItem *, const QPoint&, int); void playSelected(); void listDelete(); protected slots: /* void cancelMenuTimer(); */ /* void showFileMenu(); */ }; #endif // PLAY_LIST_WIDGET_H |