author | alwin <alwin> | 2005-04-14 09:23:25 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-04-14 09:23:25 (UTC) |
commit | c643e152dc7d2167381d3fc0568ad4043de5604e (patch) (unidiff) | |
tree | 3050f49d659a1d6eb54cca2a08ed64cf0d04842a | |
parent | cb10570b4118161a066b741c2674d8d522670623 (diff) | |
download | opie-c643e152dc7d2167381d3fc0568ad4043de5604e.zip opie-c643e152dc7d2167381d3fc0568ad4043de5604e.tar.gz opie-c643e152dc7d2167381d3fc0568ad4043de5604e.tar.bz2 |
gui polish
-rw-r--r-- | noncore/multimedia/opieplayer3/mwindow.cpp | 9 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/mwindow.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/playlist.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/videowidget.cpp | 1 |
4 files changed, 14 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer3/mwindow.cpp b/noncore/multimedia/opieplayer3/mwindow.cpp index 75d1490..0898c7b 100644 --- a/noncore/multimedia/opieplayer3/mwindow.cpp +++ b/noncore/multimedia/opieplayer3/mwindow.cpp | |||
@@ -14,83 +14,84 @@ | |||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include "mwindow.h" | 34 | #include "mwindow.h" |
35 | #include "playlist.h" | 35 | #include "playlist.h" |
36 | #include "audiowidget.h" | 36 | #include "audiowidget.h" |
37 | #include "videowidget.h" | 37 | #include "videowidget.h" |
38 | #include "../opieplayer2/lib.h" | 38 | #include "../opieplayer2/lib.h" |
39 | 39 | ||
40 | #include <opie2/oapplicationfactory.h> | 40 | #include <opie2/oapplicationfactory.h> |
41 | #include <opie2/owidgetstack.h> | 41 | #include <opie2/owidgetstack.h> |
42 | #include <opie2/ofileselector.h> | 42 | #include <opie2/ofileselector.h> |
43 | #include <opie2/odebug.h> | 43 | #include <opie2/odebug.h> |
44 | 44 | ||
45 | #include <qpe/resource.h> | 45 | #include <qpe/resource.h> |
46 | #include <qpe/qpeapplication.h> | ||
46 | 47 | ||
47 | #include <qfileinfo.h> | 48 | #include <qfileinfo.h> |
48 | #include <qfile.h> | 49 | #include <qfile.h> |
49 | #include <qtoolbar.h> | 50 | #include <qtoolbar.h> |
50 | #include <qpopupmenu.h> | 51 | #include <qpopupmenu.h> |
51 | #include <qmenubar.h> | 52 | #include <qmenubar.h> |
52 | #include <qtimer.h> | 53 | #include <qtimer.h> |
53 | #include <qslider.h> | 54 | #include <qslider.h> |
54 | #include <qlayout.h> | 55 | #include <qlayout.h> |
55 | 56 | ||
56 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) | 57 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) |
57 | 58 | ||
58 | using namespace Opie::Ui; | 59 | using namespace Opie::Ui; |
59 | 60 | ||
60 | PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) | 61 | PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) |
61 | : QMainWindow(w,name,f) | 62 | : QMainWindow(w,name,f) |
62 | { | 63 | { |
63 | checkLib(); | 64 | checkLib(); |
64 | setCaption( QObject::tr("Opie Mediaplayer 3" ) ); | 65 | setCaption(appTitle()); |
65 | 66 | ||
66 | m_MainBox = new QWidget(this); | 67 | m_MainBox = new QWidget(this); |
67 | 68 | ||
68 | QVBoxLayout*m_l = new QVBoxLayout(m_MainBox); | 69 | QVBoxLayout*m_l = new QVBoxLayout(m_MainBox); |
69 | 70 | ||
70 | m_stack = new OWidgetStack(m_MainBox); | 71 | m_stack = new OWidgetStack(m_MainBox); |
71 | m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); | 72 | m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); |
72 | m_l->addWidget(m_stack); | 73 | m_l->addWidget(m_stack); |
73 | m_PosSlider = new QSlider(QSlider::Horizontal,m_MainBox); | 74 | m_PosSlider = new QSlider(QSlider::Horizontal,m_MainBox); |
74 | m_l->addWidget(m_PosSlider); | 75 | m_l->addWidget(m_PosSlider); |
75 | m_PosSlider->setEnabled(false); | 76 | m_PosSlider->setEnabled(false); |
76 | 77 | ||
77 | m_playList = new PlaylistView(m_stack,"playlist"); | 78 | m_playList = new PlaylistView(m_stack,"playlist"); |
78 | m_stack->addWidget(m_playList,stack_list); | 79 | m_stack->addWidget(m_playList,stack_list); |
79 | connect(m_playList,SIGNAL(contentChanged(int)),this,SLOT(slotListChanged(int))); | 80 | connect(m_playList,SIGNAL(contentChanged(int)),this,SLOT(slotListChanged(int))); |
80 | m_sfl = new OFileSelector("video/*;audio/*",m_stack); | 81 | m_sfl = new OFileSelector("video/*;audio/*",m_stack); |
81 | m_stack->addWidget(m_sfl,stack_file); | 82 | m_stack->addWidget(m_sfl,stack_file); |
82 | connect(m_sfl, SIGNAL(fileSelected(const DocLnk &)), m_playList, SLOT(slotAddFile(const DocLnk &))); | 83 | connect(m_sfl, SIGNAL(fileSelected(const DocLnk &)), m_playList, SLOT(slotAddFile(const DocLnk &))); |
83 | m_AudioPlayer = new AudioWidget(m_stack); | 84 | m_AudioPlayer = new AudioWidget(m_stack); |
84 | m_stack->addWidget(m_AudioPlayer,stack_audio); | 85 | m_stack->addWidget(m_AudioPlayer,stack_audio); |
85 | connect(this,SIGNAL(sigPos(int)),m_AudioPlayer,SLOT(updatePos(int))); | 86 | connect(this,SIGNAL(sigPos(int)),m_AudioPlayer,SLOT(updatePos(int))); |
86 | m_VideoPlayer = new VideoWidget(m_stack); | 87 | m_VideoPlayer = new VideoWidget(m_stack); |
87 | m_stack->addWidget(m_VideoPlayer,stack_video); | 88 | m_stack->addWidget(m_VideoPlayer,stack_video); |
88 | connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int))); | 89 | connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int))); |
89 | connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked())); | 90 | connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked())); |
90 | 91 | ||
91 | connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int))); | 92 | connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int))); |
92 | connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int))); | 93 | connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int))); |
93 | connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed())); | 94 | connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed())); |
94 | connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased())); | 95 | connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased())); |
95 | m_pressed = false; | 96 | m_pressed = false; |
96 | m_uppos=0; | 97 | m_uppos=0; |
@@ -182,165 +183,169 @@ void PMainWindow::slotShowMediaWindow() | |||
182 | } else { | 183 | } else { |
183 | m_stack->raiseWidget(stack_video); | 184 | m_stack->raiseWidget(stack_video); |
184 | } | 185 | } |
185 | mediaWindowraised(); | 186 | mediaWindowraised(); |
186 | return; | 187 | return; |
187 | } | 188 | } |
188 | } | 189 | } |
189 | 190 | ||
190 | void PMainWindow::slotPlayList() | 191 | void PMainWindow::slotPlayList() |
191 | { | 192 | { |
192 | if (m_playing && m_LastItem && m_PlayLib) { | 193 | if (m_playing && m_LastItem && m_PlayLib) { |
193 | slotShowMediaWindow(); | 194 | slotShowMediaWindow(); |
194 | return; | 195 | return; |
195 | } | 196 | } |
196 | 197 | ||
197 | m_LastItem = m_playList->currentItem(); | 198 | m_LastItem = m_playList->currentItem(); |
198 | if (!m_LastItem) { | 199 | if (!m_LastItem) { |
199 | slotPlayNext(); | 200 | slotPlayNext(); |
200 | return; | 201 | return; |
201 | } | 202 | } |
202 | //m_VideoPlayer->setFullScreen(a_ShowFull->isOn()); | 203 | //m_VideoPlayer->setFullScreen(a_ShowFull->isOn()); |
203 | slotPlayCurrent(); | 204 | slotPlayCurrent(); |
204 | } | 205 | } |
205 | 206 | ||
206 | void PMainWindow::slotUserStop() | 207 | void PMainWindow::slotUserStop() |
207 | { | 208 | { |
208 | if (!m_playing || !m_PlayLib) return; | 209 | if (!m_playing || !m_PlayLib) return; |
209 | m_playing = false; | 210 | m_playing = false; |
210 | m_PlayLib->stop(); | 211 | m_PlayLib->stop(); |
211 | m_PosSlider->setEnabled(false); | 212 | m_PosSlider->setEnabled(false); |
212 | hideVideo(); | 213 | hideVideo(); |
213 | slotShowList(); | 214 | slotShowList(); |
215 | setCaption(appTitle()); | ||
214 | } | 216 | } |
215 | 217 | ||
216 | void PMainWindow::slotTogglePlay(bool how) | 218 | void PMainWindow::slotTogglePlay(bool how) |
217 | { | 219 | { |
218 | if (how == m_playing) { | 220 | if (how == m_playing) { |
219 | if (how) { | 221 | if (how) { |
220 | slotShowMediaWindow(); | 222 | slotShowMediaWindow(); |
221 | } | 223 | } |
222 | return; | 224 | return; |
223 | } | 225 | } |
224 | if (how) { | 226 | if (how) { |
225 | slotPlayList(); | 227 | slotPlayList(); |
226 | } else { | 228 | } else { |
227 | slotUserStop(); | 229 | slotUserStop(); |
228 | } | 230 | } |
229 | } | 231 | } |
230 | 232 | ||
231 | void PMainWindow::hideVideo() | 233 | void PMainWindow::hideVideo() |
232 | { | 234 | { |
233 | if (m_VideoPlayer->isVisible() && a_ShowFull->isOn()) { | 235 | if (m_VideoPlayer->isVisible() && a_ShowFull->isOn()) { |
234 | //m_VideoPlayer->showNormal(); | 236 | //m_VideoPlayer->showNormal(); |
235 | m_VideoPlayer->hide(); | 237 | m_VideoPlayer->hide(); |
236 | } | 238 | } |
237 | } | 239 | } |
238 | 240 | ||
239 | void PMainWindow::slotPlayCurrent() | 241 | void PMainWindow::slotPlayCurrent() |
240 | { | 242 | { |
241 | if (!m_LastItem) { | 243 | if (!m_LastItem) { |
242 | if (m_PlayLib) m_PlayLib->stop(); | 244 | if (m_PlayLib) m_PlayLib->stop(); |
243 | m_PosSlider->setEnabled(false); | 245 | m_PosSlider->setEnabled(false); |
244 | a_playAction->setOn(false); | 246 | a_playAction->setOn(false); |
245 | hideVideo(); | 247 | hideVideo(); |
246 | slotShowList(); | 248 | slotShowList(); |
249 | setCaption(appTitle()); | ||
247 | return; | 250 | return; |
248 | } | 251 | } |
249 | m_CurrentPos = 0; | 252 | m_CurrentPos = 0; |
250 | m_playList->setCurrentItem(m_LastItem); | 253 | m_playList->setCurrentItem(m_LastItem); |
251 | m_uppos = 0; | 254 | m_uppos = 0; |
252 | m_PosSlider->setValue(0); | 255 | m_PosSlider->setValue(0); |
253 | int result = 0; | 256 | int result = 0; |
254 | if (!m_LastItem->isVideo()) { | 257 | if (!m_LastItem->isVideo()) { |
255 | hideVideo(); | 258 | hideVideo(); |
256 | m_playing = true; | 259 | m_playing = true; |
257 | m_stack->raiseWidget(stack_audio); | 260 | m_stack->raiseWidget(stack_audio); |
258 | result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); | 261 | result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); |
259 | } else { | 262 | } else { |
260 | m_playing = true; | 263 | m_playing = true; |
261 | setupVideo(a_ShowFull->isOn()); | 264 | setupVideo(a_ShowFull->isOn()); |
262 | result = m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); | 265 | result = m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); |
263 | } | 266 | } |
264 | if (result<0) { | 267 | if (result<0) { |
265 | // fehler | 268 | // fehler |
266 | return; | 269 | return; |
267 | } | 270 | } |
268 | mediaWindowraised(); | 271 | mediaWindowraised(); |
272 | setCaption(appTitle()+" - "+m_LastItem->Lnk().name()); | ||
269 | odebug << "Range: " << result << oendl; | 273 | odebug << "Range: " << result << oendl; |
270 | m_PosSlider->setEnabled(true); | 274 | m_PosSlider->setEnabled(true); |
271 | m_PosSlider->setRange(0,m_PlayLib->length()); | 275 | m_PosSlider->setRange(0,m_PlayLib->length()); |
272 | m_PosSlider->setValue(m_PlayLib->currentTime()); | 276 | m_PosSlider->setValue(m_PlayLib->currentTime()); |
273 | QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) ); | 277 | QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) ); |
274 | } | 278 | } |
275 | 279 | ||
276 | void PMainWindow::slotPlayNext() | 280 | void PMainWindow::slotPlayNext() |
277 | { | 281 | { |
278 | PlaylistItem*item = m_playList->nextItem(m_LastItem); | 282 | PlaylistItem*item = m_playList->nextItem(m_LastItem); |
279 | if (!item) return; | 283 | if (!item) return; |
280 | m_LastItem = item; | 284 | m_LastItem = item; |
281 | slotPlayCurrent(); | 285 | slotPlayCurrent(); |
282 | } | 286 | } |
283 | 287 | ||
284 | void PMainWindow::slotGoNext() | 288 | void PMainWindow::slotGoNext() |
285 | { | 289 | { |
286 | m_LastItem = m_playList->nextItem(m_LastItem); | 290 | m_LastItem = m_playList->nextItem(m_LastItem); |
287 | slotPlayCurrent(); | 291 | slotPlayCurrent(); |
288 | } | 292 | } |
289 | 293 | ||
290 | void PMainWindow::slotPlayPrevious() | 294 | void PMainWindow::slotPlayPrevious() |
291 | { | 295 | { |
292 | PlaylistItem*item = m_playList->prevItem(m_LastItem); | 296 | PlaylistItem*item = m_playList->prevItem(m_LastItem); |
293 | if (!item) return; | 297 | if (!item) return; |
294 | m_LastItem = item; | 298 | m_LastItem = item; |
295 | slotPlayCurrent(); | 299 | slotPlayCurrent(); |
296 | } | 300 | } |
297 | 301 | ||
298 | void PMainWindow::slotStopped() | 302 | void PMainWindow::slotStopped() |
299 | { | 303 | { |
300 | if (!m_playing) return; | 304 | if (!m_playing) return; |
301 | odebug << "Slot stopped" << oendl; | 305 | odebug << "Slot stopped" << oendl; |
302 | m_playing = false; | 306 | m_playing = false; |
303 | slotGoNext(); | 307 | slotGoNext(); |
304 | } | 308 | } |
305 | 309 | ||
306 | void PMainWindow::slotCheckPos() | 310 | void PMainWindow::slotCheckPos() |
307 | { | 311 | { |
308 | if (!m_playing) return; | 312 | if (!m_playing) return; |
309 | if (!m_pressed) { | 313 | if (!m_pressed) { |
310 | m_uppos = m_PlayLib->currentTime(); | 314 | m_uppos = m_PlayLib->currentTime(); |
311 | emit sigPos(m_uppos); | 315 | emit sigPos(m_uppos); |
312 | m_PosSlider->setValue(m_PlayLib->currentTime()); | 316 | m_PosSlider->setValue(m_PlayLib->currentTime()); |
313 | } | 317 | } |
314 | QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) ); | 318 | qApp->processEvents(100); |
319 | QTimer::singleShot( 900, this, SLOT( slotCheckPos() ) ); | ||
315 | } | 320 | } |
316 | 321 | ||
317 | void PMainWindow::slotRemoveFiles() | 322 | void PMainWindow::slotRemoveFiles() |
318 | { | 323 | { |
319 | if (m_playing||!m_playList->isVisible()) return; | 324 | if (m_playing||!m_playList->isVisible()) return; |
320 | PlaylistItem* Item = m_playList->currentItem(); | 325 | PlaylistItem* Item = m_playList->currentItem(); |
321 | slotShowList(); | 326 | slotShowList(); |
322 | m_playList->removeFromList(Item); | 327 | m_playList->removeFromList(Item); |
323 | } | 328 | } |
324 | 329 | ||
325 | void PMainWindow::setupActions() | 330 | void PMainWindow::setupActions() |
326 | { | 331 | { |
327 | a_appendFiles = new QAction(tr("Append file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false ); | 332 | a_appendFiles = new QAction(tr("Append file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false ); |
328 | connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles())); | 333 | connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles())); |
329 | a_addDir = new QAction(tr("Add directory"),Resource::loadIconSet("folder_open"),0,0,this,0,false); | 334 | a_addDir = new QAction(tr("Add directory"),Resource::loadIconSet("folder_open"),0,0,this,0,false); |
330 | connect(a_addDir,SIGNAL(activated()),m_playList,SLOT(slotAppendDir())); | 335 | connect(a_addDir,SIGNAL(activated()),m_playList,SLOT(slotAppendDir())); |
331 | a_loadPlaylist = new QAction(tr("Append playlist"),Resource::loadIconSet("opieplayer2/add_to_playlist"),0,0,this,0,false); | 336 | a_loadPlaylist = new QAction(tr("Append playlist"),Resource::loadIconSet("opieplayer2/add_to_playlist"),0,0,this,0,false); |
332 | connect(a_loadPlaylist,SIGNAL(activated()),m_playList,SLOT(slotOpenM3u())); | 337 | connect(a_loadPlaylist,SIGNAL(activated()),m_playList,SLOT(slotOpenM3u())); |
333 | a_savePlaylist = new QAction(tr("Save playlist"),Resource::loadIconSet("save"),0,0,this,0,false); | 338 | a_savePlaylist = new QAction(tr("Save playlist"),Resource::loadIconSet("save"),0,0,this,0,false); |
334 | connect(a_savePlaylist,SIGNAL(activated()),m_playList,SLOT(slotSaveAsM3u())); | 339 | connect(a_savePlaylist,SIGNAL(activated()),m_playList,SLOT(slotSaveAsM3u())); |
335 | 340 | ||
336 | playlistOnly = new QActionGroup(this,"playlistgroup",false); | 341 | playlistOnly = new QActionGroup(this,"playlistgroup",false); |
337 | playlistOnly->insert(a_appendFiles); | 342 | playlistOnly->insert(a_appendFiles); |
338 | playlistOnly->insert(a_addDir); | 343 | playlistOnly->insert(a_addDir); |
339 | playlistOnly->insert(a_loadPlaylist); | 344 | playlistOnly->insert(a_loadPlaylist); |
340 | playlistOnly->insert(a_savePlaylist); | 345 | playlistOnly->insert(a_savePlaylist); |
341 | 346 | ||
342 | a_showPlaylist = new QAction(tr("Show playlist"),Resource::loadIconSet( "txt" ), 0, 0, this, 0, false ); | 347 | a_showPlaylist = new QAction(tr("Show playlist"),Resource::loadIconSet( "txt" ), 0, 0, this, 0, false ); |
343 | connect(a_showPlaylist,SIGNAL(activated()),this,SLOT(slotShowList())); | 348 | connect(a_showPlaylist,SIGNAL(activated()),this,SLOT(slotShowList())); |
344 | a_ShowMedia = new QAction(tr("Show media window"),Resource::loadIconSet("opieplayer2/musicfile"), 0, 0, this, 0, false ); | 349 | a_ShowMedia = new QAction(tr("Show media window"),Resource::loadIconSet("opieplayer2/musicfile"), 0, 0, this, 0, false ); |
345 | connect(a_ShowMedia,SIGNAL(activated()),this,SLOT(slotShowMediaWindow())); | 350 | connect(a_ShowMedia,SIGNAL(activated()),this,SLOT(slotShowMediaWindow())); |
346 | 351 | ||
diff --git a/noncore/multimedia/opieplayer3/mwindow.h b/noncore/multimedia/opieplayer3/mwindow.h index 5d011d5..3ea9a52 100644 --- a/noncore/multimedia/opieplayer3/mwindow.h +++ b/noncore/multimedia/opieplayer3/mwindow.h | |||
@@ -35,64 +35,65 @@ | |||
35 | #define _mwindow_h | 35 | #define _mwindow_h |
36 | 36 | ||
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | 38 | ||
39 | #include <qpe/applnk.h> | 39 | #include <qpe/applnk.h> |
40 | 40 | ||
41 | #include <qaction.h> | 41 | #include <qaction.h> |
42 | 42 | ||
43 | namespace Opie { | 43 | namespace Opie { |
44 | namespace Ui { | 44 | namespace Ui { |
45 | class OWidgetStack; | 45 | class OWidgetStack; |
46 | class OFileSelector; | 46 | class OFileSelector; |
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | namespace XINE { | 50 | namespace XINE { |
51 | class Lib; | 51 | class Lib; |
52 | } | 52 | } |
53 | 53 | ||
54 | class PlaylistView; | 54 | class PlaylistView; |
55 | class QToolBar; | 55 | class QToolBar; |
56 | class QPopupMenu; | 56 | class QPopupMenu; |
57 | class QMenuBar; | 57 | class QMenuBar; |
58 | class AudioWidget; | 58 | class AudioWidget; |
59 | class VideoWidget; | 59 | class VideoWidget; |
60 | class PlaylistItem; | 60 | class PlaylistItem; |
61 | class QSlider; | 61 | class QSlider; |
62 | 62 | ||
63 | class PMainWindow : public QMainWindow { | 63 | class PMainWindow : public QMainWindow { |
64 | Q_OBJECT | 64 | Q_OBJECT |
65 | public: | 65 | public: |
66 | static QString appName() { return QString::fromLatin1("opie-mediaplayer3" ); } | 66 | static QString appName() { return QString::fromLatin1("opie-mediaplayer3" ); } |
67 | static QString appTitle() {return QString::fromLatin1("Opie Mediaplayer 3" ); } | ||
67 | PMainWindow(QWidget*, const char*, WFlags ); | 68 | PMainWindow(QWidget*, const char*, WFlags ); |
68 | virtual ~PMainWindow(); | 69 | virtual ~PMainWindow(); |
69 | 70 | ||
70 | public slots: | 71 | public slots: |
71 | virtual void slotVideoclicked(); | 72 | virtual void slotVideoclicked(); |
72 | protected: | 73 | protected: |
73 | 74 | ||
74 | /* GUI parts */ | 75 | /* GUI parts */ |
75 | static const int stack_list = 0; | 76 | static const int stack_list = 0; |
76 | static const int stack_file = 1; | 77 | static const int stack_file = 1; |
77 | static const int stack_audio = 2; | 78 | static const int stack_audio = 2; |
78 | static const int stack_video = 3; | 79 | static const int stack_video = 3; |
79 | Opie::Ui::OWidgetStack *m_stack; | 80 | Opie::Ui::OWidgetStack *m_stack; |
80 | Opie::Ui::OFileSelector*m_sfl; | 81 | Opie::Ui::OFileSelector*m_sfl; |
81 | PlaylistView*m_playList; | 82 | PlaylistView*m_playList; |
82 | AudioWidget*m_AudioPlayer; | 83 | AudioWidget*m_AudioPlayer; |
83 | VideoWidget*m_VideoPlayer; | 84 | VideoWidget*m_VideoPlayer; |
84 | QWidget*m_MainBox; | 85 | QWidget*m_MainBox; |
85 | QSlider*m_PosSlider; | 86 | QSlider*m_PosSlider; |
86 | 87 | ||
87 | QAction*a_appendFiles,*a_removeFiles,*a_showPlaylist,*a_playAction,*a_stopAction; | 88 | QAction*a_appendFiles,*a_removeFiles,*a_showPlaylist,*a_playAction,*a_stopAction; |
88 | QAction*a_playNext,*a_playPrevious,*a_ShowFull,*a_stopPlay,*a_ShowMedia; | 89 | QAction*a_playNext,*a_playPrevious,*a_ShowFull,*a_stopPlay,*a_ShowMedia; |
89 | QAction*a_addDir,*a_loadPlaylist,*a_savePlaylist; | 90 | QAction*a_addDir,*a_loadPlaylist,*a_savePlaylist; |
90 | QAction*a_Scaleup; | 91 | QAction*a_Scaleup; |
91 | QActionGroup*playersGroup,*playlistOnly,*settingsGroup; | 92 | QActionGroup*playersGroup,*playlistOnly,*settingsGroup; |
92 | QToolBar*m_toolBar; | 93 | QToolBar*m_toolBar; |
93 | QPopupMenu *fileMenu,*dispMenu,*playMenu,*configMenu; | 94 | QPopupMenu *fileMenu,*dispMenu,*playMenu,*configMenu; |
94 | QMenuBar*m_menuBar; | 95 | QMenuBar*m_menuBar; |
95 | XINE::Lib*m_PlayLib; | 96 | XINE::Lib*m_PlayLib; |
96 | 97 | ||
97 | void setupActions(); | 98 | void setupActions(); |
98 | void setupToolBar(); | 99 | void setupToolBar(); |
diff --git a/noncore/multimedia/opieplayer3/playlist.cpp b/noncore/multimedia/opieplayer3/playlist.cpp index 2eb40e3..6f2e668 100644 --- a/noncore/multimedia/opieplayer3/playlist.cpp +++ b/noncore/multimedia/opieplayer3/playlist.cpp | |||
@@ -135,100 +135,104 @@ void PlaylistView::addFile(const QString&aFile,const QString&aName) | |||
135 | name = fileInfo.fileName(); | 135 | name = fileInfo.fileName(); |
136 | } | 136 | } |
137 | int i = m_Infolib->setfile(aFile.utf8().data()); | 137 | int i = m_Infolib->setfile(aFile.utf8().data()); |
138 | /* realy! otherwise we get an "stopped" signal when playing! - I don't know why */ | 138 | /* realy! otherwise we get an "stopped" signal when playing! - I don't know why */ |
139 | m_Infolib->stop(); | 139 | m_Infolib->stop(); |
140 | odebug << "File set: " << i << " ("<<aFile.utf8().data()<<")"<<oendl; | 140 | odebug << "File set: " << i << " ("<<aFile.utf8().data()<<")"<<oendl; |
141 | if (i<1) { | 141 | if (i<1) { |
142 | i = m_Infolib->error(); | 142 | i = m_Infolib->error(); |
143 | odebug << "Errorcode: " << i << oendl; | 143 | odebug << "Errorcode: " << i << oendl; |
144 | QString msg; | 144 | QString msg; |
145 | msg = QString(tr("Error open file %1: ")).arg(name); | 145 | msg = QString(tr("Error open file %1: ")).arg(name); |
146 | switch (i) { | 146 | switch (i) { |
147 | case 1: | 147 | case 1: |
148 | msg += tr("No input plugin"); | 148 | msg += tr("No input plugin"); |
149 | break; | 149 | break; |
150 | case 2: | 150 | case 2: |
151 | msg += tr("No demuxer plugin"); | 151 | msg += tr("No demuxer plugin"); |
152 | break; | 152 | break; |
153 | case 3: | 153 | case 3: |
154 | msg += tr("Demuxer failed"); | 154 | msg += tr("Demuxer failed"); |
155 | break; | 155 | break; |
156 | case 4: | 156 | case 4: |
157 | msg+=tr("Malformed mrl"); | 157 | msg+=tr("Malformed mrl"); |
158 | break; | 158 | break; |
159 | default: | 159 | default: |
160 | msg += tr("Unknown error"); | 160 | msg += tr("Unknown error"); |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | QMessageBox::warning(0,tr("Error reading fileheader"),msg); | 163 | QMessageBox::warning(0,tr("Error reading fileheader"),msg); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | m_lastItem = m_items.last(); | 166 | m_lastItem = m_items.last(); |
167 | PlaylistItem*_it = currentItem(); | ||
168 | |||
167 | if (m_lastItem) { | 169 | if (m_lastItem) { |
168 | m_lastItem = new PlaylistItem(aFile,this,m_lastItem); | 170 | m_lastItem = new PlaylistItem(aFile,this,m_lastItem); |
169 | } else { | 171 | } else { |
170 | m_lastItem = new PlaylistItem(aFile,this); | 172 | m_lastItem = new PlaylistItem(aFile,this); |
171 | } | 173 | } |
172 | m_lastItem->setExpandable(false); | 174 | m_lastItem->setExpandable(false); |
173 | m_lastItem->setText(1,name); | 175 | m_lastItem->setText(1,name); |
174 | 176 | ||
175 | QString codec = m_Infolib->metaInfo(6); | 177 | QString codec = m_Infolib->metaInfo(6); |
176 | if (codec.isEmpty()) { | 178 | if (codec.isEmpty()) { |
177 | codec = m_Infolib->metaInfo(7); | 179 | codec = m_Infolib->metaInfo(7); |
178 | } | 180 | } |
179 | // codec | 181 | // codec |
180 | m_lastItem->setText(COL_TYPE,codec); | 182 | m_lastItem->setText(COL_TYPE,codec); |
181 | // title | 183 | // title |
182 | m_lastItem->setText(COL_TITLE,m_Infolib->metaInfo(0)); | 184 | m_lastItem->setText(COL_TITLE,m_Infolib->metaInfo(0)); |
183 | // artist | 185 | // artist |
184 | m_lastItem->setText(COL_ARTIST,m_Infolib->metaInfo(2)); | 186 | m_lastItem->setText(COL_ARTIST,m_Infolib->metaInfo(2)); |
185 | // album | 187 | // album |
186 | m_lastItem->setText(COL_ALBUM,m_Infolib->metaInfo(4)); | 188 | m_lastItem->setText(COL_ALBUM,m_Infolib->metaInfo(4)); |
187 | int l = m_Infolib->length(); | 189 | int l = m_Infolib->length(); |
188 | int h = l/3600; | 190 | int h = l/3600; |
189 | l-=h*3600; | 191 | l-=h*3600; |
190 | int m = l/60; | 192 | int m = l/60; |
191 | l-=m*60; | 193 | l-=m*60; |
192 | codec = ""; | 194 | codec = ""; |
193 | if (h>0) { | 195 | if (h>0) { |
194 | codec.sprintf("%2i:%2i:%2i h",h,m,l); | 196 | codec.sprintf("%2i:%2i:%2i h",h,m,l); |
195 | } else { | 197 | } else { |
196 | codec.sprintf("%02i:%02i m",m,l); | 198 | codec.sprintf("%02i:%02i m",m,l); |
197 | } | 199 | } |
198 | // time | 200 | // time |
199 | m_lastItem->setText(COL_TIME,codec); | 201 | m_lastItem->setText(COL_TIME,codec); |
200 | m_lastItem->Video(m_Infolib->hasVideo()); | 202 | m_lastItem->Video(m_Infolib->hasVideo()); |
201 | m_items.append(m_lastItem); | 203 | m_items.append(m_lastItem); |
202 | setSelected(m_lastItem,true); | 204 | if (_it==NULL) { |
205 | setSelected(m_lastItem,true); | ||
206 | } | ||
203 | } | 207 | } |
204 | 208 | ||
205 | void PlaylistView::slotAppendDir() | 209 | void PlaylistView::slotAppendDir() |
206 | { | 210 | { |
207 | QString _dir = Opie::Ui::OFileDialog::getDirectory(Opie::Ui::OFileSelector::Extended,m_lastDir,0,m_lastDir); | 211 | QString _dir = Opie::Ui::OFileDialog::getDirectory(Opie::Ui::OFileSelector::Extended,m_lastDir,0,m_lastDir); |
208 | if (_dir.isEmpty()) return; | 212 | if (_dir.isEmpty()) return; |
209 | m_lastDir = _dir; | 213 | m_lastDir = _dir; |
210 | QDir sDir(_dir); | 214 | QDir sDir(_dir); |
211 | QStringList list = sDir.entryList(DEFAULT_FILE_TYPES,QDir::Files,QDir::Name | QDir::IgnoreCase); | 215 | QStringList list = sDir.entryList(DEFAULT_FILE_TYPES,QDir::Files,QDir::Name | QDir::IgnoreCase); |
212 | for (unsigned i = 0; i < list.count();++i) { | 216 | for (unsigned i = 0; i < list.count();++i) { |
213 | addFile(_dir+QString("/")+list[i]); | 217 | addFile(_dir+QString("/")+list[i]); |
214 | } | 218 | } |
215 | emit contentChanged(childCount()); | 219 | emit contentChanged(childCount()); |
216 | } | 220 | } |
217 | 221 | ||
218 | void PlaylistView::slotOpenM3u() | 222 | void PlaylistView::slotOpenM3u() |
219 | { | 223 | { |
220 | QStringList types; | 224 | QStringList types; |
221 | QMap<QString, QStringList> mimeTypes; | 225 | QMap<QString, QStringList> mimeTypes; |
222 | types << "audio/x-mpegurl"; | 226 | types << "audio/x-mpegurl"; |
223 | mimeTypes.insert("Playlists",types); | 227 | mimeTypes.insert("Playlists",types); |
224 | // mimeTypes.insert("All",types); | 228 | // mimeTypes.insert("All",types); |
225 | QString fileName= Opie::Ui::OFileDialog::getOpenFileName(Opie::Ui::OFileSelector::EXTENDED, | 229 | QString fileName= Opie::Ui::OFileDialog::getOpenFileName(Opie::Ui::OFileSelector::EXTENDED, |
226 | m_lastDir,"playlist.m3u", mimeTypes); | 230 | m_lastDir,"playlist.m3u", mimeTypes); |
227 | if (fileName.isEmpty()) { | 231 | if (fileName.isEmpty()) { |
228 | return; | 232 | return; |
229 | } | 233 | } |
230 | readPlayList(fileName); | 234 | readPlayList(fileName); |
231 | emit contentChanged(childCount()); | 235 | emit contentChanged(childCount()); |
232 | } | 236 | } |
233 | 237 | ||
234 | void PlaylistView::readPlayList(const QString&fileName) | 238 | void PlaylistView::readPlayList(const QString&fileName) |
diff --git a/noncore/multimedia/opieplayer3/videowidget.cpp b/noncore/multimedia/opieplayer3/videowidget.cpp index 833ecb4..414400b 100644 --- a/noncore/multimedia/opieplayer3/videowidget.cpp +++ b/noncore/multimedia/opieplayer3/videowidget.cpp | |||
@@ -28,64 +28,65 @@ VideoWidget::~VideoWidget() | |||
28 | } | 28 | } |
29 | 29 | ||
30 | void VideoWidget::slotClicked() | 30 | void VideoWidget::slotClicked() |
31 | { | 31 | { |
32 | emit videoclicked(); | 32 | emit videoclicked(); |
33 | } | 33 | } |
34 | 34 | ||
35 | void VideoWidget::closeEvent(QCloseEvent*e) | 35 | void VideoWidget::closeEvent(QCloseEvent*e) |
36 | { | 36 | { |
37 | } | 37 | } |
38 | 38 | ||
39 | void VideoWidget::fullScreen(bool /* how */) | 39 | void VideoWidget::fullScreen(bool /* how */) |
40 | { | 40 | { |
41 | } | 41 | } |
42 | 42 | ||
43 | int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib) | 43 | int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib) |
44 | { | 44 | { |
45 | m_current = aLnk; | 45 | m_current = aLnk; |
46 | bool recon; | 46 | bool recon; |
47 | if (m_xineLib != aLib) { | 47 | if (m_xineLib != aLib) { |
48 | if (m_xineLib) disconnect(m_xineLib); | 48 | if (m_xineLib) disconnect(m_xineLib); |
49 | m_xineLib = aLib; | 49 | m_xineLib = aLib; |
50 | if (aLib) m_xineLib->setWidget(m_Videodisplay); | 50 | if (aLib) m_xineLib->setWidget(m_Videodisplay); |
51 | } | 51 | } |
52 | if (!m_xineLib) { | 52 | if (!m_xineLib) { |
53 | return -1; | 53 | return -1; |
54 | } | 54 | } |
55 | connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped())); | 55 | connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped())); |
56 | m_xineLib->setWidget(m_Videodisplay); | 56 | m_xineLib->setWidget(m_Videodisplay); |
57 | m_xineLib->setShowVideo(true); | 57 | m_xineLib->setShowVideo(true); |
58 | int res = m_xineLib->play(m_current.file()); | 58 | int res = m_xineLib->play(m_current.file()); |
59 | vSize = m_xineLib->videoSize(); | 59 | vSize = m_xineLib->videoSize(); |
60 | |||
60 | slot_Videoresized(m_Videodisplay->size()); | 61 | slot_Videoresized(m_Videodisplay->size()); |
61 | odebug << "Xine play: " << res << oendl; | 62 | odebug << "Xine play: " << res << oendl; |
62 | if (res != 1) { | 63 | if (res != 1) { |
63 | return -2; | 64 | return -2; |
64 | } | 65 | } |
65 | return m_xineLib->length(); | 66 | return m_xineLib->length(); |
66 | } | 67 | } |
67 | 68 | ||
68 | void VideoWidget::stopPlaying() | 69 | void VideoWidget::stopPlaying() |
69 | { | 70 | { |
70 | if (m_xineLib) { | 71 | if (m_xineLib) { |
71 | m_xineLib->stop(); | 72 | m_xineLib->stop(); |
72 | } | 73 | } |
73 | } | 74 | } |
74 | 75 | ||
75 | void VideoWidget::slotStopped() | 76 | void VideoWidget::slotStopped() |
76 | { | 77 | { |
77 | } | 78 | } |
78 | 79 | ||
79 | void VideoWidget::slot_Videoresized(const QSize&s) | 80 | void VideoWidget::slot_Videoresized(const QSize&s) |
80 | { | 81 | { |
81 | if (m_xineLib) { | 82 | if (m_xineLib) { |
82 | if (vSize.width()<s.width()&&vSize.height()<s.height()&&!m_scaleUp) { | 83 | if (vSize.width()<s.width()&&vSize.height()<s.height()&&!m_scaleUp) { |
83 | m_xineLib->resize(vSize); | 84 | m_xineLib->resize(vSize); |
84 | } else { | 85 | } else { |
85 | m_xineLib->resize(s); | 86 | m_xineLib->resize(s); |
86 | } | 87 | } |
87 | } | 88 | } |
88 | } | 89 | } |
89 | 90 | ||
90 | void VideoWidget::scaleUp(bool how) | 91 | void VideoWidget::scaleUp(bool how) |
91 | { | 92 | { |