summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp42
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h7
2 files changed, 28 insertions, 21 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 56b75f2..3b33209 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -11,152 +11,152 @@
.> <`_,   >  .   <= 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/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <opie/oticker.h>
#include <qwidget.h>
#include <qpixmap.h>
#include <qbutton.h>
#include <qpainter.h>
#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 char * const skin_mask_file_names[10] = {
- "play", "stop", "next", "prev", "up",
- "down", "loop", "playlist", "forward", "back"
+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 )
{
- Button defaultButton;
-
- Button toggleButton = defaultButton;
- toggleButton.buttonType = ToggleButton;
-
- buttons.reserve( 10 );
- buttons.push_back( toggleButton ); // play
- buttons.push_back( defaultButton ); // stop
- buttons.push_back( defaultButton ); // next
- buttons.push_back( defaultButton ); // previous
- buttons.push_back( defaultButton ); // volume up
- buttons.push_back( defaultButton ); // volume down
- buttons.push_back( toggleButton ); // repeat/loop
- buttons.push_back( defaultButton ); // playlist
- buttons.push_back( defaultButton ); // forward
- buttons.push_back( defaultButton ); // back
+ for ( uint i = 0; i < buttonCount; ++i ) {
+ Button button;
+ button.buttonType = skinInfo[ i ].buttonType;
+ buttons.push_back( button );
+ }
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;
pixBg = 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) ) );
buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
buttonMask.fill( 0 );
- masks.reserve( 10 );
+ masks.reserve( buttonCount );
for ( uint i = 0; i < masks.capacity(); i++ ) {
- QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" );
+ QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" );
masks.push_back( QBitmap( filename ) );
if ( !masks[i].isNull() ) {
QImage imgMask = masks[i].convertToImage();
uchar **dest = buttonMask.jumpTable();
for ( int y = 0; y < imgUp.height(); y++ ) {
uchar *line = dest[y];
for ( int x = 0; x < imgUp.width(); x++ )
if ( !qRed( imgMask.pixel( x, y ) ) )
line[x] = i + 1;
}
}
}
buttonPixUp.resize( masks.size(), QPixmap() );
buttonPixDown.resize( masks.size(), QPixmap() );
setBackgroundPixmap( pixBg );
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( pixBg );
// 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 );
connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index aa8891f..e0f2cf1 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -2,87 +2,94 @@
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.
*/
#ifndef MEDIAWIDGET_H
#define MEDIAWIDGET_H
#include <qwidget.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 };
enum ButtonType { NormalButton, ToggleButton };
struct Button
{
Button() : buttonType( NormalButton ), isHeld( false ), isDown( false ) {}
ButtonType buttonType : 1;
bool isHeld : 1;
bool isDown : 1;
};
typedef std::vector<Button> ButtonVector;
+ struct SkinButtonInfo
+ {
+ Command command;
+ const char *fileName;
+ ButtonType buttonType;
+ };
+
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;
signals:
void moreReleased();
void lessReleased();
void forwardReleased();
void backReleased();
protected:
virtual void closeEvent( QCloseEvent * );
void handleCommand( Command command, bool buttonDown );
bool isOverButton( const QPoint &position, int buttonId ) const;
void paintButton( int buttonId );
virtual void paintButton( QPainter &p, int i ) = 0;
void toggleButton( int buttonId );
MediaPlayerState &mediaPlayerState;
PlayListWidget &playList;
ButtonVector buttons;
QImage buttonMask;
QPoint upperLeftOfButtonMask;
};
#endif // MEDIAWIDGET_H
/* vim: et sw=4 ts=4
*/