Diffstat (limited to 'noncore/multimedia/opieplayer2/videowidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 60a3563..5b53568 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -10,48 +10,49 @@ | |||
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpeapplication.h> | ||
34 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
35 | #include <qpe/mediaplayerplugininterface.h> | 36 | #include <qpe/mediaplayerplugininterface.h> |
36 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
37 | 38 | ||
38 | 39 | ||
39 | #include <qwidget.h> | 40 | #include <qwidget.h> |
40 | #include <qpainter.h> | 41 | #include <qpainter.h> |
41 | #include <qpixmap.h> | 42 | #include <qpixmap.h> |
42 | #include <qslider.h> | 43 | #include <qslider.h> |
43 | #include <qdrawutil.h> | 44 | #include <qdrawutil.h> |
44 | #include "videowidget.h" | 45 | #include "videowidget.h" |
45 | #include "mediaplayerstate.h" | 46 | #include "mediaplayerstate.h" |
46 | 47 | ||
47 | 48 | ||
48 | #ifdef Q_WS_QWS | 49 | #ifdef Q_WS_QWS |
49 | # define USE_DIRECT_PAINTER | 50 | # define USE_DIRECT_PAINTER |
50 | # include <qdirectpainter_qws.h> | 51 | # include <qdirectpainter_qws.h> |
51 | # include <qgfxraster_qws.h> | 52 | # include <qgfxraster_qws.h> |
52 | #endif | 53 | #endif |
53 | 54 | ||
54 | 55 | ||
55 | extern MediaPlayerState *mediaPlayerState; | 56 | extern MediaPlayerState *mediaPlayerState; |
56 | 57 | ||
57 | 58 | ||
@@ -83,49 +84,49 @@ static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | |||
83 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 84 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
84 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 85 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
85 | 86 | ||
86 | 87 | ||
87 | setCaption( tr("OpiePlayer - Video") ); | 88 | setCaption( tr("OpiePlayer - Video") ); |
88 | 89 | ||
89 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 90 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
90 | 91 | ||
91 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 92 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
92 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 93 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
93 | 94 | ||
94 | Config cfg("OpiePlayer"); | 95 | Config cfg("OpiePlayer"); |
95 | cfg.setGroup("Options"); | 96 | cfg.setGroup("Options"); |
96 | skin = cfg.readEntry("Skin","default"); | 97 | skin = cfg.readEntry("Skin","default"); |
97 | 98 | ||
98 | QString skinPath = "opieplayer2/skins/" + skin; | 99 | QString skinPath = "opieplayer2/skins/" + skin; |
99 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 100 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
100 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 101 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
101 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 102 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
102 | 103 | ||
103 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 104 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
104 | imgButtonMask->fill( 0 ); | 105 | imgButtonMask->fill( 0 ); |
105 | 106 | ||
106 | for ( int i = 0; i < 7; i++ ) { | 107 | for ( int i = 0; i < 7; i++ ) { |
107 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; | 108 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
108 | masks[i] = new QBitmap( filename ); | 109 | masks[i] = new QBitmap( filename ); |
109 | 110 | ||
110 | if ( !masks[i]->isNull() ) { | 111 | if ( !masks[i]->isNull() ) { |
111 | QImage imgMask = masks[i]->convertToImage(); | 112 | QImage imgMask = masks[i]->convertToImage(); |
112 | uchar **dest = imgButtonMask->jumpTable(); | 113 | uchar **dest = imgButtonMask->jumpTable(); |
113 | for ( int y = 0; y < imgUp->height(); y++ ) { | 114 | for ( int y = 0; y < imgUp->height(); y++ ) { |
114 | uchar *line = dest[y]; | 115 | uchar *line = dest[y]; |
115 | for ( int x = 0; x < imgUp->width(); x++ ) { | 116 | for ( int x = 0; x < imgUp->width(); x++ ) { |
116 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 117 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
117 | line[x] = i + 1; | 118 | line[x] = i + 1; |
118 | } | 119 | } |
119 | } | 120 | } |
120 | } | 121 | } |
121 | } | 122 | } |
122 | 123 | ||
123 | for ( int i = 0; i < 7; i++ ) { | 124 | for ( int i = 0; i < 7; i++ ) { |
124 | buttonPixUp[i] = NULL; | 125 | buttonPixUp[i] = NULL; |
125 | buttonPixDown[i] = NULL; | 126 | buttonPixDown[i] = NULL; |
126 | } | 127 | } |
127 | 128 | ||
128 | setBackgroundPixmap( *pixBg ); | 129 | setBackgroundPixmap( *pixBg ); |
129 | 130 | ||
130 | slider = new QSlider( Qt::Horizontal, this ); | 131 | slider = new QSlider( Qt::Horizontal, this ); |
131 | slider->setMinValue( 0 ); | 132 | slider->setMinValue( 0 ); |
@@ -161,50 +162,50 @@ VideoWidget::~VideoWidget() { | |||
161 | delete imgButtonMask; | 162 | delete imgButtonMask; |
162 | for ( int i = 0; i < 7; i++ ) { | 163 | for ( int i = 0; i < 7; i++ ) { |
163 | delete masks[i]; | 164 | delete masks[i]; |
164 | } | 165 | } |
165 | 166 | ||
166 | } | 167 | } |
167 | 168 | ||
168 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 169 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
169 | QPixmap pix( img.width(), img.height() ); | 170 | QPixmap pix( img.width(), img.height() ); |
170 | QPainter p( &pix ); | 171 | QPainter p( &pix ); |
171 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 172 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
172 | p.drawImage( 0, 0, img ); | 173 | p.drawImage( 0, 0, img ); |
173 | return new QPixmap( pix ); | 174 | return new QPixmap( pix ); |
174 | } | 175 | } |
175 | 176 | ||
176 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 177 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
177 | QPixmap *pixmap = new QPixmap( pix ); | 178 | QPixmap *pixmap = new QPixmap( pix ); |
178 | pixmap->setMask( mask ); | 179 | pixmap->setMask( mask ); |
179 | return pixmap; | 180 | return pixmap; |
180 | } | 181 | } |
181 | 182 | ||
182 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 183 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
183 | int h = height(); | 184 | int h = height(); |
184 | int w = width(); | 185 | int w = width(); |
185 | int Vh = 160; | 186 | //int Vh = 160; |
186 | int Vw = 220; | 187 | //int Vw = 220; |
187 | 188 | ||
188 | slider->setFixedWidth( w - 20 ); | 189 | slider->setFixedWidth( w - 20 ); |
189 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 190 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
190 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 191 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
191 | slider->setFocusPolicy( QWidget::NoFocus ); | 192 | slider->setFocusPolicy( QWidget::NoFocus ); |
192 | slider->setBackgroundPixmap( *pixBg ); | 193 | slider->setBackgroundPixmap( *pixBg ); |
193 | 194 | ||
194 | xoff = 0;// ( imgUp->width() ) / 2; | 195 | xoff = 0;// ( imgUp->width() ) / 2; |
195 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 196 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
196 | QPoint p( xoff, yoff ); | 197 | QPoint p( xoff, yoff ); |
197 | 198 | ||
198 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 199 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
199 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 200 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
200 | 201 | ||
201 | for ( int i = 0; i < 7; i++ ) { | 202 | for ( int i = 0; i < 7; i++ ) { |
202 | if ( !masks[i]->isNull() ) { | 203 | if ( !masks[i]->isNull() ) { |
203 | delete buttonPixUp[i]; | 204 | delete buttonPixUp[i]; |
204 | delete buttonPixDown[i]; | 205 | delete buttonPixDown[i]; |
205 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 206 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
206 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 207 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
207 | } | 208 | } |
208 | } | 209 | } |
209 | 210 | ||
210 | delete pixUp; | 211 | delete pixUp; |