author | llornkcor <llornkcor> | 2002-08-10 17:41:15 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-10 17:41:15 (UTC) |
commit | b488752cf2149443dcebcc8f7ad21c1ba47070fa (patch) (unidiff) | |
tree | 461adc8345f14d495466e5082f36651a844bde67 | |
parent | fb46a101bab9348ebfb68094b7c6cf54e56ea774 (diff) | |
download | opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.zip opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.tar.gz opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.tar.bz2 |
added skins to videowidget, fixed fullscreen menu. Still needs work on buttonmask.
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 41 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 246 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 17 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 323 |
7 files changed, 384 insertions, 254 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index dc90a62..2ee9383 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,569 +1,569 @@ | |||
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 | #include <qwidget.h> | 38 | #include <qwidget.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include <qbutton.h> | 40 | #include <qbutton.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | #include <qframe.h> | 42 | #include <qframe.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | 44 | ||
45 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | #include <stdio.h> | 46 | #include <stdio.h> |
47 | 47 | ||
48 | #include "audiowidget.h" | 48 | #include "audiowidget.h" |
49 | #include "mediaplayerstate.h" | 49 | #include "mediaplayerstate.h" |
50 | 50 | ||
51 | extern MediaPlayerState *mediaPlayerState; | 51 | extern MediaPlayerState *mediaPlayerState; |
52 | 52 | ||
53 | static const int xo = -2; // movable x offset | 53 | static const int xo = -2; // movable x offset |
54 | static const int yo = 22; // movable y offset | 54 | static const int yo = 22; // movable y offset |
55 | 55 | ||
56 | 56 | ||
57 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { | 57 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { |
58 | setFrameStyle( WinPanel | Sunken ); | 58 | setFrameStyle( WinPanel | Sunken ); |
59 | setText( "No Song" ); | 59 | setText( "No Song" ); |
60 | } | 60 | } |
61 | 61 | ||
62 | Ticker::~Ticker() { | 62 | Ticker::~Ticker() { |
63 | } | 63 | } |
64 | 64 | ||
65 | void Ticker::setText( const QString& text ) { | 65 | void Ticker::setText( const QString& text ) { |
66 | pos = 0; // reset it everytime the text is changed | 66 | pos = 0; // reset it everytime the text is changed |
67 | scrollText = text; | 67 | scrollText = text; |
68 | pixelLen = fontMetrics().width( scrollText ); | 68 | pixelLen = fontMetrics().width( scrollText ); |
69 | killTimers(); | 69 | killTimers(); |
70 | if ( pixelLen > width() ) { | 70 | if ( pixelLen > width() ) { |
71 | startTimer( 50 ); | 71 | startTimer( 50 ); |
72 | } | 72 | } |
73 | update(); | 73 | update(); |
74 | } | 74 | } |
75 | 75 | ||
76 | 76 | ||
77 | void Ticker::timerEvent( QTimerEvent * ) { | 77 | void Ticker::timerEvent( QTimerEvent * ) { |
78 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | 78 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; |
79 | scroll( -1, 0, contentsRect() ); | 79 | scroll( -1, 0, contentsRect() ); |
80 | repaint( FALSE ); | 80 | repaint( FALSE ); |
81 | } | 81 | } |
82 | 82 | ||
83 | void Ticker::drawContents( QPainter *p ) { | 83 | void Ticker::drawContents( QPainter *p ) { |
84 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | 84 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) |
85 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 85 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
86 | QPixmap pm( width(), height() ); | 86 | QPixmap pm( width(), height() ); |
87 | pm.fill( colorGroup().base() ); | 87 | pm.fill( colorGroup().base() ); |
88 | QPainter pmp( &pm ); | 88 | QPainter pmp( &pm ); |
89 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | 89 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { |
90 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 90 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
91 | } | 91 | } |
92 | p->drawPixmap( 0, 0, pm ); | 92 | p->drawPixmap( 0, 0, pm ); |
93 | } | 93 | } |
94 | 94 | ||
95 | struct MediaButton { | 95 | struct MediaButton { |
96 | bool isToggle, isHeld, isDown; | 96 | bool isToggle, isHeld, isDown; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | //Layout information for the audioButtons (and if it is a toggle button or not) | 99 | //Layout information for the audioButtons (and if it is a toggle button or not) |
100 | MediaButton audioButtons[] = { | 100 | MediaButton audioButtons[] = { |
101 | { TRUE, FALSE, FALSE }, // play | 101 | { TRUE, FALSE, FALSE }, // play |
102 | { FALSE, FALSE, FALSE }, // stop | 102 | { FALSE, FALSE, FALSE }, // stop |
103 | { FALSE, FALSE, FALSE }, // pause | 103 | { FALSE, FALSE, FALSE }, // pause |
104 | { FALSE, FALSE, FALSE }, // next | 104 | { FALSE, FALSE, FALSE }, // next |
105 | { FALSE, FALSE, FALSE }, // previous | 105 | { FALSE, FALSE, FALSE }, // previous |
106 | { FALSE, FALSE, FALSE }, // volume up | 106 | { FALSE, FALSE, FALSE }, // volume up |
107 | { FALSE, FALSE, FALSE }, // volume down | 107 | { FALSE, FALSE, FALSE }, // volume down |
108 | { TRUE, FALSE, FALSE }, // repeat/loop | 108 | { TRUE, FALSE, FALSE }, // repeat/loop |
109 | { FALSE, FALSE, FALSE }, // playlist | 109 | { FALSE, FALSE, FALSE }, // playlist |
110 | { FALSE, FALSE, FALSE }, // forward | 110 | { FALSE, FALSE, FALSE }, // forward |
111 | { FALSE, FALSE, FALSE } // back | 111 | { FALSE, FALSE, FALSE } // back |
112 | }; | 112 | }; |
113 | 113 | ||
114 | const char *skin_mask_file_names[11] = { | 114 | const char *skin_mask_file_names[11] = { |
115 | "play", "stop", "pause", "next", "prev", "up", | 115 | "play", "stop", "pause", "next", "prev", "up", |
116 | "down", "loop", "playlist", "forward", "back" | 116 | "down", "loop", "playlist", "forward", "back" |
117 | }; | 117 | }; |
118 | 118 | ||
119 | 119 | ||
120 | static void changeTextColor( QWidget *w ) { | 120 | static void changeTextColor( QWidget *w ) { |
121 | QPalette p = w->palette(); | 121 | QPalette p = w->palette(); |
122 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 122 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
123 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 123 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
124 | w->setPalette( p ); | 124 | w->setPalette( p ); |
125 | } | 125 | } |
126 | 126 | ||
127 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 127 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
128 | 128 | ||
129 | 129 | ||
130 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 130 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
131 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 131 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
132 | setCaption( tr("OpiePlayer") ); | 132 | setCaption( tr("OpiePlayer") ); |
133 | 133 | ||
134 | Config cfg("OpiePlayer"); | 134 | Config cfg("OpiePlayer"); |
135 | cfg.setGroup("AudioWidget"); | 135 | cfg.setGroup("AudioWidget"); |
136 | skin = cfg.readEntry("Skin","default"); | 136 | skin = cfg.readEntry("Skin","default"); |
137 | //skin = "scaleTest"; | 137 | //skin = "scaleTest"; |
138 | // color of background, frame, degree of transparency | 138 | // color of background, frame, degree of transparency |
139 | 139 | ||
140 | QString skinPath = "opieplayer/skins/" + skin; | 140 | QString skinPath = "opieplayer2/skins/" + skin; |
141 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 141 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
142 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 142 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
143 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 143 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
144 | 144 | ||
145 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 145 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
146 | imgButtonMask->fill( 0 ); | 146 | imgButtonMask->fill( 0 ); |
147 | 147 | ||
148 | for ( int i = 0; i < 11; i++ ) { | 148 | for ( int i = 0; i < 11; i++ ) { |
149 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; | 149 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; |
150 | masks[i] = new QBitmap( filename ); | 150 | masks[i] = new QBitmap( filename ); |
151 | 151 | ||
152 | if ( !masks[i]->isNull() ) { | 152 | if ( !masks[i]->isNull() ) { |
153 | QImage imgMask = masks[i]->convertToImage(); | 153 | QImage imgMask = masks[i]->convertToImage(); |
154 | uchar **dest = imgButtonMask->jumpTable(); | 154 | uchar **dest = imgButtonMask->jumpTable(); |
155 | for ( int y = 0; y < imgUp->height(); y++ ) { | 155 | for ( int y = 0; y < imgUp->height(); y++ ) { |
156 | uchar *line = dest[y]; | 156 | uchar *line = dest[y]; |
157 | for ( int x = 0; x < imgUp->width(); x++ ) | 157 | for ( int x = 0; x < imgUp->width(); x++ ) |
158 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 158 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
159 | line[x] = i + 1; | 159 | line[x] = i + 1; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | } | 163 | } |
164 | 164 | ||
165 | for ( int i = 0; i < 11; i++ ) { | 165 | for ( int i = 0; i < 11; i++ ) { |
166 | buttonPixUp[i] = NULL; | 166 | buttonPixUp[i] = NULL; |
167 | buttonPixDown[i] = NULL; | 167 | buttonPixDown[i] = NULL; |
168 | } | 168 | } |
169 | 169 | ||
170 | setBackgroundPixmap( *pixBg ); | 170 | setBackgroundPixmap( *pixBg ); |
171 | 171 | ||
172 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 172 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
173 | changeTextColor( &songInfo ); | 173 | changeTextColor( &songInfo ); |
174 | 174 | ||
175 | slider.setFixedHeight( 20 ); | 175 | slider.setFixedHeight( 20 ); |
176 | slider.setMinValue( 0 ); | 176 | slider.setMinValue( 0 ); |
177 | slider.setMaxValue( 1 ); | 177 | slider.setMaxValue( 1 ); |
178 | slider.setFocusPolicy( QWidget::NoFocus ); | 178 | slider.setFocusPolicy( QWidget::NoFocus ); |
179 | slider.setBackgroundPixmap( *pixBg ); | 179 | slider.setBackgroundPixmap( *pixBg ); |
180 | 180 | ||
181 | time.setFocusPolicy( QWidget::NoFocus ); | 181 | time.setFocusPolicy( QWidget::NoFocus ); |
182 | time.setAlignment( Qt::AlignCenter ); | 182 | time.setAlignment( Qt::AlignCenter ); |
183 | time.setFrame(FALSE); | 183 | time.setFrame(FALSE); |
184 | changeTextColor( &time ); | 184 | changeTextColor( &time ); |
185 | 185 | ||
186 | resizeEvent( NULL ); | 186 | resizeEvent( NULL ); |
187 | 187 | ||
188 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 188 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
189 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 189 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
190 | 190 | ||
191 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 191 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
192 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 192 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
193 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 193 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
194 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 194 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
195 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 195 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
196 | 196 | ||
197 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 197 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
198 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 198 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
199 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 199 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
200 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 200 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
201 | 201 | ||
202 | 202 | ||
203 | 203 | ||
204 | // Intialise state | 204 | // Intialise state |
205 | setLength( mediaPlayerState->length() ); | 205 | setLength( mediaPlayerState->length() ); |
206 | setPosition( mediaPlayerState->position() ); | 206 | setPosition( mediaPlayerState->position() ); |
207 | setLooping( mediaPlayerState->fullscreen() ); | 207 | setLooping( mediaPlayerState->fullscreen() ); |
208 | setPaused( mediaPlayerState->paused() ); | 208 | setPaused( mediaPlayerState->paused() ); |
209 | setPlaying( mediaPlayerState->playing() ); | 209 | setPlaying( mediaPlayerState->playing() ); |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | AudioWidget::~AudioWidget() { | 213 | AudioWidget::~AudioWidget() { |
214 | 214 | ||
215 | for ( int i = 0; i < 11; i++ ) { | 215 | for ( int i = 0; i < 11; i++ ) { |
216 | delete buttonPixUp[i]; | 216 | delete buttonPixUp[i]; |
217 | delete buttonPixDown[i]; | 217 | delete buttonPixDown[i]; |
218 | } | 218 | } |
219 | delete pixBg; | 219 | delete pixBg; |
220 | delete imgUp; | 220 | delete imgUp; |
221 | delete imgDn; | 221 | delete imgDn; |
222 | delete imgButtonMask; | 222 | delete imgButtonMask; |
223 | for ( int i = 0; i < 11; i++ ) { | 223 | for ( int i = 0; i < 11; i++ ) { |
224 | delete masks[i]; | 224 | delete masks[i]; |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 228 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
229 | QPixmap pix( img.width(), img.height() ); | 229 | QPixmap pix( img.width(), img.height() ); |
230 | QPainter p( &pix ); | 230 | QPainter p( &pix ); |
231 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 231 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
232 | p.drawImage( 0, 0, img ); | 232 | p.drawImage( 0, 0, img ); |
233 | return new QPixmap( pix ); | 233 | return new QPixmap( pix ); |
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) | 237 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) |
238 | { | 238 | { |
239 | QPixmap *pixmap = new QPixmap( pix ); | 239 | QPixmap *pixmap = new QPixmap( pix ); |
240 | pixmap->setMask( mask ); | 240 | pixmap->setMask( mask ); |
241 | return pixmap; | 241 | return pixmap; |
242 | } | 242 | } |
243 | 243 | ||
244 | 244 | ||
245 | 245 | ||
246 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 246 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
247 | int h = height(); | 247 | int h = height(); |
248 | int w = width(); | 248 | int w = width(); |
249 | 249 | ||
250 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | 250 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); |
251 | slider.setFixedWidth( w - 110 ); | 251 | slider.setFixedWidth( w - 110 ); |
252 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 252 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
253 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 253 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
254 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 254 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
255 | 255 | ||
256 | xoff = ( w - imgUp->width() ) / 2; | 256 | xoff = ( w - imgUp->width() ) / 2; |
257 | yoff = (( h - imgUp->height() ) / 2) - 10; | 257 | yoff = (( h - imgUp->height() ) / 2) - 10; |
258 | QPoint p( xoff, yoff ); | 258 | QPoint p( xoff, yoff ); |
259 | 259 | ||
260 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); | 260 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); |
261 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); | 261 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); |
262 | 262 | ||
263 | for ( int i = 0; i < 11; i++ ) { | 263 | for ( int i = 0; i < 11; i++ ) { |
264 | if ( !masks[i]->isNull() ) { | 264 | if ( !masks[i]->isNull() ) { |
265 | delete buttonPixUp[i]; | 265 | delete buttonPixUp[i]; |
266 | delete buttonPixDown[i]; | 266 | delete buttonPixDown[i]; |
267 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); | 267 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); |
268 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); | 268 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | delete pixUp; | 272 | delete pixUp; |
273 | delete pixDn; | 273 | delete pixDn; |
274 | } | 274 | } |
275 | 275 | ||
276 | static bool audioSliderBeingMoved = FALSE; | 276 | static bool audioSliderBeingMoved = FALSE; |
277 | 277 | ||
278 | 278 | ||
279 | void AudioWidget::sliderPressed() { | 279 | void AudioWidget::sliderPressed() { |
280 | audioSliderBeingMoved = TRUE; | 280 | audioSliderBeingMoved = TRUE; |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | void AudioWidget::sliderReleased() { | 284 | void AudioWidget::sliderReleased() { |
285 | audioSliderBeingMoved = FALSE; | 285 | audioSliderBeingMoved = FALSE; |
286 | if ( slider.width() == 0 ) | 286 | if ( slider.width() == 0 ) |
287 | return; | 287 | return; |
288 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 288 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
289 | mediaPlayerState->setPosition( val ); | 289 | mediaPlayerState->setPosition( val ); |
290 | } | 290 | } |
291 | 291 | ||
292 | void AudioWidget::setPosition( long i ) { | 292 | void AudioWidget::setPosition( long i ) { |
293 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 293 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
294 | updateSlider( i, mediaPlayerState->length() ); | 294 | updateSlider( i, mediaPlayerState->length() ); |
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | void AudioWidget::setLength( long max ) { | 298 | void AudioWidget::setLength( long max ) { |
299 | updateSlider( mediaPlayerState->position(), max ); | 299 | updateSlider( mediaPlayerState->position(), max ); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | void AudioWidget::setView( char view ) { | 303 | void AudioWidget::setView( char view ) { |
304 | 304 | ||
305 | // this isnt working for some reason | 305 | // this isnt working for some reason |
306 | 306 | ||
307 | if ( mediaPlayerState->streaming() ) { | 307 | if ( mediaPlayerState->streaming() ) { |
308 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 308 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
309 | if( !slider.isHidden()) { | 309 | if( !slider.isHidden()) { |
310 | slider.hide(); | 310 | slider.hide(); |
311 | } | 311 | } |
312 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 312 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
313 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 313 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
314 | } else { | 314 | } else { |
315 | // this stops the slider from being moved, thus | 315 | // this stops the slider from being moved, thus |
316 | // does not stop stream when it reaches the end | 316 | // does not stop stream when it reaches the end |
317 | slider.show(); | 317 | slider.show(); |
318 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 318 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
319 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 319 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
320 | } | 320 | } |
321 | 321 | ||
322 | if ( view == 'a' ) { | 322 | if ( view == 'a' ) { |
323 | // startTimer( 150 ); | 323 | // startTimer( 150 ); |
324 | showMaximized(); | 324 | showMaximized(); |
325 | } else { | 325 | } else { |
326 | killTimers(); | 326 | killTimers(); |
327 | hide(); | 327 | hide(); |
328 | } | 328 | } |
329 | } | 329 | } |
330 | 330 | ||
331 | 331 | ||
332 | static QString timeAsString( long length ) { | 332 | static QString timeAsString( long length ) { |
333 | int minutes = length / 60; | 333 | int minutes = length / 60; |
334 | int seconds = length % 60; | 334 | int seconds = length % 60; |
335 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 335 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
336 | } | 336 | } |
337 | 337 | ||
338 | void AudioWidget::updateSlider( long i, long max ) { | 338 | void AudioWidget::updateSlider( long i, long max ) { |
339 | 339 | ||
340 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 340 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
341 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 341 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
342 | 342 | ||
343 | if ( max == 0 ) { | 343 | if ( max == 0 ) { |
344 | return; | 344 | return; |
345 | } | 345 | } |
346 | // Will flicker too much if we don't do this | 346 | // Will flicker too much if we don't do this |
347 | // Scale to something reasonable | 347 | // Scale to something reasonable |
348 | int width = slider.width(); | 348 | int width = slider.width(); |
349 | int val = int((double)i * width / max); | 349 | int val = int((double)i * width / max); |
350 | if ( !audioSliderBeingMoved ) { | 350 | if ( !audioSliderBeingMoved ) { |
351 | if ( slider.value() != val ) { | 351 | if ( slider.value() != val ) { |
352 | slider.setValue( val ); | 352 | slider.setValue( val ); |
353 | } | 353 | } |
354 | 354 | ||
355 | if ( slider.maxValue() != width ) { | 355 | if ( slider.maxValue() != width ) { |
356 | slider.setMaxValue( width ); | 356 | slider.setMaxValue( width ); |
357 | } | 357 | } |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | void AudioWidget::setToggleButton( int i, bool down ) { | 362 | void AudioWidget::setToggleButton( int i, bool down ) { |
363 | if ( down != audioButtons[i].isDown ) { | 363 | if ( down != audioButtons[i].isDown ) { |
364 | toggleButton( i ); | 364 | toggleButton( i ); |
365 | } | 365 | } |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | void AudioWidget::toggleButton( int i ) { | 369 | void AudioWidget::toggleButton( int i ) { |
370 | audioButtons[i].isDown = !audioButtons[i].isDown; | 370 | audioButtons[i].isDown = !audioButtons[i].isDown; |
371 | QPainter p(this); | 371 | QPainter p(this); |
372 | paintButton ( &p, i ); | 372 | paintButton ( &p, i ); |
373 | } | 373 | } |
374 | 374 | ||
375 | 375 | ||
376 | void AudioWidget::paintButton( QPainter *p, int i ) { | 376 | void AudioWidget::paintButton( QPainter *p, int i ) { |
377 | if ( audioButtons[i].isDown ) | 377 | if ( audioButtons[i].isDown ) |
378 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 378 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
379 | else | 379 | else |
380 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 380 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
381 | } | 381 | } |
382 | 382 | ||
383 | 383 | ||
384 | void AudioWidget::skipFor() { | 384 | void AudioWidget::skipFor() { |
385 | skipDirection = +1; | 385 | skipDirection = +1; |
386 | startTimer( 50 ); | 386 | startTimer( 50 ); |
387 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 387 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
388 | } | 388 | } |
389 | 389 | ||
390 | void AudioWidget::skipBack() { | 390 | void AudioWidget::skipBack() { |
391 | skipDirection = -1; | 391 | skipDirection = -1; |
392 | startTimer( 50 ); | 392 | startTimer( 50 ); |
393 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 393 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
394 | } | 394 | } |
395 | 395 | ||
396 | 396 | ||
397 | 397 | ||
398 | void AudioWidget::stopSkip() { | 398 | void AudioWidget::stopSkip() { |
399 | killTimers(); | 399 | killTimers(); |
400 | } | 400 | } |
401 | 401 | ||
402 | 402 | ||
403 | void AudioWidget::timerEvent( QTimerEvent * ) { | 403 | void AudioWidget::timerEvent( QTimerEvent * ) { |
404 | if ( skipDirection == +1 ) { | 404 | if ( skipDirection == +1 ) { |
405 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 405 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
406 | } else if ( skipDirection == -1 ) { | 406 | } else if ( skipDirection == -1 ) { |
407 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 407 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
408 | } | 408 | } |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 412 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
413 | for ( int i = 0; i < numButtons; i++ ) { | 413 | for ( int i = 0; i < numButtons; i++ ) { |
414 | if ( event->state() == QMouseEvent::LeftButton ) { | 414 | if ( event->state() == QMouseEvent::LeftButton ) { |
415 | 415 | ||
416 | // The test to see if the mouse click is inside the button or not | 416 | // The test to see if the mouse click is inside the button or not |
417 | int x = event->pos().x() - xoff; | 417 | int x = event->pos().x() - xoff; |
418 | int y = event->pos().y() - yoff; | 418 | int y = event->pos().y() - yoff; |
419 | 419 | ||
420 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 420 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
421 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 421 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
422 | 422 | ||
423 | if ( isOnButton && i == AudioVolumeUp ) | 423 | if ( isOnButton && i == AudioVolumeUp ) |
424 | qDebug("on up"); | 424 | qDebug("on up"); |
425 | 425 | ||
426 | if ( isOnButton && !audioButtons[i].isHeld ) { | 426 | if ( isOnButton && !audioButtons[i].isHeld ) { |
427 | audioButtons[i].isHeld = TRUE; | 427 | audioButtons[i].isHeld = TRUE; |
428 | toggleButton(i); | 428 | toggleButton(i); |
429 | switch (i) { | 429 | switch (i) { |
430 | case AudioVolumeUp: | 430 | case AudioVolumeUp: |
431 | qDebug("more clicked"); | 431 | qDebug("more clicked"); |
432 | emit moreClicked(); | 432 | emit moreClicked(); |
433 | return; | 433 | return; |
434 | case AudioVolumeDown: | 434 | case AudioVolumeDown: |
435 | emit lessClicked(); | 435 | emit lessClicked(); |
436 | return; | 436 | return; |
437 | case AudioForward: | 437 | case AudioForward: |
438 | emit forwardClicked(); | 438 | emit forwardClicked(); |
439 | return; | 439 | return; |
440 | case AudioBack: | 440 | case AudioBack: |
441 | emit backClicked(); | 441 | emit backClicked(); |
442 | return; | 442 | return; |
443 | } | 443 | } |
444 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 444 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
445 | audioButtons[i].isHeld = FALSE; | 445 | audioButtons[i].isHeld = FALSE; |
446 | toggleButton(i); | 446 | toggleButton(i); |
447 | } | 447 | } |
448 | } else { | 448 | } else { |
449 | if ( audioButtons[i].isHeld ) { | 449 | if ( audioButtons[i].isHeld ) { |
450 | audioButtons[i].isHeld = FALSE; | 450 | audioButtons[i].isHeld = FALSE; |
451 | if ( !audioButtons[i].isToggle ) { | 451 | if ( !audioButtons[i].isToggle ) { |
452 | setToggleButton( i, FALSE ); | 452 | setToggleButton( i, FALSE ); |
453 | qDebug("button toggled3 %d",i); | 453 | qDebug("button toggled3 %d",i); |
454 | } | 454 | } |
455 | switch (i) { | 455 | switch (i) { |
456 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; | 456 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; |
457 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 457 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
458 | case AudioPause: mediaPlayerState->setPaused( audioButtons[i].isDown); return; | 458 | case AudioPause: mediaPlayerState->setPaused( audioButtons[i].isDown); return; |
459 | case AudioNext: mediaPlayerState->setNext(); return; | 459 | case AudioNext: mediaPlayerState->setNext(); return; |
460 | case AudioPrevious: mediaPlayerState->setPrev(); return; | 460 | case AudioPrevious: mediaPlayerState->setPrev(); return; |
461 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 461 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
462 | case AudioVolumeUp: emit moreReleased(); return; | 462 | case AudioVolumeUp: emit moreReleased(); return; |
463 | case AudioVolumeDown: emit lessReleased(); return; | 463 | case AudioVolumeDown: emit lessReleased(); return; |
464 | case AudioPlayList: mediaPlayerState->setList(); return; | 464 | case AudioPlayList: mediaPlayerState->setList(); return; |
465 | case AudioForward: emit forwardReleased(); return; | 465 | case AudioForward: emit forwardReleased(); return; |
466 | case AudioBack: emit backReleased(); return; | 466 | case AudioBack: emit backReleased(); return; |
467 | } | 467 | } |
468 | } | 468 | } |
469 | } | 469 | } |
470 | } | 470 | } |
471 | } | 471 | } |
472 | 472 | ||
473 | 473 | ||
474 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 474 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
475 | mouseMoveEvent( event ); | 475 | mouseMoveEvent( event ); |
476 | } | 476 | } |
477 | 477 | ||
478 | 478 | ||
479 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 479 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
480 | mouseMoveEvent( event ); | 480 | mouseMoveEvent( event ); |
481 | } | 481 | } |
482 | 482 | ||
483 | 483 | ||
484 | void AudioWidget::showEvent( QShowEvent* ) { | 484 | void AudioWidget::showEvent( QShowEvent* ) { |
485 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 485 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
486 | mouseMoveEvent( &event ); | 486 | mouseMoveEvent( &event ); |
487 | } | 487 | } |
488 | 488 | ||
489 | 489 | ||
490 | void AudioWidget::closeEvent( QCloseEvent* ) { | 490 | void AudioWidget::closeEvent( QCloseEvent* ) { |
491 | mediaPlayerState->setList(); | 491 | mediaPlayerState->setList(); |
492 | } | 492 | } |
493 | 493 | ||
494 | 494 | ||
495 | void AudioWidget::paintEvent( QPaintEvent * pe) { | 495 | void AudioWidget::paintEvent( QPaintEvent * pe) { |
496 | if ( !pe->erased() ) { | 496 | if ( !pe->erased() ) { |
497 | // Combine with background and double buffer | 497 | // Combine with background and double buffer |
498 | QPixmap pix( pe->rect().size() ); | 498 | QPixmap pix( pe->rect().size() ); |
499 | QPainter p( &pix ); | 499 | QPainter p( &pix ); |
500 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 500 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
501 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 501 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
502 | for ( int i = 0; i < numButtons; i++ ) | 502 | for ( int i = 0; i < numButtons; i++ ) |
503 | paintButton( &p, i ); | 503 | paintButton( &p, i ); |
504 | QPainter p2( this ); | 504 | QPainter p2( this ); |
505 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 505 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
506 | } else { | 506 | } else { |
507 | QPainter p( this ); | 507 | QPainter p( this ); |
508 | for ( int i = 0; i < numButtons; i++ ) | 508 | for ( int i = 0; i < numButtons; i++ ) |
509 | paintButton( &p, i ); | 509 | paintButton( &p, i ); |
510 | } | 510 | } |
511 | } | 511 | } |
512 | 512 | ||
513 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) | 513 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) |
514 | { | 514 | { |
515 | switch ( e->key() ) { | 515 | switch ( e->key() ) { |
516 | ////////////////////////////// Zaurus keys | 516 | ////////////////////////////// Zaurus keys |
517 | case Key_Home: | 517 | case Key_Home: |
518 | break; | 518 | break; |
519 | case Key_F9: //activity | 519 | case Key_F9: //activity |
520 | hide(); | 520 | hide(); |
521 | // qDebug("Audio F9"); | 521 | // qDebug("Audio F9"); |
522 | break; | 522 | break; |
523 | case Key_F10: //contacts | 523 | case Key_F10: //contacts |
524 | break; | 524 | break; |
525 | case Key_F11: //menu | 525 | case Key_F11: //menu |
526 | break; | 526 | break; |
527 | case Key_F12: //home | 527 | case Key_F12: //home |
528 | break; | 528 | break; |
529 | case Key_F13: //mail | 529 | case Key_F13: //mail |
530 | break; | 530 | break; |
531 | case Key_Space: { | 531 | case Key_Space: { |
532 | if(mediaPlayerState->playing()) { | 532 | if(mediaPlayerState->playing()) { |
533 | // toggleButton(1); | 533 | // toggleButton(1); |
534 | mediaPlayerState->setPlaying(FALSE); | 534 | mediaPlayerState->setPlaying(FALSE); |
535 | // toggleButton(1); | 535 | // toggleButton(1); |
536 | } else { | 536 | } else { |
537 | // toggleButton(0); | 537 | // toggleButton(0); |
538 | mediaPlayerState->setPlaying(TRUE); | 538 | mediaPlayerState->setPlaying(TRUE); |
539 | // toggleButton(0); | 539 | // toggleButton(0); |
540 | } | 540 | } |
541 | } | 541 | } |
542 | break; | 542 | break; |
543 | case Key_Down: | 543 | case Key_Down: |
544 | toggleButton(6); | 544 | toggleButton(6); |
545 | emit lessClicked(); | 545 | emit lessClicked(); |
546 | emit lessReleased(); | 546 | emit lessReleased(); |
547 | toggleButton(6); | 547 | toggleButton(6); |
548 | break; | 548 | break; |
549 | case Key_Up: | 549 | case Key_Up: |
550 | toggleButton(5); | 550 | toggleButton(5); |
551 | emit moreClicked(); | 551 | emit moreClicked(); |
552 | emit moreReleased(); | 552 | emit moreReleased(); |
553 | toggleButton(5); | 553 | toggleButton(5); |
554 | break; | 554 | break; |
555 | case Key_Right: | 555 | case Key_Right: |
556 | // toggleButton(3); | 556 | // toggleButton(3); |
557 | mediaPlayerState->setNext(); | 557 | mediaPlayerState->setNext(); |
558 | // toggleButton(3); | 558 | // toggleButton(3); |
559 | break; | 559 | break; |
560 | case Key_Left: | 560 | case Key_Left: |
561 | // toggleButton(4); | 561 | // toggleButton(4); |
562 | mediaPlayerState->setPrev(); | 562 | mediaPlayerState->setPrev(); |
563 | // toggleButton(4); | 563 | // toggleButton(4); |
564 | break; | 564 | break; |
565 | case Key_Escape: | 565 | case Key_Escape: |
566 | break; | 566 | break; |
567 | 567 | ||
568 | }; | 568 | }; |
569 | } | 569 | } |
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 135c67c..57b1c81 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp | |||
@@ -1,269 +1,272 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qpe/qlibrary.h> | 2 | #include <qpe/qlibrary.h> |
3 | #include <qpe/config.h> | 3 | #include <qpe/config.h> |
4 | #include <qvaluelist.h> | 4 | #include <qvaluelist.h> |
5 | #include <qobject.h> | 5 | #include <qobject.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | #include "mediaplayerstate.h" | 7 | #include "mediaplayerstate.h" |
8 | 8 | ||
9 | 9 | ||
10 | 10 | ||
11 | //#define MediaPlayerDebug(x) qDebug x | 11 | //#define MediaPlayerDebug(x) qDebug x |
12 | #define MediaPlayerDebug(x) | 12 | #define MediaPlayerDebug(x) |
13 | 13 | ||
14 | 14 | ||
15 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 15 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
16 | : QObject( parent, name ) { | 16 | : QObject( parent, name ) { |
17 | Config cfg( "OpiePlayer" ); | 17 | Config cfg( "OpiePlayer" ); |
18 | readConfig( cfg ); | 18 | readConfig( cfg ); |
19 | 19 | ||
20 | } | 20 | } |
21 | 21 | ||
22 | 22 | ||
23 | MediaPlayerState::~MediaPlayerState() { | 23 | MediaPlayerState::~MediaPlayerState() { |
24 | Config cfg( "OpiePlayer" ); | 24 | Config cfg( "OpiePlayer" ); |
25 | writeConfig( cfg ); | 25 | writeConfig( cfg ); |
26 | 26 | ||
27 | } | 27 | } |
28 | 28 | ||
29 | 29 | ||
30 | void MediaPlayerState::readConfig( Config& cfg ) { | 30 | void MediaPlayerState::readConfig( Config& cfg ) { |
31 | cfg.setGroup("Options"); | 31 | cfg.setGroup("Options"); |
32 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); | 32 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); |
33 | isScaled = cfg.readBoolEntry( "Scaling" ); | 33 | isScaled = cfg.readBoolEntry( "Scaling" ); |
34 | isLooping = cfg.readBoolEntry( "Looping" ); | 34 | isLooping = cfg.readBoolEntry( "Looping" ); |
35 | isShuffled = cfg.readBoolEntry( "Shuffle" ); | 35 | isShuffled = cfg.readBoolEntry( "Shuffle" ); |
36 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); | 36 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); |
37 | usePlaylist = TRUE; | 37 | usePlaylist = TRUE; |
38 | isPlaying = FALSE; | 38 | isPlaying = FALSE; |
39 | isPaused = FALSE; | 39 | isPaused = FALSE; |
40 | curPosition = 0; | 40 | curPosition = 0; |
41 | curLength = 0; | 41 | curLength = 0; |
42 | curView = 'l'; | 42 | curView = 'l'; |
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
46 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 46 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
47 | cfg.setGroup("Options"); | 47 | cfg.setGroup("Options"); |
48 | cfg.writeEntry("FullScreen", isFullscreen ); | 48 | cfg.writeEntry("FullScreen", isFullscreen ); |
49 | cfg.writeEntry("Scaling", isScaled ); | 49 | cfg.writeEntry("Scaling", isScaled ); |
50 | cfg.writeEntry("Looping", isLooping ); | 50 | cfg.writeEntry("Looping", isLooping ); |
51 | cfg.writeEntry("Shuffle", isShuffled ); | 51 | cfg.writeEntry("Shuffle", isShuffled ); |
52 | cfg.writeEntry("UsePlayList", usePlaylist ); | 52 | cfg.writeEntry("UsePlayList", usePlaylist ); |
53 | } | 53 | } |
54 | 54 | ||
55 | 55 | ||
56 | 56 | ||
57 | 57 | ||
58 | // public stuff | 58 | // public stuff |
59 | 59 | ||
60 | 60 | ||
61 | bool MediaPlayerState::streaming() { | 61 | bool MediaPlayerState::streaming() { |
62 | return isStreaming; | 62 | return isStreaming; |
63 | } | 63 | } |
64 | 64 | ||
65 | bool MediaPlayerState::fullscreen() { | 65 | bool MediaPlayerState::fullscreen() { |
66 | return isFullscreen; | 66 | return isFullscreen; |
67 | } | 67 | } |
68 | 68 | ||
69 | bool MediaPlayerState::scaled() { | 69 | bool MediaPlayerState::scaled() { |
70 | return isScaled; | 70 | return isScaled; |
71 | } | 71 | } |
72 | 72 | ||
73 | bool MediaPlayerState::looping() { | 73 | bool MediaPlayerState::looping() { |
74 | return isLooping; | 74 | return isLooping; |
75 | } | 75 | } |
76 | 76 | ||
77 | bool MediaPlayerState::shuffled() { | 77 | bool MediaPlayerState::shuffled() { |
78 | return isShuffled; | 78 | return isShuffled; |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | bool MediaPlayerState:: playlist() { | 82 | bool MediaPlayerState:: playlist() { |
83 | return usePlaylist; | 83 | return usePlaylist; |
84 | } | 84 | } |
85 | 85 | ||
86 | bool MediaPlayerState::paused() { | 86 | bool MediaPlayerState::paused() { |
87 | return isPaused; | 87 | return isPaused; |
88 | } | 88 | } |
89 | 89 | ||
90 | bool MediaPlayerState::playing() { | 90 | bool MediaPlayerState::playing() { |
91 | return isPlaying; | 91 | return isPlaying; |
92 | } | 92 | } |
93 | 93 | ||
94 | bool MediaPlayerState::stop() { | 94 | bool MediaPlayerState::stop() { |
95 | return isStoped; | 95 | return isStoped; |
96 | } | 96 | } |
97 | 97 | ||
98 | long MediaPlayerState::position() { | 98 | long MediaPlayerState::position() { |
99 | return curPosition; | 99 | return curPosition; |
100 | } | 100 | } |
101 | 101 | ||
102 | long MediaPlayerState::length() { | 102 | long MediaPlayerState::length() { |
103 | return curLength; | 103 | return curLength; |
104 | } | 104 | } |
105 | 105 | ||
106 | char MediaPlayerState::view() { | 106 | char MediaPlayerState::view() { |
107 | return curView; | 107 | return curView; |
108 | } | 108 | } |
109 | 109 | ||
110 | // slots | 110 | // slots |
111 | void MediaPlayerState::setIsStreaming( bool b ) { | 111 | void MediaPlayerState::setIsStreaming( bool b ) { |
112 | 112 | ||
113 | if ( isStreaming == b ) { | 113 | if ( isStreaming == b ) { |
114 | return; | 114 | return; |
115 | } | 115 | } |
116 | isStreaming = b; | 116 | isStreaming = b; |
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | void MediaPlayerState::setFullscreen( bool b ) { | 120 | void MediaPlayerState::setFullscreen( bool b ) { |
121 | if ( isFullscreen == b ) { | 121 | if ( isFullscreen == b ) { |
122 | return; | 122 | return; |
123 | } | 123 | } |
124 | isFullscreen = b; | 124 | isFullscreen = b; |
125 | emit fullscreenToggled(b); | 125 | emit fullscreenToggled(b); |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | void MediaPlayerState::setScaled( bool b ) { | 129 | void MediaPlayerState::setScaled( bool b ) { |
130 | if ( isScaled == b ) { | 130 | if ( isScaled == b ) { |
131 | return; | 131 | return; |
132 | } | 132 | } |
133 | isScaled = b; | 133 | isScaled = b; |
134 | emit scaledToggled(b); | 134 | emit scaledToggled(b); |
135 | } | 135 | } |
136 | 136 | ||
137 | void MediaPlayerState::setLooping( bool b ) { | 137 | void MediaPlayerState::setLooping( bool b ) { |
138 | if ( isLooping == b ) { | 138 | if ( isLooping == b ) { |
139 | return; | 139 | return; |
140 | } | 140 | } |
141 | isLooping = b; | 141 | isLooping = b; |
142 | emit loopingToggled(b); | 142 | emit loopingToggled(b); |
143 | } | 143 | } |
144 | 144 | ||
145 | void MediaPlayerState::setShuffled( bool b ) { | 145 | void MediaPlayerState::setShuffled( bool b ) { |
146 | if ( isShuffled == b ) { | 146 | if ( isShuffled == b ) { |
147 | return; | 147 | return; |
148 | } | 148 | } |
149 | isShuffled = b; | 149 | isShuffled = b; |
150 | emit shuffledToggled(b); | 150 | emit shuffledToggled(b); |
151 | } | 151 | } |
152 | 152 | ||
153 | void MediaPlayerState::setPlaylist( bool b ) { | 153 | void MediaPlayerState::setPlaylist( bool b ) { |
154 | if ( usePlaylist == b ) { | 154 | if ( usePlaylist == b ) { |
155 | return; | 155 | return; |
156 | } | 156 | } |
157 | usePlaylist = b; | 157 | usePlaylist = b; |
158 | emit playlistToggled(b); | 158 | emit playlistToggled(b); |
159 | } | 159 | } |
160 | 160 | ||
161 | void MediaPlayerState::setPaused( bool b ) { | 161 | void MediaPlayerState::setPaused( bool b ) { |
162 | if(b) qDebug("setPaused true"); | ||
163 | else qDebug("setPaused false"); | ||
164 | |||
162 | if ( isPaused == b ) { | 165 | if ( isPaused == b ) { |
163 | return; | 166 | return; |
164 | } | 167 | } |
165 | isPaused = b; | 168 | isPaused = b; |
166 | emit pausedToggled(b); | 169 | emit pausedToggled(b); |
167 | } | 170 | } |
168 | 171 | ||
169 | void MediaPlayerState::setPlaying( bool b ) { | 172 | void MediaPlayerState::setPlaying( bool b ) { |
170 | if ( isPlaying == b ) { | 173 | if ( isPlaying == b ) { |
171 | return; | 174 | return; |
172 | } | 175 | } |
173 | isPlaying = b; | 176 | isPlaying = b; |
174 | isStoped = !b; | 177 | isStoped = !b; |
175 | emit playingToggled(b); | 178 | emit playingToggled(b); |
176 | } | 179 | } |
177 | 180 | ||
178 | void MediaPlayerState::setStop( bool b ) { | 181 | void MediaPlayerState::setStop( bool b ) { |
179 | if ( isStoped == b ) { | 182 | if ( isStoped == b ) { |
180 | return; | 183 | return; |
181 | } | 184 | } |
182 | isStoped = b; | 185 | isStoped = b; |
183 | emit stopToggled(b); | 186 | emit stopToggled(b); |
184 | } | 187 | } |
185 | 188 | ||
186 | void MediaPlayerState::setPosition( long p ) { | 189 | void MediaPlayerState::setPosition( long p ) { |
187 | if ( curPosition == p ) { | 190 | if ( curPosition == p ) { |
188 | return; | 191 | return; |
189 | } | 192 | } |
190 | curPosition = p; | 193 | curPosition = p; |
191 | emit positionChanged(p); | 194 | emit positionChanged(p); |
192 | } | 195 | } |
193 | 196 | ||
194 | void MediaPlayerState::updatePosition( long p ){ | 197 | void MediaPlayerState::updatePosition( long p ){ |
195 | if ( curPosition == p ) { | 198 | if ( curPosition == p ) { |
196 | return; | 199 | return; |
197 | } | 200 | } |
198 | curPosition = p; | 201 | curPosition = p; |
199 | emit positionUpdated(p); | 202 | emit positionUpdated(p); |
200 | } | 203 | } |
201 | 204 | ||
202 | void MediaPlayerState::setLength( long l ) { | 205 | void MediaPlayerState::setLength( long l ) { |
203 | if ( curLength == l ) { | 206 | if ( curLength == l ) { |
204 | return; | 207 | return; |
205 | } | 208 | } |
206 | curLength = l; | 209 | curLength = l; |
207 | emit lengthChanged(l); | 210 | emit lengthChanged(l); |
208 | } | 211 | } |
209 | 212 | ||
210 | void MediaPlayerState::setView( char v ) { | 213 | void MediaPlayerState::setView( char v ) { |
211 | if ( curView == v ) { | 214 | if ( curView == v ) { |
212 | return; | 215 | return; |
213 | } | 216 | } |
214 | curView = v; | 217 | curView = v; |
215 | emit viewChanged(v); | 218 | emit viewChanged(v); |
216 | } | 219 | } |
217 | 220 | ||
218 | void MediaPlayerState::setPrev(){ | 221 | void MediaPlayerState::setPrev(){ |
219 | emit prev(); | 222 | emit prev(); |
220 | } | 223 | } |
221 | 224 | ||
222 | void MediaPlayerState::setNext() { | 225 | void MediaPlayerState::setNext() { |
223 | emit next(); | 226 | emit next(); |
224 | } | 227 | } |
225 | 228 | ||
226 | void MediaPlayerState::setList() { | 229 | void MediaPlayerState::setList() { |
227 | setPlaying( FALSE ); | 230 | setPlaying( FALSE ); |
228 | setView('l'); | 231 | setView('l'); |
229 | } | 232 | } |
230 | 233 | ||
231 | void MediaPlayerState::setVideo() { | 234 | void MediaPlayerState::setVideo() { |
232 | setView('v'); | 235 | setView('v'); |
233 | } | 236 | } |
234 | 237 | ||
235 | void MediaPlayerState::setAudio() { | 238 | void MediaPlayerState::setAudio() { |
236 | setView('a'); | 239 | setView('a'); |
237 | } | 240 | } |
238 | 241 | ||
239 | void MediaPlayerState::toggleFullscreen() { | 242 | void MediaPlayerState::toggleFullscreen() { |
240 | setFullscreen( !isFullscreen ); | 243 | setFullscreen( !isFullscreen ); |
241 | } | 244 | } |
242 | 245 | ||
243 | void MediaPlayerState::toggleScaled() { | 246 | void MediaPlayerState::toggleScaled() { |
244 | setScaled( !isScaled); | 247 | setScaled( !isScaled); |
245 | } | 248 | } |
246 | 249 | ||
247 | void MediaPlayerState::toggleLooping() { | 250 | void MediaPlayerState::toggleLooping() { |
248 | setLooping( !isLooping); | 251 | setLooping( !isLooping); |
249 | } | 252 | } |
250 | 253 | ||
251 | void MediaPlayerState::toggleShuffled() { | 254 | void MediaPlayerState::toggleShuffled() { |
252 | setShuffled( !isShuffled); | 255 | setShuffled( !isShuffled); |
253 | } | 256 | } |
254 | 257 | ||
255 | void MediaPlayerState::togglePlaylist() { | 258 | void MediaPlayerState::togglePlaylist() { |
256 | setPlaylist( !usePlaylist); | 259 | setPlaylist( !usePlaylist); |
257 | } | 260 | } |
258 | 261 | ||
259 | void MediaPlayerState::togglePaused() { | 262 | void MediaPlayerState::togglePaused() { |
260 | setPaused( !isPaused); | 263 | setPaused( !isPaused); |
261 | } | 264 | } |
262 | 265 | ||
263 | void MediaPlayerState::togglePlaying() { | 266 | void MediaPlayerState::togglePlaying() { |
264 | setPlaying( !isPlaying); | 267 | setPlaying( !isPlaying); |
265 | } | 268 | } |
266 | 269 | ||
267 | 270 | ||
268 | 271 | ||
269 | 272 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index b43d9f7..65458e7 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1211 +1,1236 @@ | |||
1 | 1 | ||
2 | #define QTOPIA_INTERNAL_FSLP | 2 | #define QTOPIA_INTERNAL_FSLP |
3 | #include <qpe/qcopenvelope_qws.h> | 3 | #include <qpe/qcopenvelope_qws.h> |
4 | 4 | ||
5 | #include <qpe/qpemenubar.h> | 5 | #include <qpe/qpemenubar.h> |
6 | #include <qpe/qpetoolbar.h> | 6 | #include <qpe/qpetoolbar.h> |
7 | #include <qpe/fileselector.h> | 7 | #include <qpe/fileselector.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/lnkproperties.h> | 9 | #include <qpe/lnkproperties.h> |
10 | #include <qpe/storage.h> | 10 | #include <qpe/storage.h> |
11 | 11 | ||
12 | #include <qpe/applnk.h> | 12 | #include <qpe/applnk.h> |
13 | #include <qpopupmenu.h> | ||
13 | #include <qpe/config.h> | 14 | #include <qpe/config.h> |
14 | #include <qpe/global.h> | 15 | #include <qpe/global.h> |
15 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
16 | #include <qaction.h> | 17 | #include <qaction.h> |
17 | #include <qcursor.h> | 18 | #include <qcursor.h> |
18 | #include <qimage.h> | 19 | #include <qimage.h> |
19 | #include <qfile.h> | 20 | #include <qfile.h> |
20 | #include <qdir.h> | 21 | #include <qdir.h> |
21 | #include <qlayout.h> | 22 | #include <qlayout.h> |
22 | #include <qlabel.h> | 23 | #include <qlabel.h> |
23 | #include <qlist.h> | 24 | #include <qlist.h> |
24 | #include <qlistbox.h> | 25 | #include <qlistbox.h> |
25 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
26 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
27 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
28 | #include <qtabwidget.h> | 29 | #include <qtabwidget.h> |
29 | #include <qlistview.h> | 30 | #include <qlistview.h> |
30 | #include <qpoint.h> | 31 | #include <qpoint.h> |
31 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
32 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
33 | #include <qregexp.h> | 34 | #include <qregexp.h> |
34 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
35 | 36 | ||
36 | 37 | ||
37 | #include "playlistselection.h" | 38 | #include "playlistselection.h" |
38 | #include "playlistwidget.h" | 39 | #include "playlistwidget.h" |
39 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
40 | 41 | ||
41 | #include "inputDialog.h" | 42 | #include "inputDialog.h" |
42 | 43 | ||
43 | #include <stdlib.h> | 44 | #include <stdlib.h> |
44 | #include "audiowidget.h" | 45 | #include "audiowidget.h" |
45 | #include "videowidget.h" | 46 | #include "videowidget.h" |
46 | 47 | ||
47 | #include <unistd.h> | 48 | #include <unistd.h> |
48 | #include <sys/file.h> | 49 | #include <sys/file.h> |
49 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
50 | #include <sys/soundcard.h> | 51 | #include <sys/soundcard.h> |
51 | 52 | ||
52 | // for setBacklight() | 53 | // for setBacklight() |
53 | #include <linux/fb.h> | 54 | #include <linux/fb.h> |
54 | #include <sys/types.h> | 55 | #include <sys/types.h> |
55 | #include <sys/stat.h> | 56 | #include <sys/stat.h> |
56 | #include <stdlib.h> | 57 | #include <stdlib.h> |
57 | 58 | ||
58 | #define BUTTONS_ON_TOOLBAR | 59 | #define BUTTONS_ON_TOOLBAR |
59 | #define SIDE_BUTTONS | 60 | #define SIDE_BUTTONS |
60 | #define CAN_SAVE_LOAD_PLAYLISTS | 61 | #define CAN_SAVE_LOAD_PLAYLISTS |
61 | 62 | ||
62 | extern MediaPlayerState *mediaPlayerState; | 63 | extern MediaPlayerState *mediaPlayerState; |
63 | 64 | ||
64 | 65 | ||
65 | class PlayListWidgetPrivate { | 66 | class PlayListWidgetPrivate { |
66 | public: | 67 | public: |
67 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 68 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
68 | QFrame *playListFrame; | 69 | QFrame *playListFrame; |
69 | FileSelector *files; | 70 | FileSelector *files; |
70 | PlayListSelection *selectedFiles; | 71 | PlayListSelection *selectedFiles; |
71 | bool setDocumentUsed; | 72 | bool setDocumentUsed; |
72 | DocLnk *current; | 73 | DocLnk *current; |
73 | }; | 74 | }; |
74 | 75 | ||
75 | 76 | ||
76 | class ToolButton : public QToolButton { | 77 | class ToolButton : public QToolButton { |
77 | public: | 78 | public: |
78 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 79 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
79 | : QToolButton( parent, name ) { | 80 | : QToolButton( parent, name ) { |
80 | setTextLabel( name ); | 81 | setTextLabel( name ); |
81 | setPixmap( Resource::loadPixmap( icon ) ); | 82 | setPixmap( Resource::loadPixmap( icon ) ); |
82 | setAutoRaise( TRUE ); | 83 | setAutoRaise( TRUE ); |
83 | setFocusPolicy( QWidget::NoFocus ); | 84 | setFocusPolicy( QWidget::NoFocus ); |
84 | setToggleButton( t ); | 85 | setToggleButton( t ); |
85 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 86 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
86 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 87 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
87 | } | 88 | } |
88 | }; | 89 | }; |
89 | 90 | ||
90 | 91 | ||
91 | class MenuItem : public QAction { | 92 | class MenuItem : public QAction { |
92 | public: | 93 | public: |
93 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 94 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
94 | : QAction( text, QString::null, 0, 0 ) { | 95 | : QAction( text, QString::null, 0, 0 ) { |
95 | connect( this, SIGNAL( activated() ), handler, slot ); | 96 | connect( this, SIGNAL( activated() ), handler, slot ); |
96 | addTo( parent ); | 97 | addTo( parent ); |
97 | } | 98 | } |
98 | }; | 99 | }; |
99 | 100 | ||
100 | 101 | ||
101 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 102 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
102 | : QMainWindow( parent, name, fl ) { | 103 | : QMainWindow( parent, name, fl ) { |
103 | 104 | ||
104 | d = new PlayListWidgetPrivate; | 105 | d = new PlayListWidgetPrivate; |
105 | d->setDocumentUsed = FALSE; | 106 | d->setDocumentUsed = FALSE; |
106 | d->current = NULL; | 107 | d->current = NULL; |
107 | fromSetDocument = FALSE; | 108 | fromSetDocument = FALSE; |
108 | insanityBool=FALSE; | 109 | insanityBool=FALSE; |
109 | audioScan = FALSE; | 110 | audioScan = FALSE; |
110 | videoScan = FALSE; | 111 | videoScan = FALSE; |
111 | 112 | ||
112 | setBackgroundMode( PaletteButton ); | 113 | setBackgroundMode( PaletteButton ); |
113 | 114 | ||
114 | setCaption( tr("OpiePlayer") ); | 115 | setCaption( tr("OpiePlayer") ); |
115 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 116 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
116 | 117 | ||
117 | setToolBarsMovable( FALSE ); | 118 | setToolBarsMovable( FALSE ); |
118 | 119 | ||
119 | // Create Toolbar | 120 | // Create Toolbar |
120 | QPEToolBar *toolbar = new QPEToolBar( this ); | 121 | QPEToolBar *toolbar = new QPEToolBar( this ); |
121 | toolbar->setHorizontalStretchable( TRUE ); | 122 | toolbar->setHorizontalStretchable( TRUE ); |
122 | 123 | ||
123 | // Create Menubar | 124 | // Create Menubar |
124 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 125 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
125 | menu->setMargin( 0 ); | 126 | menu->setMargin( 0 ); |
126 | 127 | ||
127 | QPEToolBar *bar = new QPEToolBar( this ); | 128 | QPEToolBar *bar = new QPEToolBar( this ); |
128 | bar->setLabel( tr( "Play Operations" ) ); | 129 | bar->setLabel( tr( "Play Operations" ) ); |
129 | 130 | ||
130 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 131 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
131 | tbDeletePlaylist->setFlat(TRUE); | 132 | tbDeletePlaylist->setFlat(TRUE); |
132 | tbDeletePlaylist->setFixedSize(20,20); | 133 | tbDeletePlaylist->setFixedSize(20,20); |
133 | 134 | ||
134 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 135 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
135 | this , SLOT(addSelected()) ); | 136 | this , SLOT(addSelected()) ); |
136 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 137 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
137 | this , SLOT(removeSelected()) ); | 138 | this , SLOT(removeSelected()) ); |
138 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 139 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
139 | this , SLOT( btnPlay(bool) ), TRUE ); | 140 | this , SLOT( btnPlay(bool) ), TRUE ); |
140 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 141 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
141 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 142 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
142 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 143 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
143 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 144 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
144 | tbDeletePlaylist->hide(); | 145 | tbDeletePlaylist->hide(); |
145 | 146 | ||
146 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 147 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
147 | menu->insertItem( tr( "File" ), pmPlayList ); | 148 | menu->insertItem( tr( "File" ), pmPlayList ); |
148 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 149 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
149 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 150 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
150 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 151 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
151 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 152 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
152 | pmPlayList->insertSeparator(-1); | 153 | pmPlayList->insertSeparator(-1); |
153 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 154 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
154 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | 155 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); |
155 | pmPlayList->insertSeparator(-1); | 156 | pmPlayList->insertSeparator(-1); |
156 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 157 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
157 | pmPlayList->insertSeparator(-1); | 158 | pmPlayList->insertSeparator(-1); |
158 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 159 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
159 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 160 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
160 | 161 | ||
161 | QPopupMenu *pmView = new QPopupMenu( this ); | 162 | |
163 | pmView = new QPopupMenu( this ); | ||
162 | menu->insertItem( tr( "View" ), pmView ); | 164 | menu->insertItem( tr( "View" ), pmView ); |
165 | pmView->isCheckable(); | ||
166 | |||
167 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), this, SLOT( toggleFull() ) ); | ||
163 | 168 | ||
164 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 169 | Config cfg( "OpiePlayer" ); |
165 | fullScreenButton->addTo(pmView); | 170 | bool b= cfg.readBoolEntry("FullScreen", 0); |
166 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 171 | mediaPlayerState->setFullscreen( b ); |
167 | //scaleButton->addTo(pmView); | 172 | pmView->setItemChecked( -16, b ); |
173 | |||
174 | pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), this, SLOT(toggleScaled() ) ); | ||
168 | 175 | ||
169 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 176 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
170 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 177 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
171 | 178 | ||
172 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 179 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
173 | 180 | ||
174 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 181 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
175 | // tabWidget->setTabShape(QTabWidget::Triangular); | 182 | // tabWidget->setTabShape(QTabWidget::Triangular); |
176 | 183 | ||
177 | QWidget *pTab; | 184 | QWidget *pTab; |
178 | pTab = new QWidget( tabWidget, "pTab" ); | 185 | pTab = new QWidget( tabWidget, "pTab" ); |
179 | tabWidget->insertTab( pTab,"Playlist"); | 186 | tabWidget->insertTab( pTab,"Playlist"); |
180 | 187 | ||
181 | 188 | ||
182 | // Add the playlist area | 189 | // Add the playlist area |
183 | 190 | ||
184 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 191 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
185 | d->playListFrame = vbox3; | 192 | d->playListFrame = vbox3; |
186 | d->playListFrame ->setMinimumSize(235,260); | 193 | d->playListFrame ->setMinimumSize(235,260); |
187 | 194 | ||
188 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 195 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
189 | 196 | ||
190 | d->selectedFiles = new PlayListSelection( hbox2); | 197 | d->selectedFiles = new PlayListSelection( hbox2); |
191 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 198 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
192 | 199 | ||
193 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 200 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
194 | 201 | ||
195 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 202 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
196 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 203 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
197 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 204 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
198 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 205 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
199 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 206 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
200 | 207 | ||
201 | QWidget *aTab; | 208 | QWidget *aTab; |
202 | aTab = new QWidget( tabWidget, "aTab" ); | 209 | aTab = new QWidget( tabWidget, "aTab" ); |
203 | audioView = new QListView( aTab, "Audioview" ); | 210 | audioView = new QListView( aTab, "Audioview" ); |
204 | audioView->setMinimumSize(233,260); | 211 | audioView->setMinimumSize(233,260); |
205 | audioView->addColumn( tr("Title"),140); | 212 | audioView->addColumn( tr("Title"),140); |
206 | audioView->addColumn(tr("Size"), -1); | 213 | audioView->addColumn(tr("Size"), -1); |
207 | audioView->addColumn(tr("Media"),-1); | 214 | audioView->addColumn(tr("Media"),-1); |
208 | audioView->setColumnAlignment(1, Qt::AlignRight); | 215 | audioView->setColumnAlignment(1, Qt::AlignRight); |
209 | audioView->setColumnAlignment(2, Qt::AlignRight); | 216 | audioView->setColumnAlignment(2, Qt::AlignRight); |
210 | audioView->setAllColumnsShowFocus(TRUE); | 217 | audioView->setAllColumnsShowFocus(TRUE); |
211 | 218 | ||
212 | audioView->setMultiSelection( TRUE ); | 219 | audioView->setMultiSelection( TRUE ); |
213 | audioView->setSelectionMode( QListView::Extended); | 220 | audioView->setSelectionMode( QListView::Extended); |
214 | 221 | ||
215 | tabWidget->insertTab(aTab,tr("Audio")); | 222 | tabWidget->insertTab(aTab,tr("Audio")); |
216 | 223 | ||
217 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 224 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
218 | 225 | ||
219 | QWidget *vTab; | 226 | QWidget *vTab; |
220 | vTab = new QWidget( tabWidget, "vTab" ); | 227 | vTab = new QWidget( tabWidget, "vTab" ); |
221 | videoView = new QListView( vTab, "Videoview" ); | 228 | videoView = new QListView( vTab, "Videoview" ); |
222 | videoView->setMinimumSize(233,260); | 229 | videoView->setMinimumSize(233,260); |
223 | 230 | ||
224 | videoView->addColumn(tr("Title"),140); | 231 | videoView->addColumn(tr("Title"),140); |
225 | videoView->addColumn(tr("Size"),-1); | 232 | videoView->addColumn(tr("Size"),-1); |
226 | videoView->addColumn(tr("Media"),-1); | 233 | videoView->addColumn(tr("Media"),-1); |
227 | videoView->setColumnAlignment(1, Qt::AlignRight); | 234 | videoView->setColumnAlignment(1, Qt::AlignRight); |
228 | videoView->setColumnAlignment(2, Qt::AlignRight); | 235 | videoView->setColumnAlignment(2, Qt::AlignRight); |
229 | videoView->setAllColumnsShowFocus(TRUE); | 236 | videoView->setAllColumnsShowFocus(TRUE); |
230 | videoView->setMultiSelection( TRUE ); | 237 | videoView->setMultiSelection( TRUE ); |
231 | videoView->setSelectionMode( QListView::Extended); | 238 | videoView->setSelectionMode( QListView::Extended); |
232 | 239 | ||
233 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 240 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
234 | 241 | ||
235 | tabWidget->insertTab( vTab,tr("Video")); | 242 | tabWidget->insertTab( vTab,tr("Video")); |
236 | 243 | ||
237 | //playlists list | 244 | //playlists list |
238 | QWidget *LTab; | 245 | QWidget *LTab; |
239 | LTab = new QWidget( tabWidget, "LTab" ); | 246 | LTab = new QWidget( tabWidget, "LTab" ); |
240 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 247 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
241 | playLists->setMinimumSize(233,260); | 248 | playLists->setMinimumSize(233,260); |
242 | tabWidget->insertTab(LTab,tr("Lists")); | 249 | tabWidget->insertTab(LTab,tr("Lists")); |
243 | 250 | ||
244 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 251 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
245 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 252 | |
246 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 253 | connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); |
254 | |||
255 | // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); | ||
256 | |||
247 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 257 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
248 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 258 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
249 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 259 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 260 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
251 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 261 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
252 | this,SLOT( playIt( QListViewItem *)) ); | 262 | this,SLOT( playIt( QListViewItem *)) ); |
253 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 263 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
254 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 264 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
255 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 265 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
256 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 266 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
257 | this,SLOT( playIt( QListViewItem *)) ); | 267 | this,SLOT( playIt( QListViewItem *)) ); |
258 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 268 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
259 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 269 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
260 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 270 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
261 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 271 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
262 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 272 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
263 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 273 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
264 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 274 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
265 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 275 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
266 | 276 | ||
267 | setCentralWidget( vbox5 ); | 277 | setCentralWidget( vbox5 ); |
268 | 278 | ||
269 | Config cfg( "OpiePlayer" ); | ||
270 | readConfig( cfg ); | 279 | readConfig( cfg ); |
271 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 280 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
272 | loadList(DocLnk( currentPlaylist)); | 281 | loadList(DocLnk( currentPlaylist)); |
273 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 282 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
274 | 283 | ||
275 | initializeStates(); | 284 | initializeStates(); |
276 | } | 285 | } |
277 | 286 | ||
278 | 287 | ||
279 | PlayListWidget::~PlayListWidget() { | 288 | PlayListWidget::~PlayListWidget() { |
280 | Config cfg( "OpiePlayer" ); | 289 | Config cfg( "OpiePlayer" ); |
281 | writeConfig( cfg ); | 290 | writeConfig( cfg ); |
282 | 291 | ||
283 | if ( d->current ) { | 292 | if ( d->current ) { |
284 | delete d->current; | 293 | delete d->current; |
285 | } | 294 | } |
286 | delete d; | 295 | delete d; |
287 | } | 296 | } |
288 | 297 | ||
289 | 298 | ||
290 | void PlayListWidget::initializeStates() { | 299 | void PlayListWidget::initializeStates() { |
291 | 300 | ||
292 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 301 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
293 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 302 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
294 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 303 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
295 | setPlaylist( true); | 304 | setPlaylist( true); |
296 | } | 305 | } |
297 | 306 | ||
298 | 307 | ||
299 | void PlayListWidget::readConfig( Config& cfg ) { | 308 | void PlayListWidget::readConfig( Config& cfg ) { |
300 | cfg.setGroup("PlayList"); | 309 | cfg.setGroup("PlayList"); |
301 | QString currentString = cfg.readEntry("current", "" ); | 310 | QString currentString = cfg.readEntry("current", "" ); |
302 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 311 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
303 | for ( int i = 0; i < noOfFiles; i++ ) { | 312 | for ( int i = 0; i < noOfFiles; i++ ) { |
304 | QString entryName; | 313 | QString entryName; |
305 | entryName.sprintf( "File%i", i + 1 ); | 314 | entryName.sprintf( "File%i", i + 1 ); |
306 | QString linkFile = cfg.readEntry( entryName ); | 315 | QString linkFile = cfg.readEntry( entryName ); |
307 | DocLnk lnk( linkFile ); | 316 | DocLnk lnk( linkFile ); |
308 | if ( lnk.isValid() ) { | 317 | if ( lnk.isValid() ) { |
309 | d->selectedFiles->addToSelection( lnk ); | 318 | d->selectedFiles->addToSelection( lnk ); |
310 | } | 319 | } |
311 | } | 320 | } |
312 | d->selectedFiles->setSelectedItem( currentString); | 321 | d->selectedFiles->setSelectedItem( currentString); |
313 | } | 322 | } |
314 | 323 | ||
315 | 324 | ||
316 | void PlayListWidget::writeConfig( Config& cfg ) const { | 325 | void PlayListWidget::writeConfig( Config& cfg ) const { |
317 | 326 | ||
318 | d->selectedFiles->writeCurrent( cfg); | 327 | d->selectedFiles->writeCurrent( cfg); |
319 | cfg.setGroup("PlayList"); | 328 | cfg.setGroup("PlayList"); |
320 | int noOfFiles = 0; | 329 | int noOfFiles = 0; |
321 | d->selectedFiles->first(); | 330 | d->selectedFiles->first(); |
322 | do { | 331 | do { |
323 | const DocLnk *lnk = d->selectedFiles->current(); | 332 | const DocLnk *lnk = d->selectedFiles->current(); |
324 | if ( lnk ) { | 333 | if ( lnk ) { |
325 | QString entryName; | 334 | QString entryName; |
326 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 335 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
327 | cfg.writeEntry( entryName, lnk->linkFile() ); | 336 | cfg.writeEntry( entryName, lnk->linkFile() ); |
328 | // if this link does exist, add it so we have the file | 337 | // if this link does exist, add it so we have the file |
329 | // next time... | 338 | // next time... |
330 | if ( !QFile::exists( lnk->linkFile() ) ) { | 339 | if ( !QFile::exists( lnk->linkFile() ) ) { |
331 | // the way writing lnks doesn't really check for out | 340 | // the way writing lnks doesn't really check for out |
332 | // of disk space, but check it anyway. | 341 | // of disk space, but check it anyway. |
333 | if ( !lnk->writeLink() ) { | 342 | if ( !lnk->writeLink() ) { |
334 | QMessageBox::critical( 0, tr("Out of space"), | 343 | QMessageBox::critical( 0, tr("Out of space"), |
335 | tr( "There was a problem saving " | 344 | tr( "There was a problem saving " |
336 | "the playlist.\n" | 345 | "the playlist.\n" |
337 | "Your playlist " | 346 | "Your playlist " |
338 | "may be missing some entries\n" | 347 | "may be missing some entries\n" |
339 | "the next time you start it." ) | 348 | "the next time you start it." ) |
340 | ); | 349 | ); |
341 | } | 350 | } |
342 | } | 351 | } |
343 | noOfFiles++; | 352 | noOfFiles++; |
344 | } | 353 | } |
345 | } | 354 | } |
346 | while ( d->selectedFiles->next() ); | 355 | while ( d->selectedFiles->next() ); |
347 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 356 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
348 | } | 357 | } |
349 | 358 | ||
350 | 359 | ||
351 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 360 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
352 | d->setDocumentUsed = FALSE; | 361 | d->setDocumentUsed = FALSE; |
353 | if ( mediaPlayerState->playlist() ) { | 362 | if ( mediaPlayerState->playlist() ) { |
354 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 363 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
355 | d->selectedFiles->addToSelection( lnk ); | 364 | d->selectedFiles->addToSelection( lnk ); |
356 | } | 365 | } |
357 | else | 366 | else |
358 | mediaPlayerState->setPlaying( TRUE ); | 367 | mediaPlayerState->setPlaying( TRUE ); |
359 | } | 368 | } |
360 | 369 | ||
361 | 370 | ||
362 | void PlayListWidget::clearList() { | 371 | void PlayListWidget::clearList() { |
363 | while ( first() ) { | 372 | while ( first() ) { |
364 | d->selectedFiles->removeSelected(); | 373 | d->selectedFiles->removeSelected(); |
365 | } | 374 | } |
366 | } | 375 | } |
367 | 376 | ||
368 | 377 | ||
369 | void PlayListWidget::addAllToList() { | 378 | void PlayListWidget::addAllToList() { |
370 | DocLnkSet filesAll; | 379 | DocLnkSet filesAll; |
371 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 380 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
372 | QListIterator<DocLnk> Adit( filesAll.children() ); | 381 | QListIterator<DocLnk> Adit( filesAll.children() ); |
373 | for ( ; Adit.current(); ++Adit ) { | 382 | for ( ; Adit.current(); ++Adit ) { |
374 | if(QFileInfo(Adit.current()->file()).exists()) { | 383 | if(QFileInfo(Adit.current()->file()).exists()) { |
375 | d->selectedFiles->addToSelection( **Adit ); | 384 | d->selectedFiles->addToSelection( **Adit ); |
376 | } | 385 | } |
377 | } | 386 | } |
378 | } | 387 | } |
379 | 388 | ||
380 | 389 | ||
381 | void PlayListWidget::addAllMusicToList() { | 390 | void PlayListWidget::addAllMusicToList() { |
382 | QListIterator<DocLnk> dit( files.children() ); | 391 | QListIterator<DocLnk> dit( files.children() ); |
383 | for ( ; dit.current(); ++dit ) { | 392 | for ( ; dit.current(); ++dit ) { |
384 | if(QFileInfo(dit.current()->file()).exists()) { | 393 | if(QFileInfo(dit.current()->file()).exists()) { |
385 | d->selectedFiles->addToSelection( **dit ); | 394 | d->selectedFiles->addToSelection( **dit ); |
386 | } | 395 | } |
387 | } | 396 | } |
388 | } | 397 | } |
389 | 398 | ||
390 | 399 | ||
391 | void PlayListWidget::addAllVideoToList() { | 400 | void PlayListWidget::addAllVideoToList() { |
392 | QListIterator<DocLnk> dit( vFiles.children() ); | 401 | QListIterator<DocLnk> dit( vFiles.children() ); |
393 | for ( ; dit.current(); ++dit ) | 402 | for ( ; dit.current(); ++dit ) |
394 | if(QFileInfo( dit.current()->file()).exists()) | 403 | if(QFileInfo( dit.current()->file()).exists()) |
395 | d->selectedFiles->addToSelection( **dit ); | 404 | d->selectedFiles->addToSelection( **dit ); |
396 | } | 405 | } |
397 | 406 | ||
398 | 407 | ||
399 | void PlayListWidget::setDocument(const QString& fileref) { | 408 | void PlayListWidget::setDocument(const QString& fileref) { |
400 | qDebug(fileref); | 409 | qDebug(fileref); |
401 | fromSetDocument = TRUE; | 410 | fromSetDocument = TRUE; |
402 | if ( fileref.isNull() ) { | 411 | if ( fileref.isNull() ) { |
403 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 412 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
404 | return; | 413 | return; |
405 | } | 414 | } |
406 | 415 | ||
407 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 416 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
408 | readm3u( fileref); | 417 | readm3u( fileref); |
409 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 418 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
410 | readPls( fileref); | 419 | readPls( fileref); |
411 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 420 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
412 | clearList(); | 421 | clearList(); |
413 | loadList(DocLnk(fileref)); | 422 | loadList(DocLnk(fileref)); |
414 | d->selectedFiles->first(); | 423 | d->selectedFiles->first(); |
415 | } else { | 424 | } else { |
416 | clearList(); | 425 | clearList(); |
417 | addToSelection( DocLnk( fileref ) ); | 426 | addToSelection( DocLnk( fileref ) ); |
418 | d->setDocumentUsed = TRUE; | 427 | d->setDocumentUsed = TRUE; |
419 | mediaPlayerState->setPlaying( FALSE ); | 428 | mediaPlayerState->setPlaying( FALSE ); |
420 | qApp->processEvents(); | 429 | qApp->processEvents(); |
421 | mediaPlayerState->setPlaying( TRUE ); | 430 | mediaPlayerState->setPlaying( TRUE ); |
422 | qApp->processEvents(); | 431 | qApp->processEvents(); |
423 | setCaption(tr("OpiePlayer")); | 432 | setCaption(tr("OpiePlayer")); |
424 | } | 433 | } |
425 | } | 434 | } |
426 | 435 | ||
427 | 436 | ||
428 | void PlayListWidget::setActiveWindow() { | 437 | void PlayListWidget::setActiveWindow() { |
429 | qDebug("SETTING active window"); | 438 | qDebug("SETTING active window"); |
430 | // When we get raised we need to ensure that it switches views | 439 | // When we get raised we need to ensure that it switches views |
431 | char origView = mediaPlayerState->view(); | 440 | char origView = mediaPlayerState->view(); |
432 | mediaPlayerState->setView( 'l' ); // invalidate | 441 | mediaPlayerState->setView( 'l' ); // invalidate |
433 | mediaPlayerState->setView( origView ); // now switch back | 442 | mediaPlayerState->setView( origView ); // now switch back |
434 | } | 443 | } |
435 | 444 | ||
436 | 445 | ||
437 | void PlayListWidget::useSelectedDocument() { | 446 | void PlayListWidget::useSelectedDocument() { |
438 | d->setDocumentUsed = FALSE; | 447 | d->setDocumentUsed = FALSE; |
439 | } | 448 | } |
440 | 449 | ||
441 | 450 | ||
442 | const DocLnk *PlayListWidget::current() { // this is fugly | 451 | const DocLnk *PlayListWidget::current() { // this is fugly |
443 | 452 | ||
444 | switch (tabWidget->currentPageIndex()) { | 453 | switch (tabWidget->currentPageIndex()) { |
445 | case 0: //playlist | 454 | case 0: //playlist |
446 | { | 455 | { |
447 | qDebug("playlist"); | 456 | qDebug("playlist"); |
448 | if ( mediaPlayerState->playlist() ) { | 457 | if ( mediaPlayerState->playlist() ) { |
449 | return d->selectedFiles->current(); | 458 | return d->selectedFiles->current(); |
450 | } else if ( d->setDocumentUsed && d->current ) { | 459 | } else if ( d->setDocumentUsed && d->current ) { |
451 | return d->current; | 460 | return d->current; |
452 | } else { | 461 | } else { |
453 | return d->files->selected(); | 462 | return d->files->selected(); |
454 | } | 463 | } |
455 | } | 464 | } |
456 | break; | 465 | break; |
457 | case 1://audio | 466 | case 1://audio |
458 | { | 467 | { |
459 | qDebug("audioView"); | 468 | qDebug("audioView"); |
460 | QListIterator<DocLnk> dit( files.children() ); | 469 | QListIterator<DocLnk> dit( files.children() ); |
461 | for ( ; dit.current(); ++dit ) { | 470 | for ( ; dit.current(); ++dit ) { |
462 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 471 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
463 | qDebug("here"); | 472 | qDebug("here"); |
464 | insanityBool=TRUE; | 473 | insanityBool=TRUE; |
465 | return dit; | 474 | return dit; |
466 | } | 475 | } |
467 | } | 476 | } |
468 | } | 477 | } |
469 | break; | 478 | break; |
470 | case 2: // video | 479 | case 2: // video |
471 | { | 480 | { |
472 | qDebug("videoView"); | 481 | qDebug("videoView"); |
473 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 482 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
474 | for ( ; Vdit.current(); ++Vdit ) { | 483 | for ( ; Vdit.current(); ++Vdit ) { |
475 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 484 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
476 | insanityBool=TRUE; | 485 | insanityBool=TRUE; |
477 | return Vdit; | 486 | return Vdit; |
478 | } | 487 | } |
479 | } | 488 | } |
480 | } | 489 | } |
481 | break; | 490 | break; |
482 | }; | 491 | }; |
483 | return 0; | 492 | return 0; |
484 | } | 493 | } |
485 | 494 | ||
486 | bool PlayListWidget::prev() { | 495 | bool PlayListWidget::prev() { |
487 | if ( mediaPlayerState->playlist() ) { | 496 | if ( mediaPlayerState->playlist() ) { |
488 | if ( mediaPlayerState->shuffled() ) { | 497 | if ( mediaPlayerState->shuffled() ) { |
489 | const DocLnk *cur = current(); | 498 | const DocLnk *cur = current(); |
490 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 499 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
491 | for ( int i = 0; i < j; i++ ) { | 500 | for ( int i = 0; i < j; i++ ) { |
492 | if ( !d->selectedFiles->next() ) | 501 | if ( !d->selectedFiles->next() ) |
493 | d->selectedFiles->first(); | 502 | d->selectedFiles->first(); |
494 | } | 503 | } |
495 | if ( cur == current() ) | 504 | if ( cur == current() ) |
496 | if ( !d->selectedFiles->next() ) | 505 | if ( !d->selectedFiles->next() ) |
497 | d->selectedFiles->first(); | 506 | d->selectedFiles->first(); |
498 | return TRUE; | 507 | return TRUE; |
499 | } else { | 508 | } else { |
500 | if ( !d->selectedFiles->prev() ) { | 509 | if ( !d->selectedFiles->prev() ) { |
501 | if ( mediaPlayerState->looping() ) { | 510 | if ( mediaPlayerState->looping() ) { |
502 | return d->selectedFiles->last(); | 511 | return d->selectedFiles->last(); |
503 | } else { | 512 | } else { |
504 | return FALSE; | 513 | return FALSE; |
505 | } | 514 | } |
506 | } | 515 | } |
507 | return TRUE; | 516 | return TRUE; |
508 | } | 517 | } |
509 | } else { | 518 | } else { |
510 | return mediaPlayerState->looping(); | 519 | return mediaPlayerState->looping(); |
511 | } | 520 | } |
512 | } | 521 | } |
513 | 522 | ||
514 | 523 | ||
515 | bool PlayListWidget::next() { | 524 | bool PlayListWidget::next() { |
516 | if ( mediaPlayerState->playlist() ) { | 525 | if ( mediaPlayerState->playlist() ) { |
517 | if ( mediaPlayerState->shuffled() ) { | 526 | if ( mediaPlayerState->shuffled() ) { |
518 | return prev(); | 527 | return prev(); |
519 | } else { | 528 | } else { |
520 | if ( !d->selectedFiles->next() ) { | 529 | if ( !d->selectedFiles->next() ) { |
521 | if ( mediaPlayerState->looping() ) { | 530 | if ( mediaPlayerState->looping() ) { |
522 | return d->selectedFiles->first(); | 531 | return d->selectedFiles->first(); |
523 | } else { | 532 | } else { |
524 | return FALSE; | 533 | return FALSE; |
525 | } | 534 | } |
526 | } | 535 | } |
527 | return TRUE; | 536 | return TRUE; |
528 | } | 537 | } |
529 | } else { | 538 | } else { |
530 | return mediaPlayerState->looping(); | 539 | return mediaPlayerState->looping(); |
531 | } | 540 | } |
532 | } | 541 | } |
533 | 542 | ||
534 | 543 | ||
535 | bool PlayListWidget::first() { | 544 | bool PlayListWidget::first() { |
536 | if ( mediaPlayerState->playlist() ) | 545 | if ( mediaPlayerState->playlist() ) |
537 | return d->selectedFiles->first(); | 546 | return d->selectedFiles->first(); |
538 | else | 547 | else |
539 | return mediaPlayerState->looping(); | 548 | return mediaPlayerState->looping(); |
540 | } | 549 | } |
541 | 550 | ||
542 | 551 | ||
543 | bool PlayListWidget::last() { | 552 | bool PlayListWidget::last() { |
544 | if ( mediaPlayerState->playlist() ) | 553 | if ( mediaPlayerState->playlist() ) |
545 | return d->selectedFiles->last(); | 554 | return d->selectedFiles->last(); |
546 | else | 555 | else |
547 | return mediaPlayerState->looping(); | 556 | return mediaPlayerState->looping(); |
548 | } | 557 | } |
549 | 558 | ||
550 | 559 | ||
551 | void PlayListWidget::saveList() { | 560 | void PlayListWidget::saveList() { |
552 | 561 | ||
553 | QString filename; | 562 | QString filename; |
554 | InputDialog *fileDlg; | 563 | InputDialog *fileDlg; |
555 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 564 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
556 | fileDlg->exec(); | 565 | fileDlg->exec(); |
557 | if( fileDlg->result() == 1 ) { | 566 | if( fileDlg->result() == 1 ) { |
558 | if ( d->current ) | 567 | if ( d->current ) |
559 | delete d->current; | 568 | delete d->current; |
560 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 569 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
561 | // qDebug("saving playlist "+filename+".playlist"); | 570 | // qDebug("saving playlist "+filename+".playlist"); |
562 | Config cfg( filename +".playlist"); | 571 | Config cfg( filename +".playlist"); |
563 | writeConfig( cfg ); | 572 | writeConfig( cfg ); |
564 | 573 | ||
565 | DocLnk lnk; | 574 | DocLnk lnk; |
566 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 575 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
567 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 576 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
568 | lnk.setIcon("opieplayer/playlist2"); | 577 | lnk.setIcon("opieplayer/playlist2"); |
569 | lnk.setName( filename); //sets file name | 578 | lnk.setName( filename); //sets file name |
570 | // qDebug(filename); | 579 | // qDebug(filename); |
571 | if(!lnk.writeLink()) { | 580 | if(!lnk.writeLink()) { |
572 | qDebug("Writing doclink did not work"); | 581 | qDebug("Writing doclink did not work"); |
573 | } | 582 | } |
574 | } | 583 | } |
575 | Config config( "OpiePlayer" ); | 584 | Config config( "OpiePlayer" ); |
576 | config.writeEntry("CurrentPlaylist",filename); | 585 | config.writeEntry("CurrentPlaylist",filename); |
577 | setCaption(tr("OpiePlayer: ")+filename); | 586 | setCaption(tr("OpiePlayer: ")+filename); |
578 | d->selectedFiles->first(); | 587 | d->selectedFiles->first(); |
579 | if(fileDlg) { | 588 | if(fileDlg) { |
580 | delete fileDlg; | 589 | delete fileDlg; |
581 | } | 590 | } |
582 | } | 591 | } |
583 | 592 | ||
584 | void PlayListWidget::loadList( const DocLnk & lnk) { | 593 | void PlayListWidget::loadList( const DocLnk & lnk) { |
585 | QString name= lnk.name(); | 594 | QString name= lnk.name(); |
586 | // qDebug("currentList is "+name); | 595 | // qDebug("currentList is "+name); |
587 | if( name.length()>1) { | 596 | if( name.length()>1) { |
588 | setCaption("OpiePlayer: "+name); | 597 | setCaption("OpiePlayer: "+name); |
589 | // qDebug("load list "+ name+".playlist"); | 598 | // qDebug("load list "+ name+".playlist"); |
590 | clearList(); | 599 | clearList(); |
591 | Config cfg( name+".playlist"); | 600 | Config cfg( name+".playlist"); |
592 | readConfig(cfg); | 601 | readConfig(cfg); |
593 | 602 | ||
594 | tabWidget->setCurrentPage(0); | 603 | tabWidget->setCurrentPage(0); |
595 | 604 | ||
596 | Config config( "OpiePlayer" ); | 605 | Config config( "OpiePlayer" ); |
597 | config.writeEntry("CurrentPlaylist", name); | 606 | config.writeEntry("CurrentPlaylist", name); |
598 | // d->selectedFiles->first(); | 607 | // d->selectedFiles->first(); |
599 | } | 608 | } |
600 | 609 | ||
601 | } | 610 | } |
602 | 611 | ||
603 | void PlayListWidget::setPlaylist( bool shown ) { | 612 | void PlayListWidget::setPlaylist( bool shown ) { |
604 | if ( shown ) { | 613 | if ( shown ) { |
605 | d->playListFrame->show(); | 614 | d->playListFrame->show(); |
606 | } else { | 615 | } else { |
607 | d->playListFrame->hide(); | 616 | d->playListFrame->hide(); |
608 | } | 617 | } |
609 | } | 618 | } |
610 | 619 | ||
611 | void PlayListWidget::setView( char view ) { | 620 | void PlayListWidget::setView( char view ) { |
612 | if ( view == 'l' ) | 621 | if ( view == 'l' ) |
613 | showMaximized(); | 622 | showMaximized(); |
614 | else | 623 | else |
615 | hide(); | 624 | hide(); |
616 | } | 625 | } |
617 | 626 | ||
618 | void PlayListWidget::addSelected() { | 627 | void PlayListWidget::addSelected() { |
619 | 628 | ||
620 | Config cfg( "OpiePlayer" ); | 629 | Config cfg( "OpiePlayer" ); |
621 | cfg.setGroup("PlayList"); | 630 | cfg.setGroup("PlayList"); |
622 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 631 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
623 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 632 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
624 | 633 | ||
625 | switch (tabWidget->currentPageIndex()) { | 634 | switch (tabWidget->currentPageIndex()) { |
626 | case 0: //playlist | 635 | case 0: //playlist |
627 | break; | 636 | break; |
628 | case 1: { //audio | 637 | case 1: { //audio |
629 | QListViewItemIterator it( audioView ); | 638 | QListViewItemIterator it( audioView ); |
630 | // iterate through all items of the listview | 639 | // iterate through all items of the listview |
631 | for ( ; it.current(); ++it ) { | 640 | for ( ; it.current(); ++it ) { |
632 | if ( it.current()->isSelected() ) { | 641 | if ( it.current()->isSelected() ) { |
633 | QListIterator<DocLnk> dit( files.children() ); | 642 | QListIterator<DocLnk> dit( files.children() ); |
634 | for ( ; dit.current(); ++dit ) { | 643 | for ( ; dit.current(); ++dit ) { |
635 | if( dit.current()->name() == it.current()->text(0) ) { | 644 | if( dit.current()->name() == it.current()->text(0) ) { |
636 | d->selectedFiles->addToSelection( **dit ); | 645 | d->selectedFiles->addToSelection( **dit ); |
637 | } | 646 | } |
638 | } | 647 | } |
639 | audioView->setSelected( it.current(),FALSE); | 648 | audioView->setSelected( it.current(),FALSE); |
640 | } | 649 | } |
641 | } | 650 | } |
642 | tabWidget->setCurrentPage(0); | 651 | tabWidget->setCurrentPage(0); |
643 | } | 652 | } |
644 | break; | 653 | break; |
645 | case 2: { // video | 654 | case 2: { // video |
646 | QListViewItemIterator it( videoView ); | 655 | QListViewItemIterator it( videoView ); |
647 | // iterate through all items of the listview | 656 | // iterate through all items of the listview |
648 | for ( ; it.current(); ++it ) { | 657 | for ( ; it.current(); ++it ) { |
649 | if ( it.current()->isSelected() ) { | 658 | if ( it.current()->isSelected() ) { |
650 | QListIterator<DocLnk> dit( vFiles.children() ); | 659 | QListIterator<DocLnk> dit( vFiles.children() ); |
651 | for ( ; dit.current(); ++dit ) { | 660 | for ( ; dit.current(); ++dit ) { |
652 | if( dit.current()->name() == it.current()->text(0) ) { | 661 | if( dit.current()->name() == it.current()->text(0) ) { |
653 | d->selectedFiles->addToSelection( **dit ); | 662 | d->selectedFiles->addToSelection( **dit ); |
654 | } | 663 | } |
655 | } | 664 | } |
656 | videoView->setSelected( it.current(),FALSE); | 665 | videoView->setSelected( it.current(),FALSE); |
657 | } | 666 | } |
658 | } | 667 | } |
659 | tabWidget->setCurrentPage(0); | 668 | tabWidget->setCurrentPage(0); |
660 | } | 669 | } |
661 | break; | 670 | break; |
662 | }; | 671 | }; |
663 | } | 672 | } |
664 | 673 | ||
665 | void PlayListWidget::removeSelected() { | 674 | void PlayListWidget::removeSelected() { |
666 | d->selectedFiles->removeSelected( ); | 675 | d->selectedFiles->removeSelected( ); |
667 | } | 676 | } |
668 | 677 | ||
669 | void PlayListWidget::playIt( QListViewItem *it) { | 678 | void PlayListWidget::playIt( QListViewItem *it) { |
670 | qDebug("playIt"); | 679 | qDebug("playIt"); |
671 | mediaPlayerState->setPlaying(FALSE); | 680 | mediaPlayerState->setPlaying(FALSE); |
672 | mediaPlayerState->setPlaying(TRUE); | 681 | mediaPlayerState->setPlaying(TRUE); |
673 | d->selectedFiles->unSelect(); | 682 | d->selectedFiles->unSelect(); |
674 | } | 683 | } |
675 | 684 | ||
676 | void PlayListWidget::addToSelection( QListViewItem *it) { | 685 | void PlayListWidget::addToSelection( QListViewItem *it) { |
677 | d->setDocumentUsed = FALSE; | 686 | d->setDocumentUsed = FALSE; |
678 | 687 | ||
679 | if(it) { | 688 | if(it) { |
680 | switch (tabWidget->currentPageIndex()) { | 689 | switch (tabWidget->currentPageIndex()) { |
681 | case 1: { | 690 | case 1: { |
682 | QListIterator<DocLnk> dit( files.children() ); | 691 | QListIterator<DocLnk> dit( files.children() ); |
683 | for ( ; dit.current(); ++dit ) { | 692 | for ( ; dit.current(); ++dit ) { |
684 | if( dit.current()->name() == it->text(0)) { | 693 | if( dit.current()->name() == it->text(0)) { |
685 | d->selectedFiles->addToSelection( **dit ); | 694 | d->selectedFiles->addToSelection( **dit ); |
686 | } | 695 | } |
687 | } | 696 | } |
688 | } | 697 | } |
689 | break; | 698 | break; |
690 | case 2: { | 699 | case 2: { |
691 | QListIterator<DocLnk> dit( vFiles.children() ); | 700 | QListIterator<DocLnk> dit( vFiles.children() ); |
692 | for ( ; dit.current(); ++dit ) { | 701 | for ( ; dit.current(); ++dit ) { |
693 | if( dit.current()->name() == it->text(0)) { | 702 | if( dit.current()->name() == it->text(0)) { |
694 | d->selectedFiles->addToSelection( **dit ); | 703 | d->selectedFiles->addToSelection( **dit ); |
695 | } | 704 | } |
696 | } | 705 | } |
697 | } | 706 | } |
698 | break; | 707 | break; |
699 | case 0: | 708 | case 0: |
700 | break; | 709 | break; |
701 | }; | 710 | }; |
702 | tabWidget->setCurrentPage(0); | 711 | tabWidget->setCurrentPage(0); |
703 | } | 712 | } |
704 | } | 713 | } |
705 | 714 | ||
706 | void PlayListWidget::tabChanged(QWidget *widg) { | 715 | void PlayListWidget::tabChanged(QWidget *widg) { |
707 | 716 | ||
708 | switch ( tabWidget->currentPageIndex()) { | 717 | switch ( tabWidget->currentPageIndex()) { |
709 | case 0: | 718 | case 0: |
710 | { | 719 | { |
711 | if( !tbDeletePlaylist->isHidden()) | 720 | if( !tbDeletePlaylist->isHidden()) |
712 | tbDeletePlaylist->hide(); | 721 | tbDeletePlaylist->hide(); |
713 | d->tbRemoveFromList->setEnabled(TRUE); | 722 | d->tbRemoveFromList->setEnabled(TRUE); |
714 | d->tbAddToList->setEnabled(FALSE); | 723 | d->tbAddToList->setEnabled(FALSE); |
715 | } | 724 | } |
716 | break; | 725 | break; |
717 | case 1: | 726 | case 1: |
718 | { | 727 | { |
719 | audioView->clear(); | 728 | audioView->clear(); |
720 | populateAudioView(); | 729 | populateAudioView(); |
721 | 730 | ||
722 | if( !tbDeletePlaylist->isHidden()) | 731 | if( !tbDeletePlaylist->isHidden()) |
723 | tbDeletePlaylist->hide(); | 732 | tbDeletePlaylist->hide(); |
724 | d->tbRemoveFromList->setEnabled(FALSE); | 733 | d->tbRemoveFromList->setEnabled(FALSE); |
725 | d->tbAddToList->setEnabled(TRUE); | 734 | d->tbAddToList->setEnabled(TRUE); |
726 | } | 735 | } |
727 | break; | 736 | break; |
728 | case 2: | 737 | case 2: |
729 | { | 738 | { |
730 | videoView->clear(); | 739 | videoView->clear(); |
731 | populateVideoView(); | 740 | populateVideoView(); |
732 | if( !tbDeletePlaylist->isHidden()) | 741 | if( !tbDeletePlaylist->isHidden()) |
733 | tbDeletePlaylist->hide(); | 742 | tbDeletePlaylist->hide(); |
734 | d->tbRemoveFromList->setEnabled(FALSE); | 743 | d->tbRemoveFromList->setEnabled(FALSE); |
735 | d->tbAddToList->setEnabled(TRUE); | 744 | d->tbAddToList->setEnabled(TRUE); |
736 | } | 745 | } |
737 | break; | 746 | break; |
738 | case 3: | 747 | case 3: |
739 | { | 748 | { |
740 | if( tbDeletePlaylist->isHidden()) | 749 | if( tbDeletePlaylist->isHidden()) |
741 | tbDeletePlaylist->show(); | 750 | tbDeletePlaylist->show(); |
742 | playLists->reread(); | 751 | playLists->reread(); |
743 | } | 752 | } |
744 | break; | 753 | break; |
745 | }; | 754 | }; |
746 | } | 755 | } |
747 | 756 | ||
748 | void PlayListWidget::btnPlay(bool b) { | 757 | void PlayListWidget::btnPlay(bool b) { |
749 | 758 | ||
750 | // mediaPlayerState->setPlaying(b); | 759 | // mediaPlayerState->setPlaying(b); |
751 | switch ( tabWidget->currentPageIndex()) { | 760 | switch ( tabWidget->currentPageIndex()) { |
752 | case 0: | 761 | case 0: |
753 | { | 762 | { |
754 | mediaPlayerState->setPlaying(b); | 763 | mediaPlayerState->setPlaying(b); |
755 | } | 764 | } |
756 | break; | 765 | break; |
757 | case 1: | 766 | case 1: |
758 | { | 767 | { |
759 | addToSelection( audioView->currentItem() ); | 768 | addToSelection( audioView->currentItem() ); |
760 | mediaPlayerState->setPlaying(b); | 769 | mediaPlayerState->setPlaying(b); |
761 | d->selectedFiles->removeSelected( ); | 770 | d->selectedFiles->removeSelected( ); |
762 | tabWidget->setCurrentPage(1); | 771 | tabWidget->setCurrentPage(1); |
763 | d->selectedFiles->unSelect(); | 772 | d->selectedFiles->unSelect(); |
764 | insanityBool=FALSE; | 773 | insanityBool=FALSE; |
765 | }// audioView->clearSelection(); | 774 | }// audioView->clearSelection(); |
766 | break; | 775 | break; |
767 | case 2: | 776 | case 2: |
768 | { | 777 | { |
769 | addToSelection( videoView->currentItem() ); | 778 | addToSelection( videoView->currentItem() ); |
770 | mediaPlayerState->setPlaying(b); | 779 | mediaPlayerState->setPlaying(b); |
771 | qApp->processEvents(); | 780 | qApp->processEvents(); |
772 | d->selectedFiles->removeSelected( ); | 781 | d->selectedFiles->removeSelected( ); |
773 | tabWidget->setCurrentPage(2); | 782 | tabWidget->setCurrentPage(2); |
774 | d->selectedFiles->unSelect(); | 783 | d->selectedFiles->unSelect(); |
775 | insanityBool=FALSE; | 784 | insanityBool=FALSE; |
776 | }// videoView->clearSelection(); | 785 | }// videoView->clearSelection(); |
777 | break; | 786 | break; |
778 | }; | 787 | }; |
779 | 788 | ||
780 | } | 789 | } |
781 | 790 | ||
782 | void PlayListWidget::deletePlaylist() { | 791 | void PlayListWidget::deletePlaylist() { |
783 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 792 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
784 | (tr("You really want to delete\nthis playlist?")), | 793 | (tr("You really want to delete\nthis playlist?")), |
785 | (tr("Yes")), (tr("No")), 0 )){ | 794 | (tr("Yes")), (tr("No")), 0 )){ |
786 | case 0: // Yes clicked, | 795 | case 0: // Yes clicked, |
787 | QFile().remove(playLists->selected()->file()); | 796 | QFile().remove(playLists->selected()->file()); |
788 | QFile().remove(playLists->selected()->linkFile()); | 797 | QFile().remove(playLists->selected()->linkFile()); |
789 | playLists->reread(); | 798 | playLists->reread(); |
790 | break; | 799 | break; |
791 | case 1: // Cancel | 800 | case 1: // Cancel |
792 | break; | 801 | break; |
793 | }; | 802 | }; |
794 | } | 803 | } |
795 | 804 | ||
796 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { | 805 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { |
797 | switch (mouse) { | 806 | switch (mouse) { |
798 | case 1: | 807 | case 1: |
799 | break; | 808 | break; |
800 | case 2:{ | 809 | case 2:{ |
801 | QPopupMenu m; | 810 | QPopupMenu m; |
802 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 811 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
803 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 812 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
804 | m.insertSeparator(); | 813 | m.insertSeparator(); |
805 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 814 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
806 | m.exec( QCursor::pos() ); | 815 | m.exec( QCursor::pos() ); |
807 | } | 816 | } |
808 | break; | 817 | break; |
809 | }; | 818 | }; |
810 | } | 819 | } |
811 | 820 | ||
812 | void PlayListWidget::playSelected() { | 821 | void PlayListWidget::playSelected() { |
813 | btnPlay( TRUE); | 822 | btnPlay( TRUE); |
814 | } | 823 | } |
815 | 824 | ||
816 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { | 825 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { |
817 | switch (mouse) { | 826 | switch (mouse) { |
818 | case 1: | 827 | case 1: |
819 | 828 | ||
820 | break; | 829 | break; |
821 | case 2: | 830 | case 2: |
822 | { | 831 | { |
823 | QPopupMenu m; | 832 | QPopupMenu m; |
824 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 833 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
825 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 834 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
826 | m.exec( QCursor::pos() ); | 835 | m.exec( QCursor::pos() ); |
827 | } | 836 | } |
828 | break; | 837 | break; |
829 | }; | 838 | }; |
830 | } | 839 | } |
831 | 840 | ||
832 | void PlayListWidget::listDelete() { | 841 | void PlayListWidget::listDelete() { |
833 | Config cfg( "OpiePlayer" ); | 842 | Config cfg( "OpiePlayer" ); |
834 | cfg.setGroup("PlayList"); | 843 | cfg.setGroup("PlayList"); |
835 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 844 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
836 | QString file; | 845 | QString file; |
837 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 846 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
838 | switch ( tabWidget->currentPageIndex()) { | 847 | switch ( tabWidget->currentPageIndex()) { |
839 | case 0: | 848 | case 0: |
840 | break; | 849 | break; |
841 | case 1: | 850 | case 1: |
842 | { | 851 | { |
843 | file = audioView->currentItem()->text(0); | 852 | file = audioView->currentItem()->text(0); |
844 | QListIterator<DocLnk> Pdit( files.children() ); | 853 | QListIterator<DocLnk> Pdit( files.children() ); |
845 | for ( ; Pdit.current(); ++Pdit ) { | 854 | for ( ; Pdit.current(); ++Pdit ) { |
846 | if( Pdit.current()->name() == file) { | 855 | if( Pdit.current()->name() == file) { |
847 | LnkProperties prop( Pdit.current() ); | 856 | LnkProperties prop( Pdit.current() ); |
848 | prop.showMaximized(); | 857 | prop.showMaximized(); |
849 | prop.exec(); | 858 | prop.exec(); |
850 | } | 859 | } |
851 | } | 860 | } |
852 | populateAudioView(); | 861 | populateAudioView(); |
853 | } | 862 | } |
854 | break; | 863 | break; |
855 | case 2: | 864 | case 2: |
856 | { | 865 | { |
857 | 866 | ||
858 | } | 867 | } |
859 | break; | 868 | break; |
860 | }; | 869 | }; |
861 | } | 870 | } |
862 | 871 | ||
863 | void PlayListWidget::scanForAudio() { | 872 | void PlayListWidget::scanForAudio() { |
864 | qDebug("scan for audio"); | 873 | qDebug("scan for audio"); |
865 | files.detachChildren(); | 874 | files.detachChildren(); |
866 | QListIterator<DocLnk> sdit( files.children() ); | 875 | QListIterator<DocLnk> sdit( files.children() ); |
867 | for ( ; sdit.current(); ++sdit ) { | 876 | for ( ; sdit.current(); ++sdit ) { |
868 | delete sdit.current(); | 877 | delete sdit.current(); |
869 | } | 878 | } |
870 | Global::findDocuments(&files, "audio/*"); | 879 | Global::findDocuments(&files, "audio/*"); |
871 | audioScan = TRUE; | 880 | audioScan = TRUE; |
872 | } | 881 | } |
873 | void PlayListWidget::scanForVideo() { | 882 | void PlayListWidget::scanForVideo() { |
874 | qDebug("scan for video"); | 883 | qDebug("scan for video"); |
875 | vFiles.detachChildren(); | 884 | vFiles.detachChildren(); |
876 | QListIterator<DocLnk> sdit( vFiles.children() ); | 885 | QListIterator<DocLnk> sdit( vFiles.children() ); |
877 | for ( ; sdit.current(); ++sdit ) { | 886 | for ( ; sdit.current(); ++sdit ) { |
878 | delete sdit.current(); | 887 | delete sdit.current(); |
879 | } | 888 | } |
880 | Global::findDocuments(&vFiles, "video/*"); | 889 | Global::findDocuments(&vFiles, "video/*"); |
881 | videoScan = TRUE; | 890 | videoScan = TRUE; |
882 | } | 891 | } |
883 | 892 | ||
884 | void PlayListWidget::populateAudioView() { | 893 | void PlayListWidget::populateAudioView() { |
885 | 894 | ||
886 | audioView->clear(); | 895 | audioView->clear(); |
887 | StorageInfo storageInfo; | 896 | StorageInfo storageInfo; |
888 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 897 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
889 | if(!audioScan) scanForAudio(); | 898 | if(!audioScan) scanForAudio(); |
890 | 899 | ||
891 | QListIterator<DocLnk> dit( files.children() ); | 900 | QListIterator<DocLnk> dit( files.children() ); |
892 | QListIterator<FileSystem> it ( fs ); | 901 | QListIterator<FileSystem> it ( fs ); |
893 | 902 | ||
894 | QString storage; | 903 | QString storage; |
895 | for ( ; dit.current(); ++dit ) { | 904 | for ( ; dit.current(); ++dit ) { |
896 | for( ; it.current(); ++it ){ | 905 | for( ; it.current(); ++it ){ |
897 | const QString name = (*it)->name(); | 906 | const QString name = (*it)->name(); |
898 | const QString path = (*it)->path(); | 907 | const QString path = (*it)->path(); |
899 | if(dit.current()->file().find(path) != -1 ) storage=name; | 908 | if(dit.current()->file().find(path) != -1 ) storage=name; |
900 | } | 909 | } |
901 | 910 | ||
902 | QListViewItem * newItem; | 911 | QListViewItem * newItem; |
903 | if ( QFile( dit.current()->file()).exists() ) { | 912 | if ( QFile( dit.current()->file()).exists() ) { |
904 | // qDebug(dit.current()->name()); | 913 | // qDebug(dit.current()->name()); |
905 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 914 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
906 | QString::number( QFile( dit.current()->file()).size() ), storage); | 915 | QString::number( QFile( dit.current()->file()).size() ), storage); |
907 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 916 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
908 | } | 917 | } |
909 | } | 918 | } |
910 | 919 | ||
911 | } | 920 | } |
912 | 921 | ||
913 | void PlayListWidget::populateVideoView() { | 922 | void PlayListWidget::populateVideoView() { |
914 | videoView->clear(); | 923 | videoView->clear(); |
915 | StorageInfo storageInfo; | 924 | StorageInfo storageInfo; |
916 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 925 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
917 | 926 | ||
918 | if(!videoScan ) scanForVideo(); | 927 | if(!videoScan ) scanForVideo(); |
919 | 928 | ||
920 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 929 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
921 | QListIterator<FileSystem> it ( fs ); | 930 | QListIterator<FileSystem> it ( fs ); |
922 | videoView->clear(); | 931 | videoView->clear(); |
923 | QString storage; | 932 | QString storage; |
924 | for ( ; Vdit.current(); ++Vdit ) { | 933 | for ( ; Vdit.current(); ++Vdit ) { |
925 | for( ; it.current(); ++it ){ | 934 | for( ; it.current(); ++it ){ |
926 | const QString name = (*it)->name(); | 935 | const QString name = (*it)->name(); |
927 | const QString path = (*it)->path(); | 936 | const QString path = (*it)->path(); |
928 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 937 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
929 | } | 938 | } |
930 | 939 | ||
931 | QListViewItem * newItem; | 940 | QListViewItem * newItem; |
932 | if ( QFile( Vdit.current()->file()).exists() ) { | 941 | if ( QFile( Vdit.current()->file()).exists() ) { |
933 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 942 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
934 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 943 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
935 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 944 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
936 | } | 945 | } |
937 | } | 946 | } |
938 | } | 947 | } |
939 | 948 | ||
940 | void PlayListWidget::openFile() { | 949 | void PlayListWidget::openFile() { |
941 | QString filename, name; | 950 | QString filename, name; |
942 | InputDialog *fileDlg; | 951 | InputDialog *fileDlg; |
943 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 952 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
944 | fileDlg->exec(); | 953 | fileDlg->exec(); |
945 | if( fileDlg->result() == 1 ) { | 954 | if( fileDlg->result() == 1 ) { |
946 | filename = fileDlg->LineEdit1->text(); | 955 | filename = fileDlg->LineEdit1->text(); |
947 | 956 | ||
948 | qDebug("Selected filename is "+filename); | 957 | qDebug("Selected filename is "+filename); |
949 | if(filename.right(3) == "m3u") { | 958 | if(filename.right(3) == "m3u") { |
950 | readm3u( filename ); | 959 | readm3u( filename ); |
951 | } else if(filename.right(3) == "pls") { | 960 | } else if(filename.right(3) == "pls") { |
952 | readPls( filename ); | 961 | readPls( filename ); |
953 | } else { | 962 | } else { |
954 | DocLnk lnk; | 963 | DocLnk lnk; |
955 | 964 | ||
956 | lnk.setName(filename); //sets file name | 965 | lnk.setName(filename); //sets file name |
957 | lnk.setFile(filename); //sets File property | 966 | lnk.setFile(filename); //sets File property |
958 | lnk.setType("audio/x-mpegurl"); | 967 | lnk.setType("audio/x-mpegurl"); |
959 | lnk.setExec("opieplayer"); | 968 | lnk.setExec("opieplayer"); |
960 | lnk.setIcon("opieplayer/MPEGPlayer"); | 969 | lnk.setIcon("opieplayer/MPEGPlayer"); |
961 | 970 | ||
962 | if(!lnk.writeLink()) { | 971 | if(!lnk.writeLink()) { |
963 | qDebug("Writing doclink did not work"); | 972 | qDebug("Writing doclink did not work"); |
964 | } | 973 | } |
965 | d->selectedFiles->addToSelection( lnk); | 974 | d->selectedFiles->addToSelection( lnk); |
966 | } | 975 | } |
967 | } | 976 | } |
968 | if(fileDlg) { | 977 | if(fileDlg) { |
969 | delete fileDlg; | 978 | delete fileDlg; |
970 | } | 979 | } |
971 | } | 980 | } |
972 | 981 | ||
973 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 982 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
974 | { | 983 | { |
975 | switch ( e->key() ) { | 984 | switch ( e->key() ) { |
976 | ////////////////////////////// Zaurus keys | 985 | ////////////////////////////// Zaurus keys |
977 | case Key_F9: //activity | 986 | case Key_F9: //activity |
978 | // if(audioUI->isHidden()) | 987 | // if(audioUI->isHidden()) |
979 | // audioUI->showMaximized(); | 988 | // audioUI->showMaximized(); |
980 | break; | 989 | break; |
981 | case Key_F10: //contacts | 990 | case Key_F10: //contacts |
982 | // if( videoUI->isHidden()) | 991 | // if( videoUI->isHidden()) |
983 | // videoUI->showMaximized(); | 992 | // videoUI->showMaximized(); |
984 | break; | 993 | break; |
985 | case Key_F11: //menu | 994 | case Key_F11: //menu |
986 | break; | 995 | break; |
987 | case Key_F12: //home | 996 | case Key_F12: //home |
988 | // doBlank(); | 997 | // doBlank(); |
989 | break; | 998 | break; |
990 | case Key_F13: //mail | 999 | case Key_F13: //mail |
991 | // doUnblank(); | 1000 | // doUnblank(); |
992 | break; | 1001 | break; |
993 | case Key_Q: //add to playlist | 1002 | case Key_Q: //add to playlist |
994 | qDebug("Add"); | 1003 | qDebug("Add"); |
995 | addSelected(); | 1004 | addSelected(); |
996 | break; | 1005 | break; |
997 | case Key_R: //remove from playlist | 1006 | case Key_R: //remove from playlist |
998 | removeSelected(); | 1007 | removeSelected(); |
999 | break; | 1008 | break; |
1000 | // case Key_P: //play | 1009 | // case Key_P: //play |
1001 | // qDebug("Play"); | 1010 | // qDebug("Play"); |
1002 | // playSelected(); | 1011 | // playSelected(); |
1003 | // break; | 1012 | // break; |
1004 | case Key_Space: | 1013 | case Key_Space: |
1005 | qDebug("Play"); | 1014 | qDebug("Play"); |
1006 | // playSelected(); puh | 1015 | // playSelected(); puh |
1007 | break; | 1016 | break; |
1008 | case Key_1: | 1017 | case Key_1: |
1009 | tabWidget->setCurrentPage(0); | 1018 | tabWidget->setCurrentPage(0); |
1010 | break; | 1019 | break; |
1011 | case Key_2: | 1020 | case Key_2: |
1012 | tabWidget->setCurrentPage(1); | 1021 | tabWidget->setCurrentPage(1); |
1013 | break; | 1022 | break; |
1014 | case Key_3: | 1023 | case Key_3: |
1015 | tabWidget->setCurrentPage(2); | 1024 | tabWidget->setCurrentPage(2); |
1016 | break; | 1025 | break; |
1017 | case Key_4: | 1026 | case Key_4: |
1018 | tabWidget->setCurrentPage(3); | 1027 | tabWidget->setCurrentPage(3); |
1019 | break; | 1028 | break; |
1020 | case Key_Down: | 1029 | case Key_Down: |
1021 | if ( !d->selectedFiles->next() ) | 1030 | if ( !d->selectedFiles->next() ) |
1022 | d->selectedFiles->first(); | 1031 | d->selectedFiles->first(); |
1023 | 1032 | ||
1024 | break; | 1033 | break; |
1025 | case Key_Up: | 1034 | case Key_Up: |
1026 | if ( !d->selectedFiles->prev() ) | 1035 | if ( !d->selectedFiles->prev() ) |
1027 | // d->selectedFiles->last(); | 1036 | // d->selectedFiles->last(); |
1028 | 1037 | ||
1029 | break; | 1038 | break; |
1030 | 1039 | ||
1031 | } | 1040 | } |
1032 | } | 1041 | } |
1033 | 1042 | ||
1034 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | 1043 | void PlayListWidget::keyPressEvent( QKeyEvent *e) |
1035 | { | 1044 | { |
1036 | // qDebug("Key press"); | 1045 | // qDebug("Key press"); |
1037 | // switch ( e->key() ) { | 1046 | // switch ( e->key() ) { |
1038 | // ////////////////////////////// Zaurus keys | 1047 | // ////////////////////////////// Zaurus keys |
1039 | // case Key_A: //add to playlist | 1048 | // case Key_A: //add to playlist |
1040 | // qDebug("Add"); | 1049 | // qDebug("Add"); |
1041 | // addSelected(); | 1050 | // addSelected(); |
1042 | // break; | 1051 | // break; |
1043 | // case Key_R: //remove from playlist | 1052 | // case Key_R: //remove from playlist |
1044 | // removeSelected(); | 1053 | // removeSelected(); |
1045 | // break; | 1054 | // break; |
1046 | // case Key_P: //play | 1055 | // case Key_P: //play |
1047 | // qDebug("Play"); | 1056 | // qDebug("Play"); |
1048 | // playSelected(); | 1057 | // playSelected(); |
1049 | // break; | 1058 | // break; |
1050 | // case Key_Space: | 1059 | // case Key_Space: |
1051 | // qDebug("Play"); | 1060 | // qDebug("Play"); |
1052 | // playSelected(); | 1061 | // playSelected(); |
1053 | // break; | 1062 | // break; |
1054 | // } | 1063 | // } |
1055 | } | 1064 | } |
1056 | 1065 | ||
1057 | void PlayListWidget::doBlank() { | 1066 | void PlayListWidget::doBlank() { |
1058 | qDebug("do blanking"); | 1067 | qDebug("do blanking"); |
1059 | fd=open("/dev/fb0",O_RDWR); | 1068 | fd=open("/dev/fb0",O_RDWR); |
1060 | if (fd != -1) { | 1069 | if (fd != -1) { |
1061 | ioctl(fd,FBIOBLANK,1); | 1070 | ioctl(fd,FBIOBLANK,1); |
1062 | // close(fd); | 1071 | // close(fd); |
1063 | } | 1072 | } |
1064 | } | 1073 | } |
1065 | 1074 | ||
1066 | void PlayListWidget::doUnblank() { | 1075 | void PlayListWidget::doUnblank() { |
1067 | // this crashes opieplayer with a segfault | 1076 | // this crashes opieplayer with a segfault |
1068 | // int fd; | 1077 | // int fd; |
1069 | // fd=open("/dev/fb0",O_RDWR); | 1078 | // fd=open("/dev/fb0",O_RDWR); |
1070 | qDebug("do unblanking"); | 1079 | qDebug("do unblanking"); |
1071 | if (fd != -1) { | 1080 | if (fd != -1) { |
1072 | ioctl(fd,FBIOBLANK,0); | 1081 | ioctl(fd,FBIOBLANK,0); |
1073 | close(fd); | 1082 | close(fd); |
1074 | } | 1083 | } |
1075 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1084 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1076 | h <<-3;// v[1]; // -3 Force on | 1085 | h <<-3;// v[1]; // -3 Force on |
1077 | } | 1086 | } |
1078 | 1087 | ||
1079 | void PlayListWidget::readm3u(const QString &filename) { | 1088 | void PlayListWidget::readm3u(const QString &filename) { |
1080 | 1089 | ||
1081 | qDebug("m3u filename is "+filename); | 1090 | qDebug("m3u filename is "+filename); |
1082 | QFile f(filename); | 1091 | QFile f(filename); |
1083 | 1092 | ||
1084 | if(f.open(IO_ReadOnly)) { | 1093 | if(f.open(IO_ReadOnly)) { |
1085 | QTextStream t(&f); | 1094 | QTextStream t(&f); |
1086 | QString s;//, first, second; | 1095 | QString s;//, first, second; |
1087 | int i=0; | 1096 | int i=0; |
1088 | while ( !t.atEnd()) { | 1097 | while ( !t.atEnd()) { |
1089 | s=t.readLine(); | 1098 | s=t.readLine(); |
1090 | 1099 | ||
1091 | if(s.find("#",0,TRUE) == -1) { | 1100 | if(s.find("#",0,TRUE) == -1) { |
1092 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1101 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1093 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1102 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1094 | s=s.right(s.length()-2); | 1103 | s=s.right(s.length()-2); |
1095 | DocLnk lnk( s ); | 1104 | DocLnk lnk( s ); |
1096 | QFileInfo f(s); | 1105 | QFileInfo f(s); |
1097 | QString name = f.baseName(); | 1106 | QString name = f.baseName(); |
1098 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 1107 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
1099 | lnk.setName( name ); | 1108 | lnk.setName( name ); |
1100 | s=s.replace( QRegExp("\\"),"/"); | 1109 | s=s.replace( QRegExp("\\"),"/"); |
1101 | lnk.setFile( s ); | 1110 | lnk.setFile( s ); |
1102 | lnk.writeLink(); | 1111 | lnk.writeLink(); |
1103 | qDebug("add "+name); | 1112 | qDebug("add "+name); |
1104 | d->selectedFiles->addToSelection( lnk); | 1113 | d->selectedFiles->addToSelection( lnk); |
1105 | } else { // is url | 1114 | } else { // is url |
1106 | s.replace(QRegExp("%20")," "); | 1115 | s.replace(QRegExp("%20")," "); |
1107 | DocLnk lnk( s ); | 1116 | DocLnk lnk( s ); |
1108 | QString name; | 1117 | QString name; |
1109 | if(name.left(4)=="http") { | 1118 | if(name.left(4)=="http") { |
1110 | name = s.right( s.length() - 7); | 1119 | name = s.right( s.length() - 7); |
1111 | } else { | 1120 | } else { |
1112 | name = s; | 1121 | name = s; |
1113 | } | 1122 | } |
1114 | lnk.setName(name); | 1123 | lnk.setName(name); |
1115 | if(s.at(s.length()-4) == '.') { | 1124 | if(s.at(s.length()-4) == '.') { |
1116 | lnk.setFile( s); | 1125 | lnk.setFile( s); |
1117 | } else { | 1126 | } else { |
1118 | lnk.setFile( s+"/"); | 1127 | lnk.setFile( s+"/"); |
1119 | } | 1128 | } |
1120 | lnk.setType("audio/x-mpegurl"); | 1129 | lnk.setType("audio/x-mpegurl"); |
1121 | lnk.writeLink(); | 1130 | lnk.writeLink(); |
1122 | d->selectedFiles->addToSelection( lnk); | 1131 | d->selectedFiles->addToSelection( lnk); |
1123 | } | 1132 | } |
1124 | i++; | 1133 | i++; |
1125 | } | 1134 | } |
1126 | } | 1135 | } |
1127 | } | 1136 | } |
1128 | } | 1137 | } |
1129 | f.close(); | 1138 | f.close(); |
1130 | } | 1139 | } |
1131 | 1140 | ||
1132 | void PlayListWidget::writem3u() { | 1141 | void PlayListWidget::writem3u() { |
1133 | 1142 | ||
1134 | InputDialog *fileDlg; | 1143 | InputDialog *fileDlg; |
1135 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | 1144 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); |
1136 | fileDlg->exec(); | 1145 | fileDlg->exec(); |
1137 | QString filename,list; | 1146 | QString filename,list; |
1138 | if( fileDlg->result() == 1 ) { | 1147 | if( fileDlg->result() == 1 ) { |
1139 | filename = fileDlg->LineEdit1->text(); | 1148 | filename = fileDlg->LineEdit1->text(); |
1140 | qDebug(filename); | 1149 | qDebug(filename); |
1141 | int noOfFiles = 0; | 1150 | int noOfFiles = 0; |
1142 | d->selectedFiles->first(); | 1151 | d->selectedFiles->first(); |
1143 | do { | 1152 | do { |
1144 | // we dont check for existance because of url's | 1153 | // we dont check for existance because of url's |
1145 | // qDebug(d->selectedFiles->current()->file()); | 1154 | // qDebug(d->selectedFiles->current()->file()); |
1146 | list += d->selectedFiles->current()->file()+"\n"; | 1155 | list += d->selectedFiles->current()->file()+"\n"; |
1147 | noOfFiles++; | 1156 | noOfFiles++; |
1148 | } | 1157 | } |
1149 | while ( d->selectedFiles->next() ); | 1158 | while ( d->selectedFiles->next() ); |
1150 | qDebug(list); | 1159 | qDebug(list); |
1151 | if(filename.left(1) != "/") | 1160 | if(filename.left(1) != "/") |
1152 | filename=QPEApplication::documentDir()+"/"+filename; | 1161 | filename=QPEApplication::documentDir()+"/"+filename; |
1153 | if(filename.right(3) != "m3u") | 1162 | if(filename.right(3) != "m3u") |
1154 | filename=filename+".m3u"; | 1163 | filename=filename+".m3u"; |
1155 | 1164 | ||
1156 | QFile f(filename); | 1165 | QFile f(filename); |
1157 | f.open(IO_WriteOnly); | 1166 | f.open(IO_WriteOnly); |
1158 | f.writeBlock(list, list.length()); | 1167 | f.writeBlock(list, list.length()); |
1159 | f.close(); | 1168 | f.close(); |
1160 | } | 1169 | } |
1161 | if(fileDlg) delete fileDlg; | 1170 | if(fileDlg) delete fileDlg; |
1162 | } | 1171 | } |
1163 | 1172 | ||
1164 | void PlayListWidget::readPls(const QString &filename) { | 1173 | void PlayListWidget::readPls(const QString &filename) { |
1165 | 1174 | ||
1166 | qDebug("pls filename is "+filename); | 1175 | qDebug("pls filename is "+filename); |
1167 | QFile f(filename); | 1176 | QFile f(filename); |
1168 | 1177 | ||
1169 | if(f.open(IO_ReadOnly)) { | 1178 | if(f.open(IO_ReadOnly)) { |
1170 | QTextStream t(&f); | 1179 | QTextStream t(&f); |
1171 | QString s;//, first, second; | 1180 | QString s;//, first, second; |
1172 | int i=0; | 1181 | int i=0; |
1173 | while ( !t.atEnd()) { | 1182 | while ( !t.atEnd()) { |
1174 | s=t.readLine(); | 1183 | s=t.readLine(); |
1175 | if(s.left(4) == "File") { | 1184 | if(s.left(4) == "File") { |
1176 | s=s.right(s.length() - 6); | 1185 | s=s.right(s.length() - 6); |
1177 | s.replace(QRegExp("%20")," "); | 1186 | s.replace(QRegExp("%20")," "); |
1178 | qDebug("adding "+s+" to playlist"); | 1187 | qDebug("adding "+s+" to playlist"); |
1179 | // numberofentries=2 | 1188 | // numberofentries=2 |
1180 | // File1=http | 1189 | // File1=http |
1181 | // Title | 1190 | // Title |
1182 | // Length | 1191 | // Length |
1183 | // Version | 1192 | // Version |
1184 | // File2=http | 1193 | // File2=http |
1185 | s=s.replace( QRegExp("\\"),"/"); | 1194 | s=s.replace( QRegExp("\\"),"/"); |
1186 | DocLnk lnk( s ); | 1195 | DocLnk lnk( s ); |
1187 | QFileInfo f(s); | 1196 | QFileInfo f(s); |
1188 | QString name = f.baseName(); | 1197 | QString name = f.baseName(); |
1189 | if(name.left(4)=="http") | 1198 | if(name.left(4)=="http") |
1190 | name = s.right( s.length() - 7); | 1199 | name = s.right( s.length() - 7); |
1191 | else | 1200 | else |
1192 | name=s; | 1201 | name=s; |
1193 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1202 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1194 | lnk.setName( name); | 1203 | lnk.setName( name); |
1195 | if(s.at(s.length()-4) == '.') // if this is probably a file | 1204 | if(s.at(s.length()-4) == '.') // if this is probably a file |
1196 | lnk.setFile( s); | 1205 | lnk.setFile( s); |
1197 | else { //if its a url | 1206 | else { //if its a url |
1198 | if( name.right(1).find('/') == -1) | 1207 | if( name.right(1).find('/') == -1) |
1199 | s+="/"; | 1208 | s+="/"; |
1200 | lnk.setFile( s); | 1209 | lnk.setFile( s); |
1201 | } | 1210 | } |
1202 | lnk.setType("audio/x-mpegurl"); | 1211 | lnk.setType("audio/x-mpegurl"); |
1203 | 1212 | ||
1204 | qDebug("DocLnk add "+name); | 1213 | qDebug("DocLnk add "+name); |
1205 | d->selectedFiles->addToSelection( lnk); | 1214 | d->selectedFiles->addToSelection( lnk); |
1206 | } | 1215 | } |
1207 | } | 1216 | } |
1208 | i++; | 1217 | i++; |
1209 | } | 1218 | } |
1210 | } | 1219 | } |
1211 | 1220 | ||
1221 | void PlayListWidget::pmViewActivated(int index) { | ||
1222 | qDebug("%d", index); | ||
1223 | switch(index) { | ||
1224 | case -16: | ||
1225 | { | ||
1226 | |||
1227 | mediaPlayerState->toggleFullscreen(); | ||
1228 | bool b=mediaPlayerState->fullscreen(); | ||
1229 | pmView->setItemChecked( index,b); | ||
1230 | Config cfg( "OpiePlayer" ); | ||
1231 | cfg.writeEntry("FullScreen", b); | ||
1232 | |||
1233 | } | ||
1234 | break; | ||
1235 | }; | ||
1236 | } | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index e44096b..fdfa666 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -1,107 +1,111 @@ | |||
1 | 1 | ||
2 | #ifndef PLAY_LIST_WIDGET_H | 2 | #ifndef PLAY_LIST_WIDGET_H |
3 | #define PLAY_LIST_WIDGET_H | 3 | #define PLAY_LIST_WIDGET_H |
4 | 4 | ||
5 | #include <qmainwindow.h> | 5 | #include <qmainwindow.h> |
6 | #include <qpe/applnk.h> | 6 | #include <qpe/applnk.h> |
7 | #include <qtabwidget.h> | 7 | #include <qtabwidget.h> |
8 | #include <qpe/fileselector.h> | 8 | #include <qpe/fileselector.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qpopupmenu.h> | ||
10 | 11 | ||
11 | /* #include <qtimer.h> */ | 12 | /* #include <qtimer.h> */ |
12 | 13 | ||
13 | 14 | ||
14 | class PlayListWidgetPrivate; | 15 | class PlayListWidgetPrivate; |
15 | class Config; | 16 | class Config; |
16 | class QListViewItem; | 17 | class QListViewItem; |
17 | class QListView; | 18 | class QListView; |
18 | class QPoint; | 19 | class QPoint; |
19 | class QAction; | 20 | class QAction; |
20 | class QLabel; | 21 | class QLabel; |
21 | 22 | ||
22 | class PlayListWidget : public QMainWindow { | 23 | class PlayListWidget : public QMainWindow { |
23 | Q_OBJECT | 24 | Q_OBJECT |
24 | public: | 25 | public: |
25 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 26 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
26 | ~PlayListWidget(); | 27 | ~PlayListWidget(); |
27 | QTabWidget * tabWidget; | 28 | QTabWidget * tabWidget; |
28 | QAction *fullScreenButton, *scaleButton; | 29 | // MenuItem *fullScreenButton, *scaleButton; |
30 | // QAction *fullScreenButton, *scaleButton; | ||
29 | DocLnkSet files; | 31 | DocLnkSet files; |
30 | DocLnkSet vFiles; | 32 | DocLnkSet vFiles; |
31 | QListView *audioView, *videoView, *playlistView; | 33 | QListView *audioView, *videoView, *playlistView; |
32 | QLabel *libString; | 34 | QLabel *libString; |
35 | QPopupMenu *pmView ; | ||
33 | bool fromSetDocument; | 36 | bool fromSetDocument; |
34 | bool insanityBool; | 37 | bool insanityBool; |
35 | QString setDocFileRef; | 38 | QString setDocFileRef; |
36 | // retrieve the current playlist entry (media file link) | 39 | // retrieve the current playlist entry (media file link) |
37 | const DocLnk *current(); | 40 | const DocLnk *current(); |
38 | void useSelectedDocument(); | 41 | void useSelectedDocument(); |
39 | /* QTimer * menuTimer; */ | 42 | /* QTimer * menuTimer; */ |
40 | FileSelector* playLists; | 43 | FileSelector* playLists; |
41 | QPushButton *tbDeletePlaylist; | 44 | QPushButton *tbDeletePlaylist; |
42 | int fd, selected; | 45 | int fd, selected; |
43 | public slots: | 46 | public slots: |
44 | bool first(); | 47 | bool first(); |
45 | bool last(); | 48 | bool last(); |
46 | bool next(); | 49 | bool next(); |
47 | bool prev(); | 50 | bool prev(); |
48 | /* void setFullScreen(); */ | 51 | /* void setFullScreen(); */ |
49 | /* void setScaled(); */ | 52 | /* void setScaled(); */ |
50 | protected: | 53 | protected: |
51 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | 54 | /* void contentsMousePressEvent( QMouseEvent * e ); */ |
52 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | 55 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ |
53 | void keyReleaseEvent( QKeyEvent *e); | 56 | void keyReleaseEvent( QKeyEvent *e); |
54 | void keyPressEvent( QKeyEvent *e); | 57 | void keyPressEvent( QKeyEvent *e); |
55 | private: | 58 | private: |
56 | bool audioScan, videoScan; | 59 | bool audioScan, videoScan; |
57 | void doBlank(); | 60 | void doBlank(); |
58 | void doUnblank(); | 61 | void doUnblank(); |
59 | void readm3u(const QString &); | 62 | void readm3u(const QString &); |
60 | void readPls(const QString &); | 63 | void readPls(const QString &); |
61 | 64 | ||
62 | 65 | ||
63 | void initializeStates(); | 66 | void initializeStates(); |
64 | void readConfig( Config& cfg ); | 67 | void readConfig( Config& cfg ); |
65 | void writeConfig( Config& cfg ) const; | 68 | void writeConfig( Config& cfg ) const; |
66 | PlayListWidgetPrivate *d; // Private implementation data | 69 | PlayListWidgetPrivate *d; // Private implementation data |
67 | void populateAudioView(); | 70 | void populateAudioView(); |
68 | void populateVideoView(); | 71 | void populateVideoView(); |
69 | private slots: | 72 | private slots: |
73 | void pmViewActivated(int); | ||
70 | void writem3u(); | 74 | void writem3u(); |
71 | void scanForAudio(); | 75 | void scanForAudio(); |
72 | void scanForVideo(); | 76 | void scanForVideo(); |
73 | void openFile(); | 77 | void openFile(); |
74 | void setDocument( const QString& fileref ); | 78 | void setDocument( const QString& fileref ); |
75 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 79 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
76 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 80 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
77 | void setActiveWindow(); // need to handle this to show the right view | 81 | void setActiveWindow(); // need to handle this to show the right view |
78 | void setPlaylist( bool ); // Show/Hide the playlist | 82 | void setPlaylist( bool ); // Show/Hide the playlist |
79 | void setView( char ); | 83 | void setView( char ); |
80 | void clearList(); | 84 | void clearList(); |
81 | void addAllToList(); | 85 | void addAllToList(); |
82 | void addAllMusicToList(); | 86 | void addAllMusicToList(); |
83 | void addAllVideoToList(); | 87 | void addAllVideoToList(); |
84 | void saveList(); // Save the playlist | 88 | void saveList(); // Save the playlist |
85 | void loadList( const DocLnk &); // Load a playlist | 89 | void loadList( const DocLnk &); // Load a playlist |
86 | void playIt( QListViewItem *); | 90 | void playIt( QListViewItem *); |
87 | 91 | ||
88 | void btnPlay(bool); | 92 | void btnPlay(bool); |
89 | void deletePlaylist(); | 93 | void deletePlaylist(); |
90 | void addSelected(); | 94 | void addSelected(); |
91 | void removeSelected(); | 95 | void removeSelected(); |
92 | void tabChanged(QWidget*); | 96 | void tabChanged(QWidget*); |
93 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 97 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
94 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 98 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
95 | void playSelected(); | 99 | void playSelected(); |
96 | void listDelete(); | 100 | void listDelete(); |
97 | 101 | ||
98 | protected slots: | 102 | protected slots: |
99 | /* void cancelMenuTimer(); */ | 103 | /* void cancelMenuTimer(); */ |
100 | /* void showFileMenu(); */ | 104 | /* void showFileMenu(); */ |
101 | 105 | ||
102 | 106 | ||
103 | }; | 107 | }; |
104 | 108 | ||
105 | 109 | ||
106 | #endif // PLAY_LIST_WIDGET_H | 110 | #endif // PLAY_LIST_WIDGET_H |
107 | 111 | ||
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 188b18d..419c3ae 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,381 +1,463 @@ | |||
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/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/mediaplayerplugininterface.h> | ||
35 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
36 | 37 | ||
37 | #include <qwidget.h> | 38 | #include <qwidget.h> |
38 | #include <qpainter.h> | 39 | #include <qpainter.h> |
39 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
40 | #include <qslider.h> | 41 | #include <qslider.h> |
41 | #include <qdrawutil.h> | 42 | #include <qdrawutil.h> |
42 | #include "videowidget.h" | 43 | #include "videowidget.h" |
43 | #include "mediaplayerstate.h" | 44 | #include "mediaplayerstate.h" |
44 | 45 | ||
45 | 46 | ||
46 | #ifdef Q_WS_QWS | 47 | #ifdef Q_WS_QWS |
47 | # define USE_DIRECT_PAINTER | 48 | # define USE_DIRECT_PAINTER |
48 | # include <qdirectpainter_qws.h> | 49 | # include <qdirectpainter_qws.h> |
49 | # include <qgfxraster_qws.h> | 50 | # include <qgfxraster_qws.h> |
50 | #endif | 51 | #endif |
51 | 52 | ||
52 | 53 | ||
53 | extern MediaPlayerState *mediaPlayerState; | 54 | extern MediaPlayerState *mediaPlayerState; |
54 | 55 | ||
55 | 56 | ||
56 | static const int xo = 2; // movable x offset | 57 | static const int xo = 2; // movable x offset |
57 | static const int yo = 0; // movable y offset | 58 | static const int yo = 0; // movable y offset |
58 | 59 | ||
59 | 60 | ||
60 | struct MediaButton { | 61 | struct MediaButton { |
61 | int xPos, yPos; | ||
62 | bool isToggle, isHeld, isDown; | 62 | bool isToggle, isHeld, isDown; |
63 | int controlType; | ||
64 | }; | 63 | }; |
65 | 64 | ||
66 | |||
67 | // Layout information for the videoButtons (and if it is a toggle button or not) | ||
68 | MediaButton videoButtons[] = { | 65 | MediaButton videoButtons[] = { |
69 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous | 66 | { FALSE, FALSE, FALSE }, // previous |
70 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop | 67 | { FALSE, FALSE, FALSE }, // stop |
71 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play | 68 | { TRUE, FALSE, FALSE }, // play |
72 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause | 69 | { TRUE, FALSE, FALSE }, // pause |
73 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next | 70 | { FALSE, FALSE, FALSE }, // next |
74 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist | 71 | { FALSE, FALSE, FALSE }, // playlist |
75 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen | 72 | { TRUE, FALSE, FALSE } // fullscreen |
76 | }; | 73 | }; |
77 | 74 | ||
75 | const char *skinV_mask_file_names[7] = { | ||
76 | "stop","play","back","fwd","up","down","full" | ||
77 | }; | ||
78 | 78 | ||
79 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 79 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
80 | 80 | ||
81 | 81 | ||
82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
84 | setCaption( tr("OpiePlayer - Video") ); | 84 | setCaption( tr("OpiePlayer - Video") ); |
85 | |||
86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | ||
87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | ||
88 | |||
85 | Config cfg("OpiePlayer"); | 89 | Config cfg("OpiePlayer"); |
86 | cfg.setGroup("VideoWidget"); | 90 | cfg.setGroup("VideoWidget"); |
91 | skin = cfg.readEntry("Skin","default"); | ||
92 | |||
93 | QString skinPath = "opieplayer2/skins/" + skin; | ||
94 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | ||
95 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | ||
96 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | ||
97 | |||
98 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | ||
99 | imgButtonMask->fill( 0 ); | ||
100 | |||
101 | for ( int i = 0; i < 7; i++ ) { | ||
102 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; | ||
103 | masks[i] = new QBitmap( filename ); | ||
104 | qDebug(filename); | ||
105 | if ( !masks[i]->isNull() ) { | ||
106 | QImage imgMask = masks[i]->convertToImage(); | ||
107 | uchar **dest = imgButtonMask->jumpTable(); | ||
108 | for ( int y = 0; y < imgUp->height(); y++ ) { | ||
109 | uchar *line = dest[y]; | ||
110 | for ( int x = 0; x < imgUp->width(); x++ ) { | ||
111 | if ( !qRed( imgMask.pixel( x, y ) ) ) | ||
112 | line[x] = i + 1; | ||
113 | } | ||
114 | } | ||
115 | } | ||
87 | 116 | ||
88 | QString Button0aPix, Button0bPix, controlsPix; | 117 | } |
89 | Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); | ||
90 | Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); | ||
91 | controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); | ||
92 | 118 | ||
93 | cfg.setGroup("AudioWidget"); | 119 | for ( int i = 0; i < 7; i++ ) { |
94 | QString skin = cfg.readEntry("Skin","default"); | 120 | buttonPixUp[i] = NULL; |
95 | QString skinPath = "opieplayer/skins/" + skin; | 121 | buttonPixDown[i] = NULL; |
96 | backgroundPix = QString("%1/background").arg(skinPath) ; | 122 | } |
97 | 123 | ||
98 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); | 124 | setBackgroundPixmap( *pixBg ); |
99 | pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); | ||
100 | pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); | ||
101 | pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); | ||
102 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | ||
103 | 125 | ||
104 | slider = new QSlider( Qt::Horizontal, this ); | 126 | slider = new QSlider( Qt::Horizontal, this ); |
105 | slider->setMinValue( 0 ); | 127 | slider->setMinValue( 0 ); |
106 | slider->setMaxValue( 1 ); | 128 | slider->setMaxValue( 1 ); |
107 | 129 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | |
108 | slider->setBackgroundPixmap( *this->backgroundPixmap () ); //Resource::loadPixmap( backgroundPix ) ); | ||
109 | slider->setBackgroundOrigin( QWidget::ParentOrigin); | ||
110 | slider->setFocusPolicy( QWidget::NoFocus ); | 130 | slider->setFocusPolicy( QWidget::NoFocus ); |
111 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 131 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
112 | 132 | ||
113 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | ||
114 | |||
115 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | ||
116 | |||
117 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 133 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
118 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 134 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
119 | 135 | ||
120 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 136 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
121 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 137 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
122 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 138 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
123 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 139 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
124 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 140 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
125 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 141 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
126 | 142 | ||
127 | // Intialise state | ||
128 | setLength( mediaPlayerState->length() ); | 143 | setLength( mediaPlayerState->length() ); |
129 | setPosition( mediaPlayerState->position() ); | 144 | setPosition( mediaPlayerState->position() ); |
130 | setFullscreen( mediaPlayerState->fullscreen() ); | 145 | |
146 | ////////////////////////// FIXME | ||
147 | // setFullscreen( mediaPlayerState->fullscreen() ); | ||
131 | setPaused( mediaPlayerState->paused() ); | 148 | setPaused( mediaPlayerState->paused() ); |
132 | setPlaying( mediaPlayerState->playing() ); | 149 | setPlaying( mediaPlayerState->playing() ); |
133 | 150 | qDebug("finished videowidget"); | |
134 | } | 151 | } |
135 | 152 | ||
136 | 153 | ||
137 | VideoWidget::~VideoWidget() { | 154 | VideoWidget::~VideoWidget() { |
138 | for ( int i = 0; i < 3; i++ ) { | 155 | for ( int i = 0; i < 7; i++ ) { |
139 | delete pixmaps[i]; | 156 | delete buttonPixUp[i]; |
157 | delete buttonPixDown[i]; | ||
158 | } | ||
159 | |||
160 | delete pixBg; | ||
161 | delete imgUp; | ||
162 | delete imgDn; | ||
163 | delete imgButtonMask; | ||
164 | for ( int i = 0; i < 7; i++ ) { | ||
165 | delete masks[i]; | ||
140 | } | 166 | } |
141 | delete currentFrame; | ||
142 | } | 167 | } |
143 | 168 | ||
169 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | ||
170 | QPixmap pix( img.width(), img.height() ); | ||
171 | QPainter p( &pix ); | ||
172 | p.drawTiledPixmap( pix.rect(), bg, offset ); | ||
173 | p.drawImage( 0, 0, img ); | ||
174 | return new QPixmap( pix ); | ||
175 | } | ||
144 | 176 | ||
145 | static bool videoSliderBeingMoved = FALSE; | 177 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
178 | QPixmap *pixmap = new QPixmap( pix ); | ||
179 | pixmap->setMask( mask ); | ||
180 | return pixmap; | ||
181 | } | ||
182 | |||
183 | void VideoWidget::resizeEvent( QResizeEvent * ) { | ||
184 | int h = height(); | ||
185 | int w = width(); | ||
186 | int Vh = 160; | ||
187 | //videoFrame->height(); | ||
188 | int Vw = 220; | ||
189 | //videoFrame->width(); | ||
190 | // songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | ||
191 | |||
192 | slider->setFixedWidth( w - 110 ); | ||
193 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | ||
194 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | ||
195 | // time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | ||
196 | xoff = 0;// ( imgUp->width() ) / 2; | ||
197 | yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; | ||
198 | QPoint p( xoff, yoff ); | ||
199 | |||
200 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | ||
201 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | ||
202 | |||
203 | for ( int i = 0; i < 7; i++ ) { | ||
204 | if ( !masks[i]->isNull() ) { | ||
205 | delete buttonPixUp[i]; | ||
206 | delete buttonPixDown[i]; | ||
207 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | ||
208 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | ||
209 | } | ||
210 | } | ||
146 | 211 | ||
212 | delete pixUp; | ||
213 | delete pixDn; | ||
214 | } | ||
215 | |||
216 | static bool videoSliderBeingMoved = FALSE; | ||
147 | 217 | ||
148 | void VideoWidget::sliderPressed() { | 218 | void VideoWidget::sliderPressed() { |
149 | videoSliderBeingMoved = TRUE; | 219 | videoSliderBeingMoved = TRUE; |
150 | } | 220 | } |
151 | 221 | ||
152 | |||
153 | void VideoWidget::sliderReleased() { | 222 | void VideoWidget::sliderReleased() { |
154 | videoSliderBeingMoved = FALSE; | 223 | videoSliderBeingMoved = FALSE; |
155 | if ( slider->width() == 0 ) { | 224 | if ( slider->width() == 0 ) { |
156 | return; | 225 | return; |
157 | } | 226 | } |
158 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 227 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
159 | mediaPlayerState->setPosition( val ); | 228 | mediaPlayerState->setPosition( val ); |
160 | } | 229 | } |
161 | 230 | ||
162 | |||
163 | void VideoWidget::setPosition( long i ) { | 231 | void VideoWidget::setPosition( long i ) { |
164 | updateSlider( i, mediaPlayerState->length() ); | 232 | updateSlider( i, mediaPlayerState->length() ); |
165 | } | 233 | } |
166 | 234 | ||
167 | 235 | ||
168 | void VideoWidget::setLength( long max ) { | 236 | void VideoWidget::setLength( long max ) { |
169 | updateSlider( mediaPlayerState->position(), max ); | 237 | updateSlider( mediaPlayerState->position(), max ); |
170 | } | 238 | } |
171 | 239 | ||
172 | |||
173 | void VideoWidget::setView( char view ) { | 240 | void VideoWidget::setView( char view ) { |
174 | if ( view == 'v' ) { | 241 | if ( view == 'v' ) { |
175 | makeVisible(); | 242 | makeVisible(); |
176 | } else { | 243 | } else { |
177 | // Effectively blank the view next time we show it so it looks nicer | 244 | // Effectively blank the view next time we show it so it looks nicer |
178 | scaledWidth = 0; | 245 | scaledWidth = 0; |
179 | scaledHeight = 0; | 246 | scaledHeight = 0; |
180 | hide(); | 247 | hide(); |
181 | } | 248 | } |
182 | } | 249 | } |
183 | 250 | ||
184 | |||
185 | void VideoWidget::updateSlider( long i, long max ) { | 251 | void VideoWidget::updateSlider( long i, long max ) { |
186 | // Will flicker too much if we don't do this | 252 | // Will flicker too much if we don't do this |
187 | if ( max == 0 ) { | 253 | if ( max == 0 ) { |
188 | return; | 254 | return; |
189 | } | 255 | } |
190 | int width = slider->width(); | 256 | int width = slider->width(); |
191 | int val = int((double)i * width / max); | 257 | int val = int((double)i * width / max); |
192 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 258 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
193 | if ( slider->value() != val ) { | 259 | if ( slider->value() != val ) { |
194 | slider->setValue( val ); | 260 | slider->setValue( val ); |
195 | } | 261 | } |
196 | if ( slider->maxValue() != width ) { | 262 | if ( slider->maxValue() != width ) { |
197 | slider->setMaxValue( width ); | 263 | slider->setMaxValue( width ); |
198 | } | 264 | } |
199 | } | 265 | } |
200 | } | 266 | } |
201 | 267 | ||
202 | |||
203 | void VideoWidget::setToggleButton( int i, bool down ) { | 268 | void VideoWidget::setToggleButton( int i, bool down ) { |
204 | if ( down != videoButtons[i].isDown ) { | 269 | if ( down != videoButtons[i].isDown ) { |
205 | toggleButton( i ); | 270 | toggleButton( i ); |
206 | } | 271 | } |
207 | } | 272 | } |
208 | 273 | ||
209 | |||
210 | void VideoWidget::toggleButton( int i ) { | 274 | void VideoWidget::toggleButton( int i ) { |
211 | videoButtons[i].isDown = !videoButtons[i].isDown; | 275 | videoButtons[i].isDown = !videoButtons[i].isDown; |
212 | QPainter p(this); | 276 | QPainter p(this); |
213 | paintButton ( &p, i ); | 277 | paintButton ( &p, i ); |
214 | } | 278 | } |
215 | 279 | ||
216 | |||
217 | void VideoWidget::paintButton( QPainter *p, int i ) { | 280 | void VideoWidget::paintButton( QPainter *p, int i ) { |
218 | int x = videoButtons[i].xPos; | ||
219 | int y = videoButtons[i].yPos; | ||
220 | int offset = 10 + videoButtons[i].isDown; | ||
221 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); | ||
222 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); | ||
223 | } | ||
224 | 281 | ||
282 | if ( videoButtons[i].isDown ) | ||
283 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | ||
284 | else | ||
285 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | ||
286 | } | ||
225 | 287 | ||
226 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 288 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
227 | for ( int i = 0; i < numButtons; i++ ) { | 289 | for ( int i = 0; i < numButtons; i++ ) { |
228 | int x = videoButtons[i].xPos; | ||
229 | int y = videoButtons[i].yPos; | ||
230 | if ( event->state() == QMouseEvent::LeftButton ) { | 290 | if ( event->state() == QMouseEvent::LeftButton ) { |
231 | // The test to see if the mouse click is inside the circular button or not | 291 | // The test to see if the mouse click is inside the button or not |
232 | // (compared with the radius squared to avoid a square-root of our distance) | 292 | int x = event->pos().x() - xoff; |
233 | int radius = 16; | 293 | int y = event->pos().y() - yoff; |
234 | QPoint center = QPoint( x + radius, y + radius ); | 294 | |
235 | QPoint dXY = center - event->pos(); | 295 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
236 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 296 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
237 | bool isOnButton = dist <= (radius * radius); | ||
238 | if ( isOnButton != videoButtons[i].isHeld ) { | 297 | if ( isOnButton != videoButtons[i].isHeld ) { |
239 | videoButtons[i].isHeld = isOnButton; | 298 | videoButtons[i].isHeld = isOnButton; |
240 | toggleButton(i); | 299 | toggleButton(i); |
241 | } | 300 | } |
242 | } else { | 301 | } else { |
243 | if ( videoButtons[i].isHeld ) { | 302 | if ( videoButtons[i].isHeld ) { |
244 | videoButtons[i].isHeld = FALSE; | 303 | videoButtons[i].isHeld = FALSE; |
245 | if ( !videoButtons[i].isToggle ) | 304 | if ( !videoButtons[i].isToggle ) |
246 | setToggleButton( i, FALSE ); | 305 | setToggleButton( i, FALSE ); |
247 | qDebug("button toggled3 %d",i); | ||
248 | } | 306 | } |
249 | |||
250 | } | 307 | } |
251 | switch (i) { | 308 | switch (i) { |
252 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 309 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
253 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 310 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
254 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 311 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
255 | case VideoNext: mediaPlayerState->setNext(); return; | 312 | case VideoNext: mediaPlayerState->setNext(); return; |
256 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 313 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
257 | case VideoPlayList: mediaPlayerState->setList(); return; | 314 | case VideoPlayList: mediaPlayerState->setList(); return; |
258 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 315 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
259 | } | 316 | } |
260 | 317 | ||
261 | } | 318 | } |
262 | } | 319 | } |
263 | 320 | ||
264 | |||
265 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 321 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
266 | mouseMoveEvent( event ); | 322 | mouseMoveEvent( event ); |
267 | } | 323 | } |
268 | 324 | ||
269 | |||
270 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 325 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
271 | if ( mediaPlayerState->fullscreen() ) { | 326 | if ( mediaPlayerState->fullscreen() ) { |
272 | mediaPlayerState->setFullscreen( FALSE ); | 327 | mediaPlayerState->setFullscreen( FALSE ); |
273 | makeVisible(); | 328 | makeVisible(); |
274 | 329 | ||
275 | mouseMoveEvent( event ); | 330 | mouseMoveEvent( event ); |
276 | } | 331 | } |
277 | } | 332 | } |
278 | 333 | ||
279 | 334 | ||
280 | void VideoWidget::makeVisible() { | 335 | void VideoWidget::makeVisible() { |
281 | if ( mediaPlayerState->fullscreen() ) { | 336 | if ( mediaPlayerState->fullscreen() ) { |
282 | setBackgroundMode( QWidget::NoBackground ); | 337 | setBackgroundMode( QWidget::NoBackground ); |
283 | showFullScreen(); | 338 | showFullScreen(); |
284 | resize( qApp->desktop()->size() ); | 339 | resize( qApp->desktop()->size() ); |
285 | slider->hide(); | 340 | slider->hide(); |
286 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 341 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
287 | } else { | 342 | } else { |
288 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 343 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
289 | showNormal(); | 344 | showNormal(); |
290 | showMaximized(); | 345 | showMaximized(); |
291 | slider->show(); | 346 | slider->show(); |
292 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); | 347 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); |
293 | } | 348 | } |
294 | } | 349 | } |
295 | 350 | ||
296 | 351 | ||
297 | void VideoWidget::paintEvent( QPaintEvent * ) { | 352 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
298 | QPainter p( this ); | 353 | QPainter p( this ); |
299 | 354 | ||
300 | if ( mediaPlayerState->fullscreen() ) { | 355 | if ( mediaPlayerState->fullscreen() ) { |
301 | // Clear the background | 356 | // Clear the background |
302 | p.setBrush( QBrush( Qt::black ) ); | 357 | p.setBrush( QBrush( Qt::black ) ); |
303 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); | 358 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); |
304 | 359 | ||
305 | } else { | 360 | } else { |
306 | 361 | ||
307 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); | 362 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); |
308 | // draw the buttons | 363 | // draw the buttons |
309 | 364 | ||
310 | for ( int i = 0; i < numButtons; i++ ) { | 365 | if ( !pe->erased() ) { |
311 | paintButton( &p, i ); | 366 | // Combine with background and double buffer |
367 | QPixmap pix( pe->rect().size() ); | ||
368 | QPainter p( &pix ); | ||
369 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | ||
370 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | ||
371 | for ( int i = 0; i < numButtons; i++ ) | ||
372 | paintButton( &p, i ); | ||
373 | QPainter p2( this ); | ||
374 | p2.drawPixmap( pe->rect().topLeft(), pix ); | ||
375 | } else { | ||
376 | QPainter p( this ); | ||
377 | for ( int i = 0; i < numButtons; i++ ) | ||
378 | paintButton( &p, i ); | ||
312 | } | 379 | } |
313 | // draw the slider | 380 | // for ( int i = 0; i < numButtons; i++ ) { |
314 | slider->repaint( TRUE ); | 381 | // paintButton( &p, i ); |
315 | } | 382 | // } |
383 | // // draw the slider | ||
384 | // slider->repaint( TRUE ); | ||
385 | } | ||
316 | } | 386 | } |
317 | 387 | ||
318 | 388 | ||
319 | void VideoWidget::closeEvent( QCloseEvent* ) { | 389 | void VideoWidget::closeEvent( QCloseEvent* ) { |
320 | mediaPlayerState->setList(); | 390 | mediaPlayerState->setList(); |
321 | } | 391 | } |
322 | 392 | ||
323 | 393 | ||
394 | bool VideoWidget::playVideo() { | ||
395 | bool result = FALSE; | ||
396 | |||
397 | int stream = 0; | ||
398 | |||
399 | int sw = 240; | ||
400 | int sh = 320; | ||
401 | int dd = QPixmap::defaultDepth(); | ||
402 | int w = height(); | ||
403 | int h = width(); | ||
324 | 404 | ||
325 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) | 405 | return true; |
326 | { | 406 | } |
407 | |||
408 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | ||
327 | switch ( e->key() ) { | 409 | switch ( e->key() ) { |
328 | ////////////////////////////// Zaurus keys | 410 | ////////////////////////////// Zaurus keys |
329 | case Key_Home: | 411 | case Key_Home: |
330 | break; | 412 | break; |
331 | case Key_F9: //activity | 413 | case Key_F9: //activity |
332 | break; | 414 | break; |
333 | case Key_F10: //contacts | 415 | case Key_F10: //contacts |
334 | // hide(); | 416 | // hide(); |
335 | break; | 417 | break; |
336 | case Key_F11: //menu | 418 | case Key_F11: //menu |
337 | break; | 419 | break; |
338 | case Key_F12: //home | 420 | case Key_F12: //home |
339 | break; | 421 | break; |
340 | case Key_F13: //mail | 422 | case Key_F13: //mail |
341 | break; | 423 | break; |
342 | case Key_Space: { | 424 | case Key_Space: { |
343 | if(mediaPlayerState->playing()) { | 425 | if(mediaPlayerState->playing()) { |
344 | mediaPlayerState->setPlaying(FALSE); | 426 | mediaPlayerState->setPlaying(FALSE); |
345 | } else { | 427 | } else { |
346 | mediaPlayerState->setPlaying(TRUE); | 428 | mediaPlayerState->setPlaying(TRUE); |
347 | } | 429 | } |
348 | } | 430 | } |
349 | break; | 431 | break; |
350 | case Key_Down: | 432 | case Key_Down: |
351 | // toggleButton(6); | 433 | // toggleButton(6); |
352 | // emit lessClicked(); | 434 | // emit lessClicked(); |
353 | // emit lessReleased(); | 435 | // emit lessReleased(); |
354 | // toggleButton(6); | 436 | // toggleButton(6); |
355 | break; | 437 | break; |
356 | case Key_Up: | 438 | case Key_Up: |
357 | // toggleButton(5); | 439 | // toggleButton(5); |
358 | // emit moreClicked(); | 440 | // emit moreClicked(); |
359 | // emit moreReleased(); | 441 | // emit moreReleased(); |
360 | // toggleButton(5); | 442 | // toggleButton(5); |
361 | break; | 443 | break; |
362 | case Key_Right: | 444 | case Key_Right: |
363 | mediaPlayerState->setNext(); | 445 | mediaPlayerState->setNext(); |
364 | break; | 446 | break; |
365 | case Key_Left: | 447 | case Key_Left: |
366 | mediaPlayerState->setPrev(); | 448 | mediaPlayerState->setPrev(); |
367 | break; | 449 | break; |
368 | case Key_Escape: | 450 | case Key_Escape: |
369 | break; | 451 | break; |
370 | 452 | ||
371 | }; | 453 | }; |
372 | } | 454 | } |
455 | |||
373 | XineVideoWidget* VideoWidget::vidWidget() { | 456 | XineVideoWidget* VideoWidget::vidWidget() { |
374 | return videoFrame; | 457 | return videoFrame; |
375 | } | 458 | } |
376 | 459 | ||
377 | 460 | ||
378 | void VideoWidget::setFullscreen ( bool b ) | 461 | void VideoWidget::setFullscreen ( bool b ) { |
379 | { | 462 | setToggleButton( VideoFullscreen, b ); |
380 | setToggleButton( VideoFullscreen, b ); | ||
381 | } | 463 | } |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 04e810e..830696e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -1,101 +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 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 | class QPixmap; | 40 | class QPixmap; |
41 | class QSlider; | 41 | class QSlider; |
42 | 42 | ||
43 | enum VideoButtons { | 43 | enum VideoButtons { |
44 | VideoPrevious, | 44 | VideoPrevious, |
45 | VideoStop, | 45 | VideoStop, |
46 | VideoPlay, | 46 | VideoPlay, |
47 | VideoPause, | 47 | VideoPause, |
48 | VideoNext, | 48 | VideoNext, |
49 | VideoPlayList, | 49 | VideoPlayList, |
50 | VideoFullscreen | 50 | VideoFullscreen |
51 | }; | 51 | }; |
52 | 52 | ||
53 | class VideoWidget : public QWidget { | 53 | class VideoWidget : public QWidget { |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | public: | 55 | public: |
56 | VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 56 | VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
57 | ~VideoWidget(); | 57 | ~VideoWidget(); |
58 | 58 | ||
59 | bool playVideo(); | ||
59 | XineVideoWidget* vidWidget(); | 60 | XineVideoWidget* vidWidget(); |
60 | public slots: | 61 | public slots: |
61 | void updateSlider( long, long ); | 62 | void updateSlider( long, long ); |
62 | void sliderPressed( ); | 63 | void sliderPressed( ); |
63 | void sliderReleased( ); | 64 | void sliderReleased( ); |
64 | void setPaused( bool b) { setToggleButton( VideoPause, b ); } | 65 | void setPaused( bool b) { setToggleButton( VideoPause, b ); } |
65 | void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } | 66 | void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } |
66 | void setFullscreen( bool b ); | 67 | void setFullscreen( bool b ); |
67 | void makeVisible(); | 68 | void makeVisible(); |
68 | void setPosition( long ); | 69 | void setPosition( long ); |
69 | void setLength( long ); | 70 | void setLength( long ); |
70 | void setView( char ); | 71 | void setView( char ); |
71 | 72 | ||
72 | signals: | 73 | signals: |
73 | void sliderMoved( long ); | 74 | void sliderMoved( long ); |
74 | void videoResized ( const QSize &s ); | 75 | void videoResized ( const QSize &s ); |
75 | 76 | ||
76 | protected: | 77 | protected: |
78 | QString skin; | ||
79 | void resizeEvent( QResizeEvent * ); | ||
77 | void paintEvent( QPaintEvent *pe ); | 80 | void paintEvent( QPaintEvent *pe ); |
78 | void mouseMoveEvent( QMouseEvent *event ); | 81 | void mouseMoveEvent( QMouseEvent *event ); |
79 | void mousePressEvent( QMouseEvent *event ); | 82 | void mousePressEvent( QMouseEvent *event ); |
80 | void mouseReleaseEvent( QMouseEvent *event ); | 83 | void mouseReleaseEvent( QMouseEvent *event ); |
81 | void closeEvent( QCloseEvent *event ); | 84 | void closeEvent( QCloseEvent *event ); |
82 | void keyReleaseEvent( QKeyEvent *e); | 85 | void keyReleaseEvent( QKeyEvent *e); |
83 | 86 | ||
84 | private: | 87 | private: |
88 | // Ticker songInfo; | ||
89 | QPixmap *pixBg; | ||
90 | QImage *imgUp; | ||
91 | QImage *imgDn; | ||
92 | QImage *imgButtonMask; | ||
93 | QBitmap *masks[7]; | ||
94 | QPixmap *buttonPixUp[7]; | ||
95 | QPixmap *buttonPixDown[7]; | ||
96 | // QPixmap *pixmaps[4]; | ||
97 | int xoff, yoff; | ||
98 | |||
99 | |||
85 | void paintButton( QPainter *p, int i ); | 100 | void paintButton( QPainter *p, int i ); |
86 | void toggleButton( int ); | 101 | void toggleButton( int ); |
87 | void setToggleButton( int, bool ); | 102 | void setToggleButton( int, bool ); |
88 | 103 | ||
89 | QString backgroundPix; | 104 | QString backgroundPix; |
90 | QSlider *slider; | 105 | QSlider *slider; |
91 | QPixmap *pixmaps[3]; | 106 | QPixmap *pixmaps[3]; |
92 | QImage *currentFrame; | 107 | QImage *currentFrame; |
93 | int scaledWidth; | 108 | int scaledWidth; |
94 | int scaledHeight; | 109 | int scaledHeight; |
95 | XineVideoWidget* videoFrame; | 110 | XineVideoWidget* videoFrame; |
96 | }; | 111 | }; |
97 | 112 | ||
98 | #endif // VIDEO_WIDGET_H | 113 | #endif // VIDEO_WIDGET_H |
99 | 114 | ||
100 | 115 | ||
101 | 116 | ||
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 98446a0..d65006b 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -1,267 +1,268 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | This file is part of the Opie Project | 3 | This file is part of the Opie Project |
4 | 4 | ||
5 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 5 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
6 | Copyright (c) 2002 LJP <> | 6 | Copyright (c) 2002 LJP <> |
7 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 7 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
8 | =. | 8 | =. |
9 | .=l. | 9 | .=l. |
10 | .>+-= | 10 | .>+-= |
11 | _;:, .> :=|. This program is free software; you can | 11 | _;:, .> :=|. This program is free software; you can |
12 | .> <`_, > . <= redistribute it and/or modify it under | 12 | .> <`_, > . <= redistribute it and/or modify it under |
13 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 13 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
14 | .="- .-=="i, .._ License as published by the Free Software | 14 | .="- .-=="i, .._ License as published by the Free Software |
15 | - . .-<_> .<> Foundation; either version 2 of the License, | 15 | - . .-<_> .<> Foundation; either version 2 of the License, |
16 | ._= =} : or (at your option) any later version. | 16 | ._= =} : or (at your option) any later version. |
17 | .%`+i> _;_. | 17 | .%`+i> _;_. |
18 | .i_,=:_. -<s. This program is distributed in the hope that | 18 | .i_,=:_. -<s. This program is distributed in the hope that |
19 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 19 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
20 | : .. .:, . . . without even the implied warranty of | 20 | : .. .:, . . . without even the implied warranty of |
21 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 21 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
22 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 22 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
23 | ..}^=.= = ; Library General Public License for more | 23 | ..}^=.= = ; Library General Public License for more |
24 | ++= -. .` .: details. | 24 | ++= -. .` .: details. |
25 | : = ...= . :.=- | 25 | : = ...= . :.=- |
26 | -. .:....=;==+<; You should have received a copy of the GNU | 26 | -. .:....=;==+<; You should have received a copy of the GNU |
27 | -_. . . )=. = Library General Public License along with | 27 | -_. . . )=. = Library General Public License along with |
28 | -- :-=` this library; see the file COPYING.LIB. | 28 | -- :-=` this library; see the file COPYING.LIB. |
29 | If not, write to the Free Software Foundation, | 29 | If not, write to the Free Software Foundation, |
30 | Inc., 59 Temple Place - Suite 330, | 30 | Inc., 59 Temple Place - Suite 330, |
31 | Boston, MA 02111-1307, USA. | 31 | Boston, MA 02111-1307, USA. |
32 | 32 | ||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <qimage.h> | 35 | #include <qimage.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qgfx_qws.h> | 37 | #include <qgfx_qws.h> |
38 | #include <qdirectpainter_qws.h> | 38 | #include <qdirectpainter_qws.h> |
39 | #include <qgfx_qws.h> | 39 | #include <qgfx_qws.h> |
40 | #include <qsize.h> | 40 | #include <qsize.h> |
41 | #include <qapplication.h> | 41 | #include <qapplication.h> |
42 | #include <qpainter.h> | ||
42 | 43 | ||
43 | #include <qpe/resource.h> | 44 | #include <qpe/resource.h> |
44 | 45 | ||
45 | #include "xinevideowidget.h" | 46 | #include "xinevideowidget.h" |
46 | 47 | ||
47 | 48 | ||
48 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) | 49 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) |
49 | { | 50 | { |
50 | ((char *) src ) += len; | 51 | ((char *) src ) += len; |
51 | 52 | ||
52 | len >>= 1; | 53 | len >>= 1; |
53 | while ( len-- ) | 54 | while ( len-- ) |
54 | *((short int *) dst )++ = *--((short int *) src ); | 55 | *((short int *) dst )++ = *--((short int *) src ); |
55 | } | 56 | } |
56 | 57 | ||
57 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) | 58 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) |
58 | { | 59 | { |
59 | len >>= 1; | 60 | len >>= 1; |
60 | while ( len-- ) { | 61 | while ( len-- ) { |
61 | *((short int *) dst )++ = *((short int *) src ); | 62 | *((short int *) dst )++ = *((short int *) src ); |
62 | ((char *) src ) += step; | 63 | ((char *) src ) += step; |
63 | } | 64 | } |
64 | } | 65 | } |
65 | 66 | ||
66 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) | 67 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) |
67 | { | 68 | { |
68 | len >>= 1; | 69 | len >>= 1; |
69 | 70 | ||
70 | ((char *) src ) += ( len * step ); | 71 | ((char *) src ) += ( len * step ); |
71 | 72 | ||
72 | while ( len-- ) { | 73 | while ( len-- ) { |
73 | ((char *) src ) -= step; | 74 | ((char *) src ) -= step; |
74 | *((short int *) dst )++ = *((short int *) src ); | 75 | *((short int *) dst )++ = *((short int *) src ); |
75 | } | 76 | } |
76 | } | 77 | } |
77 | 78 | ||
78 | 79 | ||
79 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | 80 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) |
80 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) | 81 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) |
81 | { | 82 | { |
82 | setBackgroundMode ( NoBackground ); | 83 | setBackgroundMode ( NoBackground ); |
83 | 84 | ||
84 | m_image = 0; | 85 | m_image = 0; |
85 | m_buff = 0; | 86 | m_buff = 0; |
86 | m_bytes_per_line_fb = qt_screen-> linestep ( ); | 87 | m_bytes_per_line_fb = qt_screen-> linestep ( ); |
87 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; | 88 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; |
88 | m_rotation = 0; | 89 | m_rotation = 0; |
89 | } | 90 | } |
90 | 91 | ||
91 | 92 | ||
92 | XineVideoWidget::~XineVideoWidget ( ) | 93 | XineVideoWidget::~XineVideoWidget ( ) |
93 | { | 94 | { |
94 | delete m_image; | 95 | delete m_image; |
95 | } | 96 | } |
96 | 97 | ||
97 | void XineVideoWidget::clear ( ) | 98 | void XineVideoWidget::clear ( ) |
98 | { | 99 | { |
99 | m_buff = 0; | 100 | m_buff = 0; |
100 | repaint ( false ); | 101 | repaint ( false ); |
101 | } | 102 | } |
102 | 103 | ||
103 | void XineVideoWidget::paintEvent ( QPaintEvent * ) | 104 | void XineVideoWidget::paintEvent ( QPaintEvent * ) |
104 | { | 105 | { |
105 | //qWarning( "painting <<<" ); | 106 | //qWarning( "painting <<<" ); |
106 | if ( m_buff == 0 ) { | 107 | if ( m_buff == 0 ) { |
107 | QPainter p ( this ); | 108 | QPainter p ( this ); |
108 | p. fillRect ( rect ( ), black ); | 109 | p. fillRect ( rect ( ), black ); |
109 | if ( m_image ) | 110 | if ( m_image ) |
110 | p. drawImage ( 0, 0, *m_image ); | 111 | p. drawImage ( 0, 0, *m_image ); |
111 | //qWarning ( "logo\n" ); | 112 | //qWarning ( "logo\n" ); |
112 | } | 113 | } |
113 | else { | 114 | else { |
114 | // qWarning ( "paintevent\n" ); | 115 | // qWarning ( "paintevent\n" ); |
115 | 116 | ||
116 | QArray <QRect> qt_bug_workaround_clip_rects; | 117 | QArray <QRect> qt_bug_workaround_clip_rects; |
117 | 118 | ||
118 | { | 119 | { |
119 | QDirectPainter dp ( this ); | 120 | QDirectPainter dp ( this ); |
120 | 121 | ||
121 | int rot = dp. transformOrientation ( ) + m_rotation; | 122 | int rot = dp. transformOrientation ( ) + m_rotation; |
122 | 123 | ||
123 | uchar *fb = dp. frameBuffer ( ); | 124 | uchar *fb = dp. frameBuffer ( ); |
124 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; | 125 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; |
125 | 126 | ||
126 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 127 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
127 | 128 | ||
128 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); | 129 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); |
129 | 130 | ||
130 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { | 131 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { |
131 | const QRect &clip = dp. rect ( i ); | 132 | const QRect &clip = dp. rect ( i ); |
132 | 133 | ||
133 | qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 134 | qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
134 | 135 | ||
135 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); | 136 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); |
136 | uchar *src = frame; | 137 | uchar *src = frame; |
137 | 138 | ||
138 | switch ( rot ) { | 139 | switch ( rot ) { |
139 | case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; | 140 | case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; |
140 | case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break; | 141 | case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break; |
141 | case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break; | 142 | case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break; |
142 | case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; | 143 | case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; |
143 | } | 144 | } |
144 | 145 | ||
145 | uint leftfill = 0; | 146 | uint leftfill = 0; |
146 | uint framefill = 0; | 147 | uint framefill = 0; |
147 | uint rightfill = 0; | 148 | uint rightfill = 0; |
148 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; | 149 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; |
149 | 150 | ||
150 | if ( clip. left ( ) < framerect. left ( )) | 151 | if ( clip. left ( ) < framerect. left ( )) |
151 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; | 152 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; |
152 | if ( clip. right ( ) > framerect. right ( )) | 153 | if ( clip. right ( ) > framerect. right ( )) |
153 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; | 154 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; |
154 | 155 | ||
155 | framefill = clipwidth - ( leftfill + rightfill ); | 156 | framefill = clipwidth - ( leftfill + rightfill ); |
156 | 157 | ||
157 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { | 158 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { |
158 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { | 159 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { |
159 | memset ( dst, 0, clipwidth ); | 160 | memset ( dst, 0, clipwidth ); |
160 | } | 161 | } |
161 | else { | 162 | else { |
162 | if ( leftfill ) | 163 | if ( leftfill ) |
163 | memset ( dst, 0, leftfill ); | 164 | memset ( dst, 0, leftfill ); |
164 | 165 | ||
165 | if ( framefill ) { | 166 | if ( framefill ) { |
166 | switch ( rot ) { | 167 | switch ( rot ) { |
167 | case 0: memcpy ( dst + leftfill, src, framefill ); break; | 168 | case 0: memcpy ( dst + leftfill, src, framefill ); break; |
168 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 169 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
169 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; | 170 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; |
170 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 171 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
171 | } | 172 | } |
172 | } | 173 | } |
173 | if ( rightfill ) | 174 | if ( rightfill ) |
174 | memset ( dst + leftfill + framefill, 0, rightfill ); | 175 | memset ( dst + leftfill + framefill, 0, rightfill ); |
175 | } | 176 | } |
176 | 177 | ||
177 | dst += m_bytes_per_line_fb; | 178 | dst += m_bytes_per_line_fb; |
178 | 179 | ||
179 | switch ( rot ) { | 180 | switch ( rot ) { |
180 | case 0: src += m_bytes_per_line_frame; break; | 181 | case 0: src += m_bytes_per_line_frame; break; |
181 | case 1: src -= m_bytes_per_pixel; break; | 182 | case 1: src -= m_bytes_per_pixel; break; |
182 | case 2: src -= m_bytes_per_line_frame; break; | 183 | case 2: src -= m_bytes_per_line_frame; break; |
183 | case 3: src += m_bytes_per_pixel; break; | 184 | case 3: src += m_bytes_per_pixel; break; |
184 | } | 185 | } |
185 | } | 186 | } |
186 | } | 187 | } |
187 | } | 188 | } |
188 | //qWarning ( " ||| painting |||" ); | 189 | //qWarning ( " ||| painting |||" ); |
189 | { | 190 | { |
190 | // QVFB hack by MArtin Jones | 191 | // QVFB hack by MArtin Jones |
191 | QPainter p ( this ); | 192 | QPainter p ( this ); |
192 | 193 | ||
193 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | 194 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { |
194 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); | 195 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); |
195 | } | 196 | } |
196 | } | 197 | } |
197 | } | 198 | } |
198 | //qWarning( "painting >>>" ); | 199 | //qWarning( "painting >>>" ); |
199 | } | 200 | } |
200 | 201 | ||
201 | 202 | ||
202 | void XineVideoWidget::setImage ( QImage* image ) | 203 | void XineVideoWidget::setImage ( QImage* image ) |
203 | { | 204 | { |
204 | delete m_image; | 205 | delete m_image; |
205 | m_image = image; | 206 | m_image = image; |
206 | } | 207 | } |
207 | 208 | ||
208 | void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) | 209 | void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) |
209 | { | 210 | { |
210 | bool rot90 = (( -m_rotation ) & 1 ); | 211 | bool rot90 = (( -m_rotation ) & 1 ); |
211 | 212 | ||
212 | if ( rot90 ) { | 213 | if ( rot90 ) { |
213 | int d = w; | 214 | int d = w; |
214 | w = h; | 215 | w = h; |
215 | h = d; | 216 | h = d; |
216 | } | 217 | } |
217 | 218 | ||
218 | m_lastframe = m_thisframe; | 219 | m_lastframe = m_thisframe; |
219 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 220 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
220 | 221 | ||
221 | //qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 222 | // qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
222 | 223 | ||
223 | m_buff = img; | 224 | m_buff = img; |
224 | m_bytes_per_line_frame = bpl; | 225 | m_bytes_per_line_frame = bpl; |
225 | 226 | ||
226 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); | 227 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
227 | } | 228 | } |
228 | 229 | ||
229 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | 230 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) |
230 | { | 231 | { |
231 | QSize s = size ( ); | 232 | QSize s = size ( ); |
232 | bool fs = ( s == qApp-> desktop ( )-> size ( )); | 233 | bool fs = ( s == qApp-> desktop ( )-> size ( )); |
233 | 234 | ||
234 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | 235 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; |
235 | 236 | ||
236 | if ( fs && qt_screen-> isTransformed ( )) { | 237 | if ( fs && qt_screen-> isTransformed ( )) { |
237 | s = qt_screen-> mapToDevice ( s ); | 238 | s = qt_screen-> mapToDevice ( s ); |
238 | } | 239 | } |
239 | 240 | ||
240 | //qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); | 241 | // qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); |
241 | 242 | ||
242 | emit videoResized ( s ); | 243 | emit videoResized ( s ); |
243 | } | 244 | } |
244 | 245 | ||
245 | 246 | ||
246 | void XineVideoWidget::mousePressEvent ( QMouseEvent *me ) | 247 | void XineVideoWidget::mousePressEvent ( QMouseEvent *me ) |
247 | { | 248 | { |
248 | QWidget *p = parentWidget ( ); | 249 | QWidget *p = parentWidget ( ); |
249 | 250 | ||
250 | if ( p ) { | 251 | if ( p ) { |
251 | QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); | 252 | QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); |
252 | 253 | ||
253 | QApplication::sendEvent ( p, &pme ); | 254 | QApplication::sendEvent ( p, &pme ); |
254 | } | 255 | } |
255 | } | 256 | } |
256 | 257 | ||
257 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me ) | 258 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me ) |
258 | { | 259 | { |
259 | QWidget *p = parentWidget ( ); | 260 | QWidget *p = parentWidget ( ); |
260 | 261 | ||
261 | if ( p ) { | 262 | if ( p ) { |
262 | QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); | 263 | QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); |
263 | 264 | ||
264 | QApplication::sendEvent ( p, &pme ); | 265 | QApplication::sendEvent ( p, &pme ); |
265 | } | 266 | } |
266 | } | 267 | } |
267 | 268 | ||