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