summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 15:01:12 (UTC)
committer simon <simon>2002-12-09 15:01:12 (UTC)
commitd3451a94e3a4425f9f1b1dcc3999259270780631 (patch) (unidiff)
tree6d0613d5ce951e08a8af539b28a689c96b0955c8
parent9ab8a657b23fd1871c4a376fdd097732c14392e0 (diff)
downloadopie-d3451a94e3a4425f9f1b1dcc3999259270780631.zip
opie-d3451a94e3a4425f9f1b1dcc3999259270780631.tar.gz
opie-d3451a94e3a4425f9f1b1dcc3999259270780631.tar.bz2
- get rid of the masks array and re-use the Button structure
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp22
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h2
2 files changed, 10 insertions, 14 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 7d85d63..089ef6a 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -87,37 +87,39 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
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
90 Config cfg("OpiePlayer"); 90 Config cfg("OpiePlayer");
91 cfg.setGroup("Options"); 91 cfg.setGroup("Options");
92 skin = cfg.readEntry("Skin","default"); 92 skin = cfg.readEntry("Skin","default");
93 93
94 QString skinPath = "opieplayer2/skins/" + skin; 94 QString skinPath = "opieplayer2/skins/" + skin;
95 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 95 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
96 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 96 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
97 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 97 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
98 98
99 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 99 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
100 buttonMask.fill( 0 ); 100 buttonMask.fill( 0 );
101 101
102 for ( int i = 0; i < 7; i++ ) { 102 for ( int i = 0; i < 7; i++ ) {
103 Button &button = buttons[ i ];
104
103 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 105 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
104 masks[i] = new QBitmap( filename ); 106 button.mask = QBitmap( filename );
105 107
106 if ( !masks[i]->isNull() ) { 108 if ( !button.mask.isNull() ) {
107 QImage imgMask = masks[i]->convertToImage(); 109 QImage imgMask = button.mask.convertToImage();
108 uchar **dest = buttonMask.jumpTable(); 110 uchar **dest = buttonMask.jumpTable();
109 for ( int y = 0; y < imgUp.height(); y++ ) { 111 for ( int y = 0; y < imgUp.height(); y++ ) {
110 uchar *line = dest[y]; 112 uchar *line = dest[y];
111 for ( int x = 0; x < imgUp.width(); x++ ) { 113 for ( int x = 0; x < imgUp.width(); x++ ) {
112 if ( !qRed( imgMask.pixel( x, y ) ) ) 114 if ( !qRed( imgMask.pixel( x, y ) ) )
113 line[x] = i + 1; 115 line[x] = i + 1;
114 } 116 }
115 } 117 }
116 } 118 }
117 } 119 }
118 120
119 for ( int i = 0; i < 7; i++ ) { 121 for ( int i = 0; i < 7; i++ ) {
120 buttonPixUp[i] = NULL; 122 buttonPixUp[i] = NULL;
121 buttonPixDown[i] = NULL; 123 buttonPixDown[i] = NULL;
122 } 124 }
123 125
@@ -126,42 +128,36 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
126 slider = new QSlider( Qt::Horizontal, this ); 128 slider = new QSlider( Qt::Horizontal, this );
127 slider->setMinValue( 0 ); 129 slider->setMinValue( 0 );
128 slider->setMaxValue( 1 ); 130 slider->setMaxValue( 1 );
129 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 131 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
130 //slider->setFocusPolicy( QWidget::NoFocus ); 132 //slider->setFocusPolicy( QWidget::NoFocus );
131 133
132 resizeEvent( NULL ); 134 resizeEvent( NULL );
133 135
134 setLength( mediaPlayerState.length() ); 136 setLength( mediaPlayerState.length() );
135 setPosition( mediaPlayerState.position() ); 137 setPosition( mediaPlayerState.position() );
136 setFullscreen( mediaPlayerState.isFullscreen() ); 138 setFullscreen( mediaPlayerState.isFullscreen() );
137 setPlaying( mediaPlayerState.isPlaying() ); 139 setPlaying( mediaPlayerState.isPlaying() );
138} 140}
139 141
140 142
141VideoWidget::~VideoWidget() { 143VideoWidget::~VideoWidget() {
142
143 for ( int i = 0; i < 7; i++ ) { 144 for ( int i = 0; i < 7; i++ ) {
144 delete buttonPixUp[i]; 145 delete buttonPixUp[i];
145 delete buttonPixDown[i]; 146 delete buttonPixDown[i];
146 } 147 }
147
148 for ( int i = 0; i < 7; i++ ) {
149 delete masks[i];
150 }
151
152} 148}
153 149
154QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 150QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
155 QPixmap pix( img.width(), img.height() ); 151 QPixmap pix( img.width(), img.height() );
156 QPainter p( &pix ); 152 QPainter p( &pix );
157 p.drawTiledPixmap( pix.rect(), bg, offset ); 153 p.drawTiledPixmap( pix.rect(), bg, offset );
158 p.drawImage( 0, 0, img ); 154 p.drawImage( 0, 0, img );
159 return new QPixmap( pix ); 155 return new QPixmap( pix );
160} 156}
161 157
162QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 158QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
163 QPixmap *pixmap = new QPixmap( pix ); 159 QPixmap *pixmap = new QPixmap( pix );
164 pixmap->setMask( mask ); 160 pixmap->setMask( mask );
165 return pixmap; 161 return pixmap;
166} 162}
167 163
@@ -175,37 +171,39 @@ void VideoWidget::resizeEvent( QResizeEvent * ) {
175 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 171 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
176 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 172 slider->setBackgroundOrigin( QWidget::ParentOrigin );
177 slider->setFocusPolicy( QWidget::NoFocus ); 173 slider->setFocusPolicy( QWidget::NoFocus );
178 slider->setBackgroundPixmap( pixBg ); 174 slider->setBackgroundPixmap( pixBg );
179 175
180 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 176 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
181 if(w>h) 177 if(w>h)
182 upperLeftOfButtonMask.ry() = 0; 178 upperLeftOfButtonMask.ry() = 0;
183 else 179 else
184 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 180 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
185 QPoint p = upperLeftOfButtonMask; 181 QPoint p = upperLeftOfButtonMask;
186 182
187 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); 183 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p );
188 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); 184 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p );
189 185
190 for ( int i = 0; i < 7; i++ ) { 186 for ( int i = 0; i < 7; i++ ) {
191 if ( !masks[i]->isNull() ) { 187 Button &button = buttons[ i ];
188
189 if ( !button.mask.isNull() ) {
192 delete buttonPixUp[i]; 190 delete buttonPixUp[i];
193 delete buttonPixDown[i]; 191 delete buttonPixDown[i];
194 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 192 buttonPixUp[i] = maskVPixToMask( *pixUp, button.mask );
195 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 193 buttonPixDown[i] = maskVPixToMask( *pixDn, button.mask );
196 } 194 }
197 } 195 }
198 196
199 delete pixUp; 197 delete pixUp;
200 delete pixDn; 198 delete pixDn;
201} 199}
202 200
203static bool videoSliderBeingMoved = FALSE; 201static bool videoSliderBeingMoved = FALSE;
204 202
205void VideoWidget::sliderPressed() { 203void VideoWidget::sliderPressed() {
206 videoSliderBeingMoved = TRUE; 204 videoSliderBeingMoved = TRUE;
207} 205}
208 206
209void VideoWidget::sliderReleased() { 207void VideoWidget::sliderReleased() {
210 videoSliderBeingMoved = FALSE; 208 videoSliderBeingMoved = FALSE;
211 if ( slider->width() == 0 ) { 209 if ( slider->width() == 0 ) {
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index cb6171c..fd301f9 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -87,37 +87,35 @@ signals:
87 87
88protected: 88protected:
89 89
90 void resizeEvent( QResizeEvent * ); 90 void resizeEvent( QResizeEvent * );
91 void paintEvent( QPaintEvent *pe ); 91 void paintEvent( QPaintEvent *pe );
92 void showEvent( QShowEvent *se ); 92 void showEvent( QShowEvent *se );
93 void mouseMoveEvent( QMouseEvent *event ); 93 void mouseMoveEvent( QMouseEvent *event );
94 void mousePressEvent( QMouseEvent *event ); 94 void mousePressEvent( QMouseEvent *event );
95 void mouseReleaseEvent( QMouseEvent *event ); 95 void mouseReleaseEvent( QMouseEvent *event );
96 void keyReleaseEvent( QKeyEvent *e); 96 void keyReleaseEvent( QKeyEvent *e);
97 97
98private: 98private:
99// Ticker songInfo; 99// Ticker songInfo;
100 QPixmap pixBg; 100 QPixmap pixBg;
101 QImage imgUp; 101 QImage imgUp;
102 QImage imgDn; 102 QImage imgDn;
103 QBitmap *masks[7];
104 QPixmap *buttonPixUp[7]; 103 QPixmap *buttonPixUp[7];
105 QPixmap *buttonPixDown[7]; 104 QPixmap *buttonPixDown[7];
106 QString skin; 105 QString skin;
107// QPixmap *pixmaps[4];
108 106
109 107
110 virtual void paintButton( QPainter &p, int i ); 108 virtual void paintButton( QPainter &p, int i );
111 void setToggleButton( int, bool ); 109 void setToggleButton( int, bool );
112 110
113 QString backgroundPix; 111 QString backgroundPix;
114 QSlider *slider; 112 QSlider *slider;
115 QPixmap *pixmaps[3]; 113 QPixmap *pixmaps[3];
116 QImage *currentFrame; 114 QImage *currentFrame;
117 int scaledWidth; 115 int scaledWidth;
118 int scaledHeight; 116 int scaledHeight;
119 XineVideoWidget* videoFrame; 117 XineVideoWidget* videoFrame;
120}; 118};
121 119
122#endif // VIDEO_WIDGET_H 120#endif // VIDEO_WIDGET_H
123 121