Diffstat (limited to 'core/multimedia/opieplayer/audiowidget.h') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.h | 73 |
1 files changed, 20 insertions, 53 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h index b3d39bf..c686741 100644 --- a/core/multimedia/opieplayer/audiowidget.h +++ b/core/multimedia/opieplayer/audiowidget.h | |||
@@ -4,143 +4,110 @@ | |||
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef AUDIO_WIDGET_H | 21 | #ifndef AUDIO_WIDGET_H |
22 | #define AUDIO_WIDGET_H | 22 | #define AUDIO_WIDGET_H |
23 | 23 | ||
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #include <qdrawutil.h> | 26 | #include <qdrawutil.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | #include <qbitmap.h> | ||
28 | #include <qstring.h> | 29 | #include <qstring.h> |
29 | #include <qslider.h> | 30 | #include <qslider.h> |
31 | #include <qlineedit.h> | ||
30 | #include <qframe.h> | 32 | #include <qframe.h> |
31 | 33 | ||
34 | #include <opie/oticker.h> | ||
32 | 35 | ||
33 | class QPixmap; | 36 | class QPixmap; |
34 | 37 | ||
35 | |||
36 | enum AudioButtons { | 38 | enum AudioButtons { |
37 | AudioPlay, | 39 | AudioPlay, |
38 | AudioStop, | 40 | AudioStop, |
39 | AudioPause, | 41 | AudioPause, |
40 | AudioNext, | 42 | AudioNext, |
41 | AudioPrevious, | 43 | AudioPrevious, |
42 | AudioVolumeUp, | 44 | AudioVolumeUp, |
43 | AudioVolumeDown, | 45 | AudioVolumeDown, |
44 | AudioLoop, | 46 | AudioLoop, |
45 | AudioPlayList | 47 | AudioPlayList |
46 | }; | 48 | }; |
47 | 49 | ||
48 | 50 | ||
49 | #define USE_DBLBUF | 51 | //#define USE_DBLBUF |
50 | |||
51 | |||
52 | class Ticker : public QFrame { | ||
53 | Q_OBJECT | ||
54 | public: | ||
55 | Ticker( QWidget* parent=0 ) : QFrame( parent ) { | ||
56 | setFrameStyle( WinPanel | Sunken ); | ||
57 | setText( "No Song" ); | ||
58 | } | ||
59 | ~Ticker() { } | ||
60 | void setText( const QString& text ) { | ||
61 | pos = 0; // reset it everytime the text is changed | ||
62 | scrollText = text; | ||
63 | pixelLen = fontMetrics().width( scrollText ); | ||
64 | killTimers(); | ||
65 | if ( pixelLen > width() ) | ||
66 | startTimer( 50 ); | ||
67 | update(); | ||
68 | } | ||
69 | protected: | ||
70 | void timerEvent( QTimerEvent * ) { | ||
71 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | ||
72 | #ifndef USE_DBLBUF | ||
73 | scroll( -1, 0, contentsRect() ); | ||
74 | #else | ||
75 | repaint( FALSE ); | ||
76 | #endif | ||
77 | } | ||
78 | void drawContents( QPainter *p ) { | ||
79 | #ifndef USE_DBLBUF | ||
80 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | ||
81 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | ||
82 | #else | ||
83 | // Double buffering code. | ||
84 | // Looks like qvfb makes it look like it flickers but I don't think it really is | ||
85 | QPixmap pm( width(), height() ); | ||
86 | pm.fill( colorGroup().base() ); | ||
87 | QPainter pmp( &pm ); | ||
88 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | ||
89 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | ||
90 | p->drawPixmap( 0, 0, pm ); | ||
91 | #endif | ||
92 | } | ||
93 | private: | ||
94 | QString scrollText; | ||
95 | int pos, pixelLen; | ||
96 | }; | ||
97 | |||
98 | 52 | ||
99 | class AudioWidget : public QWidget { | 53 | class AudioWidget : public QWidget { |
100 | Q_OBJECT | 54 | Q_OBJECT |
101 | public: | 55 | public: |
102 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 56 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
103 | ~AudioWidget(); | 57 | ~AudioWidget(); |
104 | void setTickerText( const QString &text ) { songInfo->setText( text ); } | 58 | void setTickerText( const QString &text ) { songInfo.setText( text ); } |
105 | bool isStreaming; | 59 | bool isStreaming; |
106 | public slots: | 60 | public slots: |
107 | void updateSlider( long, long ); | 61 | void updateSlider( long, long ); |
108 | void sliderPressed( ); | 62 | void sliderPressed( ); |
109 | void sliderReleased( ); | 63 | void sliderReleased( ); |
110 | void setPaused( bool b) { setToggleButton( AudioPause, b ); } | 64 | void setPaused( bool b) { setToggleButton( AudioPause, b ); } |
111 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } | 65 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } |
112 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } | 66 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } |
113 | void setPosition( long ); | 67 | void setPosition( long ); |
114 | void setLength( long ); | 68 | void setLength( long ); |
115 | void setView( char ); | 69 | void setView( char ); |
116 | 70 | ||
117 | signals: | 71 | signals: |
118 | void moreClicked(); | 72 | void moreClicked(); |
119 | void lessClicked(); | 73 | void lessClicked(); |
120 | void moreReleased(); | 74 | void moreReleased(); |
121 | void lessReleased(); | 75 | void lessReleased(); |
122 | void sliderMoved(long); | 76 | void sliderMoved(long); |
123 | 77 | ||
124 | protected: | 78 | protected: |
125 | void doBlank(); | 79 | void doBlank(); |
126 | void doUnblank(); | 80 | void doUnblank(); |
127 | void paintEvent( QPaintEvent *pe ); | 81 | void paintEvent( QPaintEvent *pe ); |
128 | void showEvent( QShowEvent *se ); | 82 | void showEvent( QShowEvent *se ); |
83 | void resizeEvent( QResizeEvent *re ); | ||
129 | void mouseMoveEvent( QMouseEvent *event ); | 84 | void mouseMoveEvent( QMouseEvent *event ); |
130 | void mousePressEvent( QMouseEvent *event ); | 85 | void mousePressEvent( QMouseEvent *event ); |
131 | void mouseReleaseEvent( QMouseEvent *event ); | 86 | void mouseReleaseEvent( QMouseEvent *event ); |
132 | void timerEvent( QTimerEvent *event ); | 87 | void timerEvent( QTimerEvent *event ); |
133 | void closeEvent( QCloseEvent *event ); | 88 | void closeEvent( QCloseEvent *event ); |
134 | void keyReleaseEvent( QKeyEvent *e); | 89 | void keyReleaseEvent( QKeyEvent *e); |
135 | private: | 90 | private: |
136 | void toggleButton( int ); | 91 | void toggleButton( int ); |
137 | void setToggleButton( int, bool ); | 92 | void setToggleButton( int, bool ); |
138 | void paintButton( QPainter *p, int i ); | 93 | void paintButton( QPainter *p, int i ); |
94 | QString skin; | ||
95 | QPixmap *pixBg; | ||
96 | QImage *imgUp; | ||
97 | QImage *imgDn; | ||
98 | QImage *imgButtonMask; | ||
99 | QBitmap *masks[11]; | ||
100 | QPixmap *buttonPixUp[11]; | ||
101 | QPixmap *buttonPixDown[11]; | ||
102 | |||
139 | QPixmap *pixmaps[4]; | 103 | QPixmap *pixmaps[4]; |
140 | Ticker *songInfo; | 104 | OTicker songInfo; |
141 | QSlider *slider; | 105 | QSlider slider; |
106 | QLineEdit time; | ||
107 | int xoff, yoff; | ||
108 | |||
142 | }; | 109 | }; |
143 | 110 | ||
144 | 111 | ||
145 | #endif // AUDIO_WIDGET_H | 112 | #endif // AUDIO_WIDGET_H |
146 | 113 | ||