summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 16:01:03 (UTC)
committer simon <simon>2002-12-09 16:01:03 (UTC)
commitd8aead05894e6a28b5aab45807ff2e6f27620f97 (patch) (unidiff)
tree25b03bab434e42d3f8a134441b468ae5108e712a
parentf676d71c1fe40539ceb0c0708fdaefcc9b5e1800 (diff)
downloadopie-d8aead05894e6a28b5aab45807ff2e6f27620f97.zip
opie-d8aead05894e6a28b5aab45807ff2e6f27620f97.tar.gz
opie-d8aead05894e6a28b5aab45807ff2e6f27620f97.tar.bz2
- less hardcoding of numbers
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index f59772e..8409e5c 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -78,50 +78,51 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
78 buttons.push_back( toggleButton ); // stop 78 buttons.push_back( toggleButton ); // stop
79 buttons.push_back( toggleButton ); // next 79 buttons.push_back( toggleButton ); // next
80 buttons.push_back( toggleButton ); // previous 80 buttons.push_back( toggleButton ); // previous
81 buttons.push_back( toggleButton ); // volUp 81 buttons.push_back( toggleButton ); // volUp
82 buttons.push_back( toggleButton ); // volDown 82 buttons.push_back( toggleButton ); // volDown
83 buttons.push_back( 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
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 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 95 backgroundPixmap = 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 uint i = 0;
103 Button &button = buttons[ i ]; 103 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it, ++i ) {
104 Button &button = *it;
104 105
105 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 106 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
106 button.mask = QBitmap( filename ); 107 button.mask = QBitmap( filename );
107 108
108 if ( !button.mask.isNull() ) { 109 if ( !button.mask.isNull() ) {
109 QImage imgMask = button.mask.convertToImage(); 110 QImage imgMask = button.mask.convertToImage();
110 uchar **dest = buttonMask.jumpTable(); 111 uchar **dest = buttonMask.jumpTable();
111 for ( int y = 0; y < imgUp.height(); y++ ) { 112 for ( int y = 0; y < imgUp.height(); y++ ) {
112 uchar *line = dest[y]; 113 uchar *line = dest[y];
113 for ( int x = 0; x < imgUp.width(); x++ ) { 114 for ( int x = 0; x < imgUp.width(); x++ ) {
114 if ( !qRed( imgMask.pixel( x, y ) ) ) 115 if ( !qRed( imgMask.pixel( x, y ) ) )
115 line[x] = i + 1; 116 line[x] = i + 1;
116 } 117 }
117 } 118 }
118 } 119 }
119 } 120 }
120 121
121 setBackgroundPixmap( backgroundPixmap ); 122 setBackgroundPixmap( backgroundPixmap );
122 123
123 slider = new QSlider( Qt::Horizontal, this ); 124 slider = new QSlider( Qt::Horizontal, this );
124 slider->setMinValue( 0 ); 125 slider->setMinValue( 0 );
125 slider->setMaxValue( 1 ); 126 slider->setMaxValue( 1 );
126 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 127 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
127 //slider->setFocusPolicy( QWidget::NoFocus ); 128 //slider->setFocusPolicy( QWidget::NoFocus );
@@ -154,50 +155,50 @@ QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) {
154} 155}
155 156
156void VideoWidget::resizeEvent( QResizeEvent * ) { 157void VideoWidget::resizeEvent( QResizeEvent * ) {
157 int h = height(); 158 int h = height();
158 int w = width(); 159 int w = width();
159 //int Vh = 160; 160 //int Vh = 160;
160 //int Vw = 220; 161 //int Vw = 220;
161 162
162 slider->setFixedWidth( w - 20 ); 163 slider->setFixedWidth( w - 20 );
163 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 164 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
164 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 165 slider->setBackgroundOrigin( QWidget::ParentOrigin );
165 slider->setFocusPolicy( QWidget::NoFocus ); 166 slider->setFocusPolicy( QWidget::NoFocus );
166 slider->setBackgroundPixmap( backgroundPixmap ); 167 slider->setBackgroundPixmap( backgroundPixmap );
167 168
168 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 169 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
169 if(w>h) 170 if(w>h)
170 upperLeftOfButtonMask.ry() = 0; 171 upperLeftOfButtonMask.ry() = 0;
171 else 172 else
172 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 173 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
173 QPoint p = upperLeftOfButtonMask; 174 QPoint p = upperLeftOfButtonMask;
174 175
175 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p ); 176 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p );
176 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p ); 177 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p );
177 178
178 for ( int i = 0; i < 7; i++ ) { 179 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
179 Button &button = buttons[ i ]; 180 Button &button = *it;
180 181
181 if ( !button.mask.isNull() ) { 182 if ( !button.mask.isNull() ) {
182 button.pixUp = maskVPixToMask( *pixUp, button.mask ); 183 button.pixUp = maskVPixToMask( *pixUp, button.mask );
183 button.pixDown = maskVPixToMask( *pixDn, button.mask ); 184 button.pixDown = maskVPixToMask( *pixDn, button.mask );
184 } 185 }
185 } 186 }
186 187
187 delete pixUp; 188 delete pixUp;
188 delete pixDn; 189 delete pixDn;
189} 190}
190 191
191static bool videoSliderBeingMoved = FALSE; 192static bool videoSliderBeingMoved = FALSE;
192 193
193void VideoWidget::sliderPressed() { 194void VideoWidget::sliderPressed() {
194 videoSliderBeingMoved = TRUE; 195 videoSliderBeingMoved = TRUE;
195} 196}
196 197
197void VideoWidget::sliderReleased() { 198void VideoWidget::sliderReleased() {
198 videoSliderBeingMoved = FALSE; 199 videoSliderBeingMoved = FALSE;
199 if ( slider->width() == 0 ) { 200 if ( slider->width() == 0 ) {
200 return; 201 return;
201 } 202 }
202 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 203 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
203 mediaPlayerState.setPosition( val ); 204 mediaPlayerState.setPosition( val );