author | simon <simon> | 2002-12-11 17:38:55 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 17:38:55 (UTC) |
commit | 719acab56c57f283168b955582ab5b30b9809b02 (patch) (side-by-side diff) | |
tree | 370c9f8bae6741b0ee2303b6c04f9329757a8a3e | |
parent | aaac5c934e7053fa4323b03f7ea31c32c6388883 (diff) | |
download | opie-719acab56c57f283168b955582ab5b30b9809b02.zip opie-719acab56c57f283168b955582ab5b30b9809b02.tar.gz opie-719acab56c57f283168b955582ab5b30b9809b02.tar.bz2 |
- copyright notice fixlet
-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,87 +1,86 @@ /* - 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 ); } void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) { backgroundPixmap = skin.backgroundImage(); buttonUpImage = skin.buttonUpImage(); buttonDownImage = skin.buttonDownImage(); setupButtons( skinInfo, buttonCount, skin ); } void MediaWidget::closeEvent( QCloseEvent * ) { mediaPlayerState.setList(); } void MediaWidget::paintEvent( QPaintEvent *pe ) 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,82 +1,82 @@ /* - 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; }; #if defined( _CC_GNU_ ) // use that allocator to avoid the default allocator that on gcc2 requires libstdc++ because // in the BAD_ALLOC macro it uses std::cerr and friends :-( typedef std::vector<Button, std::__allocator<Button, simpleAndStupidAllocator> > ButtonVector; #else typedef std::vector<Button> ButtonVector; #endif struct SkinButtonInfo { Command command; const char *fileName; ButtonType type; }; 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,49 +1,68 @@ +/* + 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,64 +1,85 @@ +/* + 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 { if ( m_buttonDownImage.isNull() ) m_buttonDownImage = SkinCache::self().loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); return m_buttonDownImage; } QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const { if ( !m_buttonMask.isNull() ) return m_buttonMask; QSize buttonAreaSize = buttonUpImage().size(); m_buttonMask = QImage( buttonAreaSize, 8, 255 ); m_buttonMask.fill( 0 ); 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,64 +1,86 @@ +/* + 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 & ); }; class SkinCache : public Singleton<SkinCache> { public: SkinCache(); QImage loadImage( const QString &name ); private: typedef QDict<QImage> ImageCache; ImageCache m_cache; ThreadUtil::Mutex m_cacheGuard; }; |