author | simon <simon> | 2002-12-02 20:09:10 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 20:09:10 (UTC) |
commit | e1ef407b16b652755f9c8eefce0f617ec3996998 (patch) (unidiff) | |
tree | 6db64108908f1eee41955caa0e9d7f1d7878e5a8 | |
parent | acfbc79f2acf59fa5e4494dde4ea1c4ea5e429b7 (diff) | |
download | opie-e1ef407b16b652755f9c8eefce0f617ec3996998.zip opie-e1ef407b16b652755f9c8eefce0f617ec3996998.tar.gz opie-e1ef407b16b652755f9c8eefce0f617ec3996998.tar.bz2 |
- MediaPlayer no more uses the MediaPlayerState instance as singleton
-rw-r--r-- | noncore/multimedia/opieplayer2/main.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 55 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.h | 4 |
3 files changed, 31 insertions, 30 deletions
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp index e951554..24aba6c 100644 --- a/noncore/multimedia/opieplayer2/main.cpp +++ b/noncore/multimedia/opieplayer2/main.cpp | |||
@@ -1,34 +1,34 @@ | |||
1 | 1 | ||
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include "mediaplayerstate.h" | 3 | #include "mediaplayerstate.h" |
4 | #include "playlistwidget.h" | 4 | #include "playlistwidget.h" |
5 | #include "audiowidget.h" | 5 | #include "audiowidget.h" |
6 | #include "videowidget.h" | 6 | #include "videowidget.h" |
7 | #include "mediaplayer.h" | 7 | #include "mediaplayer.h" |
8 | 8 | ||
9 | MediaPlayerState *mediaPlayerState; | 9 | MediaPlayerState *mediaPlayerState; |
10 | PlayListWidget *playList; | 10 | PlayListWidget *playList; |
11 | AudioWidget *audioUI; | 11 | AudioWidget *audioUI; |
12 | VideoWidget *videoUI; | 12 | VideoWidget *videoUI; |
13 | 13 | ||
14 | int main(int argc, char **argv) { | 14 | int main(int argc, char **argv) { |
15 | QPEApplication a(argc,argv); | 15 | QPEApplication a(argc,argv); |
16 | 16 | ||
17 | MediaPlayerState st( 0, "mediaPlayerState" ); | 17 | MediaPlayerState st( 0, "mediaPlayerState" ); |
18 | mediaPlayerState = &st; | 18 | mediaPlayerState = &st; |
19 | PlayListWidget pl( 0, "playList" ); | 19 | PlayListWidget pl( 0, "playList" ); |
20 | playList = &pl; | 20 | playList = &pl; |
21 | pl.showMaximized(); | 21 | pl.showMaximized(); |
22 | AudioWidget aw( 0, "audioUI" ); | 22 | AudioWidget aw( 0, "audioUI" ); |
23 | audioUI = &aw; | 23 | audioUI = &aw; |
24 | VideoWidget vw( 0, "videoUI" ); | 24 | VideoWidget vw( 0, "videoUI" ); |
25 | videoUI = &vw; | 25 | videoUI = &vw; |
26 | a.processEvents(); | 26 | a.processEvents(); |
27 | MediaPlayer mp( 0, "mediaPlayer" ); | 27 | MediaPlayer mp( st, 0, "mediaPlayer" ); |
28 | 28 | ||
29 | a.showMainDocumentWidget(&pl); | 29 | a.showMainDocumentWidget(&pl); |
30 | 30 | ||
31 | return a.exec(); | 31 | return a.exec(); |
32 | } | 32 | } |
33 | 33 | ||
34 | 34 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 68bbae9..424259b 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,354 +1,353 @@ | |||
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 | #include <qfileinfo.h> | 6 | #include <qfileinfo.h> |
7 | 7 | ||
8 | #include <qmainwindow.h> | 8 | #include <qmainwindow.h> |
9 | #include <qmessagebox.h> | 9 | #include <qmessagebox.h> |
10 | #include <qwidgetstack.h> | 10 | #include <qwidgetstack.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | 12 | ||
13 | #include "mediaplayer.h" | 13 | #include "mediaplayer.h" |
14 | #include "playlistwidget.h" | 14 | #include "playlistwidget.h" |
15 | #include "audiowidget.h" | 15 | #include "audiowidget.h" |
16 | #include "videowidget.h" | 16 | #include "videowidget.h" |
17 | #include "volumecontrol.h" | 17 | #include "volumecontrol.h" |
18 | 18 | ||
19 | #include "mediaplayerstate.h" | 19 | #include "mediaplayerstate.h" |
20 | 20 | ||
21 | // for setBacklight() | 21 | // for setBacklight() |
22 | #include <linux/fb.h> | 22 | #include <linux/fb.h> |
23 | #include <sys/file.h> | 23 | #include <sys/file.h> |
24 | #include <sys/ioctl.h> | 24 | #include <sys/ioctl.h> |
25 | 25 | ||
26 | 26 | ||
27 | extern AudioWidget *audioUI; | 27 | extern AudioWidget *audioUI; |
28 | extern VideoWidget *videoUI; | 28 | extern VideoWidget *videoUI; |
29 | extern PlayListWidget *playList; | 29 | extern PlayListWidget *playList; |
30 | extern MediaPlayerState *mediaPlayerState; | ||
31 | 30 | ||
32 | 31 | ||
33 | #define FBIOBLANK 0x4611 | 32 | #define FBIOBLANK 0x4611 |
34 | 33 | ||
35 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 34 | MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
36 | : QObject( parent, name ), volumeDirection( 0 ) { | 35 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ) { |
37 | 36 | ||
38 | fd=-1;fl=-1; | 37 | fd=-1;fl=-1; |
39 | playList->setCaption( tr( "OpiePlayer: Initializating" ) ); | 38 | playList->setCaption( tr( "OpiePlayer: Initializating" ) ); |
40 | 39 | ||
41 | qApp->processEvents(); | 40 | qApp->processEvents(); |
42 | // QPEApplication::grabKeyboard(); // EVIL | 41 | // QPEApplication::grabKeyboard(); // EVIL |
43 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 42 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
44 | 43 | ||
45 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 44 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
46 | 45 | ||
47 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 46 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
48 | 47 | ||
49 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 48 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
50 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 49 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
51 | connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | 50 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); |
52 | 51 | ||
53 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 52 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
54 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 53 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
55 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 54 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
56 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 55 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
57 | 56 | ||
58 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 57 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
59 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 58 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
60 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 59 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
61 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 60 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
62 | 61 | ||
63 | volControl = new VolumeControl; | 62 | volControl = new VolumeControl; |
64 | xineControl = new XineControl(); | 63 | xineControl = new XineControl(); |
65 | Config cfg( "OpiePlayer" ); | 64 | Config cfg( "OpiePlayer" ); |
66 | cfg.setGroup("PlayList"); | 65 | cfg.setGroup("PlayList"); |
67 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 66 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
68 | playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); | 67 | playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); |
69 | } | 68 | } |
70 | 69 | ||
71 | MediaPlayer::~MediaPlayer() { | 70 | MediaPlayer::~MediaPlayer() { |
72 | delete xineControl; | 71 | delete xineControl; |
73 | delete volControl; | 72 | delete volControl; |
74 | } | 73 | } |
75 | 74 | ||
76 | void MediaPlayer::pauseCheck( bool b ) { | 75 | void MediaPlayer::pauseCheck( bool b ) { |
77 | if ( b && !mediaPlayerState->isPlaying() ) { | 76 | if ( b && !mediaPlayerState.isPlaying() ) { |
78 | mediaPlayerState->setPaused( FALSE ); | 77 | mediaPlayerState.setPaused( FALSE ); |
79 | } | 78 | } |
80 | } | 79 | } |
81 | 80 | ||
82 | void MediaPlayer::play() { | 81 | void MediaPlayer::play() { |
83 | mediaPlayerState->setPlaying( FALSE ); | 82 | mediaPlayerState.setPlaying( FALSE ); |
84 | mediaPlayerState->setPlaying( TRUE ); | 83 | mediaPlayerState.setPlaying( TRUE ); |
85 | } | 84 | } |
86 | 85 | ||
87 | void MediaPlayer::setPlaying( bool play ) { | 86 | void MediaPlayer::setPlaying( bool play ) { |
88 | if ( !play ) { | 87 | if ( !play ) { |
89 | return; | 88 | return; |
90 | } | 89 | } |
91 | 90 | ||
92 | if ( mediaPlayerState->isPaused() ) { | 91 | if ( mediaPlayerState.isPaused() ) { |
93 | mediaPlayerState->setPaused( FALSE ); | 92 | mediaPlayerState.setPaused( FALSE ); |
94 | return; | 93 | return; |
95 | } | 94 | } |
96 | 95 | ||
97 | QString tickerText, time, fileName; | 96 | QString tickerText, time, fileName; |
98 | if ( playList->currentTab() != PlayListWidget::CurrentPlayList ) { | 97 | if ( playList->currentTab() != PlayListWidget::CurrentPlayList ) { |
99 | //if playing in file list.. play in a different way | 98 | //if playing in file list.. play in a different way |
100 | // random and looping settings enabled causes problems here, | 99 | // random and looping settings enabled causes problems here, |
101 | // since there is no selected file in the playlist, but a selected file in the file list, | 100 | // since there is no selected file in the playlist, but a selected file in the file list, |
102 | // so we remember and shutoff | 101 | // so we remember and shutoff |
103 | l = mediaPlayerState->isLooping(); | 102 | l = mediaPlayerState.isLooping(); |
104 | if(l) { | 103 | if(l) { |
105 | mediaPlayerState->setLooping( false ); | 104 | mediaPlayerState.setLooping( false ); |
106 | } | 105 | } |
107 | r = mediaPlayerState->isShuffled(); | 106 | r = mediaPlayerState.isShuffled(); |
108 | mediaPlayerState->setShuffled( false ); | 107 | mediaPlayerState.setShuffled( false ); |
109 | } | 108 | } |
110 | 109 | ||
111 | PlayListWidget::Entry playListEntry = playList->currentEntry(); | 110 | PlayListWidget::Entry playListEntry = playList->currentEntry(); |
112 | fileName = playListEntry.name; | 111 | fileName = playListEntry.name; |
113 | xineControl->play( playListEntry.file ); | 112 | xineControl->play( playListEntry.file ); |
114 | 113 | ||
115 | long seconds = mediaPlayerState->length(); | 114 | long seconds = mediaPlayerState.length(); |
116 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 115 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
117 | 116 | ||
118 | if( fileName.left(4) == "http" ) { | 117 | if( fileName.left(4) == "http" ) { |
119 | fileName = QFileInfo( fileName ).baseName(); | 118 | fileName = QFileInfo( fileName ).baseName(); |
120 | if ( xineControl->getMetaInfo().isEmpty() ) { | 119 | if ( xineControl->getMetaInfo().isEmpty() ) { |
121 | tickerText = tr( " File: " ) + fileName; | 120 | tickerText = tr( " File: " ) + fileName; |
122 | } else { | 121 | } else { |
123 | tickerText = xineControl->getMetaInfo(); | 122 | tickerText = xineControl->getMetaInfo(); |
124 | } | 123 | } |
125 | } else { | 124 | } else { |
126 | if ( xineControl->getMetaInfo().isEmpty() ) { | 125 | if ( xineControl->getMetaInfo().isEmpty() ) { |
127 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 126 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
128 | } else { | 127 | } else { |
129 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; | 128 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; |
130 | } | 129 | } |
131 | } | 130 | } |
132 | audioUI->setTickerText( tickerText ); | 131 | audioUI->setTickerText( tickerText ); |
133 | } | 132 | } |
134 | 133 | ||
135 | 134 | ||
136 | void MediaPlayer::prev() { | 135 | void MediaPlayer::prev() { |
137 | if( playList->currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist | 136 | if( playList->currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist |
138 | if ( playList->prev() ) { | 137 | if ( playList->prev() ) { |
139 | play(); | 138 | play(); |
140 | } else if ( mediaPlayerState->isLooping() ) { | 139 | } else if ( mediaPlayerState.isLooping() ) { |
141 | if ( playList->last() ) { | 140 | if ( playList->last() ) { |
142 | play(); | 141 | play(); |
143 | } | 142 | } |
144 | } else { | 143 | } else { |
145 | mediaPlayerState->setList(); | 144 | mediaPlayerState.setList(); |
146 | } | 145 | } |
147 | } | 146 | } |
148 | } | 147 | } |
149 | 148 | ||
150 | 149 | ||
151 | void MediaPlayer::next() { | 150 | void MediaPlayer::next() { |
152 | 151 | ||
153 | if(playList->currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist | 152 | if(playList->currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist |
154 | if ( playList->next() ) { | 153 | if ( playList->next() ) { |
155 | play(); | 154 | play(); |
156 | } else if ( mediaPlayerState->isLooping() ) { | 155 | } else if ( mediaPlayerState.isLooping() ) { |
157 | if ( playList->first() ) { | 156 | if ( playList->first() ) { |
158 | play(); | 157 | play(); |
159 | } | 158 | } |
160 | } else { | 159 | } else { |
161 | mediaPlayerState->setList(); | 160 | mediaPlayerState.setList(); |
162 | } | 161 | } |
163 | } else { //if playing from file list, let's just stop | 162 | } else { //if playing from file list, let's just stop |
164 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); | 163 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
165 | mediaPlayerState->setPlaying(false); | 164 | mediaPlayerState.setPlaying(false); |
166 | mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); | 165 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
167 | if(l) mediaPlayerState->setLooping(l); | 166 | if(l) mediaPlayerState.setLooping(l); |
168 | if(r) mediaPlayerState->setShuffled(r); | 167 | if(r) mediaPlayerState.setShuffled(r); |
169 | } | 168 | } |
170 | qApp->processEvents(); | 169 | qApp->processEvents(); |
171 | } | 170 | } |
172 | 171 | ||
173 | 172 | ||
174 | void MediaPlayer::startDecreasingVolume() { | 173 | void MediaPlayer::startDecreasingVolume() { |
175 | volumeDirection = -1; | 174 | volumeDirection = -1; |
176 | startTimer( 100 ); | 175 | startTimer( 100 ); |
177 | volControl->decVol(2); | 176 | volControl->decVol(2); |
178 | } | 177 | } |
179 | 178 | ||
180 | 179 | ||
181 | void MediaPlayer::startIncreasingVolume() { | 180 | void MediaPlayer::startIncreasingVolume() { |
182 | volumeDirection = +1; | 181 | volumeDirection = +1; |
183 | startTimer( 100 ); | 182 | startTimer( 100 ); |
184 | volControl->incVol(2); | 183 | volControl->incVol(2); |
185 | } | 184 | } |
186 | 185 | ||
187 | 186 | ||
188 | bool drawnOnScreenDisplay = FALSE; | 187 | bool drawnOnScreenDisplay = FALSE; |
189 | unsigned int onScreenDisplayVolume = 0; | 188 | unsigned int onScreenDisplayVolume = 0; |
190 | const int yoff = 110; | 189 | const int yoff = 110; |
191 | 190 | ||
192 | void MediaPlayer::stopChangingVolume() { | 191 | void MediaPlayer::stopChangingVolume() { |
193 | killTimers(); | 192 | killTimers(); |
194 | // Get rid of the on-screen display stuff | 193 | // Get rid of the on-screen display stuff |
195 | drawnOnScreenDisplay = FALSE; | 194 | drawnOnScreenDisplay = FALSE; |
196 | onScreenDisplayVolume = 0; | 195 | onScreenDisplayVolume = 0; |
197 | int w=0; | 196 | int w=0; |
198 | int h=0; | 197 | int h=0; |
199 | if( !xineControl->hasVideo() ) { | 198 | if( !xineControl->hasVideo() ) { |
200 | w = audioUI->width(); | 199 | w = audioUI->width(); |
201 | h = audioUI->height(); | 200 | h = audioUI->height(); |
202 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 201 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
203 | } else { | 202 | } else { |
204 | w = videoUI->width(); | 203 | w = videoUI->width(); |
205 | h = videoUI->height(); | 204 | h = videoUI->height(); |
206 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 205 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
207 | } | 206 | } |
208 | } | 207 | } |
209 | 208 | ||
210 | 209 | ||
211 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 210 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
212 | if ( volumeDirection == +1 ) { | 211 | if ( volumeDirection == +1 ) { |
213 | volControl->incVol( 2 ); | 212 | volControl->incVol( 2 ); |
214 | } else if ( volumeDirection == -1 ) { | 213 | } else if ( volumeDirection == -1 ) { |
215 | volControl->decVol( 2 ); | 214 | volControl->decVol( 2 ); |
216 | } | 215 | } |
217 | 216 | ||
218 | 217 | ||
219 | // TODO FIXME | 218 | // TODO FIXME |
220 | // huh?? | 219 | // huh?? |
221 | unsigned int v= 0; | 220 | unsigned int v= 0; |
222 | v = volControl->volume(); | 221 | v = volControl->volume(); |
223 | v = v / 10; | 222 | v = v / 10; |
224 | 223 | ||
225 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 224 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
226 | return; | 225 | return; |
227 | } | 226 | } |
228 | 227 | ||
229 | int w=0; int h=0; | 228 | int w=0; int h=0; |
230 | if( !xineControl->hasVideo() ) { | 229 | if( !xineControl->hasVideo() ) { |
231 | w = audioUI->width(); | 230 | w = audioUI->width(); |
232 | h = audioUI->height(); | 231 | h = audioUI->height(); |
233 | 232 | ||
234 | if ( drawnOnScreenDisplay ) { | 233 | if ( drawnOnScreenDisplay ) { |
235 | if ( onScreenDisplayVolume > v ) { | 234 | if ( onScreenDisplayVolume > v ) { |
236 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 235 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
237 | } | 236 | } |
238 | } | 237 | } |
239 | drawnOnScreenDisplay = TRUE; | 238 | drawnOnScreenDisplay = TRUE; |
240 | onScreenDisplayVolume = v; | 239 | onScreenDisplayVolume = v; |
241 | QPainter p( audioUI ); | 240 | QPainter p( audioUI ); |
242 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 241 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
243 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 242 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
244 | 243 | ||
245 | QFont f; | 244 | QFont f; |
246 | f.setPixelSize( 20 ); | 245 | f.setPixelSize( 20 ); |
247 | f.setBold( TRUE ); | 246 | f.setBold( TRUE ); |
248 | p.setFont( f ); | 247 | p.setFont( f ); |
249 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 248 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
250 | 249 | ||
251 | for ( unsigned int i = 0; i < 10; i++ ) { | 250 | for ( unsigned int i = 0; i < 10; i++ ) { |
252 | if ( v > i ) { | 251 | if ( v > i ) { |
253 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 252 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
254 | } else { | 253 | } else { |
255 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 254 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
256 | } | 255 | } |
257 | } | 256 | } |
258 | } else { | 257 | } else { |
259 | w = videoUI->width(); | 258 | w = videoUI->width(); |
260 | h = videoUI->height(); | 259 | h = videoUI->height(); |
261 | 260 | ||
262 | if ( drawnOnScreenDisplay ) { | 261 | if ( drawnOnScreenDisplay ) { |
263 | if ( onScreenDisplayVolume > v ) { | 262 | if ( onScreenDisplayVolume > v ) { |
264 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 263 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
265 | } | 264 | } |
266 | } | 265 | } |
267 | drawnOnScreenDisplay = TRUE; | 266 | drawnOnScreenDisplay = TRUE; |
268 | onScreenDisplayVolume = v; | 267 | onScreenDisplayVolume = v; |
269 | QPainter p( videoUI ); | 268 | QPainter p( videoUI ); |
270 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 269 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
271 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 270 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
272 | 271 | ||
273 | QFont f; | 272 | QFont f; |
274 | f.setPixelSize( 20 ); | 273 | f.setPixelSize( 20 ); |
275 | f.setBold( TRUE ); | 274 | f.setBold( TRUE ); |
276 | p.setFont( f ); | 275 | p.setFont( f ); |
277 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); | 276 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); |
278 | 277 | ||
279 | for ( unsigned int i = 0; i < 10; i++ ) { | 278 | for ( unsigned int i = 0; i < 10; i++ ) { |
280 | if ( v > i ) { | 279 | if ( v > i ) { |
281 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 280 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
282 | } else { | 281 | } else { |
283 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 282 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
284 | } | 283 | } |
285 | } | 284 | } |
286 | } | 285 | } |
287 | } | 286 | } |
288 | 287 | ||
289 | 288 | ||
290 | void MediaPlayer::blank( bool b ) { | 289 | void MediaPlayer::blank( bool b ) { |
291 | fd=open("/dev/fb0",O_RDWR); | 290 | fd=open("/dev/fb0",O_RDWR); |
292 | #ifdef QT_QWS_EBX | 291 | #ifdef QT_QWS_EBX |
293 | fl= open( "/dev/fl", O_RDWR ); | 292 | fl= open( "/dev/fl", O_RDWR ); |
294 | #endif | 293 | #endif |
295 | if (fd != -1) { | 294 | if (fd != -1) { |
296 | if ( b ) { | 295 | if ( b ) { |
297 | qDebug("do blanking"); | 296 | qDebug("do blanking"); |
298 | #ifdef QT_QWS_EBX | 297 | #ifdef QT_QWS_EBX |
299 | ioctl( fd, FBIOBLANK, 1 ); | 298 | ioctl( fd, FBIOBLANK, 1 ); |
300 | if(fl !=-1) { | 299 | if(fl !=-1) { |
301 | ioctl( fl, 2 ); | 300 | ioctl( fl, 2 ); |
302 | ::close(fl); | 301 | ::close(fl); |
303 | } | 302 | } |
304 | #else | 303 | #else |
305 | ioctl( fd, FBIOBLANK, 3 ); | 304 | ioctl( fd, FBIOBLANK, 3 ); |
306 | #endif | 305 | #endif |
307 | isBlanked = TRUE; | 306 | isBlanked = TRUE; |
308 | } else { | 307 | } else { |
309 | qDebug("do unblanking"); | 308 | qDebug("do unblanking"); |
310 | ioctl( fd, FBIOBLANK, 0); | 309 | ioctl( fd, FBIOBLANK, 0); |
311 | #ifdef QT_QWS_EBX | 310 | #ifdef QT_QWS_EBX |
312 | if(fl != -1) { | 311 | if(fl != -1) { |
313 | ioctl( fl, 1); | 312 | ioctl( fl, 1); |
314 | ::close(fl); | 313 | ::close(fl); |
315 | } | 314 | } |
316 | #endif | 315 | #endif |
317 | isBlanked = FALSE; | 316 | isBlanked = FALSE; |
318 | } | 317 | } |
319 | close( fd ); | 318 | close( fd ); |
320 | } else { | 319 | } else { |
321 | qDebug("<< /dev/fb0 could not be opened >>"); | 320 | qDebug("<< /dev/fb0 could not be opened >>"); |
322 | } | 321 | } |
323 | } | 322 | } |
324 | 323 | ||
325 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 324 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
326 | switch ( e->key() ) { | 325 | switch ( e->key() ) { |
327 | ////////////////////////////// Zaurus keys | 326 | ////////////////////////////// Zaurus keys |
328 | case Key_Home: | 327 | case Key_Home: |
329 | break; | 328 | break; |
330 | case Key_F9: //activity | 329 | case Key_F9: //activity |
331 | break; | 330 | break; |
332 | case Key_F10: //contacts | 331 | case Key_F10: //contacts |
333 | break; | 332 | break; |
334 | case Key_F11: //menu | 333 | case Key_F11: //menu |
335 | break; | 334 | break; |
336 | case Key_F12: //home | 335 | case Key_F12: //home |
337 | qDebug("Blank here"); | 336 | qDebug("Blank here"); |
338 | // mediaPlayerState->toggleBlank(); | 337 | // mediaPlayerState->toggleBlank(); |
339 | break; | 338 | break; |
340 | case Key_F13: //mail | 339 | case Key_F13: //mail |
341 | qDebug("Blank here"); | 340 | qDebug("Blank here"); |
342 | // mediaPlayerState->toggleBlank(); | 341 | // mediaPlayerState->toggleBlank(); |
343 | break; | 342 | break; |
344 | } | 343 | } |
345 | } | 344 | } |
346 | 345 | ||
347 | void MediaPlayer::cleanUp() {// this happens on closing | 346 | void MediaPlayer::cleanUp() {// this happens on closing |
348 | Config cfg( "OpiePlayer" ); | 347 | Config cfg( "OpiePlayer" ); |
349 | mediaPlayerState->writeConfig( cfg ); | 348 | mediaPlayerState.writeConfig( cfg ); |
350 | playList->writeDefaultPlaylist( ); | 349 | playList->writeDefaultPlaylist( ); |
351 | 350 | ||
352 | // QPEApplication::grabKeyboard(); | 351 | // QPEApplication::grabKeyboard(); |
353 | // QPEApplication::ungrabKeyboard(); | 352 | // QPEApplication::ungrabKeyboard(); |
354 | } | 353 | } |
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h index de3886e..6aeac7c 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.h +++ b/noncore/multimedia/opieplayer2/mediaplayer.h | |||
@@ -1,75 +1,77 @@ | |||
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 LJP <> | 5 | Copyright (c) 2002 LJP <> |
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 MEDIA_PLAYER_H | 34 | #ifndef MEDIA_PLAYER_H |
35 | #define MEDIA_PLAYER_H | 35 | #define MEDIA_PLAYER_H |
36 | 36 | ||
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | #include <qframe.h> | 38 | #include <qframe.h> |
39 | 39 | ||
40 | #include "xinecontrol.h" | 40 | #include "xinecontrol.h" |
41 | 41 | ||
42 | class DocLnk; | 42 | class DocLnk; |
43 | class VolumeControl; | 43 | class VolumeControl; |
44 | class MediaPlayerState; | ||
44 | 45 | ||
45 | class MediaPlayer : public QObject { | 46 | class MediaPlayer : public QObject { |
46 | Q_OBJECT | 47 | Q_OBJECT |
47 | public: | 48 | public: |
48 | MediaPlayer( QObject *parent, const char *name ); | 49 | MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ); |
49 | ~MediaPlayer(); | 50 | ~MediaPlayer(); |
50 | private slots: | 51 | private slots: |
51 | void setPlaying( bool ); | 52 | void setPlaying( bool ); |
52 | void pauseCheck( bool ); | 53 | void pauseCheck( bool ); |
53 | void play(); | 54 | void play(); |
54 | void next(); | 55 | void next(); |
55 | void prev(); | 56 | void prev(); |
56 | void startIncreasingVolume(); | 57 | void startIncreasingVolume(); |
57 | void startDecreasingVolume(); | 58 | void startDecreasingVolume(); |
58 | void stopChangingVolume(); | 59 | void stopChangingVolume(); |
59 | void cleanUp(); | 60 | void cleanUp(); |
60 | void blank( bool ); | 61 | void blank( bool ); |
61 | 62 | ||
62 | protected: | 63 | protected: |
63 | void timerEvent( QTimerEvent *e ); | 64 | void timerEvent( QTimerEvent *e ); |
64 | void keyReleaseEvent( QKeyEvent *e); | 65 | void keyReleaseEvent( QKeyEvent *e); |
65 | private: | 66 | private: |
66 | bool isBlanked, l, r; | 67 | bool isBlanked, l, r; |
67 | int fd, fl; | 68 | int fd, fl; |
68 | int volumeDirection; | 69 | int volumeDirection; |
69 | XineControl *xineControl; | 70 | XineControl *xineControl; |
70 | VolumeControl *volControl; | 71 | VolumeControl *volControl; |
72 | MediaPlayerState &mediaPlayerState; | ||
71 | }; | 73 | }; |
72 | 74 | ||
73 | 75 | ||
74 | #endif // MEDIA_PLAYER_H | 76 | #endif // MEDIA_PLAYER_H |
75 | 77 | ||