summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 15:57:34 (UTC)
committer simon <simon>2002-12-09 15:57:34 (UTC)
commitf676d71c1fe40539ceb0c0708fdaefcc9b5e1800 (patch) (unidiff)
tree5298119bdbd8bffafcd1a31aed1c6fbcb908d3bc
parent743155915f659d701ad468eadcc2b2173b6e2770 (diff)
downloadopie-f676d71c1fe40539ceb0c0708fdaefcc9b5e1800.zip
opie-f676d71c1fe40539ceb0c0708fdaefcc9b5e1800.tar.gz
opie-f676d71c1fe40539ceb0c0708fdaefcc9b5e1800.tar.bz2
- back to a vector :P
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp7
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h10
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp16
4 files changed, 19 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 714509e..c3e206c 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -101,12 +101,13 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
101 101
102 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 102 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
103 buttonMask.fill( 0 ); 103 buttonMask.fill( 0 );
104 104
105 for ( uint i = 0; i < buttonCount; i++ ) { 105 for ( uint i = 0; i < buttonCount; i++ ) {
106 Button button; 106 Button button;
107 button.command = skinInfo[ i ].command;
107 button.type = skinInfo[ i ].type; 108 button.type = skinInfo[ i ].type;
108 109
109 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" ); 110 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" );
110 button.mask =QBitmap( filename ); 111 button.mask =QBitmap( filename );
111 112
112 if ( !button.mask.isNull() ) { 113 if ( !button.mask.isNull() ) {
@@ -117,13 +118,13 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
117 for ( int x = 0; x < imgUp.width(); x++ ) 118 for ( int x = 0; x < imgUp.width(); x++ )
118 if ( !qRed( imgMask.pixel( x, y ) ) ) 119 if ( !qRed( imgMask.pixel( x, y ) ) )
119 line[x] = i + 1; 120 line[x] = i + 1;
120 } 121 }
121 } 122 }
122 123
123 buttons.insert( i, button ); 124 buttons.push_back( button );
124 } 125 }
125 126
126 setBackgroundPixmap( backgroundPixmap ); 127 setBackgroundPixmap( backgroundPixmap );
127 128
128 songInfo.setFocusPolicy( QWidget::NoFocus ); 129 songInfo.setFocusPolicy( QWidget::NoFocus );
129// changeTextColor( &songInfo ); 130// changeTextColor( &songInfo );
@@ -205,13 +206,13 @@ void AudioWidget::resizeEvent( QResizeEvent * ) {
205 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; 206 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10;
206 QPoint p = upperLeftOfButtonMask; 207 QPoint p = upperLeftOfButtonMask;
207 208
208 QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p ); 209 QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p );
209 QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p ); 210 QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p );
210 211
211 for ( uint i = 0; i < buttons.count(); i++ ) { 212 for ( uint i = 0; i < buttons.size(); i++ ) {
212 if ( !buttons[i].mask.isNull() ) { 213 if ( !buttons[i].mask.isNull() ) {
213 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask ); 214 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask );
214 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask ); 215 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask );
215 } 216 }
216 } 217 }
217} 218}
@@ -331,13 +332,13 @@ void AudioWidget::timerEvent( QTimerEvent * ) {
331 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 332 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
332 } 333 }
333} 334}
334 335
335 336
336void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 337void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
337 for ( unsigned int i = 0; i < buttons.count(); i++ ) { 338 for ( unsigned int i = 0; i < buttons.size(); i++ ) {
338 339
339 Button &button = buttons[ i ]; 340 Button &button = buttons[ i ];
340 341
341 if ( event->state() == QMouseEvent::LeftButton ) { 342 if ( event->state() == QMouseEvent::LeftButton ) {
342 // The test to see if the mouse click is inside the button or not 343 // The test to see if the mouse click is inside the button or not
343 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 344 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 66129c9..7891a7e 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -79,12 +79,13 @@ void MediaWidget::handleCommand( Command command, bool buttonDown )
79 case Loop: mediaPlayerState.setLooping( buttonDown ); return; 79 case Loop: mediaPlayerState.setLooping( buttonDown ); return;
80 case VolumeUp: emit moreReleased(); return; 80 case VolumeUp: emit moreReleased(); return;
81 case VolumeDown: emit lessReleased(); return; 81 case VolumeDown: emit lessReleased(); return;
82 case PlayList: mediaPlayerState.setList(); return; 82 case PlayList: mediaPlayerState.setList(); return;
83 case Forward: emit forwardReleased(); return; 83 case Forward: emit forwardReleased(); return;
84 case Back: emit backReleased(); return; 84 case Back: emit backReleased(); return;
85 default: assert( false );
85 } 86 }
86} 87}
87 88
88bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 89bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
89{ 90{
90 return ( position.x() > 0 && position.y() > 0 && 91 return ( position.x() > 0 && position.y() > 0 &&
@@ -92,13 +93,13 @@ bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
92 position.y() < buttonMask.height() && 93 position.y() < buttonMask.height() &&
93 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); 94 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
94} 95}
95 96
96void MediaWidget::paintAllButtons( QPainter &p ) 97void MediaWidget::paintAllButtons( QPainter &p )
97{ 98{
98 for ( ButtonMap::ConstIterator it = buttons.begin(); 99 for ( ButtonVector::const_iterator it = buttons.begin();
99 it != buttons.end(); ++it ) 100 it != buttons.end(); ++it )
100 paintButton( p, *it ); 101 paintButton( p, *it );
101} 102}
102 103
103void MediaWidget::paintButton( const Button &button ) 104void MediaWidget::paintButton( const Button &button )
104{ 105{
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 05b7b71..efba6f3 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -32,30 +32,30 @@
32#include <vector> 32#include <vector>
33 33
34class MediaWidget : public QWidget 34class MediaWidget : public QWidget
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37public: 37public:
38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; 38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, Undefined };
39 enum ButtonType { NormalButton, ToggleButton }; 39 enum ButtonType { NormalButton, ToggleButton };
40 40
41 struct Button 41 struct Button
42 { 42 {
43 Button() : type( NormalButton ), isHeld( false ), isDown( false ) {} 43 Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {}
44
45 Command command;
44 46
45 ButtonType type : 1; 47 ButtonType type : 1;
46 bool isHeld : 1; 48 bool isHeld : 1;
47 bool isDown : 1; 49 bool isDown : 1;
48 50
49 QBitmap mask; 51 QBitmap mask;
50 QPixmap pixUp; 52 QPixmap pixUp;
51 QPixmap pixDown; 53 QPixmap pixDown;
52 }; 54 };
53 typedef std::vector<Button> ButtonVector; 55 typedef std::vector<Button> ButtonVector;
54 // when the transition is done this should be Command -> Button
55 typedef QMap<int, Button> ButtonMap;
56 56
57 struct SkinButtonInfo 57 struct SkinButtonInfo
58 { 58 {
59 Command command; 59 Command command;
60 const char *fileName; 60 const char *fileName;
61 ButtonType type; 61 ButtonType type;
@@ -94,13 +94,13 @@ protected:
94 void setToggleButton( Button &button, bool down ); 94 void setToggleButton( Button &button, bool down );
95 void toggleButton( Button &button ); 95 void toggleButton( Button &button );
96 96
97 MediaPlayerState &mediaPlayerState; 97 MediaPlayerState &mediaPlayerState;
98 PlayListWidget &playList; 98 PlayListWidget &playList;
99 99
100 ButtonMap buttons; 100 ButtonVector buttons;
101 101
102 QImage buttonMask; 102 QImage buttonMask;
103 103
104 QPoint upperLeftOfButtonMask; 104 QPoint upperLeftOfButtonMask;
105 105
106 QPixmap backgroundPixmap; 106 QPixmap backgroundPixmap;
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 9782b68..f59772e 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -71,19 +71,19 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
71 setCaption( tr("OpiePlayer - Video") ); 71 setCaption( tr("OpiePlayer - Video") );
72 72
73 Button defaultButton; 73 Button defaultButton;
74 Button toggleButton = defaultButton; 74 Button toggleButton = defaultButton;
75 toggleButton.type = ToggleButton; 75 toggleButton.type = ToggleButton;
76 76
77 buttons.insert( 0, toggleButton ); // play 77 buttons.push_back( toggleButton ); // play
78 buttons.insert( 1, toggleButton ); // stop 78 buttons.push_back( toggleButton ); // stop
79 buttons.insert( 2, toggleButton ); // next 79 buttons.push_back( toggleButton ); // next
80 buttons.insert( 3, toggleButton ); // previous 80 buttons.push_back( toggleButton ); // previous
81 buttons.insert( 4, toggleButton ); // volUp 81 buttons.push_back( toggleButton ); // volUp
82 buttons.insert( 5, toggleButton ); // volDown 82 buttons.push_back( toggleButton ); // volDown
83 buttons.insert( 6, toggleButton ); // fullscreen 83 buttons.push_back( toggleButton ); // fullscreen
84 84
85 videoFrame = new XineVideoWidget ( this, "Video frame" ); 85 videoFrame = new XineVideoWidget ( this, "Video frame" );
86 86
87 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 87 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
88 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 88 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
89 89
@@ -240,13 +240,13 @@ void VideoWidget::updateSlider( long i, long max ) {
240 slider->setMaxValue( width ); 240 slider->setMaxValue( width );
241 } 241 }
242 } 242 }
243} 243}
244 244
245void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 245void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
246 for ( unsigned int i = 0; i < buttons.count(); i++ ) { 246 for ( unsigned int i = 0; i < buttons.size(); i++ ) {
247 247
248 Button &button = buttons[ i ]; 248 Button &button = buttons[ i ];
249 249
250 if ( event->state() == QMouseEvent::LeftButton ) { 250 if ( event->state() == QMouseEvent::LeftButton ) {
251 // The test to see if the mouse click is inside the button or not 251 // The test to see if the mouse click is inside the button or not
252 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 252 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );