author | llornkcor <llornkcor> | 2002-04-21 22:23:53 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-21 22:23:53 (UTC) |
commit | 27522ce8deaa0bdc23a6b88002bc1d2e5f918ce6 (patch) (unidiff) | |
tree | 05f6e301fd80c5551301ad88c19c3bcb061834ac | |
parent | 53a4a3f6398640d182a067a8ffef9b402cd35d7a (diff) | |
download | opie-27522ce8deaa0bdc23a6b88002bc1d2e5f918ce6.zip opie-27522ce8deaa0bdc23a6b88002bc1d2e5f918ce6.tar.gz opie-27522ce8deaa0bdc23a6b88002bc1d2e5f918ce6.tar.bz2 |
comment out grabKeyboard stuff till that function works properly
-rw-r--r-- | core/multimedia/opieplayer/mediaplayer.cpp | 38 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mediaplayer.h | 6 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 51 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 4 | ||||
-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 2 |
5 files changed, 90 insertions, 11 deletions
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp index ab46a7d..b9e438b 100644 --- a/core/multimedia/opieplayer/mediaplayer.cpp +++ b/core/multimedia/opieplayer/mediaplayer.cpp | |||
@@ -1,187 +1,219 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/qlibrary.h> | 22 | #include <qpe/qlibrary.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | 25 | ||
26 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qwidgetstack.h> | 28 | #include <qwidgetstack.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | 30 | ||
31 | #include "mediaplayer.h" | 31 | #include "mediaplayer.h" |
32 | #include "playlistwidget.h" | 32 | #include "playlistwidget.h" |
33 | #include "audiowidget.h" | 33 | #include "audiowidget.h" |
34 | #include "loopcontrol.h" | 34 | #include "loopcontrol.h" |
35 | #include "audiodevice.h" | 35 | #include "audiodevice.h" |
36 | 36 | ||
37 | #include "mediaplayerstate.h" | 37 | #include "mediaplayerstate.h" |
38 | 38 | ||
39 | 39 | ||
40 | extern AudioWidget *audioUI; | 40 | extern AudioWidget *audioUI; |
41 | extern PlayListWidget *playList; | 41 | extern PlayListWidget *playList; |
42 | extern LoopControl *loopControl; | 42 | extern LoopControl *loopControl; |
43 | extern MediaPlayerState *mediaPlayerState; | 43 | extern MediaPlayerState *mediaPlayerState; |
44 | 44 | ||
45 | 45 | ||
46 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 46 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
47 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 47 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
48 | QPEApplication::grabKeyboard(); | 48 | |
49 | // QPEApplication::grabKeyboard(); | ||
50 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | ||
49 | 51 | ||
50 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 52 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
51 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 53 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
52 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 54 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
53 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 55 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
54 | 56 | ||
55 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 57 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
56 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 58 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
57 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 59 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
58 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 60 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
59 | } | 61 | } |
60 | 62 | ||
61 | 63 | ||
62 | MediaPlayer::~MediaPlayer() { | 64 | MediaPlayer::~MediaPlayer() { |
63 | QPEApplication::grabKeyboard(); | ||
64 | QPEApplication::ungrabKeyboard(); | ||
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | void MediaPlayer::pauseCheck( bool b ) { | 68 | void MediaPlayer::pauseCheck( bool b ) { |
69 | // Only pause if playing | 69 | // Only pause if playing |
70 | if ( b && !mediaPlayerState->playing() ) | 70 | if ( b && !mediaPlayerState->playing() ) |
71 | mediaPlayerState->setPaused( FALSE ); | 71 | mediaPlayerState->setPaused( FALSE ); |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | void MediaPlayer::play() { | 75 | void MediaPlayer::play() { |
76 | mediaPlayerState->setPlaying( FALSE ); | 76 | mediaPlayerState->setPlaying( FALSE ); |
77 | mediaPlayerState->setPlaying( TRUE ); | 77 | mediaPlayerState->setPlaying( TRUE ); |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | void MediaPlayer::setPlaying( bool play ) { | 81 | void MediaPlayer::setPlaying( bool play ) { |
82 | if ( !play ) { | 82 | if ( !play ) { |
83 | mediaPlayerState->setPaused( FALSE ); | 83 | mediaPlayerState->setPaused( FALSE ); |
84 | loopControl->stop( FALSE ); | 84 | loopControl->stop( FALSE ); |
85 | return; | 85 | return; |
86 | } | 86 | } |
87 | 87 | ||
88 | if ( mediaPlayerState->paused() ) { | 88 | if ( mediaPlayerState->paused() ) { |
89 | mediaPlayerState->setPaused( FALSE ); | 89 | mediaPlayerState->setPaused( FALSE ); |
90 | return; | 90 | return; |
91 | } | 91 | } |
92 | 92 | ||
93 | const DocLnk *playListCurrent = playList->current(); | 93 | const DocLnk *playListCurrent = playList->current(); |
94 | if ( playListCurrent != NULL ) { | 94 | if ( playListCurrent != NULL ) { |
95 | loopControl->stop( TRUE ); | 95 | loopControl->stop( TRUE ); |
96 | currentFile = playListCurrent; | 96 | currentFile = playListCurrent; |
97 | } | 97 | } |
98 | if ( currentFile == NULL ) { | 98 | if ( currentFile == NULL ) { |
99 | QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); | 99 | QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); |
100 | mediaPlayerState->setPlaying( FALSE ); | 100 | mediaPlayerState->setPlaying( FALSE ); |
101 | return; | 101 | return; |
102 | } | 102 | } |
103 | 103 | ||
104 | if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { | 104 | if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { |
105 | QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); | 105 | QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); |
106 | mediaPlayerState->setPlaying( FALSE ); | 106 | mediaPlayerState->setPlaying( FALSE ); |
107 | return; | 107 | return; |
108 | } | 108 | } |
109 | 109 | ||
110 | if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { | 110 | if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { |
111 | QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); | 111 | QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); |
112 | mediaPlayerState->setPlaying( FALSE ); | 112 | mediaPlayerState->setPlaying( FALSE ); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | 115 | ||
116 | if ( !loopControl->init( currentFile->file() ) ) { | 116 | if ( !loopControl->init( currentFile->file() ) ) { |
117 | QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); | 117 | QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); |
118 | mediaPlayerState->setPlaying( FALSE ); | 118 | mediaPlayerState->setPlaying( FALSE ); |
119 | return; | 119 | return; |
120 | } | 120 | } |
121 | long seconds = loopControl->totalPlaytime(); | 121 | long seconds = loopControl->totalPlaytime(); |
122 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 122 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
123 | QString tickerText; | 123 | QString tickerText; |
124 | if( currentFile->file().left(4) == "http" ) | 124 | if( currentFile->file().left(4) == "http" ) |
125 | tickerText= tr( " File: " ) + currentFile->name(); | 125 | tickerText= tr( " File: " ) + currentFile->name(); |
126 | else | 126 | else |
127 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; | 127 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; |
128 | 128 | ||
129 | QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); | 129 | QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); |
130 | if ( !fileInfo.isEmpty() ) | 130 | if ( !fileInfo.isEmpty() ) |
131 | tickerText += ", " + fileInfo; | 131 | tickerText += ", " + fileInfo; |
132 | audioUI->setTickerText( tickerText + "." ); | 132 | audioUI->setTickerText( tickerText + "." ); |
133 | 133 | ||
134 | loopControl->play(); | 134 | loopControl->play(); |
135 | 135 | ||
136 | mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' ); | 136 | mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' ); |
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
140 | void MediaPlayer::prev() { | 140 | void MediaPlayer::prev() { |
141 | if ( playList->prev() ) | 141 | if ( playList->prev() ) |
142 | play(); | 142 | play(); |
143 | else if ( mediaPlayerState->looping() ) { | 143 | else if ( mediaPlayerState->looping() ) { |
144 | if ( playList->last() ) | 144 | if ( playList->last() ) |
145 | play(); | 145 | play(); |
146 | } else | 146 | } else |
147 | mediaPlayerState->setList(); | 147 | mediaPlayerState->setList(); |
148 | } | 148 | } |
149 | 149 | ||
150 | 150 | ||
151 | void MediaPlayer::next() { | 151 | void MediaPlayer::next() { |
152 | if ( playList->next() ) | 152 | if ( playList->next() ) |
153 | play(); | 153 | play(); |
154 | else if ( mediaPlayerState->looping() ) { | 154 | else if ( mediaPlayerState->looping() ) { |
155 | if ( playList->first() ) | 155 | if ( playList->first() ) |
156 | play(); | 156 | play(); |
157 | } else | 157 | } else |
158 | mediaPlayerState->setList(); | 158 | mediaPlayerState->setList(); |
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | void MediaPlayer::startDecreasingVolume() { | 162 | void MediaPlayer::startDecreasingVolume() { |
163 | volumeDirection = -1; | 163 | volumeDirection = -1; |
164 | startTimer( 100 ); | 164 | startTimer( 100 ); |
165 | AudioDevice::decreaseVolume(); | 165 | AudioDevice::decreaseVolume(); |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | void MediaPlayer::startIncreasingVolume() { | 169 | void MediaPlayer::startIncreasingVolume() { |
170 | volumeDirection = +1; | 170 | volumeDirection = +1; |
171 | startTimer( 100 ); | 171 | startTimer( 100 ); |
172 | AudioDevice::increaseVolume(); | 172 | AudioDevice::increaseVolume(); |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
176 | void MediaPlayer::stopChangingVolume() { | 176 | void MediaPlayer::stopChangingVolume() { |
177 | killTimers(); | 177 | killTimers(); |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 181 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
182 | if ( volumeDirection == +1 ) | 182 | if ( volumeDirection == +1 ) |
183 | AudioDevice::increaseVolume(); | 183 | AudioDevice::increaseVolume(); |
184 | else if ( volumeDirection == -1 ) | 184 | else if ( volumeDirection == -1 ) |
185 | AudioDevice::decreaseVolume(); | 185 | AudioDevice::decreaseVolume(); |
186 | } | 186 | } |
187 | 187 | ||
188 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | ||
189 | switch ( e->key() ) { | ||
190 | ////////////////////////////// Zaurus keys | ||
191 | case Key_Home: | ||
192 | break; | ||
193 | case Key_F9: //activity | ||
194 | break; | ||
195 | case Key_F10: //contacts | ||
196 | break; | ||
197 | case Key_F11: //menu | ||
198 | break; | ||
199 | case Key_F12: //home | ||
200 | qDebug("Blank here"); | ||
201 | break; | ||
202 | case Key_F13: //mail | ||
203 | break; | ||
204 | } | ||
205 | } | ||
206 | |||
207 | void MediaPlayer::doBlank() { | ||
208 | |||
209 | } | ||
210 | |||
211 | void MediaPlayer::doUnblank() { | ||
212 | |||
213 | } | ||
214 | |||
215 | void MediaPlayer::cleanUp() { | ||
216 | // QPEApplication::grabKeyboard(); | ||
217 | // QPEApplication::ungrabKeyboard(); | ||
218 | |||
219 | } | ||
diff --git a/core/multimedia/opieplayer/mediaplayer.h b/core/multimedia/opieplayer/mediaplayer.h index 0354d21..cf9daea 100644 --- a/core/multimedia/opieplayer/mediaplayer.h +++ b/core/multimedia/opieplayer/mediaplayer.h | |||
@@ -1,59 +1,61 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | #ifndef MEDIA_PLAYER_H | 20 | #ifndef MEDIA_PLAYER_H |
21 | #define MEDIA_PLAYER_H | 21 | #define MEDIA_PLAYER_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qframe.h> | 24 | #include <qframe.h> |
25 | #include <qpe/qlibrary.h> | 25 | #include <qpe/qlibrary.h> |
26 | #include <qpe/mediaplayerplugininterface.h> | 26 | #include <qpe/mediaplayerplugininterface.h> |
27 | 27 | ||
28 | 28 | ||
29 | class DocLnk; | 29 | class DocLnk; |
30 | 30 | ||
31 | 31 | ||
32 | class MediaPlayer : public QObject { | 32 | class MediaPlayer : public QObject { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | public: | 34 | public: |
35 | MediaPlayer( QObject *parent, const char *name ); | 35 | MediaPlayer( QObject *parent, const char *name ); |
36 | ~MediaPlayer(); | 36 | ~MediaPlayer(); |
37 | 37 | ||
38 | private slots: | 38 | private slots: |
39 | void setPlaying( bool ); | 39 | void setPlaying( bool ); |
40 | void pauseCheck( bool ); | 40 | void pauseCheck( bool ); |
41 | void play(); | 41 | void play(); |
42 | void next(); | 42 | void next(); |
43 | void prev(); | 43 | void prev(); |
44 | void startIncreasingVolume(); | 44 | void startIncreasingVolume(); |
45 | void startDecreasingVolume(); | 45 | void startDecreasingVolume(); |
46 | void stopChangingVolume(); | 46 | void stopChangingVolume(); |
47 | 47 | ||
48 | protected: | 48 | protected: |
49 | void timerEvent( QTimerEvent *e ); | 49 | void timerEvent( QTimerEvent *e ); |
50 | // void keyReleaseEvent( QKeyEvent *e); | 50 | void keyReleaseEvent( QKeyEvent *e); |
51 | 51 | void doBlank(); | |
52 | void doUnblank(); | ||
53 | void cleanUp(); | ||
52 | private: | 54 | private: |
53 | int volumeDirection; | 55 | int volumeDirection; |
54 | const DocLnk *currentFile; | 56 | const DocLnk *currentFile; |
55 | }; | 57 | }; |
56 | 58 | ||
57 | 59 | ||
58 | #endif // MEDIA_PLAYER_H | 60 | #endif // MEDIA_PLAYER_H |
59 | 61 | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index faa6e3f..70b7cef 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,1066 +1,1107 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
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 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | #include <qpe/qcopenvelope_qws.h> | ||
22 | 23 | ||
23 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
24 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
25 | #include <qpe/fileselector.h> | 26 | #include <qpe/fileselector.h> |
26 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/lnkproperties.h> | 28 | #include <qpe/lnkproperties.h> |
28 | #include <qpe/storage.h> | 29 | #include <qpe/storage.h> |
29 | 30 | ||
30 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
31 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
32 | #include <qpe/global.h> | 33 | #include <qpe/global.h> |
33 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
34 | 35 | ||
35 | #include <qaction.h> | 36 | #include <qaction.h> |
36 | #include <qimage.h> | 37 | #include <qimage.h> |
37 | #include <qfile.h> | 38 | #include <qfile.h> |
38 | #include <qdir.h> | 39 | #include <qdir.h> |
39 | #include <qlayout.h> | 40 | #include <qlayout.h> |
40 | #include <qlabel.h> | 41 | #include <qlabel.h> |
41 | #include <qlist.h> | 42 | #include <qlist.h> |
42 | #include <qlistbox.h> | 43 | #include <qlistbox.h> |
43 | #include <qmainwindow.h> | 44 | #include <qmainwindow.h> |
44 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
45 | #include <qtoolbutton.h> | 46 | #include <qtoolbutton.h> |
46 | #include <qtabwidget.h> | 47 | #include <qtabwidget.h> |
47 | #include <qlistview.h> | 48 | #include <qlistview.h> |
48 | #include <qpoint.h> | 49 | #include <qpoint.h> |
49 | #include <qlineedit.h> | 50 | #include <qlineedit.h> |
50 | #include <qpushbutton.h> | 51 | #include <qpushbutton.h> |
51 | #include <qregexp.h> | 52 | #include <qregexp.h> |
52 | 53 | ||
53 | //#include <qtimer.h> | 54 | //#include <qtimer.h> |
54 | 55 | ||
55 | #include "playlistselection.h" | 56 | #include "playlistselection.h" |
56 | #include "playlistwidget.h" | 57 | #include "playlistwidget.h" |
57 | #include "mediaplayerstate.h" | 58 | #include "mediaplayerstate.h" |
58 | 59 | ||
59 | #include "inputDialog.h" | 60 | #include "inputDialog.h" |
60 | 61 | ||
61 | #include <stdlib.h> | 62 | #include <stdlib.h> |
62 | #include "audiowidget.h" | 63 | #include "audiowidget.h" |
63 | #include "videowidget.h" | 64 | #include "videowidget.h" |
64 | 65 | ||
66 | #include <unistd.h> | ||
67 | #include <sys/file.h> | ||
68 | #include <sys/ioctl.h> | ||
69 | #include <sys/soundcard.h> | ||
70 | |||
71 | // for setBacklight() | ||
72 | #include <linux/fb.h> | ||
73 | #include <sys/types.h> | ||
74 | #include <sys/stat.h> | ||
75 | #include <stdlib.h> | ||
76 | |||
65 | #define BUTTONS_ON_TOOLBAR | 77 | #define BUTTONS_ON_TOOLBAR |
66 | #define SIDE_BUTTONS | 78 | #define SIDE_BUTTONS |
67 | #define CAN_SAVE_LOAD_PLAYLISTS | 79 | #define CAN_SAVE_LOAD_PLAYLISTS |
68 | 80 | ||
69 | extern AudioWidget *audioUI; | 81 | extern AudioWidget *audioUI; |
70 | extern VideoWidget *videoUI; | 82 | extern VideoWidget *videoUI; |
71 | extern MediaPlayerState *mediaPlayerState; | 83 | extern MediaPlayerState *mediaPlayerState; |
72 | 84 | ||
73 | // class myFileSelector { | 85 | // class myFileSelector { |
74 | 86 | ||
75 | // }; | 87 | // }; |
76 | class PlayListWidgetPrivate { | 88 | class PlayListWidgetPrivate { |
77 | public: | 89 | public: |
78 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 90 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
79 | QFrame *playListFrame; | 91 | QFrame *playListFrame; |
80 | FileSelector *files; | 92 | FileSelector *files; |
81 | PlayListSelection *selectedFiles; | 93 | PlayListSelection *selectedFiles; |
82 | bool setDocumentUsed; | 94 | bool setDocumentUsed; |
83 | DocLnk *current; | 95 | DocLnk *current; |
84 | }; | 96 | }; |
85 | 97 | ||
86 | 98 | ||
87 | class ToolButton : public QToolButton { | 99 | class ToolButton : public QToolButton { |
88 | public: | 100 | public: |
89 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 101 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
90 | : QToolButton( parent, name ) { | 102 | : QToolButton( parent, name ) { |
91 | setTextLabel( name ); | 103 | setTextLabel( name ); |
92 | setPixmap( Resource::loadPixmap( icon ) ); | 104 | setPixmap( Resource::loadPixmap( icon ) ); |
93 | setAutoRaise( TRUE ); | 105 | setAutoRaise( TRUE ); |
94 | setFocusPolicy( QWidget::NoFocus ); | 106 | setFocusPolicy( QWidget::NoFocus ); |
95 | setToggleButton( t ); | 107 | setToggleButton( t ); |
96 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 108 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
97 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 109 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
98 | } | 110 | } |
99 | }; | 111 | }; |
100 | 112 | ||
101 | 113 | ||
102 | class MenuItem : public QAction { | 114 | class MenuItem : public QAction { |
103 | public: | 115 | public: |
104 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 116 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
105 | : QAction( text, QString::null, 0, 0 ) { | 117 | : QAction( text, QString::null, 0, 0 ) { |
106 | connect( this, SIGNAL( activated() ), handler, slot ); | 118 | connect( this, SIGNAL( activated() ), handler, slot ); |
107 | addTo( parent ); | 119 | addTo( parent ); |
108 | } | 120 | } |
109 | }; | 121 | }; |
110 | 122 | ||
111 | 123 | ||
112 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 124 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
113 | : QMainWindow( parent, name, fl ) { | 125 | : QMainWindow( parent, name, fl ) { |
114 | 126 | ||
115 | d = new PlayListWidgetPrivate; | 127 | d = new PlayListWidgetPrivate; |
116 | d->setDocumentUsed = FALSE; | 128 | d->setDocumentUsed = FALSE; |
117 | d->current = NULL; | 129 | d->current = NULL; |
118 | fromSetDocument = FALSE; | 130 | fromSetDocument = FALSE; |
119 | insanityBool=FALSE; | 131 | insanityBool=FALSE; |
120 | // menuTimer = new QTimer( this ,"menu timer"), | 132 | // menuTimer = new QTimer( this ,"menu timer"), |
121 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 133 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
122 | 134 | ||
123 | setBackgroundMode( PaletteButton ); | 135 | setBackgroundMode( PaletteButton ); |
124 | 136 | ||
125 | setCaption( tr("OpiePlayer") ); | 137 | setCaption( tr("OpiePlayer") ); |
126 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 138 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
127 | 139 | ||
128 | setToolBarsMovable( FALSE ); | 140 | setToolBarsMovable( FALSE ); |
129 | 141 | ||
130 | // Create Toolbar | 142 | // Create Toolbar |
131 | QPEToolBar *toolbar = new QPEToolBar( this ); | 143 | QPEToolBar *toolbar = new QPEToolBar( this ); |
132 | toolbar->setHorizontalStretchable( TRUE ); | 144 | toolbar->setHorizontalStretchable( TRUE ); |
133 | 145 | ||
134 | // Create Menubar | 146 | // Create Menubar |
135 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 147 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
136 | menu->setMargin( 0 ); | 148 | menu->setMargin( 0 ); |
137 | 149 | ||
138 | QPEToolBar *bar = new QPEToolBar( this ); | 150 | QPEToolBar *bar = new QPEToolBar( this ); |
139 | bar->setLabel( tr( "Play Operations" ) ); | 151 | bar->setLabel( tr( "Play Operations" ) ); |
140 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 152 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
141 | // this , SLOT( addSelected()) ); | 153 | // this , SLOT( addSelected()) ); |
142 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 154 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
143 | tbDeletePlaylist->setFlat(TRUE); | 155 | tbDeletePlaylist->setFlat(TRUE); |
144 | tbDeletePlaylist->setFixedSize(20,20); | 156 | tbDeletePlaylist->setFixedSize(20,20); |
145 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 157 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
146 | 158 | ||
147 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 159 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
148 | this , SLOT(addSelected()) ); | 160 | this , SLOT(addSelected()) ); |
149 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 161 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
150 | this , SLOT(removeSelected()) ); | 162 | this , SLOT(removeSelected()) ); |
151 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 163 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
152 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 164 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
153 | this , SLOT( btnPlay(bool) ), TRUE ); | 165 | this , SLOT( btnPlay(bool) ), TRUE ); |
154 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 166 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
155 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 167 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
156 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 168 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
157 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 169 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
158 | tbDeletePlaylist->hide(); | 170 | tbDeletePlaylist->hide(); |
159 | 171 | ||
160 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 172 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
161 | menu->insertItem( tr( "File" ), pmPlayList ); | 173 | menu->insertItem( tr( "File" ), pmPlayList ); |
162 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 174 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
163 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 175 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
164 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 176 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
165 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 177 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
166 | // pmPlayList->insertSeparator(-1); | 178 | // pmPlayList->insertSeparator(-1); |
167 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 179 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
168 | pmPlayList->insertSeparator(-1); | 180 | pmPlayList->insertSeparator(-1); |
169 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 181 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
170 | 182 | ||
171 | QPopupMenu *pmView = new QPopupMenu( this ); | 183 | QPopupMenu *pmView = new QPopupMenu( this ); |
172 | menu->insertItem( tr( "View" ), pmView ); | 184 | menu->insertItem( tr( "View" ), pmView ); |
173 | 185 | ||
174 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 186 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
175 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 187 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
176 | fullScreenButton->addTo(pmView); | 188 | fullScreenButton->addTo(pmView); |
177 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 189 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
178 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 190 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
179 | scaleButton->addTo(pmView); | 191 | scaleButton->addTo(pmView); |
180 | 192 | ||
181 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 193 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
182 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 194 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
183 | 195 | ||
184 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 196 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
185 | 197 | ||
186 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 198 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
187 | tabWidget->setTabShape(QTabWidget::Triangular); | 199 | tabWidget->setTabShape(QTabWidget::Triangular); |
188 | 200 | ||
189 | QWidget *pTab; | 201 | QWidget *pTab; |
190 | pTab = new QWidget( tabWidget, "pTab" ); | 202 | pTab = new QWidget( tabWidget, "pTab" ); |
191 | // playlistView = new QListView( pTab, "playlistview" ); | 203 | // playlistView = new QListView( pTab, "playlistview" ); |
192 | // playlistView->setMinimumSize(236,260); | 204 | // playlistView->setMinimumSize(236,260); |
193 | tabWidget->insertTab( pTab,"Playlist"); | 205 | tabWidget->insertTab( pTab,"Playlist"); |
194 | 206 | ||
195 | 207 | ||
196 | // Add the playlist area | 208 | // Add the playlist area |
197 | 209 | ||
198 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 210 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
199 | d->playListFrame = vbox3; | 211 | d->playListFrame = vbox3; |
200 | d->playListFrame ->setMinimumSize(235,260); | 212 | d->playListFrame ->setMinimumSize(235,260); |
201 | 213 | ||
202 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 214 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
203 | 215 | ||
204 | d->selectedFiles = new PlayListSelection( hbox2); | 216 | d->selectedFiles = new PlayListSelection( hbox2); |
205 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 217 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
206 | 218 | ||
207 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 219 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
208 | 220 | ||
209 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 221 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
210 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 222 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
211 | 223 | ||
212 | 224 | ||
213 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 225 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
214 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 226 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
215 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 227 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
216 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 228 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
217 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 229 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
218 | 230 | ||
219 | QWidget *aTab; | 231 | QWidget *aTab; |
220 | aTab = new QWidget( tabWidget, "aTab" ); | 232 | aTab = new QWidget( tabWidget, "aTab" ); |
221 | audioView = new QListView( aTab, "Audioview" ); | 233 | audioView = new QListView( aTab, "Audioview" ); |
222 | audioView->setMinimumSize(233,260); | 234 | audioView->setMinimumSize(233,260); |
223 | audioView->addColumn( tr("Title"),140); | 235 | audioView->addColumn( tr("Title"),140); |
224 | audioView->addColumn(tr("Size"), -1); | 236 | audioView->addColumn(tr("Size"), -1); |
225 | audioView->addColumn(tr("Media"),-1); | 237 | audioView->addColumn(tr("Media"),-1); |
226 | audioView->setColumnAlignment(1, Qt::AlignRight); | 238 | audioView->setColumnAlignment(1, Qt::AlignRight); |
227 | audioView->setColumnAlignment(2, Qt::AlignRight); | 239 | audioView->setColumnAlignment(2, Qt::AlignRight); |
228 | audioView->setAllColumnsShowFocus(TRUE); | 240 | audioView->setAllColumnsShowFocus(TRUE); |
229 | 241 | ||
230 | audioView->setMultiSelection( TRUE ); | 242 | audioView->setMultiSelection( TRUE ); |
231 | audioView->setSelectionMode( QListView::Extended); | 243 | audioView->setSelectionMode( QListView::Extended); |
232 | 244 | ||
233 | tabWidget->insertTab(aTab,tr("Audio")); | 245 | tabWidget->insertTab(aTab,tr("Audio")); |
234 | 246 | ||
235 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 247 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
236 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 248 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
237 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 249 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
238 | 250 | ||
239 | 251 | ||
240 | // audioView | 252 | // audioView |
241 | populateAudioView(); | 253 | populateAudioView(); |
242 | // videowidget | 254 | // videowidget |
243 | 255 | ||
244 | QWidget *vTab; | 256 | QWidget *vTab; |
245 | vTab = new QWidget( tabWidget, "vTab" ); | 257 | vTab = new QWidget( tabWidget, "vTab" ); |
246 | videoView = new QListView( vTab, "Videoview" ); | 258 | videoView = new QListView( vTab, "Videoview" ); |
247 | videoView->setMinimumSize(233,260); | 259 | videoView->setMinimumSize(233,260); |
248 | 260 | ||
249 | videoView->addColumn(tr("Title"),140); | 261 | videoView->addColumn(tr("Title"),140); |
250 | videoView->addColumn(tr("Size"),-1); | 262 | videoView->addColumn(tr("Size"),-1); |
251 | videoView->addColumn(tr("Media"),-1); | 263 | videoView->addColumn(tr("Media"),-1); |
252 | videoView->setColumnAlignment(1, Qt::AlignRight); | 264 | videoView->setColumnAlignment(1, Qt::AlignRight); |
253 | videoView->setColumnAlignment(2, Qt::AlignRight); | 265 | videoView->setColumnAlignment(2, Qt::AlignRight); |
254 | videoView->setAllColumnsShowFocus(TRUE); | 266 | videoView->setAllColumnsShowFocus(TRUE); |
255 | videoView->setMultiSelection( TRUE ); | 267 | videoView->setMultiSelection( TRUE ); |
256 | videoView->setSelectionMode( QListView::Extended); | 268 | videoView->setSelectionMode( QListView::Extended); |
257 | 269 | ||
258 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 270 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
259 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 271 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
260 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 272 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
261 | 273 | ||
262 | tabWidget->insertTab( vTab,tr("Video")); | 274 | tabWidget->insertTab( vTab,tr("Video")); |
263 | populateVideoView(); | 275 | populateVideoView(); |
264 | 276 | ||
265 | //playlists list | 277 | //playlists list |
266 | QWidget *LTab; | 278 | QWidget *LTab; |
267 | LTab = new QWidget( tabWidget, "LTab" ); | 279 | LTab = new QWidget( tabWidget, "LTab" ); |
268 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 280 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
269 | playLists->setMinimumSize(233,260);; | 281 | playLists->setMinimumSize(233,260);; |
270 | tabWidget->insertTab(LTab,tr("Lists")); | 282 | tabWidget->insertTab(LTab,tr("Lists")); |
271 | 283 | ||
272 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 284 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
273 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 285 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
274 | 286 | ||
275 | 287 | ||
276 | // add the library area | 288 | // add the library area |
277 | 289 | ||
278 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 290 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
279 | // this, SLOT( fauxPlay( QListViewItem *) ) ); | 291 | // this, SLOT( fauxPlay( QListViewItem *) ) ); |
280 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 292 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
281 | // this, SLOT( fauxPlay( QListViewItem *)) ); | 293 | // this, SLOT( fauxPlay( QListViewItem *)) ); |
282 | 294 | ||
283 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 295 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
284 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 296 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
285 | 297 | ||
286 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 298 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
287 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 299 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
288 | 300 | ||
289 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 301 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
290 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 302 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
291 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 303 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
292 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 304 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
293 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 305 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
294 | 306 | ||
295 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 307 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
296 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 308 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
297 | 309 | ||
298 | setCentralWidget( vbox5 ); | 310 | setCentralWidget( vbox5 ); |
299 | 311 | ||
300 | Config cfg( "OpiePlayer" ); | 312 | Config cfg( "OpiePlayer" ); |
301 | readConfig( cfg ); | 313 | readConfig( cfg ); |
302 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 314 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
303 | // qDebug("currentList is "+currentPlaylist); | 315 | // qDebug("currentList is "+currentPlaylist); |
304 | loadList(DocLnk( currentPlaylist)); | 316 | loadList(DocLnk( currentPlaylist)); |
305 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 317 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
306 | 318 | ||
307 | initializeStates(); | 319 | initializeStates(); |
308 | } | 320 | } |
309 | 321 | ||
310 | 322 | ||
311 | PlayListWidget::~PlayListWidget() { | 323 | PlayListWidget::~PlayListWidget() { |
312 | Config cfg( "OpiePlayer" ); | 324 | Config cfg( "OpiePlayer" ); |
313 | writeConfig( cfg ); | 325 | writeConfig( cfg ); |
314 | 326 | ||
315 | 327 | ||
316 | if ( d->current ) | 328 | if ( d->current ) |
317 | delete d->current; | 329 | delete d->current; |
318 | delete d; | 330 | delete d; |
319 | } | 331 | } |
320 | 332 | ||
321 | 333 | ||
322 | void PlayListWidget::initializeStates() { | 334 | void PlayListWidget::initializeStates() { |
323 | 335 | ||
324 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 336 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
325 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 337 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
326 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 338 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
327 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 339 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
328 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 340 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
329 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 341 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
330 | // setPlaylist( mediaPlayerState->playlist() ); | 342 | // setPlaylist( mediaPlayerState->playlist() ); |
331 | setPlaylist( true); | 343 | setPlaylist( true); |
332 | // d->selectedFiles->first(); | 344 | // d->selectedFiles->first(); |
333 | 345 | ||
334 | } | 346 | } |
335 | 347 | ||
336 | 348 | ||
337 | void PlayListWidget::readConfig( Config& cfg ) { | 349 | void PlayListWidget::readConfig( Config& cfg ) { |
338 | cfg.setGroup("PlayList"); | 350 | cfg.setGroup("PlayList"); |
339 | QString currentString = cfg.readEntry("current", "" ); | 351 | QString currentString = cfg.readEntry("current", "" ); |
340 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 352 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
341 | for ( int i = 0; i < noOfFiles; i++ ) { | 353 | for ( int i = 0; i < noOfFiles; i++ ) { |
342 | QString entryName; | 354 | QString entryName; |
343 | entryName.sprintf( "File%i", i + 1 ); | 355 | entryName.sprintf( "File%i", i + 1 ); |
344 | QString linkFile = cfg.readEntry( entryName ); | 356 | QString linkFile = cfg.readEntry( entryName ); |
345 | DocLnk lnk( linkFile ); | 357 | DocLnk lnk( linkFile ); |
346 | if ( lnk.isValid() ) { | 358 | if ( lnk.isValid() ) { |
347 | d->selectedFiles->addToSelection( lnk ); | 359 | d->selectedFiles->addToSelection( lnk ); |
348 | } | 360 | } |
349 | } | 361 | } |
350 | d->selectedFiles->setSelectedItem( currentString); | 362 | d->selectedFiles->setSelectedItem( currentString); |
351 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | 363 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); |
352 | } | 364 | } |
353 | 365 | ||
354 | 366 | ||
355 | void PlayListWidget::writeConfig( Config& cfg ) const { | 367 | void PlayListWidget::writeConfig( Config& cfg ) const { |
356 | 368 | ||
357 | d->selectedFiles->writeCurrent( cfg); | 369 | d->selectedFiles->writeCurrent( cfg); |
358 | cfg.setGroup("PlayList"); | 370 | cfg.setGroup("PlayList"); |
359 | int noOfFiles = 0; | 371 | int noOfFiles = 0; |
360 | d->selectedFiles->first(); | 372 | d->selectedFiles->first(); |
361 | do { | 373 | do { |
362 | const DocLnk *lnk = d->selectedFiles->current(); | 374 | const DocLnk *lnk = d->selectedFiles->current(); |
363 | if ( lnk ) { | 375 | if ( lnk ) { |
364 | QString entryName; | 376 | QString entryName; |
365 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 377 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
366 | // qDebug(entryName); | 378 | // qDebug(entryName); |
367 | cfg.writeEntry( entryName, lnk->linkFile() ); | 379 | cfg.writeEntry( entryName, lnk->linkFile() ); |
368 | // if this link does exist, add it so we have the file | 380 | // if this link does exist, add it so we have the file |
369 | // next time... | 381 | // next time... |
370 | if ( !QFile::exists( lnk->linkFile() ) ) { | 382 | if ( !QFile::exists( lnk->linkFile() ) ) { |
371 | // the way writing lnks doesn't really check for out | 383 | // the way writing lnks doesn't really check for out |
372 | // of disk space, but check it anyway. | 384 | // of disk space, but check it anyway. |
373 | if ( !lnk->writeLink() ) { | 385 | if ( !lnk->writeLink() ) { |
374 | QMessageBox::critical( 0, tr("Out of space"), | 386 | QMessageBox::critical( 0, tr("Out of space"), |
375 | tr( "There was a problem saving " | 387 | tr( "There was a problem saving " |
376 | "the playlist.\n" | 388 | "the playlist.\n" |
377 | "Your playlist " | 389 | "Your playlist " |
378 | "may be missing some entries\n" | 390 | "may be missing some entries\n" |
379 | "the next time you start it." ) | 391 | "the next time you start it." ) |
380 | ); | 392 | ); |
381 | } | 393 | } |
382 | } | 394 | } |
383 | noOfFiles++; | 395 | noOfFiles++; |
384 | } | 396 | } |
385 | } | 397 | } |
386 | while ( d->selectedFiles->next() ); | 398 | while ( d->selectedFiles->next() ); |
387 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 399 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
388 | } | 400 | } |
389 | 401 | ||
390 | 402 | ||
391 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 403 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
392 | // qDebug("add"); | 404 | // qDebug("add"); |
393 | d->setDocumentUsed = FALSE; | 405 | d->setDocumentUsed = FALSE; |
394 | if ( mediaPlayerState->playlist() ) | 406 | if ( mediaPlayerState->playlist() ) |
395 | d->selectedFiles->addToSelection( lnk ); | 407 | d->selectedFiles->addToSelection( lnk ); |
396 | else | 408 | else |
397 | mediaPlayerState->setPlaying( TRUE ); | 409 | mediaPlayerState->setPlaying( TRUE ); |
398 | } | 410 | } |
399 | 411 | ||
400 | 412 | ||
401 | void PlayListWidget::clearList() { | 413 | void PlayListWidget::clearList() { |
402 | while ( first() ) | 414 | while ( first() ) |
403 | d->selectedFiles->removeSelected(); | 415 | d->selectedFiles->removeSelected(); |
404 | } | 416 | } |
405 | 417 | ||
406 | 418 | ||
407 | void PlayListWidget::addAllToList() { | 419 | void PlayListWidget::addAllToList() { |
408 | DocLnkSet filesAll; | 420 | DocLnkSet filesAll; |
409 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 421 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
410 | QListIterator<DocLnk> Adit( filesAll.children() ); | 422 | QListIterator<DocLnk> Adit( filesAll.children() ); |
411 | for ( ; Adit.current(); ++Adit ) | 423 | for ( ; Adit.current(); ++Adit ) |
412 | d->selectedFiles->addToSelection( **Adit ); | 424 | d->selectedFiles->addToSelection( **Adit ); |
413 | } | 425 | } |
414 | 426 | ||
415 | 427 | ||
416 | void PlayListWidget::addAllMusicToList() { | 428 | void PlayListWidget::addAllMusicToList() { |
417 | // DocLnkSet files; | 429 | // DocLnkSet files; |
418 | // Global::findDocuments(&files, "audio/*"); | 430 | // Global::findDocuments(&files, "audio/*"); |
419 | QListIterator<DocLnk> dit( files.children() ); | 431 | QListIterator<DocLnk> dit( files.children() ); |
420 | for ( ; dit.current(); ++dit ) | 432 | for ( ; dit.current(); ++dit ) |
421 | d->selectedFiles->addToSelection( **dit ); | 433 | d->selectedFiles->addToSelection( **dit ); |
422 | } | 434 | } |
423 | 435 | ||
424 | 436 | ||
425 | void PlayListWidget::addAllVideoToList() { | 437 | void PlayListWidget::addAllVideoToList() { |
426 | QListIterator<DocLnk> dit( vFiles.children() ); | 438 | QListIterator<DocLnk> dit( vFiles.children() ); |
427 | for ( ; dit.current(); ++dit ) | 439 | for ( ; dit.current(); ++dit ) |
428 | d->selectedFiles->addToSelection( **dit ); | 440 | d->selectedFiles->addToSelection( **dit ); |
429 | } | 441 | } |
430 | 442 | ||
431 | 443 | ||
432 | void PlayListWidget::setDocument(const QString& fileref) { | 444 | void PlayListWidget::setDocument(const QString& fileref) { |
433 | qDebug(fileref); | 445 | qDebug(fileref); |
434 | fromSetDocument = TRUE; | 446 | fromSetDocument = TRUE; |
435 | if ( fileref.isNull() ) { | 447 | if ( fileref.isNull() ) { |
436 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 448 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
437 | return; | 449 | return; |
438 | } | 450 | } |
439 | // qDebug("setDocument "+fileref); | 451 | // qDebug("setDocument "+fileref); |
440 | // if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 452 | // if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
441 | // clearList(); | 453 | // clearList(); |
442 | // addToSelection( DocLnk( fileref ) ); | 454 | // addToSelection( DocLnk( fileref ) ); |
443 | // d->setDocumentUsed = TRUE; | 455 | // d->setDocumentUsed = TRUE; |
444 | // d->selectedFiles->first(); | 456 | // d->selectedFiles->first(); |
445 | // qApp->processEvents(); | 457 | // qApp->processEvents(); |
446 | // } | 458 | // } |
447 | // else | 459 | // else |
448 | if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 460 | if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
449 | clearList(); | 461 | clearList(); |
450 | loadList(DocLnk(fileref)); | 462 | loadList(DocLnk(fileref)); |
451 | d->selectedFiles->first(); | 463 | d->selectedFiles->first(); |
452 | } else { | 464 | } else { |
453 | clearList(); | 465 | clearList(); |
454 | addToSelection( DocLnk( fileref ) ); | 466 | addToSelection( DocLnk( fileref ) ); |
455 | d->setDocumentUsed = TRUE; | 467 | d->setDocumentUsed = TRUE; |
456 | mediaPlayerState->setPlaying( FALSE ); | 468 | mediaPlayerState->setPlaying( FALSE ); |
457 | qApp->processEvents(); | 469 | qApp->processEvents(); |
458 | mediaPlayerState->setPlaying( TRUE ); | 470 | mediaPlayerState->setPlaying( TRUE ); |
459 | qApp->processEvents(); | 471 | qApp->processEvents(); |
460 | setCaption(tr("OpiePlayer")); | 472 | setCaption(tr("OpiePlayer")); |
461 | } | 473 | } |
462 | } | 474 | } |
463 | 475 | ||
464 | 476 | ||
465 | void PlayListWidget::setActiveWindow() { | 477 | void PlayListWidget::setActiveWindow() { |
466 | // When we get raised we need to ensure that it switches views | 478 | // When we get raised we need to ensure that it switches views |
467 | char origView = mediaPlayerState->view(); | 479 | char origView = mediaPlayerState->view(); |
468 | mediaPlayerState->setView( 'l' ); // invalidate | 480 | mediaPlayerState->setView( 'l' ); // invalidate |
469 | mediaPlayerState->setView( origView ); // now switch back | 481 | mediaPlayerState->setView( origView ); // now switch back |
470 | } | 482 | } |
471 | 483 | ||
472 | 484 | ||
473 | void PlayListWidget::useSelectedDocument() { | 485 | void PlayListWidget::useSelectedDocument() { |
474 | d->setDocumentUsed = FALSE; | 486 | d->setDocumentUsed = FALSE; |
475 | } | 487 | } |
476 | 488 | ||
477 | 489 | ||
478 | const DocLnk *PlayListWidget::current() { // this is fugly | 490 | const DocLnk *PlayListWidget::current() { // this is fugly |
479 | 491 | ||
480 | // if( fromSetDocument) { | 492 | // if( fromSetDocument) { |
481 | // qDebug("from setDoc"); | 493 | // qDebug("from setDoc"); |
482 | // DocLnkSet files; | 494 | // DocLnkSet files; |
483 | // Global::findDocuments(&files, "video/*;audio/*"); | 495 | // Global::findDocuments(&files, "video/*;audio/*"); |
484 | // QListIterator<DocLnk> dit( files.children() ); | 496 | // QListIterator<DocLnk> dit( files.children() ); |
485 | // for ( ; dit.current(); ++dit ) { | 497 | // for ( ; dit.current(); ++dit ) { |
486 | // if(dit.current()->linkFile() == setDocFileRef) { | 498 | // if(dit.current()->linkFile() == setDocFileRef) { |
487 | // qDebug(setDocFileRef); | 499 | // qDebug(setDocFileRef); |
488 | // return dit; | 500 | // return dit; |
489 | // } | 501 | // } |
490 | // } | 502 | // } |
491 | // } else | 503 | // } else |
492 | 504 | ||
493 | 505 | ||
494 | switch (tabWidget->currentPageIndex()) { | 506 | switch (tabWidget->currentPageIndex()) { |
495 | case 0: //playlist | 507 | case 0: //playlist |
496 | { | 508 | { |
497 | qDebug("playlist"); | 509 | qDebug("playlist"); |
498 | if ( mediaPlayerState->playlist() ) { | 510 | if ( mediaPlayerState->playlist() ) { |
499 | return d->selectedFiles->current(); | 511 | return d->selectedFiles->current(); |
500 | } | 512 | } |
501 | else if ( d->setDocumentUsed && d->current ) { | 513 | else if ( d->setDocumentUsed && d->current ) { |
502 | return d->current; | 514 | return d->current; |
503 | } else { | 515 | } else { |
504 | return d->files->selected(); | 516 | return d->files->selected(); |
505 | } | 517 | } |
506 | } | 518 | } |
507 | break; | 519 | break; |
508 | case 1://audio | 520 | case 1://audio |
509 | { | 521 | { |
510 | qDebug("audioView"); | 522 | qDebug("audioView"); |
511 | // Global::findDocuments(&files, "audio/*"); | 523 | // Global::findDocuments(&files, "audio/*"); |
512 | QListIterator<DocLnk> dit( files.children() ); | 524 | QListIterator<DocLnk> dit( files.children() ); |
513 | for ( ; dit.current(); ++dit ) { | 525 | for ( ; dit.current(); ++dit ) { |
514 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 526 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
515 | qDebug("here"); | 527 | qDebug("here"); |
516 | insanityBool=TRUE; | 528 | insanityBool=TRUE; |
517 | return dit; | 529 | return dit; |
518 | } | 530 | } |
519 | } | 531 | } |
520 | } | 532 | } |
521 | break; | 533 | break; |
522 | case 2: // video | 534 | case 2: // video |
523 | { | 535 | { |
524 | qDebug("videoView"); | 536 | qDebug("videoView"); |
525 | // Global::findDocuments(&vFiles, "video/*"); | 537 | // Global::findDocuments(&vFiles, "video/*"); |
526 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 538 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
527 | for ( ; Vdit.current(); ++Vdit ) { | 539 | for ( ; Vdit.current(); ++Vdit ) { |
528 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 540 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
529 | insanityBool=TRUE; | 541 | insanityBool=TRUE; |
530 | return Vdit; | 542 | return Vdit; |
531 | } | 543 | } |
532 | } | 544 | } |
533 | } | 545 | } |
534 | break; | 546 | break; |
535 | }; | 547 | }; |
536 | return 0; | 548 | return 0; |
537 | } | 549 | } |
538 | 550 | ||
539 | bool PlayListWidget::prev() { | 551 | bool PlayListWidget::prev() { |
540 | if ( mediaPlayerState->playlist() ) { | 552 | if ( mediaPlayerState->playlist() ) { |
541 | if ( mediaPlayerState->shuffled() ) { | 553 | if ( mediaPlayerState->shuffled() ) { |
542 | const DocLnk *cur = current(); | 554 | const DocLnk *cur = current(); |
543 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 555 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
544 | for ( int i = 0; i < j; i++ ) { | 556 | for ( int i = 0; i < j; i++ ) { |
545 | if ( !d->selectedFiles->next() ) | 557 | if ( !d->selectedFiles->next() ) |
546 | d->selectedFiles->first(); | 558 | d->selectedFiles->first(); |
547 | } | 559 | } |
548 | if ( cur == current() ) | 560 | if ( cur == current() ) |
549 | if ( !d->selectedFiles->next() ) | 561 | if ( !d->selectedFiles->next() ) |
550 | d->selectedFiles->first(); | 562 | d->selectedFiles->first(); |
551 | return TRUE; | 563 | return TRUE; |
552 | } else { | 564 | } else { |
553 | if ( !d->selectedFiles->prev() ) { | 565 | if ( !d->selectedFiles->prev() ) { |
554 | if ( mediaPlayerState->looping() ) { | 566 | if ( mediaPlayerState->looping() ) { |
555 | return d->selectedFiles->last(); | 567 | return d->selectedFiles->last(); |
556 | } else { | 568 | } else { |
557 | return FALSE; | 569 | return FALSE; |
558 | } | 570 | } |
559 | } | 571 | } |
560 | return TRUE; | 572 | return TRUE; |
561 | } | 573 | } |
562 | } else { | 574 | } else { |
563 | return mediaPlayerState->looping(); | 575 | return mediaPlayerState->looping(); |
564 | } | 576 | } |
565 | } | 577 | } |
566 | 578 | ||
567 | 579 | ||
568 | bool PlayListWidget::next() { | 580 | bool PlayListWidget::next() { |
569 | if ( mediaPlayerState->playlist() ) { | 581 | if ( mediaPlayerState->playlist() ) { |
570 | if ( mediaPlayerState->shuffled() ) { | 582 | if ( mediaPlayerState->shuffled() ) { |
571 | return prev(); | 583 | return prev(); |
572 | } else { | 584 | } else { |
573 | if ( !d->selectedFiles->next() ) { | 585 | if ( !d->selectedFiles->next() ) { |
574 | if ( mediaPlayerState->looping() ) { | 586 | if ( mediaPlayerState->looping() ) { |
575 | return d->selectedFiles->first(); | 587 | return d->selectedFiles->first(); |
576 | } else { | 588 | } else { |
577 | return FALSE; | 589 | return FALSE; |
578 | } | 590 | } |
579 | } | 591 | } |
580 | return TRUE; | 592 | return TRUE; |
581 | } | 593 | } |
582 | } else { | 594 | } else { |
583 | return mediaPlayerState->looping(); | 595 | return mediaPlayerState->looping(); |
584 | } | 596 | } |
585 | } | 597 | } |
586 | 598 | ||
587 | 599 | ||
588 | bool PlayListWidget::first() { | 600 | bool PlayListWidget::first() { |
589 | if ( mediaPlayerState->playlist() ) | 601 | if ( mediaPlayerState->playlist() ) |
590 | return d->selectedFiles->first(); | 602 | return d->selectedFiles->first(); |
591 | else | 603 | else |
592 | return mediaPlayerState->looping(); | 604 | return mediaPlayerState->looping(); |
593 | } | 605 | } |
594 | 606 | ||
595 | 607 | ||
596 | bool PlayListWidget::last() { | 608 | bool PlayListWidget::last() { |
597 | if ( mediaPlayerState->playlist() ) | 609 | if ( mediaPlayerState->playlist() ) |
598 | return d->selectedFiles->last(); | 610 | return d->selectedFiles->last(); |
599 | else | 611 | else |
600 | return mediaPlayerState->looping(); | 612 | return mediaPlayerState->looping(); |
601 | } | 613 | } |
602 | 614 | ||
603 | 615 | ||
604 | void PlayListWidget::saveList() { | 616 | void PlayListWidget::saveList() { |
605 | 617 | ||
606 | QString filename; | 618 | QString filename; |
607 | InputDialog *fileDlg; | 619 | InputDialog *fileDlg; |
608 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 620 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
609 | fileDlg->exec(); | 621 | fileDlg->exec(); |
610 | if( fileDlg->result() == 1 ) { | 622 | if( fileDlg->result() == 1 ) { |
611 | if ( d->current ) | 623 | if ( d->current ) |
612 | delete d->current; | 624 | delete d->current; |
613 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 625 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
614 | // qDebug("saving playlist "+filename+".playlist"); | 626 | // qDebug("saving playlist "+filename+".playlist"); |
615 | Config cfg( filename +".playlist"); | 627 | Config cfg( filename +".playlist"); |
616 | writeConfig( cfg ); | 628 | writeConfig( cfg ); |
617 | 629 | ||
618 | // qDebug("same name so delete lnk??"); | 630 | // qDebug("same name so delete lnk??"); |
619 | // if( playLists->selected()->name() == filename) { | 631 | // if( playLists->selected()->name() == filename) { |
620 | 632 | ||
621 | // qDebug("same name so delete lnk"); | 633 | // qDebug("same name so delete lnk"); |
622 | // QFile().remove(playLists->selected()->file()); | 634 | // QFile().remove(playLists->selected()->file()); |
623 | // QFile().remove(playLists->selected()->linkFile()); | 635 | // QFile().remove(playLists->selected()->linkFile()); |
624 | // playLists->reread(); | 636 | // playLists->reread(); |
625 | // } | 637 | // } |
626 | // qDebug("new doclnk"); | 638 | // qDebug("new doclnk"); |
627 | DocLnk lnk; | 639 | DocLnk lnk; |
628 | // lnk.setComment( ""); | 640 | // lnk.setComment( ""); |
629 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 641 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
630 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 642 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
631 | lnk.setIcon("opieplayer/playlist2"); | 643 | lnk.setIcon("opieplayer/playlist2"); |
632 | lnk.setName( filename); //sets file name | 644 | lnk.setName( filename); //sets file name |
633 | // qDebug(filename); | 645 | // qDebug(filename); |
634 | if(!lnk.writeLink()) | 646 | if(!lnk.writeLink()) |
635 | qDebug("Writing doclink did not work"); | 647 | qDebug("Writing doclink did not work"); |
636 | } | 648 | } |
637 | Config config( "OpiePlayer" ); | 649 | Config config( "OpiePlayer" ); |
638 | config.writeEntry("CurrentPlaylist",filename); | 650 | config.writeEntry("CurrentPlaylist",filename); |
639 | setCaption(tr("OpiePlayer: ")+filename); | 651 | setCaption(tr("OpiePlayer: ")+filename); |
640 | d->selectedFiles->first(); | 652 | d->selectedFiles->first(); |
641 | if(fileDlg) | 653 | if(fileDlg) |
642 | delete fileDlg; | 654 | delete fileDlg; |
643 | } | 655 | } |
644 | 656 | ||
645 | void PlayListWidget::loadList( const DocLnk & lnk) { | 657 | void PlayListWidget::loadList( const DocLnk & lnk) { |
646 | QString name= lnk.name(); | 658 | QString name= lnk.name(); |
647 | // qDebug("currentList is "+name); | 659 | // qDebug("currentList is "+name); |
648 | if( name.length()>1) { | 660 | if( name.length()>1) { |
649 | setCaption("OpiePlayer: "+name); | 661 | setCaption("OpiePlayer: "+name); |
650 | // qDebug("load list "+ name+".playlist"); | 662 | // qDebug("load list "+ name+".playlist"); |
651 | clearList(); | 663 | clearList(); |
652 | Config cfg( name+".playlist"); | 664 | Config cfg( name+".playlist"); |
653 | readConfig(cfg); | 665 | readConfig(cfg); |
654 | 666 | ||
655 | tabWidget->setCurrentPage(0); | 667 | tabWidget->setCurrentPage(0); |
656 | 668 | ||
657 | Config config( "OpiePlayer" ); | 669 | Config config( "OpiePlayer" ); |
658 | config.writeEntry("CurrentPlaylist", name); | 670 | config.writeEntry("CurrentPlaylist", name); |
659 | // d->selectedFiles->first(); | 671 | // d->selectedFiles->first(); |
660 | } | 672 | } |
661 | 673 | ||
662 | } | 674 | } |
663 | 675 | ||
664 | void PlayListWidget::setPlaylist( bool shown ) { | 676 | void PlayListWidget::setPlaylist( bool shown ) { |
665 | if ( shown ) | 677 | if ( shown ) |
666 | d->playListFrame->show(); | 678 | d->playListFrame->show(); |
667 | else | 679 | else |
668 | d->playListFrame->hide(); | 680 | d->playListFrame->hide(); |
669 | } | 681 | } |
670 | 682 | ||
671 | void PlayListWidget::setView( char view ) { | 683 | void PlayListWidget::setView( char view ) { |
672 | if ( view == 'l' ) | 684 | if ( view == 'l' ) |
673 | showMaximized(); | 685 | showMaximized(); |
674 | else | 686 | else |
675 | hide(); | 687 | hide(); |
676 | } | 688 | } |
677 | 689 | ||
678 | void PlayListWidget::addSelected() { | 690 | void PlayListWidget::addSelected() { |
679 | 691 | ||
680 | Config cfg( "OpiePlayer" ); | 692 | Config cfg( "OpiePlayer" ); |
681 | cfg.setGroup("PlayList"); | 693 | cfg.setGroup("PlayList"); |
682 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 694 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
683 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 695 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
684 | 696 | ||
685 | switch (tabWidget->currentPageIndex()) { | 697 | switch (tabWidget->currentPageIndex()) { |
686 | case 0: //playlist | 698 | case 0: //playlist |
687 | break; | 699 | break; |
688 | case 1: { //audio | 700 | case 1: { //audio |
689 | // QString entryName; | 701 | // QString entryName; |
690 | // entryName.sprintf( "File%i", i + 1 ); | 702 | // entryName.sprintf( "File%i", i + 1 ); |
691 | // QString linkFile = cfg.readEntry( entryName ); | 703 | // QString linkFile = cfg.readEntry( entryName ); |
692 | QListViewItemIterator it( audioView ); | 704 | QListViewItemIterator it( audioView ); |
693 | // iterate through all items of the listview | 705 | // iterate through all items of the listview |
694 | for ( ; it.current(); ++it ) { | 706 | for ( ; it.current(); ++it ) { |
695 | if ( it.current()->isSelected() ) { | 707 | if ( it.current()->isSelected() ) { |
696 | QListIterator<DocLnk> dit( files.children() ); | 708 | QListIterator<DocLnk> dit( files.children() ); |
697 | for ( ; dit.current(); ++dit ) { | 709 | for ( ; dit.current(); ++dit ) { |
698 | if( dit.current()->name() == it.current()->text(0) ) { | 710 | if( dit.current()->name() == it.current()->text(0) ) { |
699 | d->selectedFiles->addToSelection( **dit ); | 711 | d->selectedFiles->addToSelection( **dit ); |
700 | } | 712 | } |
701 | } | 713 | } |
702 | audioView->setSelected( it.current(),FALSE); | 714 | audioView->setSelected( it.current(),FALSE); |
703 | } | 715 | } |
704 | } | 716 | } |
705 | tabWidget->setCurrentPage(0); | 717 | tabWidget->setCurrentPage(0); |
706 | } | 718 | } |
707 | break; | 719 | break; |
708 | case 2: { // video | 720 | case 2: { // video |
709 | QListViewItemIterator it( videoView ); | 721 | QListViewItemIterator it( videoView ); |
710 | // iterate through all items of the listview | 722 | // iterate through all items of the listview |
711 | for ( ; it.current(); ++it ) { | 723 | for ( ; it.current(); ++it ) { |
712 | if ( it.current()->isSelected() ) { | 724 | if ( it.current()->isSelected() ) { |
713 | QListIterator<DocLnk> dit( vFiles.children() ); | 725 | QListIterator<DocLnk> dit( vFiles.children() ); |
714 | for ( ; dit.current(); ++dit ) { | 726 | for ( ; dit.current(); ++dit ) { |
715 | if( dit.current()->name() == it.current()->text(0) ) { | 727 | if( dit.current()->name() == it.current()->text(0) ) { |
716 | d->selectedFiles->addToSelection( **dit ); | 728 | d->selectedFiles->addToSelection( **dit ); |
717 | } | 729 | } |
718 | } | 730 | } |
719 | 731 | ||
720 | videoView->setSelected( it.current(),FALSE); | 732 | videoView->setSelected( it.current(),FALSE); |
721 | } | 733 | } |
722 | } | 734 | } |
723 | // for ( int i = 0; i < noOfFiles; i++ ) { | 735 | // for ( int i = 0; i < noOfFiles; i++ ) { |
724 | // QString entryName; | 736 | // QString entryName; |
725 | // entryName.sprintf( "File%i", i + 1 ); | 737 | // entryName.sprintf( "File%i", i + 1 ); |
726 | // QString linkFile = cfg.readEntry( entryName ); | 738 | // QString linkFile = cfg.readEntry( entryName ); |
727 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 739 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { |
728 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), | 740 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), |
729 | // tr("This is all ready in your playlist.\nContinue?"), | 741 | // tr("This is all ready in your playlist.\nContinue?"), |
730 | // tr("Yes"),tr("No"),0,0,1); | 742 | // tr("Yes"),tr("No"),0,0,1); |
731 | // if (result !=0) | 743 | // if (result !=0) |
732 | // return; | 744 | // return; |
733 | // } | 745 | // } |
734 | // } | 746 | // } |
735 | // addToSelection( videoView->selectedItem() ); | 747 | // addToSelection( videoView->selectedItem() ); |
736 | tabWidget->setCurrentPage(0); | 748 | tabWidget->setCurrentPage(0); |
737 | } | 749 | } |
738 | break; | 750 | break; |
739 | }; | 751 | }; |
740 | } | 752 | } |
741 | 753 | ||
742 | void PlayListWidget::removeSelected() { | 754 | void PlayListWidget::removeSelected() { |
743 | d->selectedFiles->removeSelected( ); | 755 | d->selectedFiles->removeSelected( ); |
744 | } | 756 | } |
745 | 757 | ||
746 | void PlayListWidget::playIt( QListViewItem *it) { | 758 | void PlayListWidget::playIt( QListViewItem *it) { |
747 | // d->setDocumentUsed = FALSE; | 759 | // d->setDocumentUsed = FALSE; |
748 | mediaPlayerState->setPlaying(FALSE); | 760 | mediaPlayerState->setPlaying(FALSE); |
749 | mediaPlayerState->setPlaying(TRUE); | 761 | mediaPlayerState->setPlaying(TRUE); |
750 | d->selectedFiles->unSelect(); | 762 | d->selectedFiles->unSelect(); |
751 | } | 763 | } |
752 | 764 | ||
753 | void PlayListWidget::addToSelection( QListViewItem *it) { | 765 | void PlayListWidget::addToSelection( QListViewItem *it) { |
754 | d->setDocumentUsed = FALSE; | 766 | d->setDocumentUsed = FALSE; |
755 | 767 | ||
756 | if(it) { | 768 | if(it) { |
757 | switch (tabWidget->currentPageIndex()) { | 769 | switch (tabWidget->currentPageIndex()) { |
758 | case 1: { | 770 | case 1: { |
759 | QListIterator<DocLnk> dit( files.children() ); | 771 | QListIterator<DocLnk> dit( files.children() ); |
760 | for ( ; dit.current(); ++dit ) { | 772 | for ( ; dit.current(); ++dit ) { |
761 | if( dit.current()->name() == it->text(0)) { | 773 | if( dit.current()->name() == it->text(0)) { |
762 | d->selectedFiles->addToSelection( **dit ); | 774 | d->selectedFiles->addToSelection( **dit ); |
763 | } | 775 | } |
764 | } | 776 | } |
765 | } | 777 | } |
766 | break; | 778 | break; |
767 | case 2: { | 779 | case 2: { |
768 | QListIterator<DocLnk> dit( vFiles.children() ); | 780 | QListIterator<DocLnk> dit( vFiles.children() ); |
769 | for ( ; dit.current(); ++dit ) { | 781 | for ( ; dit.current(); ++dit ) { |
770 | if( dit.current()->name() == it->text(0)) { | 782 | if( dit.current()->name() == it->text(0)) { |
771 | d->selectedFiles->addToSelection( **dit ); | 783 | d->selectedFiles->addToSelection( **dit ); |
772 | } | 784 | } |
773 | } | 785 | } |
774 | } | 786 | } |
775 | break; | 787 | break; |
776 | case 0: | 788 | case 0: |
777 | break; | 789 | break; |
778 | }; | 790 | }; |
779 | tabWidget->setCurrentPage(0); | 791 | tabWidget->setCurrentPage(0); |
780 | } | 792 | } |
781 | } | 793 | } |
782 | 794 | ||
783 | void PlayListWidget::tabChanged(QWidget *widg) { | 795 | void PlayListWidget::tabChanged(QWidget *widg) { |
784 | 796 | ||
785 | switch ( tabWidget->currentPageIndex()) { | 797 | switch ( tabWidget->currentPageIndex()) { |
786 | case 0: | 798 | case 0: |
787 | { | 799 | { |
788 | if( !tbDeletePlaylist->isHidden()) | 800 | if( !tbDeletePlaylist->isHidden()) |
789 | tbDeletePlaylist->hide(); | 801 | tbDeletePlaylist->hide(); |
790 | d->tbRemoveFromList->setEnabled(TRUE); | 802 | d->tbRemoveFromList->setEnabled(TRUE); |
791 | d->tbAddToList->setEnabled(FALSE); | 803 | d->tbAddToList->setEnabled(FALSE); |
792 | } | 804 | } |
793 | break; | 805 | break; |
794 | case 1: | 806 | case 1: |
795 | { | 807 | { |
796 | if( !tbDeletePlaylist->isHidden()) | 808 | if( !tbDeletePlaylist->isHidden()) |
797 | tbDeletePlaylist->hide(); | 809 | tbDeletePlaylist->hide(); |
798 | d->tbRemoveFromList->setEnabled(FALSE); | 810 | d->tbRemoveFromList->setEnabled(FALSE); |
799 | d->tbAddToList->setEnabled(TRUE); | 811 | d->tbAddToList->setEnabled(TRUE); |
800 | } | 812 | } |
801 | break; | 813 | break; |
802 | case 2: | 814 | case 2: |
803 | { | 815 | { |
804 | if( !tbDeletePlaylist->isHidden()) | 816 | if( !tbDeletePlaylist->isHidden()) |
805 | tbDeletePlaylist->hide(); | 817 | tbDeletePlaylist->hide(); |
806 | d->tbRemoveFromList->setEnabled(FALSE); | 818 | d->tbRemoveFromList->setEnabled(FALSE); |
807 | d->tbAddToList->setEnabled(TRUE); | 819 | d->tbAddToList->setEnabled(TRUE); |
808 | } | 820 | } |
809 | break; | 821 | break; |
810 | case 3: | 822 | case 3: |
811 | { | 823 | { |
812 | if( tbDeletePlaylist->isHidden()) | 824 | if( tbDeletePlaylist->isHidden()) |
813 | tbDeletePlaylist->show(); | 825 | tbDeletePlaylist->show(); |
814 | playLists->reread(); | 826 | playLists->reread(); |
815 | } | 827 | } |
816 | break; | 828 | break; |
817 | }; | 829 | }; |
818 | } | 830 | } |
819 | 831 | ||
820 | 832 | ||
821 | 833 | ||
822 | void PlayListWidget::btnPlay(bool b) { | 834 | void PlayListWidget::btnPlay(bool b) { |
823 | 835 | ||
824 | // mediaPlayerState->setPlaying(b); | 836 | // mediaPlayerState->setPlaying(b); |
825 | switch ( tabWidget->currentPageIndex()) { | 837 | switch ( tabWidget->currentPageIndex()) { |
826 | case 0: | 838 | case 0: |
827 | { | 839 | { |
828 | mediaPlayerState->setPlaying(b); | 840 | mediaPlayerState->setPlaying(b); |
829 | } | 841 | } |
830 | break; | 842 | break; |
831 | case 1: | 843 | case 1: |
832 | { | 844 | { |
833 | addToSelection( audioView->selectedItem() ); | 845 | addToSelection( audioView->selectedItem() ); |
834 | mediaPlayerState->setPlaying(b); | 846 | mediaPlayerState->setPlaying(b); |
835 | d->selectedFiles->removeSelected( ); | 847 | d->selectedFiles->removeSelected( ); |
836 | tabWidget->setCurrentPage(1); | 848 | tabWidget->setCurrentPage(1); |
837 | d->selectedFiles->unSelect(); | 849 | d->selectedFiles->unSelect(); |
838 | // audioView->clearSelection(); | 850 | // audioView->clearSelection(); |
839 | } | 851 | } |
840 | break; | 852 | break; |
841 | case 2: | 853 | case 2: |
842 | { | 854 | { |
843 | addToSelection( videoView->selectedItem() ); | 855 | addToSelection( videoView->selectedItem() ); |
844 | mediaPlayerState->setPlaying(b); | 856 | mediaPlayerState->setPlaying(b); |
845 | qApp->processEvents(); | 857 | qApp->processEvents(); |
846 | d->selectedFiles->removeSelected( ); | 858 | d->selectedFiles->removeSelected( ); |
847 | tabWidget->setCurrentPage(2); | 859 | tabWidget->setCurrentPage(2); |
848 | d->selectedFiles->unSelect(); | 860 | d->selectedFiles->unSelect(); |
849 | // videoView->clearSelection(); | 861 | // videoView->clearSelection(); |
850 | } | 862 | } |
851 | break; | 863 | break; |
852 | }; | 864 | }; |
853 | } | 865 | } |
854 | 866 | ||
855 | void PlayListWidget::deletePlaylist() { | 867 | void PlayListWidget::deletePlaylist() { |
856 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 868 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
857 | (tr("You really want to delete\nthis playlist?")), | 869 | (tr("You really want to delete\nthis playlist?")), |
858 | (tr("Yes")), (tr("No")), 0 )){ | 870 | (tr("Yes")), (tr("No")), 0 )){ |
859 | case 0: // Yes clicked, | 871 | case 0: // Yes clicked, |
860 | QFile().remove(playLists->selected()->file()); | 872 | QFile().remove(playLists->selected()->file()); |
861 | QFile().remove(playLists->selected()->linkFile()); | 873 | QFile().remove(playLists->selected()->linkFile()); |
862 | playLists->reread(); | 874 | playLists->reread(); |
863 | break; | 875 | break; |
864 | case 1: // Cancel | 876 | case 1: // Cancel |
865 | break; | 877 | break; |
866 | }; | 878 | }; |
867 | 879 | ||
868 | } | 880 | } |
869 | 881 | ||
870 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 882 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
871 | { | 883 | { |
872 | switch (mouse) { | 884 | switch (mouse) { |
873 | case 1: | 885 | case 1: |
874 | break; | 886 | break; |
875 | case 2:{ | 887 | case 2:{ |
876 | QPopupMenu m; | 888 | QPopupMenu m; |
877 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 889 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
878 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 890 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
879 | m.insertSeparator(); | 891 | m.insertSeparator(); |
880 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 892 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
881 | m.exec( QCursor::pos() ); | 893 | m.exec( QCursor::pos() ); |
882 | } | 894 | } |
883 | break; | 895 | break; |
884 | }; | 896 | }; |
885 | } | 897 | } |
886 | 898 | ||
887 | void PlayListWidget::playSelected() | 899 | void PlayListWidget::playSelected() |
888 | { | 900 | { |
889 | btnPlay( TRUE); | 901 | btnPlay( TRUE); |
890 | d->selectedFiles->unSelect(); | 902 | d->selectedFiles->unSelect(); |
891 | } | 903 | } |
892 | 904 | ||
893 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 905 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
894 | { | 906 | { |
895 | switch (mouse) { | 907 | switch (mouse) { |
896 | case 1: | 908 | case 1: |
897 | 909 | ||
898 | break; | 910 | break; |
899 | case 2:{ | 911 | case 2:{ |
900 | QPopupMenu m; | 912 | QPopupMenu m; |
901 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 913 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
902 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 914 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
903 | // m.insertSeparator(); | 915 | // m.insertSeparator(); |
904 | m.exec( QCursor::pos() ); | 916 | m.exec( QCursor::pos() ); |
905 | } | 917 | } |
906 | break; | 918 | break; |
907 | }; | 919 | }; |
908 | 920 | ||
909 | } | 921 | } |
910 | 922 | ||
911 | void PlayListWidget::listDelete() { | 923 | void PlayListWidget::listDelete() { |
912 | Config cfg( "OpiePlayer" ); | 924 | Config cfg( "OpiePlayer" ); |
913 | cfg.setGroup("PlayList"); | 925 | cfg.setGroup("PlayList"); |
914 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 926 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
915 | QString file; | 927 | QString file; |
916 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 928 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
917 | switch ( tabWidget->currentPageIndex()) { | 929 | switch ( tabWidget->currentPageIndex()) { |
918 | case 0: | 930 | case 0: |
919 | break; | 931 | break; |
920 | case 1: | 932 | case 1: |
921 | { | 933 | { |
922 | file = audioView->selectedItem()->text(0); | 934 | file = audioView->selectedItem()->text(0); |
923 | // Global::findDocuments(&files, "audio/*"); | 935 | // Global::findDocuments(&files, "audio/*"); |
924 | // AppLnkSet appFiles; | 936 | // AppLnkSet appFiles; |
925 | QListIterator<DocLnk> dit( files.children() ); | 937 | QListIterator<DocLnk> dit( files.children() ); |
926 | for ( ; dit.current(); ++dit ) { | 938 | for ( ; dit.current(); ++dit ) { |
927 | if( dit.current()->name() == file) { | 939 | if( dit.current()->name() == file) { |
928 | // qDebug(file); | 940 | // qDebug(file); |
929 | LnkProperties prop( dit.current() ); | 941 | LnkProperties prop( dit.current() ); |
930 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 942 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
931 | prop.showMaximized(); | 943 | prop.showMaximized(); |
932 | prop.exec(); | 944 | prop.exec(); |
933 | } | 945 | } |
934 | } | 946 | } |
935 | populateAudioView(); | 947 | populateAudioView(); |
936 | } | 948 | } |
937 | break; | 949 | break; |
938 | case 2: | 950 | case 2: |
939 | { | 951 | { |
940 | // file = videoView->selectedItem()->text(0); | 952 | // file = videoView->selectedItem()->text(0); |
941 | // for ( int i = 0; i < noOfFiles; i++ ) { | 953 | // for ( int i = 0; i < noOfFiles; i++ ) { |
942 | // QString entryName; | 954 | // QString entryName; |
943 | // entryName.sprintf( "File%i", i + 1 ); | 955 | // entryName.sprintf( "File%i", i + 1 ); |
944 | // QString linkFile = cfg.readEntry( entryName ); | 956 | // QString linkFile = cfg.readEntry( entryName ); |
945 | // AppLnk lnk( AppLnk(linkFile)); | 957 | // AppLnk lnk( AppLnk(linkFile)); |
946 | // if( lnk.name() == file ) { | 958 | // if( lnk.name() == file ) { |
947 | // LnkProperties prop( &lnk); | 959 | // LnkProperties prop( &lnk); |
948 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 960 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
949 | // prop.showMaximized(); | 961 | // prop.showMaximized(); |
950 | // prop.exec(); | 962 | // prop.exec(); |
951 | // } | 963 | // } |
952 | // } | 964 | // } |
953 | } | 965 | } |
954 | break; | 966 | break; |
955 | }; | 967 | }; |
956 | } | 968 | } |
957 | 969 | ||
958 | void PlayListWidget::populateAudioView() { | 970 | void PlayListWidget::populateAudioView() { |
959 | // if(files) | 971 | // if(files) |
960 | // files.~DocLnkSet(); | 972 | // files.~DocLnkSet(); |
961 | StorageInfo storageInfo; | 973 | StorageInfo storageInfo; |
962 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 974 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
963 | 975 | ||
964 | Global::findDocuments(&files, "audio/*"); | 976 | Global::findDocuments(&files, "audio/*"); |
965 | QListIterator<DocLnk> dit( files.children() ); | 977 | QListIterator<DocLnk> dit( files.children() ); |
966 | QListIterator<FileSystem> it ( fs ); | 978 | QListIterator<FileSystem> it ( fs ); |
967 | audioView->clear(); | 979 | audioView->clear(); |
968 | QString storage; | 980 | QString storage; |
969 | for ( ; dit.current(); ++dit ) { | 981 | for ( ; dit.current(); ++dit ) { |
970 | for( ; it.current(); ++it ){ | 982 | for( ; it.current(); ++it ){ |
971 | const QString name = (*it)->name(); | 983 | const QString name = (*it)->name(); |
972 | const QString path = (*it)->path(); | 984 | const QString path = (*it)->path(); |
973 | if(dit.current()->file().find(path) != -1 ) storage=name; | 985 | if(dit.current()->file().find(path) != -1 ) storage=name; |
974 | } | 986 | } |
975 | 987 | ||
976 | QListViewItem * newItem; | 988 | QListViewItem * newItem; |
977 | if ( QFile( dit.current()->file()).exists() ) { | 989 | if ( QFile( dit.current()->file()).exists() ) { |
978 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 990 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
979 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 991 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
980 | } | 992 | } |
981 | } | 993 | } |
982 | } | 994 | } |
983 | 995 | ||
984 | void PlayListWidget::populateVideoView() { | 996 | void PlayListWidget::populateVideoView() { |
985 | StorageInfo storageInfo; | 997 | StorageInfo storageInfo; |
986 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 998 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
987 | 999 | ||
988 | Global::findDocuments(&vFiles, "video/*"); | 1000 | Global::findDocuments(&vFiles, "video/*"); |
989 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1001 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
990 | QListIterator<FileSystem> it ( fs ); | 1002 | QListIterator<FileSystem> it ( fs ); |
991 | videoView->clear(); | 1003 | videoView->clear(); |
992 | QString storage; | 1004 | QString storage; |
993 | for ( ; Vdit.current(); ++Vdit ) { | 1005 | for ( ; Vdit.current(); ++Vdit ) { |
994 | for( ; it.current(); ++it ){ | 1006 | for( ; it.current(); ++it ){ |
995 | const QString name = (*it)->name(); | 1007 | const QString name = (*it)->name(); |
996 | const QString path = (*it)->path(); | 1008 | const QString path = (*it)->path(); |
997 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1009 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
998 | } | 1010 | } |
999 | 1011 | ||
1000 | QListViewItem * newItem; | 1012 | QListViewItem * newItem; |
1001 | if ( QFile( Vdit.current()->file()).exists() ) { | 1013 | if ( QFile( Vdit.current()->file()).exists() ) { |
1002 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 1014 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
1003 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1015 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1004 | } | 1016 | } |
1005 | } | 1017 | } |
1006 | } | 1018 | } |
1007 | 1019 | ||
1008 | void PlayListWidget::openFile() { | 1020 | void PlayListWidget::openFile() { |
1009 | QString filename, name; | 1021 | QString filename, name; |
1010 | InputDialog *fileDlg; | 1022 | InputDialog *fileDlg; |
1011 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1023 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1012 | fileDlg->exec(); | 1024 | fileDlg->exec(); |
1013 | if( fileDlg->result() == 1 ) { | 1025 | if( fileDlg->result() == 1 ) { |
1014 | filename = fileDlg->LineEdit1->text(); | 1026 | filename = fileDlg->LineEdit1->text(); |
1015 | 1027 | ||
1016 | // InputDialog *fileDlg2; | 1028 | // InputDialog *fileDlg2; |
1017 | // fileDlg2 = new InputDialog(this,tr("Name"),TRUE, 0); | 1029 | // fileDlg2 = new InputDialog(this,tr("Name"),TRUE, 0); |
1018 | // fileDlg2->exec(); | 1030 | // fileDlg2->exec(); |
1019 | // if( fileDlg2->result() == 1 ) { | 1031 | // if( fileDlg2->result() == 1 ) { |
1020 | // name = fileDlg2->LineEdit1->text(); | 1032 | // name = fileDlg2->LineEdit1->text(); |
1021 | // } | 1033 | // } |
1022 | //http://205.188.234.129:8030 | 1034 | //http://205.188.234.129:8030 |
1023 | // http://66.28.68.70:8000 | 1035 | // http://66.28.68.70:8000 |
1024 | qDebug(filename); | 1036 | qDebug(filename); |
1025 | DocLnk lnk; | 1037 | DocLnk lnk; |
1026 | // if(filename.left(7) == "http://") | 1038 | // if(filename.left(7) == "http://") |
1027 | // name= filename.right(filename.length()-filename.find("http://")-7); | 1039 | // name= filename.right(filename.length()-filename.find("http://")-7); |
1028 | // else name = filename; | 1040 | // else name = filename; |
1029 | // qDebug("name is "+name); | 1041 | // qDebug("name is "+name); |
1030 | // lnk.setComment(filename); | 1042 | // lnk.setComment(filename); |
1031 | lnk.setName(filename); //sets file name | 1043 | lnk.setName(filename); //sets file name |
1032 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") | 1044 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") |
1033 | filename += "/"; | 1045 | filename += "/"; |
1034 | lnk.setFile(filename); //sets File property | 1046 | lnk.setFile(filename); //sets File property |
1035 | 1047 | ||
1036 | lnk.setType("audio/x-mpegurl"); | 1048 | lnk.setType("audio/x-mpegurl"); |
1037 | lnk.setExec("opieplayer"); | 1049 | lnk.setExec("opieplayer"); |
1038 | lnk.setIcon("opieplayer/MPEGPlayer"); | 1050 | lnk.setIcon("opieplayer/MPEGPlayer"); |
1039 | 1051 | ||
1040 | if(!lnk.writeLink()) | 1052 | if(!lnk.writeLink()) |
1041 | qDebug("Writing doclink did not work"); | 1053 | qDebug("Writing doclink did not work"); |
1042 | d->selectedFiles->addToSelection( lnk); | 1054 | d->selectedFiles->addToSelection( lnk); |
1043 | // if(fileDlg2) | 1055 | // if(fileDlg2) |
1044 | // delete fileDlg2; | 1056 | // delete fileDlg2; |
1045 | } | 1057 | } |
1046 | 1058 | ||
1047 | if(fileDlg) | 1059 | if(fileDlg) |
1048 | delete fileDlg; | 1060 | delete fileDlg; |
1049 | } | 1061 | } |
1050 | 1062 | ||
1051 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1063 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1052 | { | 1064 | { |
1053 | switch ( e->key() ) { | 1065 | switch ( e->key() ) { |
1054 | ////////////////////////////// Zaurus keys | 1066 | ////////////////////////////// Zaurus keys |
1055 | case Key_F9: //activity | 1067 | case Key_F9: //activity |
1056 | if(audioUI->isHidden()) | 1068 | // if(audioUI->isHidden()) |
1057 | audioUI->showMaximized(); | 1069 | // audioUI->showMaximized(); |
1058 | break; | 1070 | break; |
1059 | case Key_F10: //contacts | 1071 | case Key_F10: //contacts |
1060 | if( videoUI->isHidden()) | 1072 | // if( videoUI->isHidden()) |
1061 | videoUI->showMaximized(); | 1073 | // videoUI->showMaximized(); |
1062 | 1074 | break; | |
1075 | case Key_F11: //menu | ||
1076 | break; | ||
1077 | case Key_F12: //home | ||
1078 | // doBlank(); | ||
1079 | break; | ||
1080 | case Key_F13: //mail | ||
1081 | // doUnblank(); | ||
1063 | break; | 1082 | break; |
1064 | 1083 | ||
1065 | } | 1084 | } |
1066 | } | 1085 | } |
1086 | |||
1087 | void PlayListWidget::doBlank() { | ||
1088 | qDebug("do blanking"); | ||
1089 | fd=open("/dev/fb0",O_RDWR); | ||
1090 | if (fd != -1) { | ||
1091 | ioctl(fd,FBIOBLANK,1); | ||
1092 | // close(fd); | ||
1093 | } | ||
1094 | } | ||
1095 | |||
1096 | void PlayListWidget::doUnblank() { | ||
1097 | // this crashes opieplayer with a segfault | ||
1098 | // int fd; | ||
1099 | // fd=open("/dev/fb0",O_RDWR); | ||
1100 | qDebug("do unblanking"); | ||
1101 | if (fd != -1) { | ||
1102 | ioctl(fd,FBIOBLANK,0); | ||
1103 | close(fd); | ||
1104 | } | ||
1105 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | ||
1106 | h <<-3;// v[1]; // -3 Force on | ||
1107 | } | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 16b9905..f22770f 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -1,113 +1,117 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
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 | #ifndef PLAY_LIST_WIDGET_H | 20 | #ifndef PLAY_LIST_WIDGET_H |
21 | #define PLAY_LIST_WIDGET_H | 21 | #define PLAY_LIST_WIDGET_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
25 | #include <qtabwidget.h> | 25 | #include <qtabwidget.h> |
26 | #include <qpe/fileselector.h> | 26 | #include <qpe/fileselector.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | 28 | ||
29 | /* #include <qtimer.h> */ | 29 | /* #include <qtimer.h> */ |
30 | 30 | ||
31 | 31 | ||
32 | class PlayListWidgetPrivate; | 32 | class PlayListWidgetPrivate; |
33 | class Config; | 33 | class Config; |
34 | class QListViewItem; | 34 | class QListViewItem; |
35 | class QListView; | 35 | class QListView; |
36 | class QPoint; | 36 | class QPoint; |
37 | class QAction; | 37 | class QAction; |
38 | class QLabel; | 38 | class QLabel; |
39 | 39 | ||
40 | class PlayListWidget : public QMainWindow { | 40 | class PlayListWidget : public QMainWindow { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 43 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
44 | ~PlayListWidget(); | 44 | ~PlayListWidget(); |
45 | QTabWidget * tabWidget; | 45 | QTabWidget * tabWidget; |
46 | QAction *fullScreenButton, *scaleButton; | 46 | QAction *fullScreenButton, *scaleButton; |
47 | DocLnkSet files; | 47 | DocLnkSet files; |
48 | DocLnkSet vFiles; | 48 | DocLnkSet vFiles; |
49 | QListView *audioView, *videoView, *playlistView; | 49 | QListView *audioView, *videoView, *playlistView; |
50 | QLabel *libString; | 50 | QLabel *libString; |
51 | bool fromSetDocument; | 51 | bool fromSetDocument; |
52 | bool insanityBool; | 52 | bool insanityBool; |
53 | QString setDocFileRef; | 53 | QString setDocFileRef; |
54 | // retrieve the current playlist entry (media file link) | 54 | // retrieve the current playlist entry (media file link) |
55 | const DocLnk *current(); | 55 | const DocLnk *current(); |
56 | void useSelectedDocument(); | 56 | void useSelectedDocument(); |
57 | /* QTimer * menuTimer; */ | 57 | /* QTimer * menuTimer; */ |
58 | FileSelector* playLists; | 58 | FileSelector* playLists; |
59 | QPushButton *tbDeletePlaylist; | 59 | QPushButton *tbDeletePlaylist; |
60 | int fd; | ||
60 | public slots: | 61 | public slots: |
61 | bool first(); | 62 | bool first(); |
62 | bool last(); | 63 | bool last(); |
63 | bool next(); | 64 | bool next(); |
64 | bool prev(); | 65 | bool prev(); |
65 | /* void setFullScreen(); */ | 66 | /* void setFullScreen(); */ |
66 | /* void setScaled(); */ | 67 | /* void setScaled(); */ |
67 | protected: | 68 | protected: |
68 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | 69 | /* void contentsMousePressEvent( QMouseEvent * e ); */ |
69 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | 70 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ |
70 | void keyReleaseEvent( QKeyEvent *e); | 71 | void keyReleaseEvent( QKeyEvent *e); |
71 | private: | 72 | private: |
73 | void doBlank(); | ||
74 | void doUnblank(); | ||
75 | |||
72 | void initializeStates(); | 76 | void initializeStates(); |
73 | void readConfig( Config& cfg ); | 77 | void readConfig( Config& cfg ); |
74 | void writeConfig( Config& cfg ) const; | 78 | void writeConfig( Config& cfg ) const; |
75 | PlayListWidgetPrivate *d; // Private implementation data | 79 | PlayListWidgetPrivate *d; // Private implementation data |
76 | void populateAudioView(); | 80 | void populateAudioView(); |
77 | void populateVideoView(); | 81 | void populateVideoView(); |
78 | private slots: | 82 | private slots: |
79 | void openFile(); | 83 | void openFile(); |
80 | void setDocument( const QString& fileref ); | 84 | void setDocument( const QString& fileref ); |
81 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 85 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
82 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 86 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
83 | void setActiveWindow(); // need to handle this to show the right view | 87 | void setActiveWindow(); // need to handle this to show the right view |
84 | void setPlaylist( bool ); // Show/Hide the playlist | 88 | void setPlaylist( bool ); // Show/Hide the playlist |
85 | void setView( char ); | 89 | void setView( char ); |
86 | void clearList(); | 90 | void clearList(); |
87 | void addAllToList(); | 91 | void addAllToList(); |
88 | void addAllMusicToList(); | 92 | void addAllMusicToList(); |
89 | void addAllVideoToList(); | 93 | void addAllVideoToList(); |
90 | void saveList(); // Save the playlist | 94 | void saveList(); // Save the playlist |
91 | void loadList( const DocLnk &); // Load a playlist | 95 | void loadList( const DocLnk &); // Load a playlist |
92 | void playIt( QListViewItem *); | 96 | void playIt( QListViewItem *); |
93 | 97 | ||
94 | void btnPlay(bool); | 98 | void btnPlay(bool); |
95 | void deletePlaylist(); | 99 | void deletePlaylist(); |
96 | void addSelected(); | 100 | void addSelected(); |
97 | void removeSelected(); | 101 | void removeSelected(); |
98 | void tabChanged(QWidget*); | 102 | void tabChanged(QWidget*); |
99 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 103 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
100 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 104 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
101 | void playSelected(); | 105 | void playSelected(); |
102 | void listDelete(); | 106 | void listDelete(); |
103 | 107 | ||
104 | protected slots: | 108 | protected slots: |
105 | /* void cancelMenuTimer(); */ | 109 | /* void cancelMenuTimer(); */ |
106 | /* void showFileMenu(); */ | 110 | /* void showFileMenu(); */ |
107 | 111 | ||
108 | 112 | ||
109 | }; | 113 | }; |
110 | 114 | ||
111 | 115 | ||
112 | #endif // PLAY_LIST_WIDGET_H | 116 | #endif // PLAY_LIST_WIDGET_H |
113 | 117 | ||
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index d0cb764..3bce996 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -1,473 +1,473 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
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 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | #include <qpe/mediaplayerplugininterface.h> | 21 | #include <qpe/mediaplayerplugininterface.h> |
22 | #include <qwidget.h> | 22 | #include <qwidget.h> |
23 | #include <qpainter.h> | 23 | #include <qpainter.h> |
24 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
25 | #include <qslider.h> | 25 | #include <qslider.h> |
26 | #include <qdrawutil.h> | 26 | #include <qdrawutil.h> |
27 | #include "videowidget.h" | 27 | #include "videowidget.h" |
28 | #include "mediaplayerstate.h" | 28 | #include "mediaplayerstate.h" |
29 | 29 | ||
30 | 30 | ||
31 | #ifdef Q_WS_QWS | 31 | #ifdef Q_WS_QWS |
32 | # define USE_DIRECT_PAINTER | 32 | # define USE_DIRECT_PAINTER |
33 | # include <qdirectpainter_qws.h> | 33 | # include <qdirectpainter_qws.h> |
34 | # include <qgfxraster_qws.h> | 34 | # include <qgfxraster_qws.h> |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | 37 | ||
38 | extern MediaPlayerState *mediaPlayerState; | 38 | extern MediaPlayerState *mediaPlayerState; |
39 | 39 | ||
40 | 40 | ||
41 | static const int xo = 2; // movable x offset | 41 | static const int xo = 2; // movable x offset |
42 | static const int yo = 0; // movable y offset | 42 | static const int yo = 0; // movable y offset |
43 | 43 | ||
44 | 44 | ||
45 | struct MediaButton { | 45 | struct MediaButton { |
46 | int xPos, yPos; | 46 | int xPos, yPos; |
47 | bool isToggle, isHeld, isDown; | 47 | bool isToggle, isHeld, isDown; |
48 | int controlType; | 48 | int controlType; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | 51 | ||
52 | // Layout information for the videoButtons (and if it is a toggle button or not) | 52 | // Layout information for the videoButtons (and if it is a toggle button or not) |
53 | MediaButton videoButtons[] = { | 53 | MediaButton videoButtons[] = { |
54 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous | 54 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous |
55 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop | 55 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop |
56 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play | 56 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play |
57 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause | 57 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause |
58 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next | 58 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next |
59 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist | 59 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist |
60 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen | 60 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen |
61 | }; | 61 | }; |
62 | 62 | ||
63 | 63 | ||
64 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 64 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
65 | 65 | ||
66 | 66 | ||
67 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 67 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
68 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 68 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
69 | setCaption( tr("OpiePlayer") ); | 69 | setCaption( tr("OpiePlayer") ); |
70 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); | 70 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
71 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0a" ) ); | 71 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0a" ) ); |
72 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0b" ) ); | 72 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0b" ) ); |
73 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls0" ) ); | 73 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls0" ) ); |
74 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | 74 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); |
75 | 75 | ||
76 | slider = new QSlider( Qt::Horizontal, this ); | 76 | slider = new QSlider( Qt::Horizontal, this ); |
77 | slider->setMinValue( 0 ); | 77 | slider->setMinValue( 0 ); |
78 | slider->setMaxValue( 1 ); | 78 | slider->setMaxValue( 1 ); |
79 | slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); | 79 | slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
80 | slider->setFocusPolicy( QWidget::NoFocus ); | 80 | slider->setFocusPolicy( QWidget::NoFocus ); |
81 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 81 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
82 | 82 | ||
83 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 83 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
84 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 84 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
85 | 85 | ||
86 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 86 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
87 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 87 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
88 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 88 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
89 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 89 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
90 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 90 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
91 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 91 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
92 | 92 | ||
93 | // Intialise state | 93 | // Intialise state |
94 | setLength( mediaPlayerState->length() ); | 94 | setLength( mediaPlayerState->length() ); |
95 | setPosition( mediaPlayerState->position() ); | 95 | setPosition( mediaPlayerState->position() ); |
96 | setFullscreen( mediaPlayerState->fullscreen() ); | 96 | setFullscreen( mediaPlayerState->fullscreen() ); |
97 | setPaused( mediaPlayerState->paused() ); | 97 | setPaused( mediaPlayerState->paused() ); |
98 | setPlaying( mediaPlayerState->playing() ); | 98 | setPlaying( mediaPlayerState->playing() ); |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | VideoWidget::~VideoWidget() { | 102 | VideoWidget::~VideoWidget() { |
103 | for ( int i = 0; i < 3; i++ ) | 103 | for ( int i = 0; i < 3; i++ ) |
104 | delete pixmaps[i]; | 104 | delete pixmaps[i]; |
105 | delete currentFrame; | 105 | delete currentFrame; |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | static bool videoSliderBeingMoved = FALSE; | 109 | static bool videoSliderBeingMoved = FALSE; |
110 | 110 | ||
111 | 111 | ||
112 | void VideoWidget::sliderPressed() { | 112 | void VideoWidget::sliderPressed() { |
113 | videoSliderBeingMoved = TRUE; | 113 | videoSliderBeingMoved = TRUE; |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void VideoWidget::sliderReleased() { | 117 | void VideoWidget::sliderReleased() { |
118 | videoSliderBeingMoved = FALSE; | 118 | videoSliderBeingMoved = FALSE; |
119 | if ( slider->width() == 0 ) | 119 | if ( slider->width() == 0 ) |
120 | return; | 120 | return; |
121 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 121 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
122 | mediaPlayerState->setPosition( val ); | 122 | mediaPlayerState->setPosition( val ); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | void VideoWidget::setPosition( long i ) { | 126 | void VideoWidget::setPosition( long i ) { |
127 | updateSlider( i, mediaPlayerState->length() ); | 127 | updateSlider( i, mediaPlayerState->length() ); |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | void VideoWidget::setLength( long max ) { | 131 | void VideoWidget::setLength( long max ) { |
132 | updateSlider( mediaPlayerState->position(), max ); | 132 | updateSlider( mediaPlayerState->position(), max ); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | void VideoWidget::setView( char view ) { | 136 | void VideoWidget::setView( char view ) { |
137 | if ( view == 'v' ) { | 137 | if ( view == 'v' ) { |
138 | makeVisible(); | 138 | makeVisible(); |
139 | } else { | 139 | } else { |
140 | // Effectively blank the view next time we show it so it looks nicer | 140 | // Effectively blank the view next time we show it so it looks nicer |
141 | scaledWidth = 0; | 141 | scaledWidth = 0; |
142 | scaledHeight = 0; | 142 | scaledHeight = 0; |
143 | hide(); | 143 | hide(); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | void VideoWidget::updateSlider( long i, long max ) { | 148 | void VideoWidget::updateSlider( long i, long max ) { |
149 | // Will flicker too much if we don't do this | 149 | // Will flicker too much if we don't do this |
150 | if ( max == 0 ) | 150 | if ( max == 0 ) |
151 | return; | 151 | return; |
152 | int width = slider->width(); | 152 | int width = slider->width(); |
153 | int val = int((double)i * width / max); | 153 | int val = int((double)i * width / max); |
154 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 154 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
155 | if ( slider->value() != val ) | 155 | if ( slider->value() != val ) |
156 | slider->setValue( val ); | 156 | slider->setValue( val ); |
157 | if ( slider->maxValue() != width ) | 157 | if ( slider->maxValue() != width ) |
158 | slider->setMaxValue( width ); | 158 | slider->setMaxValue( width ); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | void VideoWidget::setToggleButton( int i, bool down ) { | 163 | void VideoWidget::setToggleButton( int i, bool down ) { |
164 | if ( down != videoButtons[i].isDown ) | 164 | if ( down != videoButtons[i].isDown ) |
165 | toggleButton( i ); | 165 | toggleButton( i ); |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | void VideoWidget::toggleButton( int i ) { | 169 | void VideoWidget::toggleButton( int i ) { |
170 | videoButtons[i].isDown = !videoButtons[i].isDown; | 170 | videoButtons[i].isDown = !videoButtons[i].isDown; |
171 | QPainter p(this); | 171 | QPainter p(this); |
172 | paintButton ( &p, i ); | 172 | paintButton ( &p, i ); |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
176 | void VideoWidget::paintButton( QPainter *p, int i ) { | 176 | void VideoWidget::paintButton( QPainter *p, int i ) { |
177 | int x = videoButtons[i].xPos; | 177 | int x = videoButtons[i].xPos; |
178 | int y = videoButtons[i].yPos; | 178 | int y = videoButtons[i].yPos; |
179 | int offset = 10 + videoButtons[i].isDown; | 179 | int offset = 10 + videoButtons[i].isDown; |
180 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); | 180 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); |
181 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); | 181 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 185 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
186 | for ( int i = 0; i < numButtons; i++ ) { | 186 | for ( int i = 0; i < numButtons; i++ ) { |
187 | int x = videoButtons[i].xPos; | 187 | int x = videoButtons[i].xPos; |
188 | int y = videoButtons[i].yPos; | 188 | int y = videoButtons[i].yPos; |
189 | if ( event->state() == QMouseEvent::LeftButton ) { | 189 | if ( event->state() == QMouseEvent::LeftButton ) { |
190 | // The test to see if the mouse click is inside the circular button or not | 190 | // The test to see if the mouse click is inside the circular button or not |
191 | // (compared with the radius squared to avoid a square-root of our distance) | 191 | // (compared with the radius squared to avoid a square-root of our distance) |
192 | int radius = 16; | 192 | int radius = 16; |
193 | QPoint center = QPoint( x + radius, y + radius ); | 193 | QPoint center = QPoint( x + radius, y + radius ); |
194 | QPoint dXY = center - event->pos(); | 194 | QPoint dXY = center - event->pos(); |
195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
196 | bool isOnButton = dist <= (radius * radius); | 196 | bool isOnButton = dist <= (radius * radius); |
197 | if ( isOnButton != videoButtons[i].isHeld ) { | 197 | if ( isOnButton != videoButtons[i].isHeld ) { |
198 | videoButtons[i].isHeld = isOnButton; | 198 | videoButtons[i].isHeld = isOnButton; |
199 | toggleButton(i); | 199 | toggleButton(i); |
200 | } | 200 | } |
201 | } else { | 201 | } else { |
202 | if ( videoButtons[i].isHeld ) { | 202 | if ( videoButtons[i].isHeld ) { |
203 | videoButtons[i].isHeld = FALSE; | 203 | videoButtons[i].isHeld = FALSE; |
204 | if ( !videoButtons[i].isToggle ) | 204 | if ( !videoButtons[i].isToggle ) |
205 | setToggleButton( i, FALSE ); | 205 | setToggleButton( i, FALSE ); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | switch (i) { | 208 | switch (i) { |
209 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 209 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
210 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 210 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
211 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 211 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
212 | case VideoNext: mediaPlayerState->setNext(); return; | 212 | case VideoNext: mediaPlayerState->setNext(); return; |
213 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 213 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
214 | case VideoPlayList: mediaPlayerState->setList(); return; | 214 | case VideoPlayList: mediaPlayerState->setList(); return; |
215 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 215 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
216 | } | 216 | } |
217 | 217 | ||
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 222 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
223 | mouseMoveEvent( event ); | 223 | mouseMoveEvent( event ); |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 227 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
228 | if ( mediaPlayerState->fullscreen() ) { | 228 | if ( mediaPlayerState->fullscreen() ) { |
229 | mediaPlayerState->setFullscreen( FALSE ); | 229 | mediaPlayerState->setFullscreen( FALSE ); |
230 | makeVisible(); | 230 | makeVisible(); |
231 | 231 | ||
232 | mouseMoveEvent( event ); | 232 | mouseMoveEvent( event ); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | void VideoWidget::makeVisible() { | 237 | void VideoWidget::makeVisible() { |
238 | if ( mediaPlayerState->fullscreen() ) { | 238 | if ( mediaPlayerState->fullscreen() ) { |
239 | setBackgroundMode( QWidget::NoBackground ); | 239 | setBackgroundMode( QWidget::NoBackground ); |
240 | showFullScreen(); | 240 | showFullScreen(); |
241 | resize( qApp->desktop()->size() ); | 241 | resize( qApp->desktop()->size() ); |
242 | slider->hide(); | 242 | slider->hide(); |
243 | } else { | 243 | } else { |
244 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); | 244 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
245 | showNormal(); | 245 | showNormal(); |
246 | showMaximized(); | 246 | showMaximized(); |
247 | slider->show(); | 247 | slider->show(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | 251 | ||
252 | void VideoWidget::paintEvent( QPaintEvent * ) { | 252 | void VideoWidget::paintEvent( QPaintEvent * ) { |
253 | QPainter p( this ); | 253 | QPainter p( this ); |
254 | 254 | ||
255 | if ( mediaPlayerState->fullscreen() ) { | 255 | if ( mediaPlayerState->fullscreen() ) { |
256 | // Clear the background | 256 | // Clear the background |
257 | p.setBrush( QBrush( Qt::black ) ); | 257 | p.setBrush( QBrush( Qt::black ) ); |
258 | p.drawRect( rect() ); | 258 | p.drawRect( rect() ); |
259 | 259 | ||
260 | // Draw the current frame | 260 | // Draw the current frame |
261 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen | 261 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen |
262 | } else { | 262 | } else { |
263 | // draw border | 263 | // draw border |
264 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); | 264 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); |
265 | 265 | ||
266 | // Clear the movie screen first | 266 | // Clear the movie screen first |
267 | p.setBrush( QBrush( Qt::black ) ); | 267 | p.setBrush( QBrush( Qt::black ) ); |
268 | p.drawRect( 9, 20, 220, 160 ); | 268 | p.drawRect( 9, 20, 220, 160 ); |
269 | 269 | ||
270 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) | 270 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) |
271 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 271 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
272 | 272 | ||
273 | // draw the buttons | 273 | // draw the buttons |
274 | for ( int i = 0; i < numButtons; i++ ) | 274 | for ( int i = 0; i < numButtons; i++ ) |
275 | paintButton( &p, i ); | 275 | paintButton( &p, i ); |
276 | 276 | ||
277 | // draw the slider | 277 | // draw the slider |
278 | slider->repaint( TRUE ); | 278 | slider->repaint( TRUE ); |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | void VideoWidget::closeEvent( QCloseEvent* ) { | 283 | void VideoWidget::closeEvent( QCloseEvent* ) { |
284 | mediaPlayerState->setList(); | 284 | mediaPlayerState->setList(); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | bool VideoWidget::playVideo() { | 288 | bool VideoWidget::playVideo() { |
289 | bool result = FALSE; | 289 | bool result = FALSE; |
290 | 290 | ||
291 | int stream = 0; | 291 | int stream = 0; |
292 | 292 | ||
293 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); | 293 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); |
294 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); | 294 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); |
295 | int dd = QPixmap::defaultDepth(); | 295 | int dd = QPixmap::defaultDepth(); |
296 | int w = height(); | 296 | int w = height(); |
297 | int h = width(); | 297 | int h = width(); |
298 | 298 | ||
299 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; | 299 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; |
300 | 300 | ||
301 | if ( mediaPlayerState->fullscreen() ) { | 301 | if ( mediaPlayerState->fullscreen() ) { |
302 | #ifdef USE_DIRECT_PAINTER | 302 | #ifdef USE_DIRECT_PAINTER |
303 | QDirectPainter p(this); | 303 | QDirectPainter p(this); |
304 | 304 | ||
305 | if ( ( qt_screen->transformOrientation() == 3 ) && | 305 | if ( ( qt_screen->transformOrientation() == 3 ) && |
306 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { | 306 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { |
307 | 307 | ||
308 | w = 320; | 308 | w = 320; |
309 | h = 240; | 309 | h = 240; |
310 | 310 | ||
311 | if ( mediaPlayerState->scaled() ) { | 311 | if ( mediaPlayerState->scaled() ) { |
312 | // maintain aspect ratio | 312 | // maintain aspect ratio |
313 | if ( w * sh > sw * h ) | 313 | if ( w * sh > sw * h ) |
314 | w = sw * h / sh; | 314 | w = sw * h / sh; |
315 | else | 315 | else |
316 | h = sh * w / sw; | 316 | h = sh * w / sw; |
317 | } else { | 317 | } else { |
318 | w = sw; | 318 | w = sw; |
319 | h = sh; | 319 | h = sh; |
320 | } | 320 | } |
321 | 321 | ||
322 | w--; // we can't allow libmpeg to overwrite. | 322 | w--; // we can't allow libmpeg to overwrite. |
323 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); | 323 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); |
324 | 324 | ||
325 | int ox = roff.x() - height() + 2 + (height() - w) / 2; | 325 | int ox = roff.x() - height() + 2 + (height() - w) / 2; |
326 | int oy = roff.y() + (width() - h) / 2; | 326 | int oy = roff.y() + (width() - h) / 2; |
327 | int sx = 0, sy = 0; | 327 | int sx = 0, sy = 0; |
328 | 328 | ||
329 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; | 329 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; |
330 | fp += dd * ox / 8; | 330 | fp += dd * ox / 8; |
331 | uchar **jt = new uchar*[h]; | 331 | uchar **jt = new uchar*[h]; |
332 | for ( int i = h; i; i-- ) { | 332 | for ( int i = h; i; i-- ) { |
333 | jt[h - i] = fp; | 333 | jt[h - i] = fp; |
334 | fp += p.lineStep(); | 334 | fp += p.lineStep(); |
335 | } | 335 | } |
336 | 336 | ||
337 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; | 337 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; |
338 | 338 | ||
339 | delete [] jt; | 339 | delete [] jt; |
340 | } else { | 340 | } else { |
341 | #endif | 341 | #endif |
342 | QPainter p(this); | 342 | QPainter p(this); |
343 | 343 | ||
344 | w = 320; | 344 | w = 320; |
345 | h = 240; | 345 | h = 240; |
346 | 346 | ||
347 | if ( mediaPlayerState->scaled() ) { | 347 | if ( mediaPlayerState->scaled() ) { |
348 | // maintain aspect ratio | 348 | // maintain aspect ratio |
349 | if ( w * sh > sw * h ) | 349 | if ( w * sh > sw * h ) |
350 | w = sw * h / sh; | 350 | w = sw * h / sh; |
351 | else | 351 | else |
352 | h = sh * w / sw; | 352 | h = sh * w / sw; |
353 | } else { | 353 | } else { |
354 | w = sw; | 354 | w = sw; |
355 | h = sh; | 355 | h = sh; |
356 | } | 356 | } |
357 | 357 | ||
358 | int bytes = ( dd == 16 ) ? 2 : 4; | 358 | int bytes = ( dd == 16 ) ? 2 : 4; |
359 | QImage tempFrame( w, h, bytes << 3 ); | 359 | QImage tempFrame( w, h, bytes << 3 ); |
360 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), | 360 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), |
361 | 0, 0, sw, sh, w, h, format, 0) == 0; | 361 | 0, 0, sw, sh, w, h, format, 0) == 0; |
362 | if ( result && mediaPlayerState->fullscreen() ) { | 362 | if ( result && mediaPlayerState->fullscreen() ) { |
363 | 363 | ||
364 | int rw = h, rh = w; | 364 | int rw = h, rh = w; |
365 | QImage rotatedFrame( rw, rh, bytes << 3 ); | 365 | QImage rotatedFrame( rw, rh, bytes << 3 ); |
366 | 366 | ||
367 | ushort* in = (ushort*)tempFrame.bits(); | 367 | ushort* in = (ushort*)tempFrame.bits(); |
368 | ushort* out = (ushort*)rotatedFrame.bits(); | 368 | ushort* out = (ushort*)rotatedFrame.bits(); |
369 | int spl = rotatedFrame.bytesPerLine() / bytes; | 369 | int spl = rotatedFrame.bytesPerLine() / bytes; |
370 | for (int x=0; x<h; x++) { | 370 | for (int x=0; x<h; x++) { |
371 | if ( bytes == 2 ) { | 371 | if ( bytes == 2 ) { |
372 | ushort* lout = out++ + (w - 1)*spl; | 372 | ushort* lout = out++ + (w - 1)*spl; |
373 | for (int y=0; y<w; y++) { | 373 | for (int y=0; y<w; y++) { |
374 | *lout=*in++; | 374 | *lout=*in++; |
375 | lout-=spl; | 375 | lout-=spl; |
376 | } | 376 | } |
377 | } else { | 377 | } else { |
378 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; | 378 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; |
379 | for (int y=0; y<w; y++) { | 379 | for (int y=0; y<w; y++) { |
380 | *lout=*((ulong*)in)++; | 380 | *lout=*((ulong*)in)++; |
381 | lout-=spl; | 381 | lout-=spl; |
382 | } | 382 | } |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); | 386 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); |
387 | } | 387 | } |
388 | #ifdef USE_DIRECT_PAINTER | 388 | #ifdef USE_DIRECT_PAINTER |
389 | } | 389 | } |
390 | #endif | 390 | #endif |
391 | } else { | 391 | } else { |
392 | 392 | ||
393 | w = 220; | 393 | w = 220; |
394 | h = 160; | 394 | h = 160; |
395 | 395 | ||
396 | // maintain aspect ratio | 396 | // maintain aspect ratio |
397 | if ( w * sh > sw * h ) | 397 | if ( w * sh > sw * h ) |
398 | w = sw * h / sh; | 398 | w = sw * h / sh; |
399 | else | 399 | else |
400 | h = sh * w / sw; | 400 | h = sh * w / sw; |
401 | 401 | ||
402 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; | 402 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; |
403 | 403 | ||
404 | QPainter p( this ); | 404 | QPainter p( this ); |
405 | 405 | ||
406 | // Image changed size, therefore need to blank the possibly unpainted regions first | 406 | // Image changed size, therefore need to blank the possibly unpainted regions first |
407 | if ( scaledWidth != w || scaledHeight != h ) { | 407 | if ( scaledWidth != w || scaledHeight != h ) { |
408 | p.setBrush( QBrush( Qt::black ) ); | 408 | p.setBrush( QBrush( Qt::black ) ); |
409 | p.drawRect( 9, 20, 220, 160 ); | 409 | p.drawRect( 9, 20, 220, 160 ); |
410 | } | 410 | } |
411 | 411 | ||
412 | scaledWidth = w; | 412 | scaledWidth = w; |
413 | scaledHeight = h; | 413 | scaledHeight = h; |
414 | 414 | ||
415 | if ( result ) { | 415 | if ( result ) { |
416 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 416 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
417 | } | 417 | } |
418 | 418 | ||
419 | } | 419 | } |
420 | 420 | ||
421 | return result; | 421 | return result; |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | 425 | ||
426 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) | 426 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) |
427 | { | 427 | { |
428 | switch ( e->key() ) { | 428 | switch ( e->key() ) { |
429 | ////////////////////////////// Zaurus keys | 429 | ////////////////////////////// Zaurus keys |
430 | case Key_Home: | 430 | case Key_Home: |
431 | break; | 431 | break; |
432 | case Key_F9: //activity | 432 | case Key_F9: //activity |
433 | break; | 433 | break; |
434 | case Key_F10: //contacts | 434 | case Key_F10: //contacts |
435 | hide(); | 435 | // hide(); |
436 | break; | 436 | break; |
437 | case Key_F11: //menu | 437 | case Key_F11: //menu |
438 | break; | 438 | break; |
439 | case Key_F12: //home | 439 | case Key_F12: //home |
440 | break; | 440 | break; |
441 | case Key_F13: //mail | 441 | case Key_F13: //mail |
442 | break; | 442 | break; |
443 | case Key_Space: { | 443 | case Key_Space: { |
444 | if(mediaPlayerState->playing()) { | 444 | if(mediaPlayerState->playing()) { |
445 | mediaPlayerState->setPlaying(FALSE); | 445 | mediaPlayerState->setPlaying(FALSE); |
446 | } else { | 446 | } else { |
447 | mediaPlayerState->setPlaying(TRUE); | 447 | mediaPlayerState->setPlaying(TRUE); |
448 | } | 448 | } |
449 | } | 449 | } |
450 | break; | 450 | break; |
451 | case Key_Down: | 451 | case Key_Down: |
452 | // toggleButton(6); | 452 | // toggleButton(6); |
453 | // emit lessClicked(); | 453 | // emit lessClicked(); |
454 | // emit lessReleased(); | 454 | // emit lessReleased(); |
455 | // toggleButton(6); | 455 | // toggleButton(6); |
456 | break; | 456 | break; |
457 | case Key_Up: | 457 | case Key_Up: |
458 | // toggleButton(5); | 458 | // toggleButton(5); |
459 | // emit moreClicked(); | 459 | // emit moreClicked(); |
460 | // emit moreReleased(); | 460 | // emit moreReleased(); |
461 | // toggleButton(5); | 461 | // toggleButton(5); |
462 | break; | 462 | break; |
463 | case Key_Right: | 463 | case Key_Right: |
464 | mediaPlayerState->setNext(); | 464 | mediaPlayerState->setNext(); |
465 | break; | 465 | break; |
466 | case Key_Left: | 466 | case Key_Left: |
467 | mediaPlayerState->setPrev(); | 467 | mediaPlayerState->setPrev(); |
468 | break; | 468 | break; |
469 | case Key_Escape: | 469 | case Key_Escape: |
470 | break; | 470 | break; |
471 | 471 | ||
472 | }; | 472 | }; |
473 | } | 473 | } |