author | harlekin <harlekin> | 2002-08-07 19:30:13 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-08-07 19:30:13 (UTC) |
commit | c80f0885bf402b6dd4ea637ad1b7d8b3ebd69300 (patch) (side-by-side diff) | |
tree | 558e8528408f0ab27d644554279f646723c6dad9 | |
parent | 7effde67fd121736ec658e690858c6c54bd6d125 (diff) | |
download | opie-c80f0885bf402b6dd4ea637ad1b7d8b3ebd69300.zip opie-c80f0885bf402b6dd4ea637ad1b7d8b3ebd69300.tar.gz opie-c80f0885bf402b6dd4ea637ad1b7d8b3ebd69300.tar.bz2 |
added volume handling for audio gui and other small fixes
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 14 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 38 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.h | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/opieplayer2.pro | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 23 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/volumecontrol.cpp | 59 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/volumecontrol.h | 47 |
9 files changed, 145 insertions, 47 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 0e9e7ea..955169c 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -47,49 +47,49 @@ void Ticker::timerEvent( QTimerEvent * ) { scroll( -1, 0, contentsRect() ); repaint( FALSE ); } void Ticker::drawContents( QPainter *p ) { for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); QPixmap pm( width(), height() ); pm.fill( colorGroup().base() ); QPainter pmp( &pm ); for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); } p->drawPixmap( 0, 0, pm ); } 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 }, // 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 }; const char *skin_mask_file_names[11] = { "play", "stop", "pause", "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)); @@ -321,88 +321,88 @@ void AudioWidget::updateSlider( long i, long max ) { void AudioWidget::setToggleButton( int i, bool down ) { if ( down != audioButtons[i].isDown ) { toggleButton( i ); } } void AudioWidget::toggleButton( int i ) { audioButtons[i].isDown = !audioButtons[i].isDown; QPainter p(this); paintButton ( &p, i ); } void AudioWidget::paintButton( QPainter *p, int i ) { if ( audioButtons[i].isDown ) p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); else p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); } void AudioWidget::timerEvent( QTimerEvent * ) { -// static int frame = 0; -// if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { -// frame = frame >= 7 ? 0 : frame + 1; -// } } void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { for ( int i = 0; i < numButtons; i++ ) { if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the button or not int x = event->pos().x() - xoff; int y = event->pos().y() - yoff; bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); if ( isOnButton && i == AudioVolumeUp ) qDebug("on up"); if ( isOnButton && !audioButtons[i].isHeld ) { audioButtons[i].isHeld = TRUE; toggleButton(i); switch (i) { case AudioVolumeUp: qDebug("more clicked"); emit moreClicked(); return; - case AudioVolumeDown: emit lessClicked(); return; + case AudioVolumeDown: + emit lessClicked(); + return; } } else if ( !isOnButton && audioButtons[i].isHeld ) { audioButtons[i].isHeld = FALSE; toggleButton(i); } } else { if ( audioButtons[i].isHeld ) { audioButtons[i].isHeld = FALSE; - if ( !audioButtons[i].isToggle ) + if ( !audioButtons[i].isToggle ) { setToggleButton( i, FALSE ); + qDebug("button toggled3 %d",i); + } switch (i) { case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; case AudioStop: mediaPlayerState->setPlaying(FALSE); return; case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; case AudioNext: mediaPlayerState->setNext(); return; case AudioPrevious: mediaPlayerState->setPrev(); return; case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; case AudioVolumeUp: emit moreReleased(); return; case AudioVolumeDown: emit lessReleased(); return; case AudioPlayList: mediaPlayerState->setList(); return; } } } } } void AudioWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { mouseMoveEvent( event ); diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 5411a64..8d8e4e5 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -1,68 +1,73 @@ #include <qpe/qpeapplication.h> #include <qpe/qlibrary.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qmainwindow.h> #include <qmessagebox.h> #include <qwidgetstack.h> #include <qfile.h> #include "mediaplayer.h" #include "playlistwidget.h" #include "audiowidget.h" +#include "volumecontrol.h" #include "mediaplayerstate.h" extern AudioWidget *audioUI; extern PlayListWidget *playList; extern MediaPlayerState *mediaPlayerState; MediaPlayer::MediaPlayer( QObject *parent, const char *name ) : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { xineControl = new XineControl(); // QPEApplication::grabKeyboard(); // EVIL connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); + volControl = new VolumeControl; + } MediaPlayer::~MediaPlayer() { + delete xineControl; + delete volControl; } void MediaPlayer::pauseCheck( bool b ) { // Only pause if playing if ( b && !mediaPlayerState->playing() ) { mediaPlayerState->setPaused( FALSE ); } } void MediaPlayer::play() { mediaPlayerState->setPlaying( FALSE ); mediaPlayerState->setPlaying( TRUE ); } void MediaPlayer::setPlaying( bool play ) { if ( !play ) { mediaPlayerState->setPaused( FALSE ); return; } if ( mediaPlayerState->paused() ) { mediaPlayerState->setPaused( FALSE ); return; } @@ -104,120 +109,121 @@ void MediaPlayer::prev() { play(); } } else { mediaPlayerState->setList(); } } void MediaPlayer::next() { if ( playList->next() ) { play(); } else if ( mediaPlayerState->looping() ) { if ( playList->first() ) { play(); } } else { mediaPlayerState->setList(); } } void MediaPlayer::startDecreasingVolume() { volumeDirection = -1; startTimer( 100 ); - // da kommt demnächst osound denk ich mal - /////////////////////////// lets just move those change volume here - // AudioDevice::decreaseVolume(); + volControl->decVol(2); } void MediaPlayer::startIncreasingVolume() { volumeDirection = +1; startTimer( 100 ); - // AudioDevice::increaseVolume(); + volControl->incVol(2); } bool drawnOnScreenDisplay = FALSE; unsigned int onScreenDisplayVolume = 0; const int yoff = 110; void MediaPlayer::stopChangingVolume() { killTimers(); // Get rid of the on-screen display stuff drawnOnScreenDisplay = FALSE; onScreenDisplayVolume = 0; int w = audioUI->width(); int h = audioUI->height(); audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); } void MediaPlayer::timerEvent( QTimerEvent * ) { - // if ( volumeDirection == +1 ) - // AudioDevice::increaseVolume(); - // else if ( volumeDirection == -1 ) - // AudioDevice::decreaseVolume(); + if ( volumeDirection == +1 ) { + volControl->incVol(2); + } else if ( volumeDirection == -1 ) { + volControl->decVol(2); + } -// Display an on-screen display volume - unsigned int l, r, v; bool m; // TODO FIXME -// AudioDevice::getVolume( l, r, m ); -// v = ((l + r) * 11) / (2*0xFFFF); + int v; + v = volControl->getVolume(); + v = v / 10; - if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) + if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { return; + } int w = audioUI->width(); int h = audioUI->height(); if ( drawnOnScreenDisplay ) { - if ( onScreenDisplayVolume > v ) + if ( onScreenDisplayVolume > v ) { audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); } + } drawnOnScreenDisplay = TRUE; onScreenDisplayVolume = v; QPainter p( audioUI ); p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); QFont f; f.setPixelSize( 20 ); f.setBold( TRUE ); p.setFont( f ); p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); for ( unsigned int i = 0; i < 10; i++ ) { - if ( v > i ) + if ( v > i ) { p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); - else + } else { p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); } } +} void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: break; case Key_F9: //activity break; case Key_F10: //contacts break; case Key_F11: //menu break; case Key_F12: //home qDebug("Blank here"); break; case Key_F13: //mail break; } } void MediaPlayer::doBlank() { } diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h index 7b79066..16213b5 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.h +++ b/noncore/multimedia/opieplayer2/mediaplayer.h @@ -1,46 +1,46 @@ #ifndef MEDIA_PLAYER_H #define MEDIA_PLAYER_H #include <qmainwindow.h> #include <qframe.h> #include <qpe/qlibrary.h> #include <qpe/mediaplayerplugininterface.h> #include "xinecontrol.h" class DocLnk; - +class VolumeControl; class MediaPlayer : public QObject { Q_OBJECT public: MediaPlayer( QObject *parent, const char *name ); ~MediaPlayer(); private slots: void setPlaying( bool ); void pauseCheck( bool ); void play(); void next(); void prev(); void startIncreasingVolume(); void startDecreasingVolume(); void stopChangingVolume(); void cleanUp(); protected: void timerEvent( QTimerEvent *e ); void keyReleaseEvent( QKeyEvent *e); void doBlank(); void doUnblank(); private: int volumeDirection; const DocLnk *currentFile; XineControl *xineControl; - + VolumeControl *volControl; }; #endif // MEDIA_PLAYER_H diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro index fee9242..edc4624 100644 --- a/noncore/multimedia/opieplayer2/opieplayer2.pro +++ b/noncore/multimedia/opieplayer2/opieplayer2.pro @@ -1,23 +1,23 @@ TEMPLATE = app CONFIG = qt warn_on release #release DESTDIR = $(OPIEDIR)/bin HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ - frame.h lib.h xinevideowidget.h \ + frame.h lib.h xinevideowidget.h volumecontrol.h\ alphablend.h yuv2rgb.h SOURCES = main.cpp \ playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ - frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp \ + frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp\ alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S TARGET = opieplayer2 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lpthread -lopie -lxine -lxineutils MOC_DIR=qpeobj OBJECTS_DIR=qpeobj INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 9065d63..b43d9f7 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -143,49 +143,49 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 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( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); pmPlayList->insertSeparator(-1); 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); + //scaleButton->addTo(pmView); 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" ); 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 ); diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index af06079..188b18d 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp @@ -11,49 +11,48 @@ .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qpe/resource.h> -#include <qpe/mediaplayerplugininterface.h> #include <qpe/config.h> #include <qwidget.h> #include <qpainter.h> #include <qpixmap.h> #include <qslider.h> #include <qdrawutil.h> #include "videowidget.h" #include "mediaplayerstate.h" #ifdef Q_WS_QWS # define USE_DIRECT_PAINTER # include <qdirectpainter_qws.h> # include <qgfxraster_qws.h> #endif extern MediaPlayerState *mediaPlayerState; static const int xo = 2; // movable x offset static const int yo = 0; // movable y offset @@ -66,68 +65,69 @@ struct MediaButton { // Layout information for the videoButtons (and if it is a toggle button or not) MediaButton videoButtons[] = { { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen }; static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { setCaption( tr("OpiePlayer - Video") ); Config cfg("OpiePlayer"); cfg.setGroup("VideoWidget"); QString Button0aPix, Button0bPix, controlsPix; - //backgroundPix=cfg.readEntry( "backgroundPix", "opieplayer/metalFinish"); Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); cfg.setGroup("AudioWidget"); QString skin = cfg.readEntry("Skin","default"); QString skinPath = "opieplayer/skins/" + skin; backgroundPix = QString("%1/background").arg(skinPath) ; setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); slider = new QSlider( Qt::Horizontal, this ); slider->setMinValue( 0 ); slider->setMaxValue( 1 ); - slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); + + slider->setBackgroundPixmap( *this->backgroundPixmap () ); //Resource::loadPixmap( backgroundPix ) ); + slider->setBackgroundOrigin( QWidget::ParentOrigin); slider->setFocusPolicy( QWidget::NoFocus ); slider->setGeometry( QRect( 7, 250, 220, 20 ) ); videoFrame = new XineVideoWidget ( this, "Video frame" ); connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 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( positionChanged(long) ),this, SLOT( setPosition(long) ) ); connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 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() ); setFullscreen( mediaPlayerState->fullscreen() ); setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); @@ -223,49 +223,51 @@ void VideoWidget::paintButton( QPainter *p, int i ) { } void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { for ( int i = 0; i < numButtons; i++ ) { int x = videoButtons[i].xPos; int y = videoButtons[i].yPos; if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the circular button or not // (compared with the radius squared to avoid a square-root of our distance) int radius = 16; QPoint center = QPoint( x + radius, y + radius ); QPoint dXY = center - event->pos(); int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); bool isOnButton = dist <= (radius * radius); if ( isOnButton != videoButtons[i].isHeld ) { videoButtons[i].isHeld = isOnButton; toggleButton(i); } } else { if ( videoButtons[i].isHeld ) { videoButtons[i].isHeld = FALSE; if ( !videoButtons[i].isToggle ) setToggleButton( i, FALSE ); + qDebug("button toggled3 %d",i); } + } switch (i) { case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; case VideoStop: mediaPlayerState->setPlaying(FALSE); return; case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; case VideoNext: mediaPlayerState->setNext(); return; case VideoPrevious: mediaPlayerState->setPrev(); return; case VideoPlayList: mediaPlayerState->setList(); return; case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; } } } void VideoWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { if ( mediaPlayerState->fullscreen() ) { mediaPlayerState->setFullscreen( FALSE ); makeVisible(); @@ -298,63 +300,48 @@ void VideoWidget::paintEvent( QPaintEvent * ) { if ( mediaPlayerState->fullscreen() ) { // Clear the background p.setBrush( QBrush( Qt::black ) ); // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); } else { // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); // draw the buttons for ( int i = 0; i < numButtons; i++ ) { paintButton( &p, i ); } // draw the slider slider->repaint( TRUE ); } } void VideoWidget::closeEvent( QCloseEvent* ) { mediaPlayerState->setList(); } -bool VideoWidget::playVideo() { - bool result = FALSE; - - int stream = 0; - - int sw = 240; - int sh = 320; - int dd = QPixmap::defaultDepth(); - int w = height(); - int h = width(); - - return true; -} - - void VideoWidget::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: break; case Key_F9: //activity break; case Key_F10: //contacts // hide(); break; case Key_F11: //menu break; case Key_F12: //home break; case Key_F13: //mail break; case Key_Space: { if(mediaPlayerState->playing()) { mediaPlayerState->setPlaying(FALSE); } else { mediaPlayerState->setPlaying(TRUE); } diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index fc53f89..04e810e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h @@ -35,49 +35,48 @@ #define VIDEO_WIDGET_H #include <qwidget.h> #include "xinevideowidget.h" class QPixmap; class QSlider; enum VideoButtons { VideoPrevious, VideoStop, VideoPlay, VideoPause, VideoNext, VideoPlayList, VideoFullscreen }; class VideoWidget : public QWidget { Q_OBJECT public: VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); ~VideoWidget(); - bool playVideo(); XineVideoWidget* vidWidget(); public slots: void updateSlider( long, long ); void sliderPressed( ); void sliderReleased( ); void setPaused( bool b) { setToggleButton( VideoPause, b ); } void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } void setFullscreen( bool b ); void makeVisible(); void setPosition( long ); void setLength( long ); void setView( char ); signals: void sliderMoved( long ); void videoResized ( const QSize &s ); protected: void paintEvent( QPaintEvent *pe ); void mouseMoveEvent( QMouseEvent *event ); void mousePressEvent( QMouseEvent *event ); void mouseReleaseEvent( QMouseEvent *event ); void closeEvent( QCloseEvent *event ); void keyReleaseEvent( QKeyEvent *e); diff --git a/noncore/multimedia/opieplayer2/volumecontrol.cpp b/noncore/multimedia/opieplayer2/volumecontrol.cpp new file mode 100644 index 0000000..b8ec0df --- a/dev/null +++ b/noncore/multimedia/opieplayer2/volumecontrol.cpp @@ -0,0 +1,59 @@ + +#include <qpe/qpeapplication.h> +#include <qpe/config.h> +#include "qpe/qcopenvelope_qws.h" +#include <qmessagebox.h> + +#include "volumecontrol.h" + +int VolumeControl::getVolume() { + int volumePerc; + Config cfg( "qpe" ); + cfg. setGroup( "Volume" ); + volumePerc = cfg. readNumEntry( "VolumePercent", 50 ); + m_volumePerc = volumePerc; + return volumePerc; +} + + +void VolumeControl::setVolume( int volumePerc ) { + Config cfg("qpe"); + cfg.setGroup("Volume"); + + if ( volumePerc > 100 ) { + volumePerc = 100; + } + if ( volumePerc < 0 ) { + volumePerc = 0; + } + + m_volumePerc = volumePerc; + cfg.writeEntry("VolumePercent", volumePerc ); + QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; +} + + +void VolumeControl::incVol( int ammount ) { + int oldVol = getVolume(); + setVolume( oldVol + ammount); +} + +void VolumeControl::decVol( int ammount ) { + int oldVol = getVolume(); + setVolume( oldVol - ammount); +} + + +VolumeControl::VolumeControl( ) { + getVolume(); +} + +VolumeControl::~VolumeControl() { + QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; +} + + + + + + diff --git a/noncore/multimedia/opieplayer2/volumecontrol.h b/noncore/multimedia/opieplayer2/volumecontrol.h new file mode 100644 index 0000000..37be398 --- a/dev/null +++ b/noncore/multimedia/opieplayer2/volumecontrol.h @@ -0,0 +1,47 @@ +/************* + * this is only a quick hack and will be later replaced by osound + * + **********/ + + +#ifndef VOLUMECONTROL_H +#define VOLUMECONTROL_H + + + +#include <qobject.h> + +class VolumeControl : public QObject { + Q_OBJECT +public: + VolumeControl(); + ~VolumeControl(); + + // increase by "ammount" + void incVol( int ammount ); + void decVol( int ammount ); + + /** + * Get the volume in percent + * @return volume percentage + */ + int getVolume(); + +public slots: + + /** + * Set the volume in percent + * @value volumePerc between 0 and 100 + */ + void setVolume( int volumePerc ); + + + +private: + + int m_volumePerc; + +}; + +#endif + |