summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp83
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/main.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.h1
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp47
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h2
9 files changed, 87 insertions, 61 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index fd18dbb..0516089 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -43,237 +43,240 @@
#include <qframe.h>
#include <qlayout.h>
#include <qdir.h>
#include <stdlib.h>
#include <stdio.h>
#include "audiowidget.h"
#include "mediaplayerstate.h"
#include "playlistwidget.h"
namespace
{
const int xo = -2; // movable x offset
const int yo = 22; // movable y offset
const MediaWidget::SkinButtonInfo skinInfo[] =
{
{ MediaWidget::Play, "play", MediaWidget::ToggleButton },
{ MediaWidget::Stop, "stop", MediaWidget::NormalButton },
{ MediaWidget::Next, "next", MediaWidget::NormalButton },
{ MediaWidget::Previous, "prev", MediaWidget::NormalButton },
{ MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
{ MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
{ MediaWidget::Loop, "loop", MediaWidget::ToggleButton },
{ MediaWidget::PlayList, "playlist", MediaWidget::NormalButton },
{ MediaWidget::Forward, "forward", MediaWidget::NormalButton },
{ MediaWidget::Back, "back", MediaWidget::NormalButton }
};
const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
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 );
}
}
AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ),
audioSliderBeingMoved( false )
{
setCaption( tr("OpiePlayer") );
- Config cfg("OpiePlayer");
- cfg.setGroup("Options");
- skin = cfg.readEntry("Skin","default");
- //skin = "scaleTest";
- // color of background, frame, degree of transparency
-
- QString skinPath = "opieplayer2/skins/" + skin;
- backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
- imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
- imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
-
- setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_", imgUp.size() );
-
- setBackgroundPixmap( backgroundPixmap );
-
- songInfo.setFocusPolicy( QWidget::NoFocus );
-// changeTextColor( &songInfo );
-// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
-// songInfo.setFrameStyle( QFrame::NoFrame);
- songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
-// songInfo.setForegroundColor(Qt::white);
-
- slider.setFixedHeight( 20 );
- slider.setMinValue( 0 );
- slider.setMaxValue( 1 );
- slider.setFocusPolicy( QWidget::NoFocus );
- slider.setBackgroundPixmap( backgroundPixmap );
-
-// Config cofg("qpe");
-// cofg.setGroup("Appearance");
-// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
-
- time.setFocusPolicy( QWidget::NoFocus );
- time.setAlignment( Qt::AlignCenter );
-
-// time.setFrame(FALSE);
-// changeTextColor( &time );
-
- resizeEvent( NULL );
+ loadSkin();
connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
// Intialise state
setLength( mediaPlayerState.length() );
setPosition( mediaPlayerState.position() );
setLooping( mediaPlayerState.isFullscreen() );
// setPaused( mediaPlayerState->paused() );
setPlaying( mediaPlayerState.isPlaying() );
-
}
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( 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 ) );
upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2;
upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10;
QPoint p = upperLeftOfButtonMask;
QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p );
QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p );
for ( uint i = 0; i < buttons.size(); i++ ) {
if ( !buttons[i].mask.isNull() ) {
buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask );
buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask );
}
}
}
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::loadSkin()
+{
+ Config cfg("OpiePlayer");
+ cfg.setGroup("Options");
+ skin = cfg.readEntry("Skin","default");
+ //skin = "scaleTest";
+ // color of background, frame, degree of transparency
+
+ QString skinPath = "opieplayer2/skins/" + skin;
+ backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
+ imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
+ imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
+
+ setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_", imgUp.size() );
+
+ setBackgroundPixmap( backgroundPixmap );
+
+ songInfo.setFocusPolicy( QWidget::NoFocus );
+// changeTextColor( &songInfo );
+// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
+// songInfo.setFrameStyle( QFrame::NoFrame);
+ songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
+// songInfo.setForegroundColor(Qt::white);
+
+ slider.setFixedHeight( 20 );
+ slider.setMinValue( 0 );
+ slider.setMaxValue( 1 );
+ slider.setFocusPolicy( QWidget::NoFocus );
+ slider.setBackgroundPixmap( backgroundPixmap );
+
+// Config cofg("qpe");
+// cofg.setGroup("Appearance");
+// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
+
+ time.setFocusPolicy( QWidget::NoFocus );
+ time.setAlignment( Qt::AlignCenter );
+
+// time.setFrame(FALSE);
+// changeTextColor( &time );
+
+ resizeEvent( 0 );
+}
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 );
}
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 53982a1..61556c6 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -23,77 +23,79 @@
++=   -.     .`     .: 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( PlayListWidget &playList, 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 );
+ virtual void loadSkin();
+
signals:
void sliderMoved(long);
protected:
void doBlank();
void doUnblank();
void resizeEvent( QResizeEvent *re );
void timerEvent( QTimerEvent *event );
void keyReleaseEvent( QKeyEvent *e);
private slots:
void skipFor();
void skipBack();
void stopSkip();
private:
int skipDirection;
QString skin;
QImage imgUp;
QImage imgDn;
OTicker songInfo;
QSlider slider;
QLineEdit time;
bool isStreaming : 1;
bool audioSliderBeingMoved : 1;
};
#endif // AUDIO_WIDGET_H
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp
index ffc7cb6..f87cee8 100644
--- a/noncore/multimedia/opieplayer2/main.cpp
+++ b/noncore/multimedia/opieplayer2/main.cpp
@@ -1,22 +1,22 @@
#include <qpe/qpeapplication.h>
#include "mediaplayerstate.h"
#include "playlistwidget.h"
#include "mediaplayer.h"
int main(int argc, char **argv) {
QPEApplication a(argc,argv);
MediaPlayerState st( 0, "mediaPlayerState" );
PlayListWidget pl( st, 0, "playList" );
pl.showMaximized();
MediaPlayer mp( pl, st, 0, "mediaPlayer" );
QObject::connect( &pl, SIGNAL( skinSelected() ),
- &mp, SLOT( recreateAudioAndVideoWidgets() ) );
+ &mp, SLOT( reloadSkins() ) );
a.showMainDocumentWidget(&pl);
return a.exec();
}
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index e1bfc2d..8a3d3e0 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -322,48 +322,54 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
break;
case Key_F9: //activity
break;
case Key_F10: //contacts
break;
case Key_F11: //menu
break;
case Key_F12: //home
qDebug("Blank here");
// mediaPlayerState->toggleBlank();
break;
case Key_F13: //mail
qDebug("Blank here");
// mediaPlayerState->toggleBlank();
break;
}
}
void MediaPlayer::cleanUp() {// this happens on closing
Config cfg( "OpiePlayer" );
mediaPlayerState.writeConfig( cfg );
playList.writeDefaultPlaylist( );
// QPEApplication::grabKeyboard();
// QPEApplication::ungrabKeyboard();
}
void MediaPlayer::recreateAudioAndVideoWidgets()
{
delete xineControl;
delete audioUI;
delete videoUI;
audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" );
videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" );
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() ) );
connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState );
}
+void MediaPlayer::reloadSkins()
+{
+ audioUI->loadSkin();
+ videoUI->loadSkin();
+}
+
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h
index dc306c4..6b316f6 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.h
+++ b/noncore/multimedia/opieplayer2/mediaplayer.h
@@ -10,80 +10,81 @@
 _;:,     .>    :=|. 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 MEDIA_PLAYER_H
#define MEDIA_PLAYER_H
#include <qmainwindow.h>
#include <qframe.h>
#include "xinecontrol.h"
#include "playlistwidget.h"
class DocLnk;
class VolumeControl;
class MediaPlayerState;
class AudioWidget;
class VideoWidget;
class MediaPlayer : public QObject {
Q_OBJECT
public:
MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name );
~MediaPlayer();
public slots:
void recreateAudioAndVideoWidgets();
+ void reloadSkins();
private slots:
void setPlaying( bool );
void pauseCheck( bool );
void play();
void next();
void prev();
void startIncreasingVolume();
void startDecreasingVolume();
void stopChangingVolume();
void cleanUp();
void blank( bool );
protected:
void timerEvent( QTimerEvent *e );
void keyReleaseEvent( QKeyEvent *e);
private:
bool isBlanked, l, r;
int fd, fl;
int volumeDirection;
XineControl *xineControl;
VolumeControl *volControl;
MediaPlayerState &mediaPlayerState;
PlayListWidget &playList;
AudioWidget *audioUI;
VideoWidget *videoUI;
};
#endif // MEDIA_PLAYER_H
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index db16b44..d60dc0d 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -1,95 +1,98 @@
/*
Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
(C) 2002 Max Reiss <harlekin@handhelds.org>
(C) 2002 L. Potter <ljp@llornkcor.com>
(C) 2002 Holger Freyther <zecke@handhelds.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"
MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
: QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
{
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::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
const QString &imagePrefix, const QSize &buttonAreaSize )
{
buttonMask = QImage( buttonAreaSize, 8, 255 );
buttonMask.fill( 0 );
+ buttons.clear();
+ buttons.reserve( buttonCount );
+
for ( uint i = 0; i < buttonCount; ++i ) {
Button button = setupButton( skinInfo[ i ], imagePrefix );
buttons.push_back( button );
}
}
MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix )
{
Button button;
button.command = buttonInfo.command;
button.type = buttonInfo.type;
QString fileName = imagePrefix + buttonInfo.fileName + ".png";
button.mask = setupButtonMask( button.command, fileName );
return button;
}
QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName )
{
QBitmap mask( fileName );
if ( mask.isNull() )
return mask;
QImage imgMask = mask.convertToImage();
uchar **dest = buttonMask.jumpTable();
for ( int y = 0; y < buttonMask.height(); y++ ) {
uchar *line = dest[y];
for ( int x = 0; x < buttonMask.width(); x++ )
if ( !qRed( imgMask.pixel( x, y ) ) )
line[x] = command + 1;
}
return mask;
}
void MediaWidget::closeEvent( QCloseEvent * )
{
mediaPlayerState.setList();
}
void MediaWidget::paintEvent( QPaintEvent *pe )
{
QPainter p( this );
if ( mediaPlayerState.isFullscreen() ) {
// Clear the background
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 148948a..8c781e9 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -27,96 +27,98 @@
#include <qmap.h>
#include "mediaplayerstate.h"
#include "playlistwidget.h"
#include <vector>
class MediaWidget : public QWidget
{
Q_OBJECT
public:
enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined };
enum ButtonType { NormalButton, ToggleButton };
struct Button
{
Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {}
Command command;
ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-(
bool isHeld : 1;
bool isDown : 1;
QBitmap mask;
QPixmap pixUp;
QPixmap pixDown;
};
typedef std::vector<Button> ButtonVector;
struct SkinButtonInfo
{
Command command;
const char *fileName;
ButtonType type;
};
typedef std::vector<QBitmap> MaskVector;
typedef std::vector<QPixmap> PixmapVector;
MediaWidget( PlayListWidget &_playList, 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;
+ virtual void loadSkin() = 0;
+
signals:
void moreReleased();
void lessReleased();
void forwardReleased();
void backReleased();
void forwardClicked();
void backClicked();
void moreClicked();
void lessClicked();
protected:
void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
const QString &imagePrefix, const QSize &buttonAreaSize );
Button setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix );
QBitmap setupButtonMask( const Command &command, const QString &fileName );
virtual void closeEvent( QCloseEvent * );
virtual void paintEvent( QPaintEvent *pe );
Button *buttonAt( const QPoint &position );
virtual void mousePressEvent( QMouseEvent *event );
virtual void mouseReleaseEvent( QMouseEvent *event );
virtual void makeVisible();
void handleCommand( Command command, bool buttonDown );
bool isOverButton( const QPoint &position, int buttonId ) const;
void paintAllButtons( QPainter &p );
void paintButton( const Button &button );
void paintButton( QPainter &p, const Button &button );
void setToggleButton( Button &button, bool down );
void setToggleButton( Command command, bool down );
void toggleButton( Button &button );
MediaPlayerState &mediaPlayerState;
PlayListWidget &playList;
ButtonVector buttons;
QImage buttonMask;
QPoint upperLeftOfButtonMask;
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index d1efaad..a03d43e 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -34,218 +34,225 @@
#include <qpe/qpeapplication.h>
#include <qpe/resource.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"
#include "playlistwidget.h"
#ifdef Q_WS_QWS
# define USE_DIRECT_PAINTER
# include <qdirectpainter_qws.h>
# include <qgfxraster_qws.h>
#endif
namespace
{
const int xo = 2; // movable x offset
const int yo = 0; // movable y offset
const MediaWidget::SkinButtonInfo skinInfo[] =
{
{ MediaWidget::Play, "play", MediaWidget::ToggleButton },
{ MediaWidget::Stop, "stop", MediaWidget::NormalButton },
{ MediaWidget::Next, "fwd", MediaWidget::NormalButton },
{ MediaWidget::Previous, "back", MediaWidget::NormalButton },
{ MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
{ MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
{ MediaWidget::FullScreen, "full", MediaWidget::ToggleButton }
};
const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
}
VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
: MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false )
{
setCaption( tr("OpiePlayer - Video") );
-
videoFrame = new XineVideoWidget ( this, "Video frame" );
connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
- Config cfg("OpiePlayer");
- cfg.setGroup("Options");
- skin = cfg.readEntry("Skin","default");
+ slider = 0;
- QString skinPath = "opieplayer2/skins/" + skin;
- backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
- imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
- imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
-
- setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_", imgUp.size() );
-
- setBackgroundPixmap( backgroundPixmap );
-
- slider = new QSlider( Qt::Horizontal, this );
- slider->setMinValue( 0 );
- slider->setMaxValue( 1 );
- slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
- //slider->setFocusPolicy( QWidget::NoFocus );
-
- resizeEvent( NULL );
+ loadSkin();
setLength( mediaPlayerState.length() );
setPosition( mediaPlayerState.position() );
setFullscreen( mediaPlayerState.isFullscreen() );
setPlaying( mediaPlayerState.isPlaying() );
}
VideoWidget::~VideoWidget()
{
}
QPixmap *combineVImageWithBackground( 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 maskVPixToMask( QPixmap pix, QBitmap mask ) {
QPixmap pixmap( pix );
pixmap.setMask( mask );
return pixmap;
}
void VideoWidget::resizeEvent( QResizeEvent * ) {
int h = height();
int w = width();
//int Vh = 160;
//int Vw = 220;
slider->setFixedWidth( w - 20 );
slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
slider->setBackgroundOrigin( QWidget::ParentOrigin );
slider->setFocusPolicy( QWidget::NoFocus );
slider->setBackgroundPixmap( backgroundPixmap );
upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
if(w>h)
upperLeftOfButtonMask.ry() = 0;
else
upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
QPoint p = upperLeftOfButtonMask;
QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p );
QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p );
for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
Button &button = *it;
if ( !button.mask.isNull() ) {
button.pixUp = maskVPixToMask( *pixUp, button.mask );
button.pixDown = maskVPixToMask( *pixDn, button.mask );
}
}
delete pixUp;
delete pixDn;
}
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::loadSkin()
+{
+ Config cfg("OpiePlayer");
+ cfg.setGroup("Options");
+ skin = cfg.readEntry("Skin","default");
+
+ QString skinPath = "opieplayer2/skins/" + skin;
+ backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
+ imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
+ imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
+
+ setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_", imgUp.size() );
+
+ setBackgroundPixmap( backgroundPixmap );
+
+ delete slider;
+ slider = new QSlider( Qt::Horizontal, this );
+ slider->setMinValue( 0 );
+ slider->setMaxValue( 1 );
+ slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
+ //slider->setFocusPolicy( QWidget::NoFocus );
+
+ resizeEvent( 0 );
+}
+
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::mouseReleaseEvent( QMouseEvent *event ) {
if ( mediaPlayerState.isFullscreen() ) {
mediaPlayerState.setFullscreen( FALSE );
makeVisible();
}
MediaWidget::mouseReleaseEvent( 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( backgroundPixmap );
QWidget *d = QApplication::desktop();
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 21a4e9e..87be371 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -21,82 +21,84 @@
  _.=:.       :    :=>`: 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 <qimage.h>
#include <qpixmap.h>
#include "xinevideowidget.h"
#include "mediawidget.h"
class QPixmap;
class QSlider;
class VideoWidget : public MediaWidget {
Q_OBJECT
public:
VideoWidget( PlayListWidget &playList, 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 );
virtual void makeVisible();
void backToNormal();
void setPosition( long );
public:
virtual void setPlaying( bool b);
virtual void setLength( long );
virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
+ virtual void loadSkin();
+
signals:
void moreClicked();
void lessClicked();
void sliderMoved( long );
void videoResized ( const QSize &s );
protected:
void resizeEvent( QResizeEvent * );
void mouseReleaseEvent( QMouseEvent *event );
void keyReleaseEvent( QKeyEvent *e);
private:
// Ticker songInfo;
QImage imgUp;
QImage imgDn;
QString skin;
QString backgroundPix;
QSlider *slider;
QImage *currentFrame;
int scaledWidth;
int scaledHeight;
XineVideoWidget* videoFrame;
bool videoSliderBeingMoved;
};
#endif // VIDEO_WIDGET_H