-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 15 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 14 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/singleton.h | 19 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.cpp | 21 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.h | 22 |
5 files changed, 76 insertions, 15 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index c0106d4..702e6d7 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp @@ -1,71 +1,70 @@ /* - Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> + Copyright (C) 2002 Simon Hausmann <simon@lst.de> (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 + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU 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, + 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. + 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 + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. 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" #include "skin.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 Skin &skin ) { buttonMask = skin.buttonMask( skinInfo, buttonCount ); buttons.clear(); buttons.reserve( buttonCount ); for ( uint i = 0; i < buttonCount; ++i ) { Button button = setupButton( skinInfo[ i ], skin ); buttons.push_back( button ); } } MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) { Button button; button.command = buttonInfo.command; button.type = buttonInfo.type; button.mask = skin.buttonMaskImage( buttonInfo.fileName ); return button; } void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) { Skin skin( guiInfo.fileNameInfix ); loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); } diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 64483d8..40eb0af 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h @@ -1,66 +1,66 @@ /* - Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> + Copyright (C) 2002 Simon Hausmann <simon@lst.de> (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 + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU 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, + 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. + 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 + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. 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 <qmap.h> #include "mediaplayerstate.h" #include "playlistwidget.h" #include <vector> #include <memory> namespace { struct simpleAndStupidAllocator { static void *allocate( size_t amount ) { return ::operator new( amount ); } static void deallocate( void *p, size_t ) { ::operator delete( p ); } }; } class Skin; 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 ), isDown( false ) {} Command command; ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( bool isDown : 1; QBitmap mask; QPixmap pixUp; QPixmap pixDown; diff --git a/noncore/multimedia/opieplayer2/singleton.h b/noncore/multimedia/opieplayer2/singleton.h index 35b3dff..83e228f 100644 --- a/noncore/multimedia/opieplayer2/singleton.h +++ b/noncore/multimedia/opieplayer2/singleton.h @@ -1,48 +1,67 @@ +/* + Copyright (C) 2002 Simon Hausmann <simon@lst.de> + + 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 SINGLETON_H #define SINGLETON_H template <class Product> struct DefaultSingletonCreator { static Product *create() { return new Product; } }; template <class Product> struct NullSingletonCreator { static Product *create() { return 0; } }; template < class T, template <class> class Creator = DefaultSingletonCreator > class Singleton { public: static T &self() { if ( !s_self ) s_self = Creator<T>::create(); return *s_self; } protected: Singleton() { s_self = static_cast<T *>( this ); } ~Singleton() { s_self = 0; } private: Singleton( const Singleton<T, Creator> &rhs ); Singleton<T, Creator> &operator=( const Singleton<T, Creator> &rhs ); static T *s_self; }; template <class T, template <class> class Creator> T *Singleton<T, Creator>::s_self = 0; #endif // SINGLETON_H /* vim: et sw=4 ts=4 diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp index 0de3023..cef3259 100644 --- a/noncore/multimedia/opieplayer2/skin.cpp +++ b/noncore/multimedia/opieplayer2/skin.cpp @@ -1,48 +1,69 @@ +/* + Copyright (C) 2002 Simon Hausmann <simon@lst.de> + (C) 2002 Max Reiss <harlekin@handhelds.org> + (C) 2002 L. Potter <ljp@llornkcor.com> + (C) 2002 Holger Freyther <zecke@handhelds.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ #include "skin.h" #include <qpe/resource.h> #include <qpe/config.h> #include <assert.h> Skin::Skin( const QString &name, const QString &fileNameInfix ) : m_fileNameInfix( fileNameInfix ) { init( name ); } Skin::Skin( const QString &fileNameInfix ) : m_fileNameInfix( fileNameInfix ) { init( defaultSkinName() ); } void Skin::init( const QString &name ) { m_skinPath = "opieplayer2/skins/" + name; } void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) { backgroundImage(); buttonUpImage(); buttonDownImage(); ( void )buttonMask( skinButtonInfo, buttonCount ); } QImage Skin::backgroundImage() const { if ( m_backgroundImage.isNull() ) m_backgroundImage = SkinCache::self().loadImage( QString( "%1/background" ).arg( m_skinPath ) ); return m_backgroundImage; } QImage Skin::buttonUpImage() const { if ( m_buttonUpImage.isNull() ) m_buttonUpImage = SkinCache::self().loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); return m_buttonUpImage; } QImage Skin::buttonDownImage() const diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h index c15d9dc..9f7326e 100644 --- a/noncore/multimedia/opieplayer2/skin.h +++ b/noncore/multimedia/opieplayer2/skin.h @@ -1,48 +1,70 @@ +/* + Copyright (C) 2002 Simon Hausmann <simon@lst.de> + (C) 2002 Max Reiss <harlekin@handhelds.org> + (C) 2002 L. Potter <ljp@llornkcor.com> + (C) 2002 Holger Freyther <zecke@handhelds.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + #ifndef SKIN_H #define SKIN_H #include <qstring.h> #include <qimage.h> #include <qmap.h> #include <qdict.h> #include "mediawidget.h" #include "threadutil.h" #include "singleton.h" class Skin { public: Skin( const QString &name, const QString &fileNameInfix ); Skin( const QString &fileNameInfix ); void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ); QImage backgroundImage() const; QImage buttonUpImage() const; QImage buttonDownImage() const; QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const; QImage buttonMaskImage( const QString &fileName ) const; static QString defaultSkinName(); private: void init( const QString &name ); void addButtonToMask( int tag, const QImage &maskImage ) const; QString m_fileNameInfix; QString m_skinPath; typedef QMap<QString, QImage> ButtonMaskImageMap; mutable QImage m_backgroundImage; mutable QImage m_buttonUpImage; mutable QImage m_buttonDownImage; mutable QImage m_buttonMask; mutable ButtonMaskImageMap m_buttonMasks; Skin( const Skin & ); Skin &operator=( const Skin & ); |