author | simon <simon> | 2002-12-02 19:52:45 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 19:52:45 (UTC) |
commit | 262f335a055e189130a3c0dd7028388ab103504e (patch) (unidiff) | |
tree | 9115845fae96d06ca3235ae1b8153b9739cf3be5 | |
parent | e77f4914311d8a623c084d01a287798440abf01f (diff) | |
download | opie-262f335a055e189130a3c0dd7028388ab103504e.zip opie-262f335a055e189130a3c0dd7028388ab103504e.tar.gz opie-262f335a055e189130a3c0dd7028388ab103504e.tar.bz2 |
- less code duplication
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 8 |
6 files changed, 14 insertions, 11 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 0b7d470..f4edb79 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,545 +1,543 @@ | |||
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) : | 93 | AudioWidget::AudioWidget(QWidget* parent, const char* name) : |
94 | 94 | ||
95 | MediaWidget( parent, name ), 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) ) ); | ||
163 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 162 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
164 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | ||
165 | connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); | 163 | connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); |
166 | 164 | ||
167 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 165 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
168 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 166 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
169 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 167 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
170 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 168 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
171 | 169 | ||
172 | // Intialise state | 170 | // Intialise state |
173 | setLength( mediaPlayerState->length() ); | 171 | setLength( mediaPlayerState->length() ); |
174 | setPosition( mediaPlayerState->position() ); | 172 | setPosition( mediaPlayerState->position() ); |
175 | setLooping( mediaPlayerState->isFullscreen() ); | 173 | setLooping( mediaPlayerState->isFullscreen() ); |
176 | // setPaused( mediaPlayerState->paused() ); | 174 | // setPaused( mediaPlayerState->paused() ); |
177 | setPlaying( mediaPlayerState->isPlaying() ); | 175 | setPlaying( mediaPlayerState->isPlaying() ); |
178 | 176 | ||
179 | } | 177 | } |
180 | 178 | ||
181 | AudioWidget::~AudioWidget() { | 179 | AudioWidget::~AudioWidget() { |
182 | 180 | ||
183 | for ( int i = 0; i < 10; i++ ) { | 181 | for ( int i = 0; i < 10; i++ ) { |
184 | delete buttonPixUp[i]; | 182 | delete buttonPixUp[i]; |
185 | delete buttonPixDown[i]; | 183 | delete buttonPixDown[i]; |
186 | } | 184 | } |
187 | for ( int i = 0; i < 10; i++ ) { | 185 | for ( int i = 0; i < 10; i++ ) { |
188 | delete masks[i]; | 186 | delete masks[i]; |
189 | } | 187 | } |
190 | // mediaPlayerState->setPlaying(false); | 188 | // mediaPlayerState->setPlaying(false); |
191 | } | 189 | } |
192 | 190 | ||
193 | namespace { | 191 | namespace { |
194 | 192 | ||
195 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 193 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
196 | QPixmap pix( img.width(), img.height() ); | 194 | QPixmap pix( img.width(), img.height() ); |
197 | QPainter p( &pix ); | 195 | QPainter p( &pix ); |
198 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 196 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
199 | p.drawImage( 0, 0, img ); | 197 | p.drawImage( 0, 0, img ); |
200 | return pix; | 198 | return pix; |
201 | } | 199 | } |
202 | 200 | ||
203 | 201 | ||
204 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { | 202 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { |
205 | QPixmap *pixmap = new QPixmap( pix ); | 203 | QPixmap *pixmap = new QPixmap( pix ); |
206 | pixmap->setMask( mask ); | 204 | pixmap->setMask( mask ); |
207 | return pixmap; | 205 | return pixmap; |
208 | } | 206 | } |
209 | 207 | ||
210 | }; | 208 | }; |
211 | 209 | ||
212 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 210 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
213 | int h = height(); | 211 | int h = height(); |
214 | int w = width(); | 212 | int w = width(); |
215 | 213 | ||
216 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 214 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
217 | slider.setFixedWidth( w - 110 ); | 215 | slider.setFixedWidth( w - 110 ); |
218 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 216 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
219 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 217 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
220 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 218 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
221 | 219 | ||
222 | xoff = ( w - imgUp.width() ) / 2; | 220 | xoff = ( w - imgUp.width() ) / 2; |
223 | yoff = (( h - imgUp.height() ) / 2) - 10; | 221 | yoff = (( h - imgUp.height() ) / 2) - 10; |
224 | QPoint p( xoff, yoff ); | 222 | QPoint p( xoff, yoff ); |
225 | 223 | ||
226 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); | 224 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); |
227 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); | 225 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); |
228 | 226 | ||
229 | for ( int i = 0; i < 10; i++ ) { | 227 | for ( int i = 0; i < 10; i++ ) { |
230 | if ( !masks[i]->isNull() ) { | 228 | if ( !masks[i]->isNull() ) { |
231 | delete buttonPixUp[i]; | 229 | delete buttonPixUp[i]; |
232 | delete buttonPixDown[i]; | 230 | delete buttonPixDown[i]; |
233 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); | 231 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); |
234 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); | 232 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); |
235 | } | 233 | } |
236 | } | 234 | } |
237 | } | 235 | } |
238 | 236 | ||
239 | static bool audioSliderBeingMoved = FALSE; | 237 | static bool audioSliderBeingMoved = FALSE; |
240 | 238 | ||
241 | 239 | ||
242 | void AudioWidget::sliderPressed() { | 240 | void AudioWidget::sliderPressed() { |
243 | audioSliderBeingMoved = TRUE; | 241 | audioSliderBeingMoved = TRUE; |
244 | } | 242 | } |
245 | 243 | ||
246 | 244 | ||
247 | void AudioWidget::sliderReleased() { | 245 | void AudioWidget::sliderReleased() { |
248 | audioSliderBeingMoved = FALSE; | 246 | audioSliderBeingMoved = FALSE; |
249 | if ( slider.width() == 0 ) | 247 | if ( slider.width() == 0 ) |
250 | return; | 248 | return; |
251 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 249 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
252 | mediaPlayerState->setPosition( val ); | 250 | mediaPlayerState->setPosition( val ); |
253 | } | 251 | } |
254 | 252 | ||
255 | void AudioWidget::setPosition( long i ) { | 253 | void AudioWidget::setPosition( long i ) { |
256 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 254 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
257 | updateSlider( i, mediaPlayerState->length() ); | 255 | updateSlider( i, mediaPlayerState->length() ); |
258 | } | 256 | } |
259 | 257 | ||
260 | 258 | ||
261 | void AudioWidget::setLength( long max ) { | 259 | void AudioWidget::setLength( long max ) { |
262 | updateSlider( mediaPlayerState->position(), max ); | 260 | updateSlider( mediaPlayerState->position(), max ); |
263 | } | 261 | } |
264 | 262 | ||
265 | 263 | ||
266 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 264 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
267 | if ( mediaType == MediaPlayerState::Audio ) { | 265 | if ( mediaType == MediaPlayerState::Audio ) { |
268 | // startTimer( 150 ); | 266 | // startTimer( 150 ); |
269 | showMaximized(); | 267 | showMaximized(); |
270 | return; | 268 | return; |
271 | } | 269 | } |
272 | 270 | ||
273 | killTimers(); | 271 | killTimers(); |
274 | hide(); | 272 | hide(); |
275 | } | 273 | } |
276 | 274 | ||
277 | 275 | ||
278 | void AudioWidget::setSeekable( bool isSeekable ) { | 276 | void AudioWidget::setSeekable( bool isSeekable ) { |
279 | 277 | ||
280 | if ( !isSeekable ) { | 278 | if ( !isSeekable ) { |
281 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 279 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
282 | if( !slider.isHidden()) { | 280 | if( !slider.isHidden()) { |
283 | slider.hide(); | 281 | slider.hide(); |
284 | } | 282 | } |
285 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 283 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
286 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 284 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
287 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 285 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
288 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 286 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
289 | } else { | 287 | } else { |
290 | // this stops the slider from being moved, thus | 288 | // this stops the slider from being moved, thus |
291 | // does not stop stream when it reaches the end | 289 | // does not stop stream when it reaches the end |
292 | slider.show(); | 290 | slider.show(); |
293 | qDebug( " CONNECT SET POSTION " ); | 291 | qDebug( " CONNECT SET POSTION " ); |
294 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 292 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
295 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 293 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
296 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 294 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
297 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 295 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
298 | } | 296 | } |
299 | } | 297 | } |
300 | 298 | ||
301 | 299 | ||
302 | static QString timeAsString( long length ) { | 300 | static QString timeAsString( long length ) { |
303 | int minutes = length / 60; | 301 | int minutes = length / 60; |
304 | int seconds = length % 60; | 302 | int seconds = length % 60; |
305 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 303 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
306 | } | 304 | } |
307 | 305 | ||
308 | void AudioWidget::updateSlider( long i, long max ) { | 306 | void AudioWidget::updateSlider( long i, long max ) { |
309 | 307 | ||
310 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 308 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
311 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 309 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
312 | 310 | ||
313 | if ( max == 0 ) { | 311 | if ( max == 0 ) { |
314 | return; | 312 | return; |
315 | } | 313 | } |
316 | // Will flicker too much if we don't do this | 314 | // Will flicker too much if we don't do this |
317 | // Scale to something reasonable | 315 | // Scale to something reasonable |
318 | int width = slider.width(); | 316 | int width = slider.width(); |
319 | int val = int((double)i * width / max); | 317 | int val = int((double)i * width / max); |
320 | if ( !audioSliderBeingMoved ) { | 318 | if ( !audioSliderBeingMoved ) { |
321 | if ( slider.value() != val ) { | 319 | if ( slider.value() != val ) { |
322 | slider.setValue( val ); | 320 | slider.setValue( val ); |
323 | } | 321 | } |
324 | 322 | ||
325 | if ( slider.maxValue() != width ) { | 323 | if ( slider.maxValue() != width ) { |
326 | slider.setMaxValue( width ); | 324 | slider.setMaxValue( width ); |
327 | } | 325 | } |
328 | } | 326 | } |
329 | } | 327 | } |
330 | 328 | ||
331 | 329 | ||
332 | void AudioWidget::setToggleButton( int i, bool down ) { | 330 | void AudioWidget::setToggleButton( int i, bool down ) { |
333 | qDebug("setToggleButton %d", i); | 331 | qDebug("setToggleButton %d", i); |
334 | if ( down != audioButtons[i].isDown ) { | 332 | if ( down != audioButtons[i].isDown ) { |
335 | toggleButton( i ); | 333 | toggleButton( i ); |
336 | } | 334 | } |
337 | } | 335 | } |
338 | 336 | ||
339 | 337 | ||
340 | void AudioWidget::toggleButton( int i ) { | 338 | void AudioWidget::toggleButton( int i ) { |
341 | audioButtons[i].isDown = !audioButtons[i].isDown; | 339 | audioButtons[i].isDown = !audioButtons[i].isDown; |
342 | QPainter p(this); | 340 | QPainter p(this); |
343 | paintButton ( &p, i ); | 341 | paintButton ( &p, i ); |
344 | } | 342 | } |
345 | 343 | ||
346 | 344 | ||
347 | void AudioWidget::paintButton( QPainter *p, int i ) { | 345 | void AudioWidget::paintButton( QPainter *p, int i ) { |
348 | if ( audioButtons[i].isDown ) { | 346 | if ( audioButtons[i].isDown ) { |
349 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 347 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
350 | } else { | 348 | } else { |
351 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 349 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
352 | } | 350 | } |
353 | } | 351 | } |
354 | 352 | ||
355 | 353 | ||
356 | void AudioWidget::skipFor() { | 354 | void AudioWidget::skipFor() { |
357 | skipDirection = +1; | 355 | skipDirection = +1; |
358 | startTimer( 50 ); | 356 | startTimer( 50 ); |
359 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 357 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
360 | } | 358 | } |
361 | 359 | ||
362 | void AudioWidget::skipBack() { | 360 | void AudioWidget::skipBack() { |
363 | skipDirection = -1; | 361 | skipDirection = -1; |
364 | startTimer( 50 ); | 362 | startTimer( 50 ); |
365 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 363 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
366 | } | 364 | } |
367 | 365 | ||
368 | 366 | ||
369 | 367 | ||
370 | void AudioWidget::stopSkip() { | 368 | void AudioWidget::stopSkip() { |
371 | killTimers(); | 369 | killTimers(); |
372 | } | 370 | } |
373 | 371 | ||
374 | 372 | ||
375 | void AudioWidget::timerEvent( QTimerEvent * ) { | 373 | void AudioWidget::timerEvent( QTimerEvent * ) { |
376 | if ( skipDirection == +1 ) { | 374 | if ( skipDirection == +1 ) { |
377 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 375 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
378 | } else if ( skipDirection == -1 ) { | 376 | } else if ( skipDirection == -1 ) { |
379 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 377 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
380 | } | 378 | } |
381 | } | 379 | } |
382 | 380 | ||
383 | 381 | ||
384 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 382 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
385 | for ( int i = 0; i < numButtons; i++ ) { | 383 | for ( int i = 0; i < numButtons; i++ ) { |
386 | if ( event->state() == QMouseEvent::LeftButton ) { | 384 | if ( event->state() == QMouseEvent::LeftButton ) { |
387 | // The test to see if the mouse click is inside the button or not | 385 | // The test to see if the mouse click is inside the button or not |
388 | int x = event->pos().x() - xoff; | 386 | int x = event->pos().x() - xoff; |
389 | int y = event->pos().y() - yoff; | 387 | int y = event->pos().y() - yoff; |
390 | 388 | ||
391 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() | 389 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() |
392 | && y < imgButtonMask.height() | 390 | && y < imgButtonMask.height() |
393 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); | 391 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); |
394 | 392 | ||
395 | if ( isOnButton && !audioButtons[i].isHeld ) { | 393 | if ( isOnButton && !audioButtons[i].isHeld ) { |
396 | audioButtons[i].isHeld = TRUE; | 394 | audioButtons[i].isHeld = TRUE; |
397 | toggleButton(i); | 395 | toggleButton(i); |
398 | switch (i) { | 396 | switch (i) { |
399 | case AudioVolumeUp: | 397 | case AudioVolumeUp: |
400 | emit moreClicked(); | 398 | emit moreClicked(); |
401 | return; | 399 | return; |
402 | case AudioVolumeDown: | 400 | case AudioVolumeDown: |
403 | emit lessClicked(); | 401 | emit lessClicked(); |
404 | return; | 402 | return; |
405 | case AudioForward: | 403 | case AudioForward: |
406 | emit forwardClicked(); | 404 | emit forwardClicked(); |
407 | return; | 405 | return; |
408 | case AudioBack: | 406 | case AudioBack: |
409 | emit backClicked(); | 407 | emit backClicked(); |
410 | return; | 408 | return; |
411 | } | 409 | } |
412 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 410 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
413 | audioButtons[i].isHeld = FALSE; | 411 | audioButtons[i].isHeld = FALSE; |
414 | toggleButton(i); | 412 | toggleButton(i); |
415 | } | 413 | } |
416 | } else { | 414 | } else { |
417 | if ( audioButtons[i].isHeld ) { | 415 | if ( audioButtons[i].isHeld ) { |
418 | audioButtons[i].isHeld = FALSE; | 416 | audioButtons[i].isHeld = FALSE; |
419 | if ( !audioButtons[i].isToggle ) { | 417 | if ( !audioButtons[i].isToggle ) { |
420 | setToggleButton( i, FALSE ); | 418 | setToggleButton( i, FALSE ); |
421 | } | 419 | } |
422 | qDebug("mouseEvent %d", i); | 420 | qDebug("mouseEvent %d", i); |
423 | switch (i) { | 421 | switch (i) { |
424 | case AudioPlay: | 422 | case AudioPlay: |
425 | if( mediaPlayerState->isPaused() ) { | 423 | if( mediaPlayerState->isPaused() ) { |
426 | mediaPlayerState->setPaused( FALSE ); | 424 | mediaPlayerState->setPaused( FALSE ); |
427 | return; | 425 | return; |
428 | } else if( !mediaPlayerState->isPaused() ) { | 426 | } else if( !mediaPlayerState->isPaused() ) { |
429 | mediaPlayerState->setPaused( TRUE ); | 427 | mediaPlayerState->setPaused( TRUE ); |
430 | return; | 428 | return; |
431 | } | 429 | } |
432 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 430 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
433 | case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return; | 431 | case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return; |
434 | case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return; | 432 | case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return; |
435 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 433 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
436 | case AudioVolumeUp: emit moreReleased(); return; | 434 | case AudioVolumeUp: emit moreReleased(); return; |
437 | case AudioVolumeDown: emit lessReleased(); return; | 435 | case AudioVolumeDown: emit lessReleased(); return; |
438 | case AudioPlayList: mediaPlayerState->setList(); return; | 436 | case AudioPlayList: mediaPlayerState->setList(); return; |
439 | case AudioForward: emit forwardReleased(); return; | 437 | case AudioForward: emit forwardReleased(); return; |
440 | case AudioBack: emit backReleased(); return; | 438 | case AudioBack: emit backReleased(); return; |
441 | } | 439 | } |
442 | } | 440 | } |
443 | } | 441 | } |
444 | } | 442 | } |
445 | } | 443 | } |
446 | 444 | ||
447 | 445 | ||
448 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 446 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
449 | mouseMoveEvent( event ); | 447 | mouseMoveEvent( event ); |
450 | } | 448 | } |
451 | 449 | ||
452 | 450 | ||
453 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 451 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
454 | mouseMoveEvent( event ); | 452 | mouseMoveEvent( event ); |
455 | } | 453 | } |
456 | 454 | ||
457 | 455 | ||
458 | void AudioWidget::showEvent( QShowEvent* ) { | 456 | void AudioWidget::showEvent( QShowEvent* ) { |
459 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 457 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
460 | mouseMoveEvent( &event ); | 458 | mouseMoveEvent( &event ); |
461 | } | 459 | } |
462 | 460 | ||
463 | 461 | ||
464 | void AudioWidget::closeEvent( QCloseEvent* ) { | 462 | void AudioWidget::closeEvent( QCloseEvent* ) { |
465 | mediaPlayerState->setList(); | 463 | mediaPlayerState->setList(); |
466 | } | 464 | } |
467 | 465 | ||
468 | 466 | ||
469 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | 467 | void AudioWidget::paintEvent( QPaintEvent * pe ) { |
470 | if ( !pe->erased() ) { | 468 | if ( !pe->erased() ) { |
471 | // Combine with background and double buffer | 469 | // Combine with background and double buffer |
472 | QPixmap pix( pe->rect().size() ); | 470 | QPixmap pix( pe->rect().size() ); |
473 | QPainter p( &pix ); | 471 | QPainter p( &pix ); |
474 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 472 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
475 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); | 473 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); |
476 | for ( int i = 0; i < numButtons; i++ ) | 474 | for ( int i = 0; i < numButtons; i++ ) |
477 | paintButton( &p, i ); | 475 | paintButton( &p, i ); |
478 | QPainter p2( this ); | 476 | QPainter p2( this ); |
479 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 477 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
480 | } else { | 478 | } else { |
481 | QPainter p( this ); | 479 | QPainter p( this ); |
482 | for ( int i = 0; i < numButtons; i++ ) | 480 | for ( int i = 0; i < numButtons; i++ ) |
483 | paintButton( &p, i ); | 481 | paintButton( &p, i ); |
484 | } | 482 | } |
485 | } | 483 | } |
486 | 484 | ||
487 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 485 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
488 | switch ( e->key() ) { | 486 | switch ( e->key() ) { |
489 | ////////////////////////////// Zaurus keys | 487 | ////////////////////////////// Zaurus keys |
490 | case Key_Home: | 488 | case Key_Home: |
491 | break; | 489 | break; |
492 | case Key_F9: //activity | 490 | case Key_F9: //activity |
493 | hide(); | 491 | hide(); |
494 | // qDebug("Audio F9"); | 492 | // qDebug("Audio F9"); |
495 | break; | 493 | break; |
496 | case Key_F10: //contacts | 494 | case Key_F10: //contacts |
497 | break; | 495 | break; |
498 | case Key_F11: //menu | 496 | case Key_F11: //menu |
499 | mediaPlayerState->toggleBlank(); | 497 | mediaPlayerState->toggleBlank(); |
500 | break; | 498 | break; |
501 | case Key_F12: //home | 499 | case Key_F12: //home |
502 | break; | 500 | break; |
503 | case Key_F13: //mail | 501 | case Key_F13: //mail |
504 | mediaPlayerState->toggleBlank(); | 502 | mediaPlayerState->toggleBlank(); |
505 | break; | 503 | break; |
506 | case Key_Space: { | 504 | case Key_Space: { |
507 | if(mediaPlayerState->isPlaying()) { | 505 | if(mediaPlayerState->isPlaying()) { |
508 | // toggleButton(1); | 506 | // toggleButton(1); |
509 | mediaPlayerState->setPlaying(FALSE); | 507 | mediaPlayerState->setPlaying(FALSE); |
510 | // toggleButton(1); | 508 | // toggleButton(1); |
511 | } else { | 509 | } else { |
512 | // toggleButton(0); | 510 | // toggleButton(0); |
513 | mediaPlayerState->setPlaying(TRUE); | 511 | mediaPlayerState->setPlaying(TRUE); |
514 | // toggleButton(0); | 512 | // toggleButton(0); |
515 | } | 513 | } |
516 | } | 514 | } |
517 | break; | 515 | break; |
518 | case Key_Down: | 516 | case Key_Down: |
519 | // toggleButton(6); | 517 | // toggleButton(6); |
520 | emit lessClicked(); | 518 | emit lessClicked(); |
521 | emit lessReleased(); | 519 | emit lessReleased(); |
522 | // toggleButton(6); | 520 | // toggleButton(6); |
523 | break; | 521 | break; |
524 | case Key_Up: | 522 | case Key_Up: |
525 | // toggleButton(5); | 523 | // toggleButton(5); |
526 | emit moreClicked(); | 524 | emit moreClicked(); |
527 | emit moreReleased(); | 525 | emit moreReleased(); |
528 | // toggleButton(5); | 526 | // toggleButton(5); |
529 | break; | 527 | break; |
530 | case Key_Right: | 528 | case Key_Right: |
531 | // toggleButton(3); | 529 | // toggleButton(3); |
532 | mediaPlayerState->setNext(); | 530 | mediaPlayerState->setNext(); |
533 | // toggleButton(3); | 531 | // toggleButton(3); |
534 | break; | 532 | break; |
535 | case Key_Left: | 533 | case Key_Left: |
536 | // toggleButton(4); | 534 | // toggleButton(4); |
537 | mediaPlayerState->setPrev(); | 535 | mediaPlayerState->setPrev(); |
538 | // toggleButton(4); | 536 | // toggleButton(4); |
539 | break; | 537 | break; |
540 | case Key_Escape: { | 538 | case Key_Escape: { |
541 | } | 539 | } |
542 | break; | 540 | break; |
543 | 541 | ||
544 | }; | 542 | }; |
545 | } | 543 | } |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 74c5b0e..83927f1 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -1,138 +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 <qpainter.h> | 37 | #include <qpainter.h> |
38 | #include <qdrawutil.h> | 38 | #include <qdrawutil.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include <qstring.h> | 40 | #include <qstring.h> |
41 | #include <qslider.h> | 41 | #include <qslider.h> |
42 | #include <qframe.h> | 42 | #include <qframe.h> |
43 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
44 | #include <qimage.h> | 44 | #include <qimage.h> |
45 | 45 | ||
46 | #include <opie/oticker.h> | 46 | #include <opie/oticker.h> |
47 | 47 | ||
48 | #include "mediawidget.h" | 48 | #include "mediawidget.h" |
49 | 49 | ||
50 | class QPixmap; | 50 | class QPixmap; |
51 | 51 | ||
52 | namespace { | 52 | namespace { |
53 | 53 | ||
54 | enum AudioButtons { | 54 | enum AudioButtons { |
55 | AudioPlay=0, | 55 | AudioPlay=0, |
56 | AudioStop, | 56 | AudioStop, |
57 | AudioNext, | 57 | AudioNext, |
58 | AudioPrevious, | 58 | AudioPrevious, |
59 | AudioVolumeUp, | 59 | AudioVolumeUp, |
60 | AudioVolumeDown, | 60 | AudioVolumeDown, |
61 | AudioLoop, | 61 | AudioLoop, |
62 | AudioPlayList, | 62 | AudioPlayList, |
63 | AudioForward, | 63 | AudioForward, |
64 | AudioBack | 64 | AudioBack |
65 | }; | 65 | }; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | class AudioWidget : public MediaWidget { | 68 | class AudioWidget : public MediaWidget { |
69 | Q_OBJECT | 69 | Q_OBJECT |
70 | public: | 70 | public: |
71 | AudioWidget( QWidget* parent=0, const char* name=0 ); | 71 | AudioWidget( QWidget* parent=0, const char* name=0 ); |
72 | ~AudioWidget(); | 72 | ~AudioWidget(); |
73 | void setTickerText( const QString &text ) { songInfo.setText( text ); } | 73 | void setTickerText( const QString &text ) { songInfo.setText( text ); } |
74 | public slots: | 74 | public slots: |
75 | void updateSlider( long, long ); | 75 | void updateSlider( long, long ); |
76 | void sliderPressed( ); | 76 | void sliderPressed( ); |
77 | void sliderReleased( ); | 77 | void sliderReleased( ); |
78 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } | 78 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } |
79 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } | ||
80 | void setPosition( long ); | 79 | void setPosition( long ); |
81 | void setLength( long ); | ||
82 | void setSeekable( bool ); | 80 | void setSeekable( bool ); |
83 | 81 | ||
84 | public: | 82 | public: |
85 | void setDisplayType( MediaPlayerState::DisplayType displayType ); | 83 | virtual void setLength( long ); |
84 | virtual void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } | ||
85 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | ||
86 | 86 | ||
87 | signals: | 87 | signals: |
88 | void moreClicked(); | 88 | void moreClicked(); |
89 | void lessClicked(); | 89 | void lessClicked(); |
90 | void moreReleased(); | 90 | void moreReleased(); |
91 | void lessReleased(); | 91 | void lessReleased(); |
92 | void forwardClicked(); | 92 | void forwardClicked(); |
93 | void backClicked(); | 93 | void backClicked(); |
94 | void forwardReleased(); | 94 | void forwardReleased(); |
95 | void backReleased(); | 95 | void backReleased(); |
96 | void sliderMoved(long); | 96 | void sliderMoved(long); |
97 | 97 | ||
98 | protected: | 98 | protected: |
99 | void doBlank(); | 99 | void doBlank(); |
100 | void doUnblank(); | 100 | void doUnblank(); |
101 | void paintEvent( QPaintEvent *pe ); | 101 | void paintEvent( QPaintEvent *pe ); |
102 | void showEvent( QShowEvent *se ); | 102 | void showEvent( QShowEvent *se ); |
103 | void resizeEvent( QResizeEvent *re ); | 103 | void resizeEvent( QResizeEvent *re ); |
104 | void mouseMoveEvent( QMouseEvent *event ); | 104 | void mouseMoveEvent( QMouseEvent *event ); |
105 | void mousePressEvent( QMouseEvent *event ); | 105 | void mousePressEvent( QMouseEvent *event ); |
106 | void mouseReleaseEvent( QMouseEvent *event ); | 106 | void mouseReleaseEvent( QMouseEvent *event ); |
107 | void timerEvent( QTimerEvent *event ); | 107 | void timerEvent( QTimerEvent *event ); |
108 | void closeEvent( QCloseEvent *event ); | 108 | void closeEvent( QCloseEvent *event ); |
109 | void keyReleaseEvent( QKeyEvent *e); | 109 | void keyReleaseEvent( QKeyEvent *e); |
110 | private slots: | 110 | private slots: |
111 | void skipFor(); | 111 | void skipFor(); |
112 | void skipBack(); | 112 | void skipBack(); |
113 | void stopSkip(); | 113 | void stopSkip(); |
114 | private: | 114 | private: |
115 | void toggleButton( int ); | 115 | void toggleButton( int ); |
116 | void setToggleButton( int, bool ); | 116 | void setToggleButton( int, bool ); |
117 | void paintButton( QPainter *p, int i ); | 117 | void paintButton( QPainter *p, int i ); |
118 | int skipDirection; | 118 | int skipDirection; |
119 | QString skin; | 119 | QString skin; |
120 | QPixmap pixBg; | 120 | QPixmap pixBg; |
121 | QImage imgUp; | 121 | QImage imgUp; |
122 | QImage imgDn; | 122 | QImage imgDn; |
123 | QImage imgButtonMask; | 123 | QImage imgButtonMask; |
124 | QBitmap *masks[10]; | 124 | QBitmap *masks[10]; |
125 | QPixmap *buttonPixUp[10]; | 125 | QPixmap *buttonPixUp[10]; |
126 | QPixmap *buttonPixDown[10]; | 126 | QPixmap *buttonPixDown[10]; |
127 | 127 | ||
128 | QPixmap *pixmaps[4]; | 128 | QPixmap *pixmaps[4]; |
129 | OTicker songInfo; | 129 | OTicker songInfo; |
130 | QSlider slider; | 130 | QSlider slider; |
131 | QLineEdit time; | 131 | QLineEdit time; |
132 | int xoff, yoff; | 132 | int xoff, yoff; |
133 | bool isStreaming : 1; | 133 | bool isStreaming : 1; |
134 | }; | 134 | }; |
135 | 135 | ||
136 | 136 | ||
137 | #endif // AUDIO_WIDGET_H | 137 | #endif // AUDIO_WIDGET_H |
138 | 138 | ||
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 9d1d7fc..83456a0 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -1,37 +1,41 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | 20 | ||
21 | #include "mediawidget.h" | 21 | #include "mediawidget.h" |
22 | 22 | ||
23 | extern MediaPlayerState *mediaPlayerState; | 23 | extern MediaPlayerState *mediaPlayerState; |
24 | 24 | ||
25 | MediaWidget::MediaWidget( QWidget *parent, const char *name ) | 25 | MediaWidget::MediaWidget( QWidget *parent, const char *name ) |
26 | : QWidget( parent, name ) | 26 | : QWidget( parent, name ) |
27 | { | 27 | { |
28 | connect( mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), | 28 | connect( mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), |
29 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); | 29 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); |
30 | connect( mediaPlayerState, SIGNAL( lengthChanged( long ) ), | ||
31 | this, SLOT( setLength( long ) ) ); | ||
32 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), | ||
33 | this, SLOT( setPlaying( bool ) ) ); | ||
30 | } | 34 | } |
31 | 35 | ||
32 | MediaWidget::~MediaWidget() | 36 | MediaWidget::~MediaWidget() |
33 | { | 37 | { |
34 | } | 38 | } |
35 | 39 | ||
36 | /* vim: et sw=4 ts=4 | 40 | /* vim: et sw=4 ts=4 |
37 | */ | 41 | */ |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index cbd08e2..fc5198e 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -1,40 +1,42 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #ifndef MEDIAWIDGET_H | 20 | #ifndef MEDIAWIDGET_H |
21 | #define MEDIAWIDGET_H | 21 | #define MEDIAWIDGET_H |
22 | 22 | ||
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | 24 | ||
25 | #include "mediaplayerstate.h" | 25 | #include "mediaplayerstate.h" |
26 | 26 | ||
27 | class MediaWidget : public QWidget | 27 | class MediaWidget : public QWidget |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | MediaWidget( QWidget *parent = 0, const char *name = 0 ); | 31 | MediaWidget( QWidget *parent = 0, const char *name = 0 ); |
32 | virtual ~MediaWidget(); | 32 | virtual ~MediaWidget(); |
33 | 33 | ||
34 | public slots: | 34 | public slots: |
35 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; | 35 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; |
36 | virtual void setLength( long length ) = 0; | ||
37 | virtual void setPlaying( bool playing ) = 0; | ||
36 | }; | 38 | }; |
37 | 39 | ||
38 | #endif // MEDIAWIDGET_H | 40 | #endif // MEDIAWIDGET_H |
39 | /* vim: et sw=4 ts=4 | 41 | /* vim: et sw=4 ts=4 |
40 | */ | 42 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 8a0016e..888fcf4 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,521 +1,518 @@ | |||
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) : | 86 | VideoWidget::VideoWidget(QWidget* parent, const char* name) : |
87 | MediaWidget( parent, name ), 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) ) ); | ||
142 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | ||
143 | |||
144 | setLength( mediaPlayerState->length() ); | 141 | setLength( mediaPlayerState->length() ); |
145 | setPosition( mediaPlayerState->position() ); | 142 | setPosition( mediaPlayerState->position() ); |
146 | setFullscreen( mediaPlayerState->isFullscreen() ); | 143 | setFullscreen( mediaPlayerState->isFullscreen() ); |
147 | setPlaying( mediaPlayerState->isPlaying() ); | 144 | setPlaying( mediaPlayerState->isPlaying() ); |
148 | } | 145 | } |
149 | 146 | ||
150 | 147 | ||
151 | VideoWidget::~VideoWidget() { | 148 | VideoWidget::~VideoWidget() { |
152 | 149 | ||
153 | for ( int i = 0; i < 7; i++ ) { | 150 | for ( int i = 0; i < 7; i++ ) { |
154 | delete buttonPixUp[i]; | 151 | delete buttonPixUp[i]; |
155 | delete buttonPixDown[i]; | 152 | delete buttonPixDown[i]; |
156 | } | 153 | } |
157 | 154 | ||
158 | delete pixBg; | 155 | delete pixBg; |
159 | delete imgUp; | 156 | delete imgUp; |
160 | delete imgDn; | 157 | delete imgDn; |
161 | delete imgButtonMask; | 158 | delete imgButtonMask; |
162 | for ( int i = 0; i < 7; i++ ) { | 159 | for ( int i = 0; i < 7; i++ ) { |
163 | delete masks[i]; | 160 | delete masks[i]; |
164 | } | 161 | } |
165 | 162 | ||
166 | } | 163 | } |
167 | 164 | ||
168 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 165 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
169 | QPixmap pix( img.width(), img.height() ); | 166 | QPixmap pix( img.width(), img.height() ); |
170 | QPainter p( &pix ); | 167 | QPainter p( &pix ); |
171 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 168 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
172 | p.drawImage( 0, 0, img ); | 169 | p.drawImage( 0, 0, img ); |
173 | return new QPixmap( pix ); | 170 | return new QPixmap( pix ); |
174 | } | 171 | } |
175 | 172 | ||
176 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 173 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
177 | QPixmap *pixmap = new QPixmap( pix ); | 174 | QPixmap *pixmap = new QPixmap( pix ); |
178 | pixmap->setMask( mask ); | 175 | pixmap->setMask( mask ); |
179 | return pixmap; | 176 | return pixmap; |
180 | } | 177 | } |
181 | 178 | ||
182 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 179 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
183 | int h = height(); | 180 | int h = height(); |
184 | int w = width(); | 181 | int w = width(); |
185 | //int Vh = 160; | 182 | //int Vh = 160; |
186 | //int Vw = 220; | 183 | //int Vw = 220; |
187 | 184 | ||
188 | slider->setFixedWidth( w - 20 ); | 185 | slider->setFixedWidth( w - 20 ); |
189 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 186 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
190 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 187 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
191 | slider->setFocusPolicy( QWidget::NoFocus ); | 188 | slider->setFocusPolicy( QWidget::NoFocus ); |
192 | slider->setBackgroundPixmap( *pixBg ); | 189 | slider->setBackgroundPixmap( *pixBg ); |
193 | 190 | ||
194 | xoff = 0;// ( imgUp->width() ) / 2; | 191 | xoff = 0;// ( imgUp->width() ) / 2; |
195 | if(w>h) | 192 | if(w>h) |
196 | yoff = 0; | 193 | yoff = 0; |
197 | else | 194 | else |
198 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 195 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
199 | QPoint p( xoff, yoff ); | 196 | QPoint p( xoff, yoff ); |
200 | 197 | ||
201 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 198 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
202 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 199 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
203 | 200 | ||
204 | for ( int i = 0; i < 7; i++ ) { | 201 | for ( int i = 0; i < 7; i++ ) { |
205 | if ( !masks[i]->isNull() ) { | 202 | if ( !masks[i]->isNull() ) { |
206 | delete buttonPixUp[i]; | 203 | delete buttonPixUp[i]; |
207 | delete buttonPixDown[i]; | 204 | delete buttonPixDown[i]; |
208 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 205 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
209 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 206 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
210 | } | 207 | } |
211 | } | 208 | } |
212 | 209 | ||
213 | delete pixUp; | 210 | delete pixUp; |
214 | delete pixDn; | 211 | delete pixDn; |
215 | } | 212 | } |
216 | 213 | ||
217 | static bool videoSliderBeingMoved = FALSE; | 214 | static bool videoSliderBeingMoved = FALSE; |
218 | 215 | ||
219 | void VideoWidget::sliderPressed() { | 216 | void VideoWidget::sliderPressed() { |
220 | videoSliderBeingMoved = TRUE; | 217 | videoSliderBeingMoved = TRUE; |
221 | } | 218 | } |
222 | 219 | ||
223 | void VideoWidget::sliderReleased() { | 220 | void VideoWidget::sliderReleased() { |
224 | videoSliderBeingMoved = FALSE; | 221 | videoSliderBeingMoved = FALSE; |
225 | if ( slider->width() == 0 ) { | 222 | if ( slider->width() == 0 ) { |
226 | return; | 223 | return; |
227 | } | 224 | } |
228 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 225 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
229 | mediaPlayerState->setPosition( val ); | 226 | mediaPlayerState->setPosition( val ); |
230 | } | 227 | } |
231 | 228 | ||
232 | void VideoWidget::setPosition( long i ) { | 229 | void VideoWidget::setPosition( long i ) { |
233 | updateSlider( i, mediaPlayerState->length() ); | 230 | updateSlider( i, mediaPlayerState->length() ); |
234 | } | 231 | } |
235 | 232 | ||
236 | 233 | ||
237 | void VideoWidget::setLength( long max ) { | 234 | void VideoWidget::setLength( long max ) { |
238 | updateSlider( mediaPlayerState->position(), max ); | 235 | updateSlider( mediaPlayerState->position(), max ); |
239 | } | 236 | } |
240 | 237 | ||
241 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 238 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
242 | { | 239 | { |
243 | if ( displayType == MediaPlayerState::Video ) { | 240 | if ( displayType == MediaPlayerState::Video ) { |
244 | makeVisible(); | 241 | makeVisible(); |
245 | return; | 242 | return; |
246 | } | 243 | } |
247 | 244 | ||
248 | // Effectively blank the view next time we show it so it looks nicer | 245 | // Effectively blank the view next time we show it so it looks nicer |
249 | scaledWidth = 0; | 246 | scaledWidth = 0; |
250 | scaledHeight = 0; | 247 | scaledHeight = 0; |
251 | hide(); | 248 | hide(); |
252 | } | 249 | } |
253 | 250 | ||
254 | void VideoWidget::updateSlider( long i, long max ) { | 251 | void VideoWidget::updateSlider( long i, long max ) { |
255 | // Will flicker too much if we don't do this | 252 | // Will flicker too much if we don't do this |
256 | if ( max == 0 ) { | 253 | if ( max == 0 ) { |
257 | return; | 254 | return; |
258 | } | 255 | } |
259 | int width = slider->width(); | 256 | int width = slider->width(); |
260 | int val = int((double)i * width / max); | 257 | int val = int((double)i * width / max); |
261 | if ( !mediaPlayerState->isFullscreen() && !videoSliderBeingMoved ) { | 258 | if ( !mediaPlayerState->isFullscreen() && !videoSliderBeingMoved ) { |
262 | if ( slider->value() != val ) { | 259 | if ( slider->value() != val ) { |
263 | slider->setValue( val ); | 260 | slider->setValue( val ); |
264 | } | 261 | } |
265 | if ( slider->maxValue() != width ) { | 262 | if ( slider->maxValue() != width ) { |
266 | slider->setMaxValue( width ); | 263 | slider->setMaxValue( width ); |
267 | } | 264 | } |
268 | } | 265 | } |
269 | } | 266 | } |
270 | 267 | ||
271 | void VideoWidget::setToggleButton( int i, bool down ) { | 268 | void VideoWidget::setToggleButton( int i, bool down ) { |
272 | if ( down != videoButtons[i].isDown ) { | 269 | if ( down != videoButtons[i].isDown ) { |
273 | toggleButton( i ); | 270 | toggleButton( i ); |
274 | } | 271 | } |
275 | } | 272 | } |
276 | 273 | ||
277 | void VideoWidget::toggleButton( int i ) { | 274 | void VideoWidget::toggleButton( int i ) { |
278 | videoButtons[i].isDown = !videoButtons[i].isDown; | 275 | videoButtons[i].isDown = !videoButtons[i].isDown; |
279 | QPainter p(this); | 276 | QPainter p(this); |
280 | paintButton ( &p, i ); | 277 | paintButton ( &p, i ); |
281 | } | 278 | } |
282 | 279 | ||
283 | void VideoWidget::paintButton( QPainter *p, int i ) { | 280 | void VideoWidget::paintButton( QPainter *p, int i ) { |
284 | 281 | ||
285 | if ( videoButtons[i].isDown ) { | 282 | if ( videoButtons[i].isDown ) { |
286 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 283 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
287 | } else { | 284 | } else { |
288 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 285 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
289 | } | 286 | } |
290 | } | 287 | } |
291 | 288 | ||
292 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 289 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
293 | for ( int i = 0; i < numVButtons; i++ ) { | 290 | for ( int i = 0; i < numVButtons; i++ ) { |
294 | if ( event->state() == QMouseEvent::LeftButton ) { | 291 | if ( event->state() == QMouseEvent::LeftButton ) { |
295 | // The test to see if the mouse click is inside the button or not | 292 | // The test to see if the mouse click is inside the button or not |
296 | int x = event->pos().x() - xoff; | 293 | int x = event->pos().x() - xoff; |
297 | int y = event->pos().y() - yoff; | 294 | int y = event->pos().y() - yoff; |
298 | 295 | ||
299 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 296 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
300 | && y < imgButtonMask->height() | 297 | && y < imgButtonMask->height() |
301 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 298 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
302 | 299 | ||
303 | if ( isOnButton && !videoButtons[i].isHeld ) { | 300 | if ( isOnButton && !videoButtons[i].isHeld ) { |
304 | videoButtons[i].isHeld = TRUE; | 301 | videoButtons[i].isHeld = TRUE; |
305 | toggleButton(i); | 302 | toggleButton(i); |
306 | 303 | ||
307 | switch (i) { | 304 | switch (i) { |
308 | case VideoVolUp: | 305 | case VideoVolUp: |
309 | emit moreClicked(); | 306 | emit moreClicked(); |
310 | return; | 307 | return; |
311 | case VideoVolDown: | 308 | case VideoVolDown: |
312 | emit lessClicked(); | 309 | emit lessClicked(); |
313 | return; | 310 | return; |
314 | } | 311 | } |
315 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | 312 | } else if ( !isOnButton && videoButtons[i].isHeld ) { |
316 | videoButtons[i].isHeld = FALSE; | 313 | videoButtons[i].isHeld = FALSE; |
317 | toggleButton(i); | 314 | toggleButton(i); |
318 | } | 315 | } |
319 | } else { | 316 | } else { |
320 | 317 | ||
321 | if ( videoButtons[i].isHeld ) { | 318 | if ( videoButtons[i].isHeld ) { |
322 | videoButtons[i].isHeld = FALSE; | 319 | videoButtons[i].isHeld = FALSE; |
323 | if ( !videoButtons[i].isToggle ) { | 320 | if ( !videoButtons[i].isToggle ) { |
324 | setToggleButton( i, FALSE ); | 321 | setToggleButton( i, FALSE ); |
325 | } | 322 | } |
326 | 323 | ||
327 | switch(i) { | 324 | switch(i) { |
328 | 325 | ||
329 | case VideoPlay: { | 326 | case VideoPlay: { |
330 | if( mediaPlayerState->isPaused() ) { | 327 | if( mediaPlayerState->isPaused() ) { |
331 | setToggleButton( i, FALSE ); | 328 | setToggleButton( i, FALSE ); |
332 | mediaPlayerState->setPaused( FALSE ); | 329 | mediaPlayerState->setPaused( FALSE ); |
333 | return; | 330 | return; |
334 | } else if( !mediaPlayerState->isPaused() ) { | 331 | } else if( !mediaPlayerState->isPaused() ) { |
335 | setToggleButton( i, TRUE ); | 332 | setToggleButton( i, TRUE ); |
336 | mediaPlayerState->setPaused( TRUE ); | 333 | mediaPlayerState->setPaused( TRUE ); |
337 | return; | 334 | return; |
338 | } else { | 335 | } else { |
339 | return; | 336 | return; |
340 | } | 337 | } |
341 | } | 338 | } |
342 | 339 | ||
343 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; | 340 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; |
344 | case VideoNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return; | 341 | case VideoNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return; |
345 | case VideoPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return; | 342 | case VideoPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return; |
346 | case VideoVolUp: emit moreReleased(); return; | 343 | case VideoVolUp: emit moreReleased(); return; |
347 | case VideoVolDown: emit lessReleased(); return; | 344 | case VideoVolDown: emit lessReleased(); return; |
348 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 345 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
349 | } | 346 | } |
350 | } | 347 | } |
351 | } | 348 | } |
352 | } | 349 | } |
353 | } | 350 | } |
354 | 351 | ||
355 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 352 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
356 | mouseMoveEvent( event ); | 353 | mouseMoveEvent( event ); |
357 | } | 354 | } |
358 | 355 | ||
359 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 356 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
360 | if ( mediaPlayerState->isFullscreen() ) { | 357 | if ( mediaPlayerState->isFullscreen() ) { |
361 | mediaPlayerState->setFullscreen( FALSE ); | 358 | mediaPlayerState->setFullscreen( FALSE ); |
362 | makeVisible(); | 359 | makeVisible(); |
363 | } | 360 | } |
364 | mouseMoveEvent( event ); | 361 | mouseMoveEvent( event ); |
365 | } | 362 | } |
366 | 363 | ||
367 | void VideoWidget::showEvent( QShowEvent* ) { | 364 | void VideoWidget::showEvent( QShowEvent* ) { |
368 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 365 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
369 | mouseMoveEvent( &event ); | 366 | mouseMoveEvent( &event ); |
370 | } | 367 | } |
371 | 368 | ||
372 | 369 | ||
373 | void VideoWidget::backToNormal() { | 370 | void VideoWidget::backToNormal() { |
374 | mediaPlayerState->setFullscreen( FALSE ); | 371 | mediaPlayerState->setFullscreen( FALSE ); |
375 | makeVisible(); | 372 | makeVisible(); |
376 | } | 373 | } |
377 | 374 | ||
378 | void VideoWidget::makeVisible() { | 375 | void VideoWidget::makeVisible() { |
379 | if ( mediaPlayerState->isFullscreen() ) { | 376 | if ( mediaPlayerState->isFullscreen() ) { |
380 | setBackgroundMode( QWidget::NoBackground ); | 377 | setBackgroundMode( QWidget::NoBackground ); |
381 | showFullScreen(); | 378 | showFullScreen(); |
382 | resize( qApp->desktop()->size() ); | 379 | resize( qApp->desktop()->size() ); |
383 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 380 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
384 | 381 | ||
385 | slider->hide(); | 382 | slider->hide(); |
386 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 383 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
387 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 384 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
388 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 385 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
389 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 386 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
390 | 387 | ||
391 | } else { | 388 | } else { |
392 | showNormal(); | 389 | showNormal(); |
393 | showMaximized(); | 390 | showMaximized(); |
394 | setBackgroundPixmap( *pixBg ); | 391 | setBackgroundPixmap( *pixBg ); |
395 | QWidget *d = QApplication::desktop(); | 392 | QWidget *d = QApplication::desktop(); |
396 | int w = d->width(); | 393 | int w = d->width(); |
397 | int h = d->height(); | 394 | int h = d->height(); |
398 | 395 | ||
399 | if(w>h) { | 396 | if(w>h) { |
400 | int newW=(w/2)-(246/2); //this will only work with 320x240 | 397 | int newW=(w/2)-(246/2); //this will only work with 320x240 |
401 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); | 398 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); |
402 | } else { | 399 | } else { |
403 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 400 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
404 | } | 401 | } |
405 | 402 | ||
406 | if ( !mediaPlayerState->isSeekable() ) { | 403 | if ( !mediaPlayerState->isSeekable() ) { |
407 | if( !slider->isHidden()) { | 404 | if( !slider->isHidden()) { |
408 | slider->hide(); | 405 | slider->hide(); |
409 | } | 406 | } |
410 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 407 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
411 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 408 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
412 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 409 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
413 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 410 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
414 | } else { | 411 | } else { |
415 | slider->show(); | 412 | slider->show(); |
416 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 413 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
417 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 414 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
418 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 415 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
419 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 416 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
420 | } | 417 | } |
421 | } | 418 | } |
422 | } | 419 | } |
423 | 420 | ||
424 | 421 | ||
425 | 422 | ||
426 | 423 | ||
427 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 424 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
428 | QPainter p( this ); | 425 | QPainter p( this ); |
429 | 426 | ||
430 | if ( mediaPlayerState->isFullscreen() ) { | 427 | if ( mediaPlayerState->isFullscreen() ) { |
431 | // Clear the background | 428 | // Clear the background |
432 | p.setBrush( QBrush( Qt::black ) ); | 429 | p.setBrush( QBrush( Qt::black ) ); |
433 | } else { | 430 | } else { |
434 | if ( !pe->erased() ) { | 431 | if ( !pe->erased() ) { |
435 | // Combine with background and double buffer | 432 | // Combine with background and double buffer |
436 | QPixmap pix( pe->rect().size() ); | 433 | QPixmap pix( pe->rect().size() ); |
437 | QPainter p( &pix ); | 434 | QPainter p( &pix ); |
438 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 435 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
439 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 436 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
440 | for ( int i = 0; i < numVButtons; i++ ) { | 437 | for ( int i = 0; i < numVButtons; i++ ) { |
441 | paintButton( &p, i ); | 438 | paintButton( &p, i ); |
442 | } | 439 | } |
443 | QPainter p2( this ); | 440 | QPainter p2( this ); |
444 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 441 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
445 | } else { | 442 | } else { |
446 | QPainter p( this ); | 443 | QPainter p( this ); |
447 | for ( int i = 0; i < numVButtons; i++ ) | 444 | for ( int i = 0; i < numVButtons; i++ ) |
448 | paintButton( &p, i ); | 445 | paintButton( &p, i ); |
449 | } | 446 | } |
450 | //slider->repaint( TRUE ); | 447 | //slider->repaint( TRUE ); |
451 | } | 448 | } |
452 | } | 449 | } |
453 | 450 | ||
454 | 451 | ||
455 | void VideoWidget::closeEvent( QCloseEvent* ) { | 452 | void VideoWidget::closeEvent( QCloseEvent* ) { |
456 | mediaPlayerState->setList(); | 453 | mediaPlayerState->setList(); |
457 | } | 454 | } |
458 | 455 | ||
459 | 456 | ||
460 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 457 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
461 | switch ( e->key() ) { | 458 | switch ( e->key() ) { |
462 | ////////////////////////////// Zaurus keys | 459 | ////////////////////////////// Zaurus keys |
463 | case Key_Home: | 460 | case Key_Home: |
464 | break; | 461 | break; |
465 | case Key_F9: //activity | 462 | case Key_F9: //activity |
466 | break; | 463 | break; |
467 | case Key_F10: //contacts | 464 | case Key_F10: //contacts |
468 | // hide(); | 465 | // hide(); |
469 | break; | 466 | break; |
470 | case Key_F11: //menu | 467 | case Key_F11: //menu |
471 | break; | 468 | break; |
472 | case Key_F12: //home | 469 | case Key_F12: //home |
473 | break; | 470 | break; |
474 | case Key_F13: //mail | 471 | case Key_F13: //mail |
475 | break; | 472 | break; |
476 | case Key_Space: { | 473 | case Key_Space: { |
477 | if(mediaPlayerState->isPlaying()) { | 474 | if(mediaPlayerState->isPlaying()) { |
478 | mediaPlayerState->setPlaying(FALSE); | 475 | mediaPlayerState->setPlaying(FALSE); |
479 | } else { | 476 | } else { |
480 | mediaPlayerState->setPlaying(TRUE); | 477 | mediaPlayerState->setPlaying(TRUE); |
481 | } | 478 | } |
482 | } | 479 | } |
483 | break; | 480 | break; |
484 | case Key_Down: | 481 | case Key_Down: |
485 | // toggleButton(6); | 482 | // toggleButton(6); |
486 | emit lessClicked(); | 483 | emit lessClicked(); |
487 | emit lessReleased(); | 484 | emit lessReleased(); |
488 | // toggleButton(6); | 485 | // toggleButton(6); |
489 | break; | 486 | break; |
490 | case Key_Up: | 487 | case Key_Up: |
491 | // toggleButton(5); | 488 | // toggleButton(5); |
492 | emit moreClicked(); | 489 | emit moreClicked(); |
493 | emit moreReleased(); | 490 | emit moreReleased(); |
494 | // toggleButton(5); | 491 | // toggleButton(5); |
495 | break; | 492 | break; |
496 | case Key_Right: | 493 | case Key_Right: |
497 | mediaPlayerState->setNext(); | 494 | mediaPlayerState->setNext(); |
498 | break; | 495 | break; |
499 | case Key_Left: | 496 | case Key_Left: |
500 | mediaPlayerState->setPrev(); | 497 | mediaPlayerState->setPrev(); |
501 | break; | 498 | break; |
502 | case Key_Escape: | 499 | case Key_Escape: |
503 | break; | 500 | break; |
504 | 501 | ||
505 | }; | 502 | }; |
506 | } | 503 | } |
507 | 504 | ||
508 | XineVideoWidget* VideoWidget::vidWidget() { | 505 | XineVideoWidget* VideoWidget::vidWidget() { |
509 | return videoFrame; | 506 | return videoFrame; |
510 | } | 507 | } |
511 | 508 | ||
512 | 509 | ||
513 | void VideoWidget::setFullscreen ( bool b ) { | 510 | void VideoWidget::setFullscreen ( bool b ) { |
514 | setToggleButton( VideoFullscreen, b ); | 511 | setToggleButton( VideoFullscreen, b ); |
515 | } | 512 | } |
516 | 513 | ||
517 | 514 | ||
518 | void VideoWidget::setPlaying( bool b) { | 515 | void VideoWidget::setPlaying( bool b) { |
519 | setToggleButton( VideoPlay, b ); | 516 | setToggleButton( VideoPlay, b ); |
520 | } | 517 | } |
521 | 518 | ||
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 8e9dd7e..816ce2e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -1,125 +1,127 @@ | |||
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 "mediawidget.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 MediaWidget { | 56 | class VideoWidget : public MediaWidget { |
57 | Q_OBJECT | 57 | Q_OBJECT |
58 | public: | 58 | public: |
59 | VideoWidget( QWidget* parent=0, const char* name=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); | ||
69 | void setFullscreen( bool b ); | 68 | void setFullscreen( bool b ); |
70 | void makeVisible(); | 69 | void makeVisible(); |
71 | void backToNormal(); | 70 | void backToNormal(); |
72 | void setPosition( long ); | 71 | void setPosition( long ); |
73 | void setLength( long ); | 72 | |
74 | void setDisplayType( MediaPlayerState::DisplayType displayType ); | 73 | public: |
74 | virtual void setPlaying( bool b); | ||
75 | virtual void setLength( long ); | ||
76 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | ||
75 | 77 | ||
76 | signals: | 78 | signals: |
77 | void moreClicked(); | 79 | void moreClicked(); |
78 | void lessClicked(); | 80 | void lessClicked(); |
79 | void moreReleased(); | 81 | void moreReleased(); |
80 | void lessReleased(); | 82 | void lessReleased(); |
81 | void sliderMoved( long ); | 83 | void sliderMoved( long ); |
82 | void videoResized ( const QSize &s ); | 84 | void videoResized ( const QSize &s ); |
83 | 85 | ||
84 | protected: | 86 | protected: |
85 | 87 | ||
86 | void resizeEvent( QResizeEvent * ); | 88 | void resizeEvent( QResizeEvent * ); |
87 | void paintEvent( QPaintEvent *pe ); | 89 | void paintEvent( QPaintEvent *pe ); |
88 | void showEvent( QShowEvent *se ); | 90 | void showEvent( QShowEvent *se ); |
89 | void mouseMoveEvent( QMouseEvent *event ); | 91 | void mouseMoveEvent( QMouseEvent *event ); |
90 | void mousePressEvent( QMouseEvent *event ); | 92 | void mousePressEvent( QMouseEvent *event ); |
91 | void mouseReleaseEvent( QMouseEvent *event ); | 93 | void mouseReleaseEvent( QMouseEvent *event ); |
92 | void closeEvent( QCloseEvent *event ); | 94 | void closeEvent( QCloseEvent *event ); |
93 | void keyReleaseEvent( QKeyEvent *e); | 95 | void keyReleaseEvent( QKeyEvent *e); |
94 | 96 | ||
95 | private: | 97 | private: |
96 | // Ticker songInfo; | 98 | // Ticker songInfo; |
97 | QPixmap *pixBg; | 99 | QPixmap *pixBg; |
98 | QImage *imgUp; | 100 | QImage *imgUp; |
99 | QImage *imgDn; | 101 | QImage *imgDn; |
100 | QImage *imgButtonMask; | 102 | QImage *imgButtonMask; |
101 | QBitmap *masks[7]; | 103 | QBitmap *masks[7]; |
102 | QPixmap *buttonPixUp[7]; | 104 | QPixmap *buttonPixUp[7]; |
103 | QPixmap *buttonPixDown[7]; | 105 | QPixmap *buttonPixDown[7]; |
104 | QString skin; | 106 | QString skin; |
105 | // QPixmap *pixmaps[4]; | 107 | // QPixmap *pixmaps[4]; |
106 | int xoff, yoff; | 108 | int xoff, yoff; |
107 | 109 | ||
108 | 110 | ||
109 | void paintButton( QPainter *p, int i ); | 111 | void paintButton( QPainter *p, int i ); |
110 | void toggleButton( int ); | 112 | void toggleButton( int ); |
111 | void setToggleButton( int, bool ); | 113 | void setToggleButton( int, bool ); |
112 | 114 | ||
113 | QString backgroundPix; | 115 | QString backgroundPix; |
114 | QSlider *slider; | 116 | QSlider *slider; |
115 | QPixmap *pixmaps[3]; | 117 | QPixmap *pixmaps[3]; |
116 | QImage *currentFrame; | 118 | QImage *currentFrame; |
117 | int scaledWidth; | 119 | int scaledWidth; |
118 | int scaledHeight; | 120 | int scaledHeight; |
119 | XineVideoWidget* videoFrame; | 121 | XineVideoWidget* videoFrame; |
120 | }; | 122 | }; |
121 | 123 | ||
122 | #endif // VIDEO_WIDGET_H | 124 | #endif // VIDEO_WIDGET_H |
123 | 125 | ||
124 | 126 | ||
125 | 127 | ||