summaryrefslogtreecommitdiff
authorsimon <simon>2003-07-31 10:37:21 (UTC)
committer simon <simon>2003-07-31 10:37:21 (UTC)
commite5bed303e50298d91a6adf9e0b5cf7dd3d975ed3 (patch) (unidiff)
tree76032b962220a336daa6f8362784a3c38bdcb4f3
parente7cb83fcf64affbf75cf868759e4e222eb8b985f (diff)
downloadopie-e5bed303e50298d91a6adf9e0b5cf7dd3d975ed3.zip
opie-e5bed303e50298d91a6adf9e0b5cf7dd3d975ed3.tar.gz
opie-e5bed303e50298d91a6adf9e0b5cf7dd3d975ed3.tar.bz2
- need an assert.h inclusion here
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 46e7b6e..3953d92 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -1,154 +1,156 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <simon@lst.de> 2 Copyright (C) 2002 Simon Hausmann <simon@lst.de>
3 (C) 2002 Max Reiss <harlekin@handhelds.org> 3 (C) 2002 Max Reiss <harlekin@handhelds.org>
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This program is free software; you can redistribute it and/or 7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public 8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details. 15 General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to 18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include "mediawidget.h" 23#include "mediawidget.h"
24#include "playlistwidget.h" 24#include "playlistwidget.h"
25#include "skin.h" 25#include "skin.h"
26 26
27#include <assert.h>
28
27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 29MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 30 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
29{ 31{
30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 32 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 33 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), 34 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
33 this, SLOT( setLength( long ) ) ); 35 this, SLOT( setLength( long ) ) );
34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 36 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
35 this, SLOT( setPlaying( bool ) ) ); 37 this, SLOT( setPlaying( bool ) ) );
36 38
37 setBackgroundMode( NoBackground ); 39 setBackgroundMode( NoBackground );
38} 40}
39 41
40MediaWidget::~MediaWidget() 42MediaWidget::~MediaWidget()
41{ 43{
42} 44}
43 45
44void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 46void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
45 const Skin &skin ) 47 const Skin &skin )
46{ 48{
47 buttonMask = skin.buttonMask( skinInfo, buttonCount ); 49 buttonMask = skin.buttonMask( skinInfo, buttonCount );
48 50
49 buttons.clear(); 51 buttons.clear();
50 buttons.reserve( buttonCount ); 52 buttons.reserve( buttonCount );
51 53
52 for ( uint i = 0; i < buttonCount; ++i ) { 54 for ( uint i = 0; i < buttonCount; ++i ) {
53 Button button = setupButton( skinInfo[ i ], skin ); 55 Button button = setupButton( skinInfo[ i ], skin );
54 buttons.push_back( button ); 56 buttons.push_back( button );
55 } 57 }
56} 58}
57 59
58MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) 60MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin )
59{ 61{
60 Button button; 62 Button button;
61 button.command = buttonInfo.command; 63 button.command = buttonInfo.command;
62 button.type = buttonInfo.type; 64 button.type = buttonInfo.type;
63 button.mask = skin.buttonMaskImage( buttonInfo.fileName ); 65 button.mask = skin.buttonMaskImage( buttonInfo.fileName );
64 66
65 return button; 67 return button;
66} 68}
67 69
68void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) 70void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo )
69{ 71{
70 Skin skin( guiInfo.fileNameInfix ); 72 Skin skin( guiInfo.fileNameInfix );
71 skin.setCachable( false ); 73 skin.setCachable( false );
72 loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); 74 loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin );
73} 75}
74 76
75void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) 77void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin )
76{ 78{
77 backgroundPixmap = skin.backgroundPixmap(); 79 backgroundPixmap = skin.backgroundPixmap();
78 buttonUpImage = skin.buttonUpImage(); 80 buttonUpImage = skin.buttonUpImage();
79 buttonDownImage = skin.buttonDownImage(); 81 buttonDownImage = skin.buttonDownImage();
80 82
81 setupButtons( skinInfo, buttonCount, skin ); 83 setupButtons( skinInfo, buttonCount, skin );
82} 84}
83 85
84void MediaWidget::closeEvent( QCloseEvent * ) 86void MediaWidget::closeEvent( QCloseEvent * )
85{ 87{
86 mediaPlayerState.setList(); 88 mediaPlayerState.setList();
87} 89}
88 90
89void MediaWidget::paintEvent( QPaintEvent *pe ) 91void MediaWidget::paintEvent( QPaintEvent *pe )
90{ 92{
91 QPainter p( this ); 93 QPainter p( this );
92 94
93 if ( mediaPlayerState.isFullscreen() ) { 95 if ( mediaPlayerState.isFullscreen() ) {
94 // Clear the background 96 // Clear the background
95 p.setBrush( QBrush( Qt::black ) ); 97 p.setBrush( QBrush( Qt::black ) );
96 return; 98 return;
97 } 99 }
98 100
99 QPixmap buffer( size() ); 101 QPixmap buffer( size() );
100 QPainter bufferedPainter( &buffer ); 102 QPainter bufferedPainter( &buffer );
101 bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) ); 103 bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) );
102 paintAllButtons( bufferedPainter ); 104 paintAllButtons( bufferedPainter );
103 p.drawPixmap( 0, 0, buffer ); 105 p.drawPixmap( 0, 0, buffer );
104} 106}
105 107
106void MediaWidget::resizeEvent( QResizeEvent *e ) 108void MediaWidget::resizeEvent( QResizeEvent *e )
107{ 109{
108 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); 110 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask );
109 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); 111 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask );
110 112
111 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 113 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
112 Button &button = *it; 114 Button &button = *it;
113 115
114 if ( button.mask.isNull() ) 116 if ( button.mask.isNull() )
115 continue; 117 continue;
116 button.pixUp = addMaskToPixmap( pixUp, button.mask ); 118 button.pixUp = addMaskToPixmap( pixUp, button.mask );
117 button.pixDown = addMaskToPixmap( pixDn, button.mask ); 119 button.pixDown = addMaskToPixmap( pixDn, button.mask );
118 } 120 }
119 121
120 QWidget::resizeEvent( e ); 122 QWidget::resizeEvent( e );
121} 123}
122 124
123MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 125MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
124{ 126{
125 if ( position.x() <= 0 || position.y() <= 0 || 127 if ( position.x() <= 0 || position.y() <= 0 ||
126 position.x() >= buttonMask.width() || 128 position.x() >= buttonMask.width() ||
127 position.y() >= buttonMask.height() ) 129 position.y() >= buttonMask.height() )
128 return 0; 130 return 0;
129 131
130 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); 132 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
131 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 133 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
132 if ( it->command + 1 == pixelIdx ) 134 if ( it->command + 1 == pixelIdx )
133 return &( *it ); 135 return &( *it );
134 136
135 return 0; 137 return 0;
136} 138}
137 139
138void MediaWidget::mousePressEvent( QMouseEvent *event ) 140void MediaWidget::mousePressEvent( QMouseEvent *event )
139{ 141{
140 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 142 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
141 143
142 if ( !button ) { 144 if ( !button ) {
143 QWidget::mousePressEvent( event ); 145 QWidget::mousePressEvent( event );
144 return; 146 return;
145 } 147 }
146 148
147 switch ( button->command ) { 149 switch ( button->command ) {
148 case VolumeUp: emit moreClicked(); return; 150 case VolumeUp: emit moreClicked(); return;
149 case VolumeDown: emit lessClicked(); return; 151 case VolumeDown: emit lessClicked(); return;
150 case Back: emit backClicked(); return; 152 case Back: emit backClicked(); return;
151 case Forward: emit forwardClicked(); return; 153 case Forward: emit forwardClicked(); return;
152 default: break; 154 default: break;
153 } 155 }
154} 156}