author | simon <simon> | 2002-12-02 19:46:48 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 19:46:48 (UTC) |
commit | e77f4914311d8a623c084d01a287798440abf01f (patch) (unidiff) | |
tree | 673375b737c4b1435929cdc804641b08d20e62c8 | |
parent | 1706751f05c1d4312beb1ca939a156b090c7b5f6 (diff) | |
download | opie-e77f4914311d8a623c084d01a287798440abf01f.zip opie-e77f4914311d8a623c084d01a287798440abf01f.tar.gz opie-e77f4914311d8a623c084d01a287798440abf01f.tar.bz2 |
- inherit from MediaWidget
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 9 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 6 |
4 files changed, 12 insertions, 13 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 1600320..0b7d470 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,355 +1,354 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
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/qpeapplication.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <opie/oticker.h> | 37 | #include <opie/oticker.h> |
38 | 38 | ||
39 | #include <qwidget.h> | 39 | #include <qwidget.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qbutton.h> | 41 | #include <qbutton.h> |
42 | #include <qpainter.h> | 42 | #include <qpainter.h> |
43 | #include <qframe.h> | 43 | #include <qframe.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | 48 | ||
49 | #include "audiowidget.h" | 49 | #include "audiowidget.h" |
50 | #include "mediaplayerstate.h" | 50 | #include "mediaplayerstate.h" |
51 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
52 | 52 | ||
53 | extern MediaPlayerState *mediaPlayerState; | 53 | extern MediaPlayerState *mediaPlayerState; |
54 | extern PlayListWidget *playList; | 54 | extern PlayListWidget *playList; |
55 | 55 | ||
56 | static const int xo = -2; // movable x offset | 56 | static const int xo = -2; // movable x offset |
57 | static const int yo = 22; // movable y offset | 57 | static const int yo = 22; // movable y offset |
58 | 58 | ||
59 | struct MediaButton { | 59 | struct MediaButton { |
60 | bool isToggle, isHeld, isDown; | 60 | bool isToggle, isHeld, isDown; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | //Layout information for the audioButtons (and if it is a toggle button or not) | 63 | //Layout information for the audioButtons (and if it is a toggle button or not) |
64 | MediaButton audioButtons[] = { | 64 | MediaButton audioButtons[] = { |
65 | { TRUE, FALSE, FALSE }, // play | 65 | { TRUE, FALSE, FALSE }, // play |
66 | { FALSE, FALSE, FALSE }, // stop | 66 | { FALSE, FALSE, FALSE }, // stop |
67 | { FALSE, FALSE, FALSE }, // next | 67 | { FALSE, FALSE, FALSE }, // next |
68 | { FALSE, FALSE, FALSE }, // previous | 68 | { FALSE, FALSE, FALSE }, // previous |
69 | { FALSE, FALSE, FALSE }, // volume up | 69 | { FALSE, FALSE, FALSE }, // volume up |
70 | { FALSE, FALSE, FALSE }, // volume down | 70 | { FALSE, FALSE, FALSE }, // volume down |
71 | { TRUE, FALSE, FALSE }, // repeat/loop | 71 | { TRUE, FALSE, FALSE }, // repeat/loop |
72 | { FALSE, FALSE, FALSE }, // playlist | 72 | { FALSE, FALSE, FALSE }, // playlist |
73 | { FALSE, FALSE, FALSE }, // forward | 73 | { FALSE, FALSE, FALSE }, // forward |
74 | { FALSE, FALSE, FALSE } // back | 74 | { FALSE, FALSE, FALSE } // back |
75 | }; | 75 | }; |
76 | 76 | ||
77 | const char * const skin_mask_file_names[10] = { | 77 | const char * const skin_mask_file_names[10] = { |
78 | "play", "stop", "next", "prev", "up", | 78 | "play", "stop", "next", "prev", "up", |
79 | "down", "loop", "playlist", "forward", "back" | 79 | "down", "loop", "playlist", "forward", "back" |
80 | }; | 80 | }; |
81 | 81 | ||
82 | 82 | ||
83 | static void changeTextColor( QWidget *w ) { | 83 | static void changeTextColor( QWidget *w ) { |
84 | QPalette p = w->palette(); | 84 | QPalette p = w->palette(); |
85 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 85 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
86 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 86 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
87 | w->setPalette( p ); | 87 | w->setPalette( p ); |
88 | } | 88 | } |
89 | 89 | ||
90 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 90 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
91 | 91 | ||
92 | 92 | ||
93 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 93 | AudioWidget::AudioWidget(QWidget* parent, const char* name) : |
94 | 94 | ||
95 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 95 | MediaWidget( parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
96 | 96 | ||
97 | setCaption( tr("OpiePlayer") ); | 97 | setCaption( tr("OpiePlayer") ); |
98 | 98 | ||
99 | Config cfg("OpiePlayer"); | 99 | Config cfg("OpiePlayer"); |
100 | cfg.setGroup("Options"); | 100 | cfg.setGroup("Options"); |
101 | skin = cfg.readEntry("Skin","default"); | 101 | skin = cfg.readEntry("Skin","default"); |
102 | //skin = "scaleTest"; | 102 | //skin = "scaleTest"; |
103 | // color of background, frame, degree of transparency | 103 | // color of background, frame, degree of transparency |
104 | 104 | ||
105 | QString skinPath = "opieplayer2/skins/" + skin; | 105 | QString skinPath = "opieplayer2/skins/" + skin; |
106 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 106 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
107 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 107 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
108 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 108 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
109 | 109 | ||
110 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 110 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
111 | imgButtonMask.fill( 0 ); | 111 | imgButtonMask.fill( 0 ); |
112 | 112 | ||
113 | for ( int i = 0; i < 10; i++ ) { | 113 | for ( int i = 0; i < 10; i++ ) { |
114 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 114 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); |
115 | masks[i] = new QBitmap( filename ); | 115 | masks[i] = new QBitmap( filename ); |
116 | 116 | ||
117 | if ( !masks[i]->isNull() ) { | 117 | if ( !masks[i]->isNull() ) { |
118 | QImage imgMask = masks[i]->convertToImage(); | 118 | QImage imgMask = masks[i]->convertToImage(); |
119 | uchar **dest = imgButtonMask.jumpTable(); | 119 | uchar **dest = imgButtonMask.jumpTable(); |
120 | for ( int y = 0; y < imgUp.height(); y++ ) { | 120 | for ( int y = 0; y < imgUp.height(); y++ ) { |
121 | uchar *line = dest[y]; | 121 | uchar *line = dest[y]; |
122 | for ( int x = 0; x < imgUp.width(); x++ ) | 122 | for ( int x = 0; x < imgUp.width(); x++ ) |
123 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 123 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
124 | line[x] = i + 1; | 124 | line[x] = i + 1; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | } | 128 | } |
129 | 129 | ||
130 | for ( int i = 0; i < 10; i++ ) { | 130 | for ( int i = 0; i < 10; i++ ) { |
131 | buttonPixUp[i] = 0l; | 131 | buttonPixUp[i] = 0l; |
132 | buttonPixDown[i] = 0l; | 132 | buttonPixDown[i] = 0l; |
133 | } | 133 | } |
134 | 134 | ||
135 | setBackgroundPixmap( pixBg ); | 135 | setBackgroundPixmap( pixBg ); |
136 | 136 | ||
137 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 137 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
138 | // changeTextColor( &songInfo ); | 138 | // changeTextColor( &songInfo ); |
139 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 139 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
140 | // songInfo.setFrameStyle( QFrame::NoFrame); | 140 | // songInfo.setFrameStyle( QFrame::NoFrame); |
141 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 141 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
142 | // songInfo.setForegroundColor(Qt::white); | 142 | // songInfo.setForegroundColor(Qt::white); |
143 | 143 | ||
144 | slider.setFixedHeight( 20 ); | 144 | slider.setFixedHeight( 20 ); |
145 | slider.setMinValue( 0 ); | 145 | slider.setMinValue( 0 ); |
146 | slider.setMaxValue( 1 ); | 146 | slider.setMaxValue( 1 ); |
147 | slider.setFocusPolicy( QWidget::NoFocus ); | 147 | slider.setFocusPolicy( QWidget::NoFocus ); |
148 | slider.setBackgroundPixmap( pixBg ); | 148 | slider.setBackgroundPixmap( pixBg ); |
149 | 149 | ||
150 | // Config cofg("qpe"); | 150 | // Config cofg("qpe"); |
151 | // cofg.setGroup("Appearance"); | 151 | // cofg.setGroup("Appearance"); |
152 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | 152 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); |
153 | 153 | ||
154 | time.setFocusPolicy( QWidget::NoFocus ); | 154 | time.setFocusPolicy( QWidget::NoFocus ); |
155 | time.setAlignment( Qt::AlignCenter ); | 155 | time.setAlignment( Qt::AlignCenter ); |
156 | 156 | ||
157 | // time.setFrame(FALSE); | 157 | // time.setFrame(FALSE); |
158 | // changeTextColor( &time ); | 158 | // changeTextColor( &time ); |
159 | 159 | ||
160 | resizeEvent( NULL ); | 160 | resizeEvent( NULL ); |
161 | 161 | ||
162 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 162 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
163 | connect( mediaPlayerState, SIGNAL( displayTypeChanged(MediaPlayerState::DisplayType) ), this, SLOT( setDisplayType(MediaPlayerState::DisplayType) ) ); | ||
164 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 163 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
165 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 164 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
166 | connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); | 165 | connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); |
167 | 166 | ||
168 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 167 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
169 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 168 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
170 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 169 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
171 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 170 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
172 | 171 | ||
173 | // Intialise state | 172 | // Intialise state |
174 | setLength( mediaPlayerState->length() ); | 173 | setLength( mediaPlayerState->length() ); |
175 | setPosition( mediaPlayerState->position() ); | 174 | setPosition( mediaPlayerState->position() ); |
176 | setLooping( mediaPlayerState->isFullscreen() ); | 175 | setLooping( mediaPlayerState->isFullscreen() ); |
177 | // setPaused( mediaPlayerState->paused() ); | 176 | // setPaused( mediaPlayerState->paused() ); |
178 | setPlaying( mediaPlayerState->isPlaying() ); | 177 | setPlaying( mediaPlayerState->isPlaying() ); |
179 | 178 | ||
180 | } | 179 | } |
181 | 180 | ||
182 | AudioWidget::~AudioWidget() { | 181 | AudioWidget::~AudioWidget() { |
183 | 182 | ||
184 | for ( int i = 0; i < 10; i++ ) { | 183 | for ( int i = 0; i < 10; i++ ) { |
185 | delete buttonPixUp[i]; | 184 | delete buttonPixUp[i]; |
186 | delete buttonPixDown[i]; | 185 | delete buttonPixDown[i]; |
187 | } | 186 | } |
188 | for ( int i = 0; i < 10; i++ ) { | 187 | for ( int i = 0; i < 10; i++ ) { |
189 | delete masks[i]; | 188 | delete masks[i]; |
190 | } | 189 | } |
191 | // mediaPlayerState->setPlaying(false); | 190 | // mediaPlayerState->setPlaying(false); |
192 | } | 191 | } |
193 | 192 | ||
194 | namespace { | 193 | namespace { |
195 | 194 | ||
196 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 195 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
197 | QPixmap pix( img.width(), img.height() ); | 196 | QPixmap pix( img.width(), img.height() ); |
198 | QPainter p( &pix ); | 197 | QPainter p( &pix ); |
199 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 198 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
200 | p.drawImage( 0, 0, img ); | 199 | p.drawImage( 0, 0, img ); |
201 | return pix; | 200 | return pix; |
202 | } | 201 | } |
203 | 202 | ||
204 | 203 | ||
205 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { | 204 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { |
206 | QPixmap *pixmap = new QPixmap( pix ); | 205 | QPixmap *pixmap = new QPixmap( pix ); |
207 | pixmap->setMask( mask ); | 206 | pixmap->setMask( mask ); |
208 | return pixmap; | 207 | return pixmap; |
209 | } | 208 | } |
210 | 209 | ||
211 | }; | 210 | }; |
212 | 211 | ||
213 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 212 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
214 | int h = height(); | 213 | int h = height(); |
215 | int w = width(); | 214 | int w = width(); |
216 | 215 | ||
217 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 216 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
218 | slider.setFixedWidth( w - 110 ); | 217 | slider.setFixedWidth( w - 110 ); |
219 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 218 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
220 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 219 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
221 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 220 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
222 | 221 | ||
223 | xoff = ( w - imgUp.width() ) / 2; | 222 | xoff = ( w - imgUp.width() ) / 2; |
224 | yoff = (( h - imgUp.height() ) / 2) - 10; | 223 | yoff = (( h - imgUp.height() ) / 2) - 10; |
225 | QPoint p( xoff, yoff ); | 224 | QPoint p( xoff, yoff ); |
226 | 225 | ||
227 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); | 226 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); |
228 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); | 227 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); |
229 | 228 | ||
230 | for ( int i = 0; i < 10; i++ ) { | 229 | for ( int i = 0; i < 10; i++ ) { |
231 | if ( !masks[i]->isNull() ) { | 230 | if ( !masks[i]->isNull() ) { |
232 | delete buttonPixUp[i]; | 231 | delete buttonPixUp[i]; |
233 | delete buttonPixDown[i]; | 232 | delete buttonPixDown[i]; |
234 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); | 233 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); |
235 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); | 234 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); |
236 | } | 235 | } |
237 | } | 236 | } |
238 | } | 237 | } |
239 | 238 | ||
240 | static bool audioSliderBeingMoved = FALSE; | 239 | static bool audioSliderBeingMoved = FALSE; |
241 | 240 | ||
242 | 241 | ||
243 | void AudioWidget::sliderPressed() { | 242 | void AudioWidget::sliderPressed() { |
244 | audioSliderBeingMoved = TRUE; | 243 | audioSliderBeingMoved = TRUE; |
245 | } | 244 | } |
246 | 245 | ||
247 | 246 | ||
248 | void AudioWidget::sliderReleased() { | 247 | void AudioWidget::sliderReleased() { |
249 | audioSliderBeingMoved = FALSE; | 248 | audioSliderBeingMoved = FALSE; |
250 | if ( slider.width() == 0 ) | 249 | if ( slider.width() == 0 ) |
251 | return; | 250 | return; |
252 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 251 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
253 | mediaPlayerState->setPosition( val ); | 252 | mediaPlayerState->setPosition( val ); |
254 | } | 253 | } |
255 | 254 | ||
256 | void AudioWidget::setPosition( long i ) { | 255 | void AudioWidget::setPosition( long i ) { |
257 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 256 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
258 | updateSlider( i, mediaPlayerState->length() ); | 257 | updateSlider( i, mediaPlayerState->length() ); |
259 | } | 258 | } |
260 | 259 | ||
261 | 260 | ||
262 | void AudioWidget::setLength( long max ) { | 261 | void AudioWidget::setLength( long max ) { |
263 | updateSlider( mediaPlayerState->position(), max ); | 262 | updateSlider( mediaPlayerState->position(), max ); |
264 | } | 263 | } |
265 | 264 | ||
266 | 265 | ||
267 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 266 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
268 | if ( mediaType == MediaPlayerState::Audio ) { | 267 | if ( mediaType == MediaPlayerState::Audio ) { |
269 | // startTimer( 150 ); | 268 | // startTimer( 150 ); |
270 | showMaximized(); | 269 | showMaximized(); |
271 | return; | 270 | return; |
272 | } | 271 | } |
273 | 272 | ||
274 | killTimers(); | 273 | killTimers(); |
275 | hide(); | 274 | hide(); |
276 | } | 275 | } |
277 | 276 | ||
278 | 277 | ||
279 | void AudioWidget::setSeekable( bool isSeekable ) { | 278 | void AudioWidget::setSeekable( bool isSeekable ) { |
280 | 279 | ||
281 | if ( !isSeekable ) { | 280 | if ( !isSeekable ) { |
282 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 281 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
283 | if( !slider.isHidden()) { | 282 | if( !slider.isHidden()) { |
284 | slider.hide(); | 283 | slider.hide(); |
285 | } | 284 | } |
286 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 285 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
287 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 286 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
288 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 287 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
289 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 288 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
290 | } else { | 289 | } else { |
291 | // this stops the slider from being moved, thus | 290 | // this stops the slider from being moved, thus |
292 | // does not stop stream when it reaches the end | 291 | // does not stop stream when it reaches the end |
293 | slider.show(); | 292 | slider.show(); |
294 | qDebug( " CONNECT SET POSTION " ); | 293 | qDebug( " CONNECT SET POSTION " ); |
295 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 294 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
296 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 295 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
297 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 296 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
298 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 297 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
299 | } | 298 | } |
300 | } | 299 | } |
301 | 300 | ||
302 | 301 | ||
303 | static QString timeAsString( long length ) { | 302 | static QString timeAsString( long length ) { |
304 | int minutes = length / 60; | 303 | int minutes = length / 60; |
305 | int seconds = length % 60; | 304 | int seconds = length % 60; |
306 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 305 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
307 | } | 306 | } |
308 | 307 | ||
309 | void AudioWidget::updateSlider( long i, long max ) { | 308 | void AudioWidget::updateSlider( long i, long max ) { |
310 | 309 | ||
311 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 310 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
312 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 311 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
313 | 312 | ||
314 | if ( max == 0 ) { | 313 | if ( max == 0 ) { |
315 | return; | 314 | return; |
316 | } | 315 | } |
317 | // Will flicker too much if we don't do this | 316 | // Will flicker too much if we don't do this |
318 | // Scale to something reasonable | 317 | // Scale to something reasonable |
319 | int width = slider.width(); | 318 | int width = slider.width(); |
320 | int val = int((double)i * width / max); | 319 | int val = int((double)i * width / max); |
321 | if ( !audioSliderBeingMoved ) { | 320 | if ( !audioSliderBeingMoved ) { |
322 | if ( slider.value() != val ) { | 321 | if ( slider.value() != val ) { |
323 | slider.setValue( val ); | 322 | slider.setValue( val ); |
324 | } | 323 | } |
325 | 324 | ||
326 | if ( slider.maxValue() != width ) { | 325 | if ( slider.maxValue() != width ) { |
327 | slider.setMaxValue( width ); | 326 | slider.setMaxValue( width ); |
328 | } | 327 | } |
329 | } | 328 | } |
330 | } | 329 | } |
331 | 330 | ||
332 | 331 | ||
333 | void AudioWidget::setToggleButton( int i, bool down ) { | 332 | void AudioWidget::setToggleButton( int i, bool down ) { |
334 | qDebug("setToggleButton %d", i); | 333 | qDebug("setToggleButton %d", i); |
335 | if ( down != audioButtons[i].isDown ) { | 334 | if ( down != audioButtons[i].isDown ) { |
336 | toggleButton( i ); | 335 | toggleButton( i ); |
337 | } | 336 | } |
338 | } | 337 | } |
339 | 338 | ||
340 | 339 | ||
341 | void AudioWidget::toggleButton( int i ) { | 340 | void AudioWidget::toggleButton( int i ) { |
342 | audioButtons[i].isDown = !audioButtons[i].isDown; | 341 | audioButtons[i].isDown = !audioButtons[i].isDown; |
343 | QPainter p(this); | 342 | QPainter p(this); |
344 | paintButton ( &p, i ); | 343 | paintButton ( &p, i ); |
345 | } | 344 | } |
346 | 345 | ||
347 | 346 | ||
348 | void AudioWidget::paintButton( QPainter *p, int i ) { | 347 | void AudioWidget::paintButton( QPainter *p, int i ) { |
349 | if ( audioButtons[i].isDown ) { | 348 | if ( audioButtons[i].isDown ) { |
350 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 349 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
351 | } else { | 350 | } else { |
352 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 351 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
353 | } | 352 | } |
354 | } | 353 | } |
355 | 354 | ||
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 91fcbc5..74c5b0e 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -1,137 +1,138 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
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 | #ifndef AUDIO_WIDGET_H | 34 | #ifndef AUDIO_WIDGET_H |
35 | #define AUDIO_WIDGET_H | 35 | #define AUDIO_WIDGET_H |
36 | 36 | ||
37 | #include <qwidget.h> | ||
38 | #include <qpainter.h> | 37 | #include <qpainter.h> |
39 | #include <qdrawutil.h> | 38 | #include <qdrawutil.h> |
40 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
41 | #include <qstring.h> | 40 | #include <qstring.h> |
42 | #include <qslider.h> | 41 | #include <qslider.h> |
43 | #include <qframe.h> | 42 | #include <qframe.h> |
44 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
45 | #include <qimage.h> | 44 | #include <qimage.h> |
46 | 45 | ||
47 | #include <opie/oticker.h> | 46 | #include <opie/oticker.h> |
48 | 47 | ||
49 | #include "mediaplayerstate.h" | 48 | #include "mediawidget.h" |
50 | 49 | ||
51 | class QPixmap; | 50 | class QPixmap; |
52 | 51 | ||
53 | namespace { | 52 | namespace { |
54 | 53 | ||
55 | enum AudioButtons { | 54 | enum AudioButtons { |
56 | AudioPlay=0, | 55 | AudioPlay=0, |
57 | AudioStop, | 56 | AudioStop, |
58 | AudioNext, | 57 | AudioNext, |
59 | AudioPrevious, | 58 | AudioPrevious, |
60 | AudioVolumeUp, | 59 | AudioVolumeUp, |
61 | AudioVolumeDown, | 60 | AudioVolumeDown, |
62 | AudioLoop, | 61 | AudioLoop, |
63 | AudioPlayList, | 62 | AudioPlayList, |
64 | AudioForward, | 63 | AudioForward, |
65 | AudioBack | 64 | AudioBack |
66 | }; | 65 | }; |
67 | }; | 66 | }; |
68 | 67 | ||
69 | class AudioWidget : public QWidget { | 68 | class AudioWidget : public MediaWidget { |
70 | Q_OBJECT | 69 | Q_OBJECT |
71 | public: | 70 | public: |
72 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 71 | AudioWidget( QWidget* parent=0, const char* name=0 ); |
73 | ~AudioWidget(); | 72 | ~AudioWidget(); |
74 | void setTickerText( const QString &text ) { songInfo.setText( text ); } | 73 | void setTickerText( const QString &text ) { songInfo.setText( text ); } |
75 | public slots: | 74 | public slots: |
76 | void updateSlider( long, long ); | 75 | void updateSlider( long, long ); |
77 | void sliderPressed( ); | 76 | void sliderPressed( ); |
78 | void sliderReleased( ); | 77 | void sliderReleased( ); |
79 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } | 78 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } |
80 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } | 79 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } |
81 | void setPosition( long ); | 80 | void setPosition( long ); |
82 | void setLength( long ); | 81 | void setLength( long ); |
83 | void setSeekable( bool ); | 82 | void setSeekable( bool ); |
83 | |||
84 | public: | ||
84 | void setDisplayType( MediaPlayerState::DisplayType displayType ); | 85 | void setDisplayType( MediaPlayerState::DisplayType displayType ); |
85 | 86 | ||
86 | signals: | 87 | signals: |
87 | void moreClicked(); | 88 | void moreClicked(); |
88 | void lessClicked(); | 89 | void lessClicked(); |
89 | void moreReleased(); | 90 | void moreReleased(); |
90 | void lessReleased(); | 91 | void lessReleased(); |
91 | void forwardClicked(); | 92 | void forwardClicked(); |
92 | void backClicked(); | 93 | void backClicked(); |
93 | void forwardReleased(); | 94 | void forwardReleased(); |
94 | void backReleased(); | 95 | void backReleased(); |
95 | void sliderMoved(long); | 96 | void sliderMoved(long); |
96 | 97 | ||
97 | protected: | 98 | protected: |
98 | void doBlank(); | 99 | void doBlank(); |
99 | void doUnblank(); | 100 | void doUnblank(); |
100 | void paintEvent( QPaintEvent *pe ); | 101 | void paintEvent( QPaintEvent *pe ); |
101 | void showEvent( QShowEvent *se ); | 102 | void showEvent( QShowEvent *se ); |
102 | void resizeEvent( QResizeEvent *re ); | 103 | void resizeEvent( QResizeEvent *re ); |
103 | void mouseMoveEvent( QMouseEvent *event ); | 104 | void mouseMoveEvent( QMouseEvent *event ); |
104 | void mousePressEvent( QMouseEvent *event ); | 105 | void mousePressEvent( QMouseEvent *event ); |
105 | void mouseReleaseEvent( QMouseEvent *event ); | 106 | void mouseReleaseEvent( QMouseEvent *event ); |
106 | void timerEvent( QTimerEvent *event ); | 107 | void timerEvent( QTimerEvent *event ); |
107 | void closeEvent( QCloseEvent *event ); | 108 | void closeEvent( QCloseEvent *event ); |
108 | void keyReleaseEvent( QKeyEvent *e); | 109 | void keyReleaseEvent( QKeyEvent *e); |
109 | private slots: | 110 | private slots: |
110 | void skipFor(); | 111 | void skipFor(); |
111 | void skipBack(); | 112 | void skipBack(); |
112 | void stopSkip(); | 113 | void stopSkip(); |
113 | private: | 114 | private: |
114 | void toggleButton( int ); | 115 | void toggleButton( int ); |
115 | void setToggleButton( int, bool ); | 116 | void setToggleButton( int, bool ); |
116 | void paintButton( QPainter *p, int i ); | 117 | void paintButton( QPainter *p, int i ); |
117 | int skipDirection; | 118 | int skipDirection; |
118 | QString skin; | 119 | QString skin; |
119 | QPixmap pixBg; | 120 | QPixmap pixBg; |
120 | QImage imgUp; | 121 | QImage imgUp; |
121 | QImage imgDn; | 122 | QImage imgDn; |
122 | QImage imgButtonMask; | 123 | QImage imgButtonMask; |
123 | QBitmap *masks[10]; | 124 | QBitmap *masks[10]; |
124 | QPixmap *buttonPixUp[10]; | 125 | QPixmap *buttonPixUp[10]; |
125 | QPixmap *buttonPixDown[10]; | 126 | QPixmap *buttonPixDown[10]; |
126 | 127 | ||
127 | QPixmap *pixmaps[4]; | 128 | QPixmap *pixmaps[4]; |
128 | OTicker songInfo; | 129 | OTicker songInfo; |
129 | QSlider slider; | 130 | QSlider slider; |
130 | QLineEdit time; | 131 | QLineEdit time; |
131 | int xoff, yoff; | 132 | int xoff, yoff; |
132 | bool isStreaming : 1; | 133 | bool isStreaming : 1; |
133 | }; | 134 | }; |
134 | 135 | ||
135 | 136 | ||
136 | #endif // AUDIO_WIDGET_H | 137 | #endif // AUDIO_WIDGET_H |
137 | 138 | ||
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 9ce2b57..8a0016e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,334 +1,333 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
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/qpeapplication.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/mediaplayerplugininterface.h> | 36 | #include <qpe/mediaplayerplugininterface.h> |
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | 38 | ||
39 | 39 | ||
40 | #include <qwidget.h> | 40 | #include <qwidget.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | #include <qpixmap.h> | 42 | #include <qpixmap.h> |
43 | #include <qslider.h> | 43 | #include <qslider.h> |
44 | #include <qdrawutil.h> | 44 | #include <qdrawutil.h> |
45 | #include "videowidget.h" | 45 | #include "videowidget.h" |
46 | #include "mediaplayerstate.h" | 46 | #include "mediaplayerstate.h" |
47 | #include "playlistwidget.h" | 47 | #include "playlistwidget.h" |
48 | 48 | ||
49 | 49 | ||
50 | #ifdef Q_WS_QWS | 50 | #ifdef Q_WS_QWS |
51 | # define USE_DIRECT_PAINTER | 51 | # define USE_DIRECT_PAINTER |
52 | # include <qdirectpainter_qws.h> | 52 | # include <qdirectpainter_qws.h> |
53 | # include <qgfxraster_qws.h> | 53 | # include <qgfxraster_qws.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | 56 | ||
57 | extern MediaPlayerState *mediaPlayerState; | 57 | extern MediaPlayerState *mediaPlayerState; |
58 | extern PlayListWidget *playList; | 58 | extern PlayListWidget *playList; |
59 | 59 | ||
60 | 60 | ||
61 | static const int xo = 2; // movable x offset | 61 | static const int xo = 2; // movable x offset |
62 | static const int yo = 0; // movable y offset | 62 | static const int yo = 0; // movable y offset |
63 | 63 | ||
64 | 64 | ||
65 | struct MediaButton { | 65 | struct MediaButton { |
66 | bool isToggle, isHeld, isDown; | 66 | bool isToggle, isHeld, isDown; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | MediaButton videoButtons[] = { | 69 | MediaButton videoButtons[] = { |
70 | { FALSE, FALSE, FALSE }, // stop | 70 | { FALSE, FALSE, FALSE }, // stop |
71 | { TRUE, FALSE, FALSE }, // play | 71 | { TRUE, FALSE, FALSE }, // play |
72 | { FALSE, FALSE, FALSE }, // previous | 72 | { FALSE, FALSE, FALSE }, // previous |
73 | { FALSE, FALSE, FALSE }, // next | 73 | { FALSE, FALSE, FALSE }, // next |
74 | { FALSE, FALSE, FALSE }, // volUp | 74 | { FALSE, FALSE, FALSE }, // volUp |
75 | { FALSE, FALSE, FALSE }, // volDown | 75 | { FALSE, FALSE, FALSE }, // volDown |
76 | { TRUE, FALSE, FALSE } // fullscreen | 76 | { TRUE, FALSE, FALSE } // fullscreen |
77 | }; | 77 | }; |
78 | 78 | ||
79 | const char *skinV_mask_file_names[7] = { | 79 | const char *skinV_mask_file_names[7] = { |
80 | "stop","play","back","fwd","up","down","full" | 80 | "stop","play","back","fwd","up","down","full" |
81 | }; | 81 | }; |
82 | 82 | ||
83 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 83 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
84 | 84 | ||
85 | 85 | ||
86 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 86 | VideoWidget::VideoWidget(QWidget* parent, const char* name) : |
87 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 87 | MediaWidget( parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) { |
88 | 88 | ||
89 | 89 | ||
90 | setCaption( tr("OpiePlayer - Video") ); | 90 | setCaption( tr("OpiePlayer - Video") ); |
91 | 91 | ||
92 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 92 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
93 | 93 | ||
94 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 94 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
95 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 95 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
96 | 96 | ||
97 | Config cfg("OpiePlayer"); | 97 | Config cfg("OpiePlayer"); |
98 | cfg.setGroup("Options"); | 98 | cfg.setGroup("Options"); |
99 | skin = cfg.readEntry("Skin","default"); | 99 | skin = cfg.readEntry("Skin","default"); |
100 | 100 | ||
101 | QString skinPath = "opieplayer2/skins/" + skin; | 101 | QString skinPath = "opieplayer2/skins/" + skin; |
102 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 102 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
103 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 103 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
104 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 104 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
105 | 105 | ||
106 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 106 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
107 | imgButtonMask->fill( 0 ); | 107 | imgButtonMask->fill( 0 ); |
108 | 108 | ||
109 | for ( int i = 0; i < 7; i++ ) { | 109 | for ( int i = 0; i < 7; i++ ) { |
110 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 110 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
111 | masks[i] = new QBitmap( filename ); | 111 | masks[i] = new QBitmap( filename ); |
112 | 112 | ||
113 | if ( !masks[i]->isNull() ) { | 113 | if ( !masks[i]->isNull() ) { |
114 | QImage imgMask = masks[i]->convertToImage(); | 114 | QImage imgMask = masks[i]->convertToImage(); |
115 | uchar **dest = imgButtonMask->jumpTable(); | 115 | uchar **dest = imgButtonMask->jumpTable(); |
116 | for ( int y = 0; y < imgUp->height(); y++ ) { | 116 | for ( int y = 0; y < imgUp->height(); y++ ) { |
117 | uchar *line = dest[y]; | 117 | uchar *line = dest[y]; |
118 | for ( int x = 0; x < imgUp->width(); x++ ) { | 118 | for ( int x = 0; x < imgUp->width(); x++ ) { |
119 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 119 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
120 | line[x] = i + 1; | 120 | line[x] = i + 1; |
121 | } | 121 | } |
122 | } | 122 | } |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | for ( int i = 0; i < 7; i++ ) { | 126 | for ( int i = 0; i < 7; i++ ) { |
127 | buttonPixUp[i] = NULL; | 127 | buttonPixUp[i] = NULL; |
128 | buttonPixDown[i] = NULL; | 128 | buttonPixDown[i] = NULL; |
129 | } | 129 | } |
130 | 130 | ||
131 | setBackgroundPixmap( *pixBg ); | 131 | setBackgroundPixmap( *pixBg ); |
132 | 132 | ||
133 | slider = new QSlider( Qt::Horizontal, this ); | 133 | slider = new QSlider( Qt::Horizontal, this ); |
134 | slider->setMinValue( 0 ); | 134 | slider->setMinValue( 0 ); |
135 | slider->setMaxValue( 1 ); | 135 | slider->setMaxValue( 1 ); |
136 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 136 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
137 | //slider->setFocusPolicy( QWidget::NoFocus ); | 137 | //slider->setFocusPolicy( QWidget::NoFocus ); |
138 | 138 | ||
139 | resizeEvent( NULL ); | 139 | resizeEvent( NULL ); |
140 | 140 | ||
141 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 141 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
142 | connect( mediaPlayerState, SIGNAL( displayTypeChanged(MediaPlayerState::DisplayType) ), this, SLOT( setDisplayType(MediaPlayerState::DisplayType) ) ); | ||
143 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 142 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
144 | 143 | ||
145 | setLength( mediaPlayerState->length() ); | 144 | setLength( mediaPlayerState->length() ); |
146 | setPosition( mediaPlayerState->position() ); | 145 | setPosition( mediaPlayerState->position() ); |
147 | setFullscreen( mediaPlayerState->isFullscreen() ); | 146 | setFullscreen( mediaPlayerState->isFullscreen() ); |
148 | setPlaying( mediaPlayerState->isPlaying() ); | 147 | setPlaying( mediaPlayerState->isPlaying() ); |
149 | } | 148 | } |
150 | 149 | ||
151 | 150 | ||
152 | VideoWidget::~VideoWidget() { | 151 | VideoWidget::~VideoWidget() { |
153 | 152 | ||
154 | for ( int i = 0; i < 7; i++ ) { | 153 | for ( int i = 0; i < 7; i++ ) { |
155 | delete buttonPixUp[i]; | 154 | delete buttonPixUp[i]; |
156 | delete buttonPixDown[i]; | 155 | delete buttonPixDown[i]; |
157 | } | 156 | } |
158 | 157 | ||
159 | delete pixBg; | 158 | delete pixBg; |
160 | delete imgUp; | 159 | delete imgUp; |
161 | delete imgDn; | 160 | delete imgDn; |
162 | delete imgButtonMask; | 161 | delete imgButtonMask; |
163 | for ( int i = 0; i < 7; i++ ) { | 162 | for ( int i = 0; i < 7; i++ ) { |
164 | delete masks[i]; | 163 | delete masks[i]; |
165 | } | 164 | } |
166 | 165 | ||
167 | } | 166 | } |
168 | 167 | ||
169 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 168 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
170 | QPixmap pix( img.width(), img.height() ); | 169 | QPixmap pix( img.width(), img.height() ); |
171 | QPainter p( &pix ); | 170 | QPainter p( &pix ); |
172 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 171 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
173 | p.drawImage( 0, 0, img ); | 172 | p.drawImage( 0, 0, img ); |
174 | return new QPixmap( pix ); | 173 | return new QPixmap( pix ); |
175 | } | 174 | } |
176 | 175 | ||
177 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 176 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
178 | QPixmap *pixmap = new QPixmap( pix ); | 177 | QPixmap *pixmap = new QPixmap( pix ); |
179 | pixmap->setMask( mask ); | 178 | pixmap->setMask( mask ); |
180 | return pixmap; | 179 | return pixmap; |
181 | } | 180 | } |
182 | 181 | ||
183 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 182 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
184 | int h = height(); | 183 | int h = height(); |
185 | int w = width(); | 184 | int w = width(); |
186 | //int Vh = 160; | 185 | //int Vh = 160; |
187 | //int Vw = 220; | 186 | //int Vw = 220; |
188 | 187 | ||
189 | slider->setFixedWidth( w - 20 ); | 188 | slider->setFixedWidth( w - 20 ); |
190 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 189 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
191 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 190 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
192 | slider->setFocusPolicy( QWidget::NoFocus ); | 191 | slider->setFocusPolicy( QWidget::NoFocus ); |
193 | slider->setBackgroundPixmap( *pixBg ); | 192 | slider->setBackgroundPixmap( *pixBg ); |
194 | 193 | ||
195 | xoff = 0;// ( imgUp->width() ) / 2; | 194 | xoff = 0;// ( imgUp->width() ) / 2; |
196 | if(w>h) | 195 | if(w>h) |
197 | yoff = 0; | 196 | yoff = 0; |
198 | else | 197 | else |
199 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 198 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
200 | QPoint p( xoff, yoff ); | 199 | QPoint p( xoff, yoff ); |
201 | 200 | ||
202 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 201 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
203 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 202 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
204 | 203 | ||
205 | for ( int i = 0; i < 7; i++ ) { | 204 | for ( int i = 0; i < 7; i++ ) { |
206 | if ( !masks[i]->isNull() ) { | 205 | if ( !masks[i]->isNull() ) { |
207 | delete buttonPixUp[i]; | 206 | delete buttonPixUp[i]; |
208 | delete buttonPixDown[i]; | 207 | delete buttonPixDown[i]; |
209 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 208 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
210 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 209 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
211 | } | 210 | } |
212 | } | 211 | } |
213 | 212 | ||
214 | delete pixUp; | 213 | delete pixUp; |
215 | delete pixDn; | 214 | delete pixDn; |
216 | } | 215 | } |
217 | 216 | ||
218 | static bool videoSliderBeingMoved = FALSE; | 217 | static bool videoSliderBeingMoved = FALSE; |
219 | 218 | ||
220 | void VideoWidget::sliderPressed() { | 219 | void VideoWidget::sliderPressed() { |
221 | videoSliderBeingMoved = TRUE; | 220 | videoSliderBeingMoved = TRUE; |
222 | } | 221 | } |
223 | 222 | ||
224 | void VideoWidget::sliderReleased() { | 223 | void VideoWidget::sliderReleased() { |
225 | videoSliderBeingMoved = FALSE; | 224 | videoSliderBeingMoved = FALSE; |
226 | if ( slider->width() == 0 ) { | 225 | if ( slider->width() == 0 ) { |
227 | return; | 226 | return; |
228 | } | 227 | } |
229 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 228 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
230 | mediaPlayerState->setPosition( val ); | 229 | mediaPlayerState->setPosition( val ); |
231 | } | 230 | } |
232 | 231 | ||
233 | void VideoWidget::setPosition( long i ) { | 232 | void VideoWidget::setPosition( long i ) { |
234 | updateSlider( i, mediaPlayerState->length() ); | 233 | updateSlider( i, mediaPlayerState->length() ); |
235 | } | 234 | } |
236 | 235 | ||
237 | 236 | ||
238 | void VideoWidget::setLength( long max ) { | 237 | void VideoWidget::setLength( long max ) { |
239 | updateSlider( mediaPlayerState->position(), max ); | 238 | updateSlider( mediaPlayerState->position(), max ); |
240 | } | 239 | } |
241 | 240 | ||
242 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 241 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
243 | { | 242 | { |
244 | if ( displayType == MediaPlayerState::Video ) { | 243 | if ( displayType == MediaPlayerState::Video ) { |
245 | makeVisible(); | 244 | makeVisible(); |
246 | return; | 245 | return; |
247 | } | 246 | } |
248 | 247 | ||
249 | // Effectively blank the view next time we show it so it looks nicer | 248 | // Effectively blank the view next time we show it so it looks nicer |
250 | scaledWidth = 0; | 249 | scaledWidth = 0; |
251 | scaledHeight = 0; | 250 | scaledHeight = 0; |
252 | hide(); | 251 | hide(); |
253 | } | 252 | } |
254 | 253 | ||
255 | void VideoWidget::updateSlider( long i, long max ) { | 254 | void VideoWidget::updateSlider( long i, long max ) { |
256 | // Will flicker too much if we don't do this | 255 | // Will flicker too much if we don't do this |
257 | if ( max == 0 ) { | 256 | if ( max == 0 ) { |
258 | return; | 257 | return; |
259 | } | 258 | } |
260 | int width = slider->width(); | 259 | int width = slider->width(); |
261 | int val = int((double)i * width / max); | 260 | int val = int((double)i * width / max); |
262 | if ( !mediaPlayerState->isFullscreen() && !videoSliderBeingMoved ) { | 261 | if ( !mediaPlayerState->isFullscreen() && !videoSliderBeingMoved ) { |
263 | if ( slider->value() != val ) { | 262 | if ( slider->value() != val ) { |
264 | slider->setValue( val ); | 263 | slider->setValue( val ); |
265 | } | 264 | } |
266 | if ( slider->maxValue() != width ) { | 265 | if ( slider->maxValue() != width ) { |
267 | slider->setMaxValue( width ); | 266 | slider->setMaxValue( width ); |
268 | } | 267 | } |
269 | } | 268 | } |
270 | } | 269 | } |
271 | 270 | ||
272 | void VideoWidget::setToggleButton( int i, bool down ) { | 271 | void VideoWidget::setToggleButton( int i, bool down ) { |
273 | if ( down != videoButtons[i].isDown ) { | 272 | if ( down != videoButtons[i].isDown ) { |
274 | toggleButton( i ); | 273 | toggleButton( i ); |
275 | } | 274 | } |
276 | } | 275 | } |
277 | 276 | ||
278 | void VideoWidget::toggleButton( int i ) { | 277 | void VideoWidget::toggleButton( int i ) { |
279 | videoButtons[i].isDown = !videoButtons[i].isDown; | 278 | videoButtons[i].isDown = !videoButtons[i].isDown; |
280 | QPainter p(this); | 279 | QPainter p(this); |
281 | paintButton ( &p, i ); | 280 | paintButton ( &p, i ); |
282 | } | 281 | } |
283 | 282 | ||
284 | void VideoWidget::paintButton( QPainter *p, int i ) { | 283 | void VideoWidget::paintButton( QPainter *p, int i ) { |
285 | 284 | ||
286 | if ( videoButtons[i].isDown ) { | 285 | if ( videoButtons[i].isDown ) { |
287 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 286 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
288 | } else { | 287 | } else { |
289 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 288 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
290 | } | 289 | } |
291 | } | 290 | } |
292 | 291 | ||
293 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 292 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
294 | for ( int i = 0; i < numVButtons; i++ ) { | 293 | for ( int i = 0; i < numVButtons; i++ ) { |
295 | if ( event->state() == QMouseEvent::LeftButton ) { | 294 | if ( event->state() == QMouseEvent::LeftButton ) { |
296 | // The test to see if the mouse click is inside the button or not | 295 | // The test to see if the mouse click is inside the button or not |
297 | int x = event->pos().x() - xoff; | 296 | int x = event->pos().x() - xoff; |
298 | int y = event->pos().y() - yoff; | 297 | int y = event->pos().y() - yoff; |
299 | 298 | ||
300 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 299 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
301 | && y < imgButtonMask->height() | 300 | && y < imgButtonMask->height() |
302 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 301 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
303 | 302 | ||
304 | if ( isOnButton && !videoButtons[i].isHeld ) { | 303 | if ( isOnButton && !videoButtons[i].isHeld ) { |
305 | videoButtons[i].isHeld = TRUE; | 304 | videoButtons[i].isHeld = TRUE; |
306 | toggleButton(i); | 305 | toggleButton(i); |
307 | 306 | ||
308 | switch (i) { | 307 | switch (i) { |
309 | case VideoVolUp: | 308 | case VideoVolUp: |
310 | emit moreClicked(); | 309 | emit moreClicked(); |
311 | return; | 310 | return; |
312 | case VideoVolDown: | 311 | case VideoVolDown: |
313 | emit lessClicked(); | 312 | emit lessClicked(); |
314 | return; | 313 | return; |
315 | } | 314 | } |
316 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | 315 | } else if ( !isOnButton && videoButtons[i].isHeld ) { |
317 | videoButtons[i].isHeld = FALSE; | 316 | videoButtons[i].isHeld = FALSE; |
318 | toggleButton(i); | 317 | toggleButton(i); |
319 | } | 318 | } |
320 | } else { | 319 | } else { |
321 | 320 | ||
322 | if ( videoButtons[i].isHeld ) { | 321 | if ( videoButtons[i].isHeld ) { |
323 | videoButtons[i].isHeld = FALSE; | 322 | videoButtons[i].isHeld = FALSE; |
324 | if ( !videoButtons[i].isToggle ) { | 323 | if ( !videoButtons[i].isToggle ) { |
325 | setToggleButton( i, FALSE ); | 324 | setToggleButton( i, FALSE ); |
326 | } | 325 | } |
327 | 326 | ||
328 | switch(i) { | 327 | switch(i) { |
329 | 328 | ||
330 | case VideoPlay: { | 329 | case VideoPlay: { |
331 | if( mediaPlayerState->isPaused() ) { | 330 | if( mediaPlayerState->isPaused() ) { |
332 | setToggleButton( i, FALSE ); | 331 | setToggleButton( i, FALSE ); |
333 | mediaPlayerState->setPaused( FALSE ); | 332 | mediaPlayerState->setPaused( FALSE ); |
334 | return; | 333 | return; |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 89af646..8e9dd7e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -1,125 +1,125 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
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 | #ifndef VIDEO_WIDGET_H | 34 | #ifndef VIDEO_WIDGET_H |
35 | #define VIDEO_WIDGET_H | 35 | #define VIDEO_WIDGET_H |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include "xinevideowidget.h" | 38 | #include "xinevideowidget.h" |
39 | 39 | ||
40 | #include "mediaplayerstate.h" | 40 | #include "mediawidget.h" |
41 | 41 | ||
42 | class QPixmap; | 42 | class QPixmap; |
43 | class QSlider; | 43 | class QSlider; |
44 | 44 | ||
45 | enum VideoButtons { | 45 | enum VideoButtons { |
46 | VideoStop = 0, | 46 | VideoStop = 0, |
47 | VideoPlay, | 47 | VideoPlay, |
48 | // VideoPause, | 48 | // VideoPause, |
49 | VideoPrevious, | 49 | VideoPrevious, |
50 | VideoNext, | 50 | VideoNext, |
51 | VideoVolUp, | 51 | VideoVolUp, |
52 | VideoVolDown, | 52 | VideoVolDown, |
53 | VideoFullscreen | 53 | VideoFullscreen |
54 | }; | 54 | }; |
55 | 55 | ||
56 | class VideoWidget : public QWidget { | 56 | class VideoWidget : public MediaWidget { |
57 | Q_OBJECT | 57 | Q_OBJECT |
58 | public: | 58 | public: |
59 | VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 59 | VideoWidget( QWidget* parent=0, const char* name=0 ); |
60 | ~VideoWidget(); | 60 | ~VideoWidget(); |
61 | 61 | ||
62 | 62 | ||
63 | XineVideoWidget* vidWidget(); | 63 | XineVideoWidget* vidWidget(); |
64 | public slots: | 64 | public slots: |
65 | void updateSlider( long, long ); | 65 | void updateSlider( long, long ); |
66 | void sliderPressed( ); | 66 | void sliderPressed( ); |
67 | void sliderReleased( ); | 67 | void sliderReleased( ); |
68 | void setPlaying( bool b); | 68 | void setPlaying( bool b); |
69 | void setFullscreen( bool b ); | 69 | void setFullscreen( bool b ); |
70 | void makeVisible(); | 70 | void makeVisible(); |
71 | void backToNormal(); | 71 | void backToNormal(); |
72 | void setPosition( long ); | 72 | void setPosition( long ); |
73 | void setLength( long ); | 73 | void setLength( long ); |
74 | void setDisplayType( MediaPlayerState::DisplayType displayType ); | 74 | void setDisplayType( MediaPlayerState::DisplayType displayType ); |
75 | 75 | ||
76 | signals: | 76 | signals: |
77 | void moreClicked(); | 77 | void moreClicked(); |
78 | void lessClicked(); | 78 | void lessClicked(); |
79 | void moreReleased(); | 79 | void moreReleased(); |
80 | void lessReleased(); | 80 | void lessReleased(); |
81 | void sliderMoved( long ); | 81 | void sliderMoved( long ); |
82 | void videoResized ( const QSize &s ); | 82 | void videoResized ( const QSize &s ); |
83 | 83 | ||
84 | protected: | 84 | protected: |
85 | 85 | ||
86 | void resizeEvent( QResizeEvent * ); | 86 | void resizeEvent( QResizeEvent * ); |
87 | void paintEvent( QPaintEvent *pe ); | 87 | void paintEvent( QPaintEvent *pe ); |
88 | void showEvent( QShowEvent *se ); | 88 | void showEvent( QShowEvent *se ); |
89 | void mouseMoveEvent( QMouseEvent *event ); | 89 | void mouseMoveEvent( QMouseEvent *event ); |
90 | void mousePressEvent( QMouseEvent *event ); | 90 | void mousePressEvent( QMouseEvent *event ); |
91 | void mouseReleaseEvent( QMouseEvent *event ); | 91 | void mouseReleaseEvent( QMouseEvent *event ); |
92 | void closeEvent( QCloseEvent *event ); | 92 | void closeEvent( QCloseEvent *event ); |
93 | void keyReleaseEvent( QKeyEvent *e); | 93 | void keyReleaseEvent( QKeyEvent *e); |
94 | 94 | ||
95 | private: | 95 | private: |
96 | // Ticker songInfo; | 96 | // Ticker songInfo; |
97 | QPixmap *pixBg; | 97 | QPixmap *pixBg; |
98 | QImage *imgUp; | 98 | QImage *imgUp; |
99 | QImage *imgDn; | 99 | QImage *imgDn; |
100 | QImage *imgButtonMask; | 100 | QImage *imgButtonMask; |
101 | QBitmap *masks[7]; | 101 | QBitmap *masks[7]; |
102 | QPixmap *buttonPixUp[7]; | 102 | QPixmap *buttonPixUp[7]; |
103 | QPixmap *buttonPixDown[7]; | 103 | QPixmap *buttonPixDown[7]; |
104 | QString skin; | 104 | QString skin; |
105 | // QPixmap *pixmaps[4]; | 105 | // QPixmap *pixmaps[4]; |
106 | int xoff, yoff; | 106 | int xoff, yoff; |
107 | 107 | ||
108 | 108 | ||
109 | void paintButton( QPainter *p, int i ); | 109 | void paintButton( QPainter *p, int i ); |
110 | void toggleButton( int ); | 110 | void toggleButton( int ); |
111 | void setToggleButton( int, bool ); | 111 | void setToggleButton( int, bool ); |
112 | 112 | ||
113 | QString backgroundPix; | 113 | QString backgroundPix; |
114 | QSlider *slider; | 114 | QSlider *slider; |
115 | QPixmap *pixmaps[3]; | 115 | QPixmap *pixmaps[3]; |
116 | QImage *currentFrame; | 116 | QImage *currentFrame; |
117 | int scaledWidth; | 117 | int scaledWidth; |
118 | int scaledHeight; | 118 | int scaledHeight; |
119 | XineVideoWidget* videoFrame; | 119 | XineVideoWidget* videoFrame; |
120 | }; | 120 | }; |
121 | 121 | ||
122 | #endif // VIDEO_WIDGET_H | 122 | #endif // VIDEO_WIDGET_H |
123 | 123 | ||
124 | 124 | ||
125 | 125 | ||