summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h1
6 files changed, 7 insertions, 12 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 3070bc3..f6e6086 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -185,338 +185,333 @@ AudioWidget::~AudioWidget() {
// mediaPlayerState->setPlaying(false);
}
namespace {
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 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, 2, w - 4, 20 ) );
slider.setFixedWidth( w - 110 );
slider.setGeometry( QRect( 15, h - 22, 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 < 10; i++ ) {
if ( !masks[i]->isNull() ) {
delete buttonPixUp[i];
delete buttonPixDown[i];
buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] );
buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] );
}
}
}
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);
updateSlider( i, mediaPlayerState.length() );
}
void AudioWidget::setLength( long max ) {
updateSlider( mediaPlayerState.position(), max );
}
void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
if ( mediaType == MediaPlayerState::Audio ) {
// startTimer( 150 );
showMaximized();
return;
}
killTimers();
hide();
}
void AudioWidget::setSeekable( bool isSeekable ) {
if ( !isSeekable ) {
qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
if( !slider.isHidden()) {
slider.hide();
}
disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
} else {
// this stops the slider from being moved, thus
// does not stop stream when it reaches the end
slider.show();
qDebug( " CONNECT SET POSTION " );
connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
}
}
static QString timeAsString( long length ) {
int minutes = length / 60;
int seconds = length % 60;
return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
}
void AudioWidget::updateSlider( long i, long max ) {
time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
if ( max == 0 ) {
return;
}
// Will flicker too much if we don't do this
// Scale to something reasonable
int width = slider.width();
int val = int((double)i * width / max);
if ( !audioSliderBeingMoved ) {
if ( slider.value() != val ) {
slider.setValue( val );
}
if ( slider.maxValue() != width ) {
slider.setMaxValue( width );
}
}
}
void AudioWidget::setToggleButton( int i, bool down ) {
qDebug("setToggleButton %d", i);
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::skipFor() {
skipDirection = +1;
startTimer( 50 );
mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
}
void AudioWidget::skipBack() {
skipDirection = -1;
startTimer( 50 );
mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
}
void AudioWidget::stopSkip() {
killTimers();
}
void AudioWidget::timerEvent( QTimerEvent * ) {
if ( skipDirection == +1 ) {
mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
} else if ( skipDirection == -1 ) {
mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
}
}
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 && !audioButtons[i].isHeld ) {
audioButtons[i].isHeld = TRUE;
toggleButton(i);
switch (i) {
case VolumeUp:
emit moreClicked();
return;
case VolumeDown:
emit lessClicked();
return;
case Forward:
emit forwardClicked();
return;
case Back:
emit backClicked();
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 ) {
setToggleButton( i, FALSE );
}
qDebug("mouseEvent %d", i);
handleCommand( static_cast<Command>( i ), audioButtons[ i ].isDown );
}
}
}
}
void AudioWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void AudioWidget::showEvent( QShowEvent* ) {
QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
mouseMoveEvent( &event );
}
-void AudioWidget::closeEvent( QCloseEvent* ) {
- mediaPlayerState.setList();
-}
-
-
void AudioWidget::paintEvent( QPaintEvent * pe ) {
if ( !pe->erased() ) {
// Combine with background and double buffer
QPixmap pix( pe->rect().size() );
QPainter p( &pix );
p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
for ( int i = 0; i < numButtons; i++ )
paintButton( &p, i );
QPainter p2( this );
p2.drawPixmap( pe->rect().topLeft(), pix );
} else {
QPainter p( this );
for ( int i = 0; i < numButtons; i++ )
paintButton( &p, i );
}
}
void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_Home:
break;
case Key_F9: //activity
hide();
// qDebug("Audio F9");
break;
case Key_F10: //contacts
break;
case Key_F11: //menu
mediaPlayerState.toggleBlank();
break;
case Key_F12: //home
break;
case Key_F13: //mail
mediaPlayerState.toggleBlank();
break;
case Key_Space: {
if(mediaPlayerState.isPlaying()) {
// toggleButton(1);
mediaPlayerState.setPlaying(FALSE);
// toggleButton(1);
} else {
// toggleButton(0);
mediaPlayerState.setPlaying(TRUE);
// toggleButton(0);
}
}
break;
case Key_Down:
// toggleButton(6);
emit lessClicked();
emit lessReleased();
// toggleButton(6);
break;
case Key_Up:
// toggleButton(5);
emit moreClicked();
emit moreReleased();
// toggleButton(5);
break;
case Key_Right:
// toggleButton(3);
mediaPlayerState.setNext();
// toggleButton(3);
break;
case Key_Left:
// toggleButton(4);
mediaPlayerState.setPrev();
// toggleButton(4);
break;
case Key_Escape: {
}
break;
};
}
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 1778a30..f092699 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -1,118 +1,117 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= 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.
*/
#ifndef AUDIO_WIDGET_H
#define AUDIO_WIDGET_H
#include <qpainter.h>
#include <qdrawutil.h>
#include <qpixmap.h>
#include <qstring.h>
#include <qslider.h>
#include <qframe.h>
#include <qlineedit.h>
#include <qimage.h>
#include <opie/oticker.h>
#include "mediawidget.h"
class QPixmap;
class AudioWidget : public MediaWidget {
Q_OBJECT
public:
AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
~AudioWidget();
void setTickerText( const QString &text ) { songInfo.setText( text ); }
public slots:
void updateSlider( long, long );
void sliderPressed( );
void sliderReleased( );
void setLooping( bool b) { setToggleButton( Loop, b ); }
void setPosition( long );
void setSeekable( bool );
public:
virtual void setLength( long );
virtual void setPlaying( bool b) { setToggleButton( Play, b ); }
virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
signals:
void moreClicked();
void lessClicked();
void forwardClicked();
void backClicked();
void sliderMoved(long);
protected:
void doBlank();
void doUnblank();
void paintEvent( QPaintEvent *pe );
void showEvent( QShowEvent *se );
void resizeEvent( QResizeEvent *re );
void mouseMoveEvent( QMouseEvent *event );
void mousePressEvent( QMouseEvent *event );
void mouseReleaseEvent( QMouseEvent *event );
void timerEvent( QTimerEvent *event );
- void closeEvent( QCloseEvent *event );
void keyReleaseEvent( QKeyEvent *e);
private slots:
void skipFor();
void skipBack();
void stopSkip();
private:
void toggleButton( int );
void setToggleButton( int, bool );
void paintButton( QPainter *p, int i );
int skipDirection;
QString skin;
QPixmap pixBg;
QImage imgUp;
QImage imgDn;
QImage imgButtonMask;
QBitmap *masks[10];
QPixmap *buttonPixUp[10];
QPixmap *buttonPixDown[10];
QPixmap *pixmaps[4];
OTicker songInfo;
QSlider slider;
QLineEdit time;
int xoff, yoff;
bool isStreaming : 1;
};
#endif // AUDIO_WIDGET_H
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 01a7295..2992fd6 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -1,58 +1,63 @@
/*
Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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 "mediawidget.h"
#include "playlistwidget.h"
extern PlayListWidget *playList;
MediaWidget::MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
: QWidget( parent, name ), mediaPlayerState( _mediaPlayerState )
{
connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
this, SLOT( setLength( long ) ) );
connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
this, SLOT( setPlaying( bool ) ) );
}
MediaWidget::~MediaWidget()
{
}
+void MediaWidget::closeEvent( QCloseEvent * )
+{
+ mediaPlayerState.setList();
+}
+
void MediaWidget::handleCommand( Command command, bool buttonDown )
{
switch ( command ) {
case Play: mediaPlayerState.togglePaused();
case Stop: mediaPlayerState.setPlaying(FALSE); return;
case Next: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
case Previous: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
case Loop: mediaPlayerState.setLooping( buttonDown ); return;
case VolumeUp: emit moreReleased(); return;
case VolumeDown: emit lessReleased(); return;
case PlayList: mediaPlayerState.setList(); return;
case Forward: emit forwardReleased(); return;
case Back: emit backReleased(); return;
}
}
/* vim: et sw=4 ts=4
*/
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 550f0fc..e3f09ce 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -1,55 +1,57 @@
/*
Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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.
*/
#ifndef MEDIAWIDGET_H
#define MEDIAWIDGET_H
#include <qwidget.h>
#include "mediaplayerstate.h"
class MediaWidget : public QWidget
{
Q_OBJECT
public:
enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back };
MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
virtual ~MediaWidget();
public slots:
virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
virtual void setLength( long length ) = 0;
virtual void setPlaying( bool playing ) = 0;
signals:
void moreReleased();
void lessReleased();
void forwardReleased();
void backReleased();
protected:
+ virtual void closeEvent( QCloseEvent * );
+
void handleCommand( Command command, bool buttonDown );
MediaPlayerState &mediaPlayerState;
};
#endif // MEDIAWIDGET_H
/* vim: et sw=4 ts=4
*/
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index b4ecb4c..41dddb7 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -194,323 +194,318 @@ void VideoWidget::resizeEvent( QResizeEvent * ) {
QPoint p( xoff, yoff );
QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
for ( int i = 0; i < 7; i++ ) {
if ( !masks[i]->isNull() ) {
delete buttonPixUp[i];
delete buttonPixDown[i];
buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
}
}
delete pixUp;
delete pixDn;
}
static bool videoSliderBeingMoved = FALSE;
void VideoWidget::sliderPressed() {
videoSliderBeingMoved = TRUE;
}
void VideoWidget::sliderReleased() {
videoSliderBeingMoved = FALSE;
if ( slider->width() == 0 ) {
return;
}
long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
mediaPlayerState.setPosition( val );
}
void VideoWidget::setPosition( long i ) {
updateSlider( i, mediaPlayerState.length() );
}
void VideoWidget::setLength( long max ) {
updateSlider( mediaPlayerState.position(), max );
}
void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
{
if ( displayType == MediaPlayerState::Video ) {
makeVisible();
return;
}
// Effectively blank the view next time we show it so it looks nicer
scaledWidth = 0;
scaledHeight = 0;
hide();
}
void VideoWidget::updateSlider( long i, long max ) {
// Will flicker too much if we don't do this
if ( max == 0 ) {
return;
}
int width = slider->width();
int val = int((double)i * width / max);
if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
if ( slider->value() != val ) {
slider->setValue( val );
}
if ( slider->maxValue() != width ) {
slider->setMaxValue( width );
}
}
}
void VideoWidget::setToggleButton( int i, bool down ) {
if ( down != videoButtons[i].isDown ) {
toggleButton( i );
}
}
void VideoWidget::toggleButton( int i ) {
videoButtons[i].isDown = !videoButtons[i].isDown;
QPainter p(this);
paintButton ( &p, i );
}
void VideoWidget::paintButton( QPainter *p, int i ) {
if ( videoButtons[i].isDown ) {
p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
} else {
p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
}
}
void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
for ( int i = 0; i < numVButtons; 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 && !videoButtons[i].isHeld ) {
videoButtons[i].isHeld = TRUE;
toggleButton(i);
switch (i) {
case VideoVolUp:
emit moreClicked();
return;
case VideoVolDown:
emit lessClicked();
return;
}
} else if ( !isOnButton && videoButtons[i].isHeld ) {
videoButtons[i].isHeld = FALSE;
toggleButton(i);
}
} else {
if ( videoButtons[i].isHeld ) {
videoButtons[i].isHeld = FALSE;
if ( !videoButtons[i].isToggle ) {
setToggleButton( i, FALSE );
}
switch(i) {
case VideoPlay: {
if( mediaPlayerState.isPaused() ) {
setToggleButton( i, FALSE );
mediaPlayerState.setPaused( FALSE );
return;
} else if( !mediaPlayerState.isPaused() ) {
setToggleButton( i, TRUE );
mediaPlayerState.setPaused( TRUE );
return;
} else {
return;
}
}
case VideoStop: mediaPlayerState.setPlaying( FALSE ); return;
case VideoNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
case VideoPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
case VideoVolUp: emit moreReleased(); return;
case VideoVolDown: emit lessReleased(); return;
case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
}
}
}
}
}
void VideoWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
if ( mediaPlayerState.isFullscreen() ) {
mediaPlayerState.setFullscreen( FALSE );
makeVisible();
}
mouseMoveEvent( event );
}
void VideoWidget::showEvent( QShowEvent* ) {
QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
mouseMoveEvent( &event );
}
void VideoWidget::backToNormal() {
mediaPlayerState.setFullscreen( FALSE );
makeVisible();
}
void VideoWidget::makeVisible() {
if ( mediaPlayerState.isFullscreen() ) {
setBackgroundMode( QWidget::NoBackground );
showFullScreen();
resize( qApp->desktop()->size() );
videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
slider->hide();
disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
} else {
showNormal();
showMaximized();
setBackgroundPixmap( *pixBg );
QWidget *d = QApplication::desktop();
int w = d->width();
int h = d->height();
if(w>h) {
int newW=(w/2)-(246/2); //this will only work with 320x240
videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
} else {
videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
}
if ( !mediaPlayerState.isSeekable() ) {
if( !slider->isHidden()) {
slider->hide();
}
disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
} else {
slider->show();
connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
}
}
}
void VideoWidget::paintEvent( QPaintEvent * pe) {
QPainter p( this );
if ( mediaPlayerState.isFullscreen() ) {
// Clear the background
p.setBrush( QBrush( Qt::black ) );
} else {
if ( !pe->erased() ) {
// Combine with background and double buffer
QPixmap pix( pe->rect().size() );
QPainter p( &pix );
p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
for ( int i = 0; i < numVButtons; i++ ) {
paintButton( &p, i );
}
QPainter p2( this );
p2.drawPixmap( pe->rect().topLeft(), pix );
} else {
QPainter p( this );
for ( int i = 0; i < numVButtons; i++ )
paintButton( &p, i );
}
//slider->repaint( TRUE );
}
}
-void VideoWidget::closeEvent( QCloseEvent* ) {
- mediaPlayerState.setList();
-}
-
-
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.isPlaying()) {
mediaPlayerState.setPlaying(FALSE);
} else {
mediaPlayerState.setPlaying(TRUE);
}
}
break;
case Key_Down:
// toggleButton(6);
emit lessClicked();
emit lessReleased();
// toggleButton(6);
break;
case Key_Up:
// toggleButton(5);
emit moreClicked();
emit moreReleased();
// toggleButton(5);
break;
case Key_Right:
mediaPlayerState.setNext();
break;
case Key_Left:
mediaPlayerState.setPrev();
break;
case Key_Escape:
break;
};
}
XineVideoWidget* VideoWidget::vidWidget() {
return videoFrame;
}
void VideoWidget::setFullscreen ( bool b ) {
setToggleButton( VideoFullscreen, b );
}
void VideoWidget::setPlaying( bool b) {
setToggleButton( VideoPlay, b );
}
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 38eb726..149c78e 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -1,127 +1,126 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= 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.
*/
#ifndef VIDEO_WIDGET_H
#define VIDEO_WIDGET_H
#include <qwidget.h>
#include "xinevideowidget.h"
#include "mediawidget.h"
class QPixmap;
class QSlider;
enum VideoButtons {
VideoStop = 0,
VideoPlay,
// VideoPause,
VideoPrevious,
VideoNext,
VideoVolUp,
VideoVolDown,
VideoFullscreen
};
class VideoWidget : public MediaWidget {
Q_OBJECT
public:
VideoWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
~VideoWidget();
XineVideoWidget* vidWidget();
public slots:
void updateSlider( long, long );
void sliderPressed( );
void sliderReleased( );
void setFullscreen( bool b );
void makeVisible();
void backToNormal();
void setPosition( long );
public:
virtual void setPlaying( bool b);
virtual void setLength( long );
virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
signals:
void moreClicked();
void lessClicked();
void moreReleased();
void lessReleased();
void sliderMoved( long );
void videoResized ( const QSize &s );
protected:
void resizeEvent( QResizeEvent * );
void paintEvent( QPaintEvent *pe );
void showEvent( QShowEvent *se );
void mouseMoveEvent( QMouseEvent *event );
void mousePressEvent( QMouseEvent *event );
void mouseReleaseEvent( QMouseEvent *event );
- void closeEvent( QCloseEvent *event );
void keyReleaseEvent( QKeyEvent *e);
private:
// Ticker songInfo;
QPixmap *pixBg;
QImage *imgUp;
QImage *imgDn;
QImage *imgButtonMask;
QBitmap *masks[7];
QPixmap *buttonPixUp[7];
QPixmap *buttonPixDown[7];
QString skin;
// QPixmap *pixmaps[4];
int xoff, yoff;
void paintButton( QPainter *p, int i );
void toggleButton( int );
void setToggleButton( int, bool );
QString backgroundPix;
QSlider *slider;
QPixmap *pixmaps[3];
QImage *currentFrame;
int scaledWidth;
int scaledHeight;
XineVideoWidget* videoFrame;
};
#endif // VIDEO_WIDGET_H