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