author | harlekin <harlekin> | 2002-07-03 14:44:22 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-07-03 14:44:22 (UTC) |
commit | e1e4956ec7ffa9a07f98b03e831f0f9627556a6c (patch) (unidiff) | |
tree | c0545c6a22732f05804bda7704227132f64b7239 | |
parent | 61770de77f2abe8012d44cce49d04489e4187644 (diff) | |
download | opie-e1e4956ec7ffa9a07f98b03e831f0f9627556a6c.zip opie-e1e4956ec7ffa9a07f98b03e831f0f9627556a6c.tar.gz opie-e1e4956ec7ffa9a07f98b03e831f0f9627556a6c.tar.bz2 |
much more code cleanup, make if look more like c++ code
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 43 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 44 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/inputDialog.cpp | 8 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/inputDialog.h | 12 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 68 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.h | 5 |
7 files changed, 65 insertions, 125 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 8d3963a..1b0de5d 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,91 +1,129 @@ | |||
1 | 1 | ||
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | 5 | ||
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
8 | #include <qbutton.h> | 8 | #include <qbutton.h> |
9 | #include <qpainter.h> | 9 | #include <qpainter.h> |
10 | #include <qframe.h> | 10 | #include <qframe.h> |
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | 12 | ||
13 | #include "audiowidget.h" | 13 | #include "audiowidget.h" |
14 | #include "mediaplayerstate.h" | 14 | #include "mediaplayerstate.h" |
15 | 15 | ||
16 | extern MediaPlayerState *mediaPlayerState; | 16 | extern MediaPlayerState *mediaPlayerState; |
17 | 17 | ||
18 | |||
19 | static const int xo = -2; // movable x offset | 18 | static const int xo = -2; // movable x offset |
20 | static const int yo = 22; // movable y offset | 19 | static const int yo = 22; // movable y offset |
21 | 20 | ||
22 | 21 | ||
22 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { | ||
23 | setFrameStyle( WinPanel | Sunken ); | ||
24 | setText( "No Song" ); | ||
25 | } | ||
26 | |||
27 | Ticker::~Ticker() { | ||
28 | } | ||
29 | |||
30 | void Ticker::setText( const QString& text ) { | ||
31 | pos = 0; // reset it everytime the text is changed | ||
32 | scrollText = text; | ||
33 | pixelLen = fontMetrics().width( scrollText ); | ||
34 | killTimers(); | ||
35 | if ( pixelLen > width() ) { | ||
36 | startTimer( 50 ); | ||
37 | } | ||
38 | update(); | ||
39 | } | ||
40 | |||
41 | |||
42 | void Ticker::timerEvent( QTimerEvent * ) { | ||
43 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | ||
44 | repaint( FALSE ); | ||
45 | } | ||
46 | |||
47 | void Ticker::drawContents( QPainter *p ) { | ||
48 | QPixmap pm( width(), height() ); | ||
49 | pm.fill( colorGroup().base() ); | ||
50 | QPainter pmp( &pm ); | ||
51 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | ||
52 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | ||
53 | } | ||
54 | p->drawPixmap( 0, 0, pm ); | ||
55 | } | ||
56 | |||
57 | |||
58 | |||
59 | |||
23 | struct MediaButton { | 60 | struct MediaButton { |
24 | int xPos, yPos; | 61 | int xPos, yPos; |
25 | int color; | 62 | int color; |
26 | bool isToggle, isBig, isHeld, isDown; | 63 | bool isToggle, isBig, isHeld, isDown; |
27 | }; | 64 | }; |
28 | 65 | ||
29 | 66 | ||
67 | |||
68 | |||
30 | // Layout information for the audioButtons (and if it is a toggle button or not) | 69 | // Layout information for the audioButtons (and if it is a toggle button or not) |
31 | MediaButton audioButtons[] = { | 70 | MediaButton audioButtons[] = { |
32 | { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play | 71 | { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play |
33 | { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop | 72 | { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop |
34 | { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause | 73 | { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause |
35 | { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next | 74 | { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next |
36 | { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous | 75 | { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous |
37 | { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up | 76 | { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up |
38 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down | 77 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down |
39 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop | 78 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop |
40 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist | 79 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist |
41 | }; | 80 | }; |
42 | 81 | ||
43 | |||
44 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 82 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
45 | 83 | ||
46 | 84 | ||
47 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 85 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
48 | QWidget( parent, name, f ) | 86 | QWidget( parent, name, f ) |
49 | { | 87 | { |
50 | setCaption( tr("OpiePlayer - Audio") ); | 88 | setCaption( tr("OpiePlayer - Audio") ); |
51 | Config cfg("OpiePlayer"); | 89 | Config cfg("OpiePlayer"); |
52 | cfg.setGroup("AudioWidget"); | 90 | cfg.setGroup("AudioWidget"); |
53 | 91 | ||
54 | QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; | 92 | QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; |
55 | backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); | 93 | backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); |
56 | buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll"); | 94 | buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll"); |
57 | buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig"); | 95 | buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig"); |
58 | controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls"); | 96 | controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls"); |
59 | 97 | ||
60 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); | 98 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); |
61 | pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) ); | 99 | pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) ); |
62 | pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) ); | 100 | pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) ); |
63 | pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) ); | 101 | pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) ); |
64 | 102 | ||
65 | songInfo = new Ticker( this ); | 103 | songInfo = new Ticker( this ); |
66 | songInfo->setFocusPolicy( QWidget::NoFocus ); | 104 | songInfo->setFocusPolicy( QWidget::NoFocus ); |
67 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); | 105 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); |
68 | 106 | ||
69 | slider = new QSlider( Qt::Horizontal, this ); | 107 | slider = new QSlider( Qt::Horizontal, this ); |
70 | slider->setFixedWidth( 220 ); | 108 | slider->setFixedWidth( 220 ); |
71 | slider->setFixedHeight( 20 ); | 109 | slider->setFixedHeight( 20 ); |
72 | slider->setMinValue( 0 ); | 110 | slider->setMinValue( 0 ); |
73 | slider->setMaxValue( 1 ); | 111 | slider->setMaxValue( 1 ); |
74 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 112 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
75 | slider->setFocusPolicy( QWidget::NoFocus ); | 113 | slider->setFocusPolicy( QWidget::NoFocus ); |
76 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); | 114 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); |
77 | 115 | ||
78 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 116 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
79 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 117 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
80 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 118 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
81 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 119 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
82 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 120 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
83 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 121 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
84 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 122 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
85 | 123 | ||
86 | // Intialise state | 124 | // Intialise state |
87 | setLength( mediaPlayerState->length() ); | 125 | setLength( mediaPlayerState->length() ); |
88 | setPosition( mediaPlayerState->position() ); | 126 | setPosition( mediaPlayerState->position() ); |
89 | setLooping( mediaPlayerState->fullscreen() ); | 127 | setLooping( mediaPlayerState->fullscreen() ); |
90 | setPaused( mediaPlayerState->paused() ); | 128 | setPaused( mediaPlayerState->paused() ); |
91 | setPlaying( mediaPlayerState->playing() ); | 129 | setPlaying( mediaPlayerState->playing() ); |
@@ -100,97 +138,96 @@ AudioWidget::~AudioWidget() { | |||
100 | } | 138 | } |
101 | } | 139 | } |
102 | 140 | ||
103 | 141 | ||
104 | static bool audioSliderBeingMoved = FALSE; | 142 | static bool audioSliderBeingMoved = FALSE; |
105 | 143 | ||
106 | 144 | ||
107 | void AudioWidget::sliderPressed() { | 145 | void AudioWidget::sliderPressed() { |
108 | audioSliderBeingMoved = TRUE; | 146 | audioSliderBeingMoved = TRUE; |
109 | } | 147 | } |
110 | 148 | ||
111 | 149 | ||
112 | void AudioWidget::sliderReleased() { | 150 | void AudioWidget::sliderReleased() { |
113 | audioSliderBeingMoved = FALSE; | 151 | audioSliderBeingMoved = FALSE; |
114 | if ( slider->width() == 0 ) { | 152 | if ( slider->width() == 0 ) { |
115 | return; | 153 | return; |
116 | } | 154 | } |
117 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 155 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
118 | mediaPlayerState->setPosition( val ); | 156 | mediaPlayerState->setPosition( val ); |
119 | } | 157 | } |
120 | 158 | ||
121 | 159 | ||
122 | void AudioWidget::setPosition( long i ) { | 160 | void AudioWidget::setPosition( long i ) { |
123 | // qDebug("set position %d",i); | 161 | // qDebug("set position %d",i); |
124 | updateSlider( i, mediaPlayerState->length() ); | 162 | updateSlider( i, mediaPlayerState->length() ); |
125 | } | 163 | } |
126 | 164 | ||
127 | 165 | ||
128 | void AudioWidget::setLength( long max ) { | 166 | void AudioWidget::setLength( long max ) { |
129 | updateSlider( mediaPlayerState->position(), max ); | 167 | updateSlider( mediaPlayerState->position(), max ); |
130 | } | 168 | } |
131 | 169 | ||
132 | 170 | ||
133 | void AudioWidget::setView( char view ) { | 171 | void AudioWidget::setView( char view ) { |
134 | if (mediaPlayerState->isStreaming) { | 172 | if (mediaPlayerState->isStreaming) { |
135 | if( !slider->isHidden()) slider->hide(); | 173 | if( !slider->isHidden()) slider->hide(); |
136 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 174 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
137 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 175 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
138 | } else { | 176 | } else { |
139 | // this stops the slider from being moved, thus | 177 | // this stops the slider from being moved, thus |
140 | // does not stop stream when it reaches the end | 178 | // does not stop stream when it reaches the end |
141 | slider->show(); | 179 | slider->show(); |
142 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 180 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
143 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 181 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
144 | } | 182 | } |
145 | 183 | ||
146 | if ( view == 'a' ) { | 184 | if ( view == 'a' ) { |
147 | startTimer( 150 ); | 185 | startTimer( 150 ); |
148 | // show(); | ||
149 | showMaximized(); | 186 | showMaximized(); |
150 | } else { | 187 | } else { |
151 | killTimers(); | 188 | killTimers(); |
152 | hide(); | 189 | hide(); |
153 | } | 190 | } |
154 | } | 191 | } |
155 | 192 | ||
156 | 193 | ||
157 | void AudioWidget::updateSlider( long i, long max ) { | 194 | void AudioWidget::updateSlider( long i, long max ) { |
158 | if ( max == 0 ) { | 195 | if ( max == 0 ) { |
159 | return; | 196 | return; |
160 | } | 197 | } |
161 | // Will flicker too much if we don't do this | 198 | // Will flicker too much if we don't do this |
162 | // Scale to something reasonable | 199 | // Scale to something reasonable |
163 | int width = slider->width(); | 200 | int width = slider->width(); |
164 | int val = int((double)i * width / max); | 201 | int val = int((double)i * width / max); |
165 | if ( !audioSliderBeingMoved ) { | 202 | if ( !audioSliderBeingMoved ) { |
166 | if ( slider->value() != val ) { | 203 | if ( slider->value() != val ) { |
167 | slider->setValue( val ); | 204 | slider->setValue( val ); |
168 | } | 205 | } |
169 | 206 | ||
170 | if ( slider->maxValue() != width ) { | 207 | if ( slider->maxValue() != width ) { |
171 | slider->setMaxValue( width ); | 208 | slider->setMaxValue( width ); |
172 | } | 209 | } |
173 | } | 210 | } |
174 | } | 211 | } |
175 | 212 | ||
176 | 213 | ||
177 | void AudioWidget::setToggleButton( int i, bool down ) { | 214 | void AudioWidget::setToggleButton( int i, bool down ) { |
178 | if ( down != audioButtons[i].isDown ) { | 215 | if ( down != audioButtons[i].isDown ) { |
179 | toggleButton( i ); | 216 | toggleButton( i ); |
180 | } | 217 | } |
181 | } | 218 | } |
182 | 219 | ||
183 | 220 | ||
184 | void AudioWidget::toggleButton( int i ) { | 221 | void AudioWidget::toggleButton( int i ) { |
185 | audioButtons[i].isDown = !audioButtons[i].isDown; | 222 | audioButtons[i].isDown = !audioButtons[i].isDown; |
186 | QPainter p(this); | 223 | QPainter p(this); |
187 | paintButton ( &p, i ); | 224 | paintButton ( &p, i ); |
188 | } | 225 | } |
189 | 226 | ||
190 | 227 | ||
191 | void AudioWidget::paintButton( QPainter *p, int i ) { | 228 | void AudioWidget::paintButton( QPainter *p, int i ) { |
192 | int x = audioButtons[i].xPos; | 229 | int x = audioButtons[i].xPos; |
193 | int y = audioButtons[i].yPos; | 230 | int y = audioButtons[i].yPos; |
194 | int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; | 231 | int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; |
195 | int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); | 232 | int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); |
196 | p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); | 233 | p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index eab5df4..441eb6e 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -1,119 +1,89 @@ | |||
1 | #ifndef AUDIO_WIDGET_H | 1 | #ifndef AUDIO_WIDGET_H |
2 | #define AUDIO_WIDGET_H | 2 | #define AUDIO_WIDGET_H |
3 | 3 | ||
4 | #include <qwidget.h> | 4 | #include <qwidget.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qdrawutil.h> | 6 | #include <qdrawutil.h> |
7 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
8 | #include <qstring.h> | 8 | #include <qstring.h> |
9 | #include <qslider.h> | 9 | #include <qslider.h> |
10 | #include <qframe.h> | 10 | #include <qframe.h> |
11 | 11 | ||
12 | 12 | ||
13 | class QPixmap; | 13 | class QPixmap; |
14 | 14 | ||
15 | enum AudioButtons { | 15 | enum AudioButtons { |
16 | AudioPlay, | 16 | AudioPlay, |
17 | AudioStop, | 17 | AudioStop, |
18 | AudioPause, | 18 | AudioPause, |
19 | AudioNext, | 19 | AudioNext, |
20 | AudioPrevious, | 20 | AudioPrevious, |
21 | AudioVolumeUp, | 21 | AudioVolumeUp, |
22 | AudioVolumeDown, | 22 | AudioVolumeDown, |
23 | AudioLoop, | 23 | AudioLoop, |
24 | AudioPlayList | 24 | AudioPlayList |
25 | }; | 25 | }; |
26 | 26 | ||
27 | 27 | ||
28 | #define USE_DBLBUF | 28 | #define USE_DBLBUF |
29 | 29 | ||
30 | 30 | ||
31 | class Ticker : public QFrame { | 31 | class Ticker : public QFrame { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | |||
33 | public: | 34 | public: |
34 | Ticker( QWidget* parent=0 ) : QFrame( parent ) { | 35 | Ticker( QWidget* parent=0 ); |
35 | setFrameStyle( WinPanel | Sunken ); | 36 | ~Ticker(); |
36 | setText( "No Song" ); | 37 | void setText( const QString& text ) ; |
37 | } | 38 | |
38 | ~Ticker() { } | ||
39 | void setText( const QString& text ) { | ||
40 | pos = 0; // reset it everytime the text is changed | ||
41 | scrollText = text; | ||
42 | pixelLen = fontMetrics().width( scrollText ); | ||
43 | killTimers(); | ||
44 | if ( pixelLen > width() ) | ||
45 | startTimer( 50 ); | ||
46 | update(); | ||
47 | } | ||
48 | protected: | 39 | protected: |
49 | void timerEvent( QTimerEvent * ) { | 40 | void timerEvent( QTimerEvent * ); |
50 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | 41 | void drawContents( QPainter *p ); |
51 | #ifndef USE_DBLBUF | ||
52 | scroll( -1, 0, contentsRect() ); | ||
53 | #else | ||
54 | repaint( FALSE ); | ||
55 | #endif | ||
56 | } | ||
57 | void drawContents( QPainter *p ) { | ||
58 | #ifndef USE_DBLBUF | ||
59 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | ||
60 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | ||
61 | #else | ||
62 | // Double buffering code. | ||
63 | // Looks like qvfb makes it look like it flickers but I don't think it really is | ||
64 | QPixmap pm( width(), height() ); | ||
65 | pm.fill( colorGroup().base() ); | ||
66 | QPainter pmp( &pm ); | ||
67 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | ||
68 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | ||
69 | p->drawPixmap( 0, 0, pm ); | ||
70 | #endif | ||
71 | } | ||
72 | private: | 42 | private: |
73 | QString scrollText; | 43 | QString scrollText; |
74 | int pos, pixelLen; | 44 | int pos, pixelLen; |
75 | }; | 45 | }; |
76 | 46 | ||
77 | 47 | ||
78 | class AudioWidget : public QWidget { | 48 | class AudioWidget : public QWidget { |
79 | Q_OBJECT | 49 | Q_OBJECT |
80 | public: | 50 | public: |
81 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 51 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
82 | ~AudioWidget(); | 52 | ~AudioWidget(); |
83 | void setTickerText( const QString &text ) { songInfo->setText( text ); } | 53 | void setTickerText( const QString &text ) { songInfo->setText( text ); } |
84 | bool isStreaming; | 54 | bool isStreaming; |
85 | public slots: | 55 | public slots: |
86 | void updateSlider( long, long ); | 56 | void updateSlider( long, long ); |
87 | void sliderPressed( ); | 57 | void sliderPressed( ); |
88 | void sliderReleased( ); | 58 | void sliderReleased( ); |
89 | void setPaused( bool b) { setToggleButton( AudioPause, b ); } | 59 | void setPaused( bool b) { setToggleButton( AudioPause, b ); } |
90 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } | 60 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } |
91 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } | 61 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } |
92 | void setPosition( long ); | 62 | void setPosition( long ); |
93 | void setLength( long ); | 63 | void setLength( long ); |
94 | void setView( char ); | 64 | void setView( char ); |
95 | 65 | ||
96 | signals: | 66 | signals: |
97 | void moreClicked(); | 67 | void moreClicked(); |
98 | void lessClicked(); | 68 | void lessClicked(); |
99 | void moreReleased(); | 69 | void moreReleased(); |
100 | void lessReleased(); | 70 | void lessReleased(); |
101 | void sliderMoved(long); | 71 | void sliderMoved(long); |
102 | 72 | ||
103 | protected: | 73 | protected: |
104 | void doBlank(); | 74 | void doBlank(); |
105 | void doUnblank(); | 75 | void doUnblank(); |
106 | void paintEvent( QPaintEvent *pe ); | 76 | void paintEvent( QPaintEvent *pe ); |
107 | void showEvent( QShowEvent *se ); | 77 | void showEvent( QShowEvent *se ); |
108 | void mouseMoveEvent( QMouseEvent *event ); | 78 | void mouseMoveEvent( QMouseEvent *event ); |
109 | void mousePressEvent( QMouseEvent *event ); | 79 | void mousePressEvent( QMouseEvent *event ); |
110 | void mouseReleaseEvent( QMouseEvent *event ); | 80 | void mouseReleaseEvent( QMouseEvent *event ); |
111 | void timerEvent( QTimerEvent *event ); | 81 | void timerEvent( QTimerEvent *event ); |
112 | void closeEvent( QCloseEvent *event ); | 82 | void closeEvent( QCloseEvent *event ); |
113 | void keyReleaseEvent( QKeyEvent *e); | 83 | void keyReleaseEvent( QKeyEvent *e); |
114 | private: | 84 | private: |
115 | void toggleButton( int ); | 85 | void toggleButton( int ); |
116 | void setToggleButton( int, bool ); | 86 | void setToggleButton( int, bool ); |
117 | void paintButton( QPainter *p, int i ); | 87 | void paintButton( QPainter *p, int i ); |
118 | QPixmap *pixmaps[4]; | 88 | QPixmap *pixmaps[4]; |
119 | Ticker *songInfo; | 89 | Ticker *songInfo; |
diff --git a/noncore/multimedia/opieplayer2/inputDialog.cpp b/noncore/multimedia/opieplayer2/inputDialog.cpp index da8e276..687aff6 100644 --- a/noncore/multimedia/opieplayer2/inputDialog.cpp +++ b/noncore/multimedia/opieplayer2/inputDialog.cpp | |||
@@ -1,56 +1,48 @@ | |||
1 | /**************************************************************************** | ||
2 | ** Form implementation generated from reading ui file 'inputDialog.ui' | ||
3 | ** | ||
4 | ** Created: Sat Mar 2 07:55:03 2002 | ||
5 | ** by: The User Interface Compiler (uic) | ||
6 | ** | ||
7 | ** WARNING! All changes made in this file will be lost! | ||
8 | ****************************************************************************/ | ||
9 | #include "inputDialog.h" | 1 | #include "inputDialog.h" |
10 | 2 | ||
11 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
12 | 4 | ||
13 | #include <opie/ofiledialog.h> | 5 | #include <opie/ofiledialog.h> |
14 | 6 | ||
15 | #include <qlineedit.h> | 7 | #include <qlineedit.h> |
16 | #include <qlayout.h> | 8 | #include <qlayout.h> |
17 | #include <qvariant.h> | 9 | #include <qvariant.h> |
18 | #include <qpushbutton.h> | 10 | #include <qpushbutton.h> |
19 | #include <qwhatsthis.h> | 11 | #include <qwhatsthis.h> |
20 | 12 | ||
21 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 13 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
22 | : QDialog( parent, name, modal, fl ) | 14 | : QDialog( parent, name, modal, fl ) |
23 | { | 15 | { |
24 | if ( !name ) | 16 | if ( !name ) |
25 | setName( "InputDialog" ); | 17 | setName( "InputDialog" ); |
26 | resize( 234, 115); | 18 | resize( 234, 115); |
27 | setMaximumSize( QSize( 240, 40)); | 19 | setMaximumSize( QSize( 240, 40)); |
28 | setCaption( tr(name ) ); | 20 | setCaption( tr(name ) ); |
29 | 21 | ||
30 | QPushButton *browserButton; | 22 | QPushButton *browserButton; |
31 | browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); | 23 | browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); |
32 | browserButton->setGeometry( QRect( 205, 10, 22, 22)); | 24 | browserButton->setGeometry( QRect( 205, 10, 22, 22)); |
33 | connect( browserButton, SIGNAL(released()),this,SLOT(browse())); | 25 | connect( browserButton, SIGNAL(released()),this,SLOT(browse())); |
34 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 26 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
35 | LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); | 27 | LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); |
36 | } | 28 | } |
37 | 29 | ||
38 | /* | 30 | /* |
39 | * Destroys the object and frees any allocated resources | 31 | * Destroys the object and frees any allocated resources |
40 | */ | 32 | */ |
41 | InputDialog::~InputDialog() | 33 | InputDialog::~InputDialog() |
42 | { | 34 | { |
43 | inputText= LineEdit1->text(); | 35 | inputText= LineEdit1->text(); |
44 | 36 | ||
45 | } | 37 | } |
46 | 38 | ||
47 | void InputDialog::browse() { | 39 | void InputDialog::browse() { |
48 | 40 | ||
49 | MimeTypes types; | 41 | MimeTypes types; |
50 | QStringList audio, video, all; | 42 | QStringList audio, video, all; |
51 | audio << "audio/*"; | 43 | audio << "audio/*"; |
52 | audio << "playlist/plain"; | 44 | audio << "playlist/plain"; |
53 | audio << "audio/x-mpegurl"; | 45 | audio << "audio/x-mpegurl"; |
54 | 46 | ||
55 | video << "video/*"; | 47 | video << "video/*"; |
56 | video << "playlist/plain"; | 48 | video << "playlist/plain"; |
diff --git a/noncore/multimedia/opieplayer2/inputDialog.h b/noncore/multimedia/opieplayer2/inputDialog.h index 3e3e36f..d4f5e12 100644 --- a/noncore/multimedia/opieplayer2/inputDialog.h +++ b/noncore/multimedia/opieplayer2/inputDialog.h | |||
@@ -1,30 +1,22 @@ | |||
1 | /**************************************************************************** | 1 | |
2 | ** Form interface generated from reading ui file 'inputDialog.ui' | ||
3 | ** | ||
4 | ** Created: Sat Mar 2 07:54:46 2002 | ||
5 | ** by: The User Interface Compiler (uic) | ||
6 | ** | ||
7 | ** WARNING! All changes made in this file will be lost! | ||
8 | ****************************************************************************/ | ||
9 | #ifndef INPUTDIALOG_H | 2 | #ifndef INPUTDIALOG_H |
10 | #define INPUTDIALOG_H | 3 | #define INPUTDIALOG_H |
11 | 4 | ||
12 | #include <qvariant.h> | 5 | #include <qvariant.h> |
13 | #include <qdialog.h> | 6 | #include <qdialog.h> |
14 | 7 | ||
15 | class QLineEdit; | 8 | class QLineEdit; |
16 | 9 | ||
17 | class InputDialog : public QDialog | 10 | class InputDialog : public QDialog { |
18 | { | ||
19 | Q_OBJECT | 11 | Q_OBJECT |
20 | 12 | ||
21 | public: | 13 | public: |
22 | 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 ); |
23 | ~InputDialog(); | 15 | ~InputDialog(); |
24 | QString inputText; | 16 | QString inputText; |
25 | QLineEdit* LineEdit1; | 17 | QLineEdit* LineEdit1; |
26 | protected slots: | 18 | protected slots: |
27 | void browse(); | 19 | void browse(); |
28 | }; | 20 | }; |
29 | 21 | ||
30 | #endif // INPUTDIALOG_H | 22 | #endif // INPUTDIALOG_H |
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index e6d0525..87184ba 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -9,195 +9,155 @@ | |||
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | 10 | ||
11 | #include "mediaplayer.h" | 11 | #include "mediaplayer.h" |
12 | #include "playlistwidget.h" | 12 | #include "playlistwidget.h" |
13 | #include "audiowidget.h" | 13 | #include "audiowidget.h" |
14 | 14 | ||
15 | #include "mediaplayerstate.h" | 15 | #include "mediaplayerstate.h" |
16 | 16 | ||
17 | 17 | ||
18 | extern AudioWidget *audioUI; | 18 | extern AudioWidget *audioUI; |
19 | extern PlayListWidget *playList; | 19 | extern PlayListWidget *playList; |
20 | extern MediaPlayerState *mediaPlayerState; | 20 | extern MediaPlayerState *mediaPlayerState; |
21 | 21 | ||
22 | 22 | ||
23 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 23 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
24 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 24 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
25 | 25 | ||
26 | 26 | ||
27 | // QPEApplication::grabKeyboard(); // EVIL | 27 | // QPEApplication::grabKeyboard(); // EVIL |
28 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 28 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
29 | 29 | ||
30 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 30 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
31 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 31 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
32 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 32 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
33 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 33 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
34 | 34 | ||
35 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 35 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
36 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 36 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
37 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 37 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
38 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 38 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
39 | } | 39 | } |
40 | 40 | ||
41 | MediaPlayer::~MediaPlayer() { | 41 | MediaPlayer::~MediaPlayer() { |
42 | } | 42 | } |
43 | 43 | ||
44 | void MediaPlayer::pauseCheck( bool b ) { | 44 | void MediaPlayer::pauseCheck( bool b ) { |
45 | // Only pause if playing | 45 | // Only pause if playing |
46 | if ( b && !mediaPlayerState->playing() ) | 46 | if ( b && !mediaPlayerState->playing() ) |
47 | mediaPlayerState->setPaused( FALSE ); | 47 | mediaPlayerState->setPaused( FALSE ); |
48 | } | 48 | } |
49 | 49 | ||
50 | void MediaPlayer::play() { | 50 | void MediaPlayer::play() { |
51 | mediaPlayerState->setPlaying( FALSE ); | 51 | mediaPlayerState->setPlaying( FALSE ); |
52 | mediaPlayerState->setPlaying( TRUE ); | 52 | mediaPlayerState->setPlaying( TRUE ); |
53 | } | 53 | } |
54 | 54 | ||
55 | void MediaPlayer::setPlaying( bool play ) { | 55 | void MediaPlayer::setPlaying( bool play ) { |
56 | if ( !play ) { | 56 | if ( !play ) { |
57 | mediaPlayerState->setPaused( FALSE ); | 57 | mediaPlayerState->setPaused( FALSE ); |
58 | // loopControl->stop( FALSE ); | 58 | return; |
59 | return; | ||
60 | } | 59 | } |
61 | 60 | ||
62 | if ( mediaPlayerState->paused() ) { | 61 | if ( mediaPlayerState->paused() ) { |
63 | mediaPlayerState->setPaused( FALSE ); | 62 | mediaPlayerState->setPaused( FALSE ); |
64 | return; | 63 | return; |
65 | } | 64 | } |
66 | 65 | ||
67 | const DocLnk *playListCurrent = playList->current(); | 66 | const DocLnk *playListCurrent = playList->current(); |
68 | if ( playListCurrent != NULL ) { | 67 | if ( playListCurrent != NULL ) { |
69 | // loopControl->stop( TRUE ); | 68 | currentFile = playListCurrent; |
70 | currentFile = playListCurrent; | ||
71 | } | ||
72 | |||
73 | /* | ||
74 | |||
75 | if ( currentFile == NULL ) { | ||
76 | QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); | ||
77 | mediaPlayerState->setPlaying( FALSE ); | ||
78 | return; | ||
79 | } | ||
80 | |||
81 | if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { | ||
82 | QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); | ||
83 | mediaPlayerState->setPlaying( FALSE ); | ||
84 | return; | ||
85 | } | ||
86 | |||
87 | if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { | ||
88 | QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); | ||
89 | mediaPlayerState->setPlaying( FALSE ); | ||
90 | return; | ||
91 | } | 69 | } |
92 | 70 | ||
93 | // if ( !loopControl->init( currentFile->file() ) ) { | 71 | audioUI->setTickerText( currentFile->file() ); |
94 | // QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); | ||
95 | // mediaPlayerState->setPlaying( FALSE ); | ||
96 | // return; | ||
97 | // } | ||
98 | // long seconds = loopControl->totalPlaytime(); | ||
99 | long seconds = 120; | ||
100 | QString time; | ||
101 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | ||
102 | QString tickerText; | ||
103 | if( currentFile->file().left(4) == "http" ) | ||
104 | tickerText= tr( " File: " ) + currentFile->name(); | ||
105 | else | ||
106 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; | ||
107 | 72 | ||
108 | QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); | ||
109 | if ( !fileInfo.isEmpty() ) | ||
110 | tickerText += ", " + fileInfo; | ||
111 | audioUI->setTickerText( tickerText + "." ); | ||
112 | 73 | ||
74 | // alles nicht nötig, xine kümmert sich drum, man muss nur den return andio oder video gui geben | ||
113 | 75 | ||
114 | */ // alles nicht nötig, xine kümmert sich drum, man muss nur den return andio oder video gui geben | 76 | // Ob auch video 'v' : 'a' |
77 | // mediaPlayerState->setView( 'v' ); | ||
115 | 78 | ||
116 | 79 | // abspielen starten. | |
117 | // loopControl->play(); | ||
118 | |||
119 | // mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' ); | ||
120 | } | 80 | } |
121 | 81 | ||
122 | 82 | ||
123 | void MediaPlayer::prev() { | 83 | void MediaPlayer::prev() { |
124 | if ( playList->prev() ) | 84 | if ( playList->prev() ) |
125 | play(); | 85 | play(); |
126 | else if ( mediaPlayerState->looping() ) { | 86 | else if ( mediaPlayerState->looping() ) { |
127 | if ( playList->last() ) | 87 | if ( playList->last() ) |
128 | play(); | 88 | play(); |
129 | } else | 89 | } else |
130 | mediaPlayerState->setList(); | 90 | mediaPlayerState->setList(); |
131 | } | 91 | } |
132 | 92 | ||
133 | 93 | ||
134 | void MediaPlayer::next() { | 94 | void MediaPlayer::next() { |
135 | if ( playList->next() ) | 95 | if ( playList->next() ) |
136 | play(); | 96 | play(); |
137 | else if ( mediaPlayerState->looping() ) { | 97 | else if ( mediaPlayerState->looping() ) { |
138 | if ( playList->first() ) | 98 | if ( playList->first() ) |
139 | play(); | 99 | play(); |
140 | } else | 100 | } else |
141 | mediaPlayerState->setList(); | 101 | mediaPlayerState->setList(); |
142 | } | 102 | } |
143 | 103 | ||
144 | 104 | ||
145 | void MediaPlayer::startDecreasingVolume() { | 105 | void MediaPlayer::startDecreasingVolume() { |
146 | volumeDirection = -1; | 106 | volumeDirection = -1; |
147 | startTimer( 100 ); | 107 | startTimer( 100 ); |
148 | // sollte volumeapplet machen | 108 | // da kommt demnächst osound denk ich mal |
149 | // AudioDevice::decreaseVolume(); | 109 | // AudioDevice::decreaseVolume(); |
150 | } | 110 | } |
151 | 111 | ||
152 | 112 | ||
153 | void MediaPlayer::startIncreasingVolume() { | 113 | void MediaPlayer::startIncreasingVolume() { |
154 | volumeDirection = +1; | 114 | volumeDirection = +1; |
155 | startTimer( 100 ); | 115 | startTimer( 100 ); |
156 | // AudioDevice::increaseVolume(); | 116 | // AudioDevice::increaseVolume(); |
157 | } | 117 | } |
158 | 118 | ||
159 | 119 | ||
160 | void MediaPlayer::stopChangingVolume() { | 120 | void MediaPlayer::stopChangingVolume() { |
161 | killTimers(); | 121 | killTimers(); |
162 | } | 122 | } |
163 | 123 | ||
164 | 124 | ||
165 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 125 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
166 | // if ( volumeDirection == +1 ) | 126 | // if ( volumeDirection == +1 ) |
167 | // AudioDevice::increaseVolume(); | 127 | // AudioDevice::increaseVolume(); |
168 | // else if ( volumeDirection == -1 ) | 128 | // else if ( volumeDirection == -1 ) |
169 | // AudioDevice::decreaseVolume(); | 129 | // AudioDevice::decreaseVolume(); |
170 | } | 130 | } |
171 | 131 | ||
172 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 132 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
173 | switch ( e->key() ) { | 133 | switch ( e->key() ) { |
174 | ////////////////////////////// Zaurus keys | 134 | ////////////////////////////// Zaurus keys |
175 | case Key_Home: | 135 | case Key_Home: |
176 | break; | 136 | break; |
177 | case Key_F9: //activity | 137 | case Key_F9: //activity |
178 | break; | 138 | break; |
179 | case Key_F10: //contacts | 139 | case Key_F10: //contacts |
180 | break; | 140 | break; |
181 | case Key_F11: //menu | 141 | case Key_F11: //menu |
182 | break; | 142 | break; |
183 | case Key_F12: //home | 143 | case Key_F12: //home |
184 | qDebug("Blank here"); | 144 | qDebug("Blank here"); |
185 | break; | 145 | break; |
186 | case Key_F13: //mail | 146 | case Key_F13: //mail |
187 | break; | 147 | break; |
188 | } | 148 | } |
189 | } | 149 | } |
190 | 150 | ||
191 | void MediaPlayer::doBlank() { | 151 | void MediaPlayer::doBlank() { |
192 | 152 | ||
193 | } | 153 | } |
194 | 154 | ||
195 | void MediaPlayer::doUnblank() { | 155 | void MediaPlayer::doUnblank() { |
196 | 156 | ||
197 | } | 157 | } |
198 | 158 | ||
199 | void MediaPlayer::cleanUp() { | 159 | void MediaPlayer::cleanUp() { |
200 | // QPEApplication::grabKeyboard(); | 160 | // QPEApplication::grabKeyboard(); |
201 | // QPEApplication::ungrabKeyboard(); | 161 | // QPEApplication::ungrabKeyboard(); |
202 | 162 | ||
203 | } | 163 | } |
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 9b5f70e..d1d30e4 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp | |||
@@ -1,76 +1,68 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | 3 | ||
4 | #include <qpe/qpeapplication.h> | 4 | #include <qpe/qpeapplication.h> |
5 | #include <qpe/qlibrary.h> | 5 | #include <qpe/qlibrary.h> |
6 | #include <qpe/config.h> | 6 | #include <qpe/config.h> |
7 | #include <qvaluelist.h> | 7 | #include <qvaluelist.h> |
8 | #include <qobject.h> | 8 | #include <qobject.h> |
9 | #include <qdir.h> | 9 | #include <qdir.h> |
10 | #include <qpe/mediaplayerplugininterface.h> | 10 | #include <qpe/mediaplayerplugininterface.h> |
11 | #include "mediaplayerstate.h" | 11 | #include "mediaplayerstate.h" |
12 | 12 | ||
13 | 13 | ||
14 | 14 | ||
15 | #ifdef QT_NO_COMPONENT | ||
16 | // Plugins which are compiled in when no plugin architecture available | ||
17 | #include "libmad/libmadpluginimpl.h" | ||
18 | #include "libmpeg3/libmpeg3pluginimpl.h" | ||
19 | #include "wavplugin/wavpluginimpl.h" | ||
20 | #endif | ||
21 | |||
22 | |||
23 | //#define MediaPlayerDebug(x) qDebug x | 15 | //#define MediaPlayerDebug(x) qDebug x |
24 | #define MediaPlayerDebug(x) | 16 | #define MediaPlayerDebug(x) |
25 | 17 | ||
26 | 18 | ||
27 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 19 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
28 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { | 20 | : QObject( parent, name ), decoder( NULL ) { |
29 | Config cfg( "OpiePlayer" ); | 21 | Config cfg( "OpiePlayer" ); |
30 | readConfig( cfg ); | 22 | readConfig( cfg ); |
31 | } | 23 | } |
32 | 24 | ||
33 | 25 | ||
34 | MediaPlayerState::~MediaPlayerState() { | 26 | MediaPlayerState::~MediaPlayerState() { |
35 | Config cfg( "OpiePlayer" ); | 27 | Config cfg( "OpiePlayer" ); |
36 | writeConfig( cfg ); | 28 | writeConfig( cfg ); |
37 | } | 29 | } |
38 | 30 | ||
39 | 31 | ||
40 | void MediaPlayerState::readConfig( Config& cfg ) { | 32 | void MediaPlayerState::readConfig( Config& cfg ) { |
41 | cfg.setGroup("Options"); | 33 | cfg.setGroup("Options"); |
42 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); | 34 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); |
43 | isScaled = cfg.readBoolEntry( "Scaling" ); | 35 | isScaled = cfg.readBoolEntry( "Scaling" ); |
44 | isLooping = cfg.readBoolEntry( "Looping" ); | 36 | isLooping = cfg.readBoolEntry( "Looping" ); |
45 | isShuffled = cfg.readBoolEntry( "Shuffle" ); | 37 | isShuffled = cfg.readBoolEntry( "Shuffle" ); |
46 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); | 38 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); |
47 | usePlaylist = TRUE; | 39 | usePlaylist = TRUE; |
48 | isPlaying = FALSE; | 40 | isPlaying = FALSE; |
49 | isPaused = FALSE; | 41 | isPaused = FALSE; |
50 | curPosition = 0; | 42 | curPosition = 0; |
51 | curLength = 0; | 43 | curLength = 0; |
52 | curView = 'l'; | 44 | curView = 'l'; |
53 | } | 45 | } |
54 | 46 | ||
55 | 47 | ||
56 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 48 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
57 | cfg.setGroup("Options"); | 49 | cfg.setGroup("Options"); |
58 | cfg.writeEntry("FullScreen", isFullscreen ); | 50 | cfg.writeEntry("FullScreen", isFullscreen ); |
59 | cfg.writeEntry("Scaling", isScaled ); | 51 | cfg.writeEntry("Scaling", isScaled ); |
60 | cfg.writeEntry("Looping", isLooping ); | 52 | cfg.writeEntry("Looping", isLooping ); |
61 | cfg.writeEntry("Shuffle", isShuffled ); | 53 | cfg.writeEntry("Shuffle", isShuffled ); |
62 | cfg.writeEntry("UsePlayList", usePlaylist ); | 54 | cfg.writeEntry("UsePlayList", usePlaylist ); |
63 | } | 55 | } |
64 | 56 | ||
65 | 57 | ||
66 | struct MediaPlayerPlugin { | 58 | struct MediaPlayerPlugin { |
67 | #ifndef QT_NO_COMPONENT | 59 | #ifndef QT_NO_COMPONENT |
68 | QLibrary *library; | 60 | QLibrary *library; |
69 | #endif | 61 | #endif |
70 | MediaPlayerPluginInterface *iface; | 62 | MediaPlayerPluginInterface *iface; |
71 | MediaPlayerDecoder *decoder; | 63 | MediaPlayerDecoder *decoder; |
72 | MediaPlayerEncoder *encoder; | 64 | MediaPlayerEncoder *encoder; |
73 | }; | 65 | }; |
74 | 66 | ||
75 | 67 | ||
76 | static QValueList<MediaPlayerPlugin> pluginList; | 68 | static QValueList<MediaPlayerPlugin> pluginList; |
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h index 374e780..8a64939 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.h +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h | |||
@@ -1,100 +1,97 @@ | |||
1 | 1 | ||
2 | #ifndef MEDIA_PLAYER_STATE_H | 2 | #ifndef MEDIA_PLAYER_STATE_H |
3 | #define MEDIA_PLAYER_STATE_H | 3 | #define MEDIA_PLAYER_STATE_H |
4 | 4 | ||
5 | 5 | ||
6 | #include <qobject.h> | 6 | #include <qobject.h> |
7 | 7 | ||
8 | 8 | ||
9 | class MediaPlayerDecoder; | 9 | class MediaPlayerDecoder; |
10 | class Config; | 10 | class Config; |
11 | 11 | ||
12 | 12 | ||
13 | class MediaPlayerState : public QObject { | 13 | class MediaPlayerState : public QObject { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | public: | 15 | public: |
16 | MediaPlayerState( QObject *parent, const char *name ); | 16 | MediaPlayerState( QObject *parent, const char *name ); |
17 | ~MediaPlayerState(); | 17 | ~MediaPlayerState(); |
18 | 18 | ||
19 | bool isStreaming; | 19 | bool isStreaming; |
20 | bool fullscreen() { return isFullscreen; } | 20 | bool fullscreen() { return isFullscreen; } |
21 | bool scaled() { return isScaled; } | 21 | bool scaled() { return isScaled; } |
22 | bool looping() { return isLooping; } | 22 | bool looping() { return isLooping; } |
23 | bool shuffled() { return isShuffled; } | 23 | bool shuffled() { return isShuffled; } |
24 | bool playlist() { return usePlaylist; } | 24 | bool playlist() { return usePlaylist; } |
25 | bool paused() { return isPaused; } | 25 | bool paused() { return isPaused; } |
26 | bool playing() { return isPlaying; } | 26 | bool playing() { return isPlaying; } |
27 | long position() { return curPosition; } | 27 | long position() { return curPosition; } |
28 | long length() { return curLength; } | 28 | long length() { return curLength; } |
29 | char view() { return curView; } | 29 | char view() { return curView; } |
30 | 30 | ||
31 | MediaPlayerDecoder *newDecoder( const QString& file ); | 31 | MediaPlayerDecoder *newDecoder( const QString& file ); |
32 | MediaPlayerDecoder *curDecoder(); | 32 | MediaPlayerDecoder *curDecoder(); |
33 | MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the | 33 | |
34 | // number of audio samples if we are using the libmad plugin | ||
35 | public slots: | 34 | public slots: |
36 | void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } | 35 | void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } |
37 | void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } | 36 | void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } |
38 | void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } | 37 | void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } |
39 | void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } | 38 | void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } |
40 | void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } | 39 | void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } |
41 | void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } | 40 | void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } |
42 | void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } | 41 | void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } |
43 | void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } | 42 | void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } |
44 | void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } | 43 | void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } |
45 | void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } | 44 | void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } |
46 | void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } | 45 | void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } |
47 | 46 | ||
48 | void setPrev() { emit prev(); } | 47 | void setPrev() { emit prev(); } |
49 | void setNext() { emit next(); } | 48 | void setNext() { emit next(); } |
50 | void setList() { setPlaying( FALSE ); setView('l'); } | 49 | void setList() { setPlaying( FALSE ); setView('l'); } |
51 | void setVideo() { setView('v'); } | 50 | void setVideo() { setView('v'); } |
52 | void setAudio() { setView('a'); } | 51 | void setAudio() { setView('a'); } |
53 | 52 | ||
54 | void toggleFullscreen() { setFullscreen( !isFullscreen ); } | 53 | void toggleFullscreen() { setFullscreen( !isFullscreen ); } |
55 | void toggleScaled() { setScaled( !isScaled); } | 54 | void toggleScaled() { setScaled( !isScaled); } |
56 | void toggleLooping() { setLooping( !isLooping); } | 55 | void toggleLooping() { setLooping( !isLooping); } |
57 | void toggleShuffled() { setShuffled( !isShuffled); } | 56 | void toggleShuffled() { setShuffled( !isShuffled); } |
58 | void togglePlaylist() { setPlaylist( !usePlaylist); } | 57 | void togglePlaylist() { setPlaylist( !usePlaylist); } |
59 | void togglePaused() { setPaused( !isPaused); } | 58 | void togglePaused() { setPaused( !isPaused); } |
60 | void togglePlaying() { setPlaying( !isPlaying); } | 59 | void togglePlaying() { setPlaying( !isPlaying); } |
61 | 60 | ||
62 | signals: | 61 | signals: |
63 | void fullscreenToggled( bool ); | 62 | void fullscreenToggled( bool ); |
64 | void scaledToggled( bool ); | 63 | void scaledToggled( bool ); |
65 | void loopingToggled( bool ); | 64 | void loopingToggled( bool ); |
66 | void shuffledToggled( bool ); | 65 | void shuffledToggled( bool ); |
67 | void playlistToggled( bool ); | 66 | void playlistToggled( bool ); |
68 | void pausedToggled( bool ); | 67 | void pausedToggled( bool ); |
69 | void playingToggled( bool ); | 68 | void playingToggled( bool ); |
70 | void positionChanged( long ); // When the slider is moved | 69 | void positionChanged( long ); // When the slider is moved |
71 | void positionUpdated( long ); // When the media file progresses | 70 | void positionUpdated( long ); // When the media file progresses |
72 | void lengthChanged( long ); | 71 | void lengthChanged( long ); |
73 | void viewChanged( char ); | 72 | void viewChanged( char ); |
74 | 73 | ||
75 | void prev(); | 74 | void prev(); |
76 | void next(); | 75 | void next(); |
77 | 76 | ||
78 | private: | 77 | private: |
79 | bool isFullscreen; | 78 | bool isFullscreen; |
80 | bool isScaled; | 79 | bool isScaled; |
81 | bool isLooping; | 80 | bool isLooping; |
82 | bool isShuffled; | 81 | bool isShuffled; |
83 | bool usePlaylist; | 82 | bool usePlaylist; |
84 | bool isPaused; | 83 | bool isPaused; |
85 | bool isPlaying; | 84 | bool isPlaying; |
86 | long curPosition; | 85 | long curPosition; |
87 | long curLength; | 86 | long curLength; |
88 | char curView; | 87 | char curView; |
89 | 88 | ||
90 | MediaPlayerDecoder *decoder; | 89 | MediaPlayerDecoder *decoder; |
91 | MediaPlayerDecoder *libmpeg3decoder; | ||
92 | // MediaPlayerDecoder *libwavdecoder; | ||
93 | 90 | ||
94 | void readConfig( Config& cfg ); | 91 | void readConfig( Config& cfg ); |
95 | void writeConfig( Config& cfg ) const; | 92 | void writeConfig( Config& cfg ) const; |
96 | }; | 93 | }; |
97 | 94 | ||
98 | 95 | ||
99 | #endif // MEDIA_PLAYER_STATE_H | 96 | #endif // MEDIA_PLAYER_STATE_H |
100 | 97 | ||