-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 46 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 4 |
2 files changed, 50 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index a0bf4db..5e1be2f 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -113,64 +113,67 @@ public: | |||
113 | setPixmap( Resource::loadPixmap( icon ) ); | 113 | setPixmap( Resource::loadPixmap( icon ) ); |
114 | setAutoRaise( TRUE ); | 114 | setAutoRaise( TRUE ); |
115 | setFocusPolicy( QWidget::NoFocus ); | 115 | setFocusPolicy( QWidget::NoFocus ); |
116 | setToggleButton( t ); | 116 | setToggleButton( t ); |
117 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 117 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
118 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 118 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
119 | } | 119 | } |
120 | }; | 120 | }; |
121 | 121 | ||
122 | 122 | ||
123 | class MenuItem : public QAction { | 123 | class MenuItem : public QAction { |
124 | public: | 124 | public: |
125 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 125 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
126 | : QAction( text, QString::null, 0, 0 ) { | 126 | : QAction( text, QString::null, 0, 0 ) { |
127 | connect( this, SIGNAL( activated() ), handler, slot ); | 127 | connect( this, SIGNAL( activated() ), handler, slot ); |
128 | addTo( parent ); | 128 | addTo( parent ); |
129 | } | 129 | } |
130 | }; | 130 | }; |
131 | 131 | ||
132 | 132 | ||
133 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 133 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
134 | : QMainWindow( parent, name, fl ) { | 134 | : QMainWindow( parent, name, fl ) { |
135 | 135 | ||
136 | d = new PlayListWidgetPrivate; | 136 | d = new PlayListWidgetPrivate; |
137 | d->setDocumentUsed = FALSE; | 137 | d->setDocumentUsed = FALSE; |
138 | d->current = NULL; | 138 | d->current = NULL; |
139 | fromSetDocument = FALSE; | 139 | fromSetDocument = FALSE; |
140 | insanityBool=FALSE; | 140 | insanityBool=FALSE; |
141 | audioScan = FALSE; | 141 | audioScan = FALSE; |
142 | videoScan = FALSE; | 142 | videoScan = FALSE; |
143 | // menuTimer = new QTimer( this ,"menu timer"), | 143 | // menuTimer = new QTimer( this ,"menu timer"), |
144 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 144 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
145 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); | ||
146 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
147 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); | ||
145 | 148 | ||
146 | setBackgroundMode( PaletteButton ); | 149 | setBackgroundMode( PaletteButton ); |
147 | 150 | ||
148 | setCaption( tr("OpiePlayer") ); | 151 | setCaption( tr("OpiePlayer") ); |
149 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 152 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
150 | 153 | ||
151 | setToolBarsMovable( FALSE ); | 154 | setToolBarsMovable( FALSE ); |
152 | 155 | ||
153 | // Create Toolbar | 156 | // Create Toolbar |
154 | QPEToolBar *toolbar = new QPEToolBar( this ); | 157 | QPEToolBar *toolbar = new QPEToolBar( this ); |
155 | toolbar->setHorizontalStretchable( TRUE ); | 158 | toolbar->setHorizontalStretchable( TRUE ); |
156 | 159 | ||
157 | // Create Menubar | 160 | // Create Menubar |
158 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 161 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
159 | menu->setMargin( 0 ); | 162 | menu->setMargin( 0 ); |
160 | 163 | ||
161 | QPEToolBar *bar = new QPEToolBar( this ); | 164 | QPEToolBar *bar = new QPEToolBar( this ); |
162 | bar->setLabel( tr( "Play Operations" ) ); | 165 | bar->setLabel( tr( "Play Operations" ) ); |
163 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 166 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
164 | // this , SLOT( addSelected()) ); | 167 | // this , SLOT( addSelected()) ); |
165 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 168 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
166 | tbDeletePlaylist->setFlat(TRUE); | 169 | tbDeletePlaylist->setFlat(TRUE); |
167 | tbDeletePlaylist->setFixedSize(20,20); | 170 | tbDeletePlaylist->setFixedSize(20,20); |
168 | 171 | ||
169 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 172 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
170 | this , SLOT(addSelected()) ); | 173 | this , SLOT(addSelected()) ); |
171 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 174 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
172 | this , SLOT(removeSelected()) ); | 175 | this , SLOT(removeSelected()) ); |
173 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 176 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
174 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 177 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
175 | this , SLOT( btnPlay(bool) ), TRUE ); | 178 | this , SLOT( btnPlay(bool) ), TRUE ); |
176 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 179 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
@@ -1391,32 +1394,75 @@ void PlayListWidget::populateSkinsMenu() { | |||
1391 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1394 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1392 | skinsDir.setFilter( QDir::Dirs ); | 1395 | skinsDir.setFilter( QDir::Dirs ); |
1393 | skinsDir.setSorting(QDir::Name ); | 1396 | skinsDir.setSorting(QDir::Name ); |
1394 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1397 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1395 | QFileInfoListIterator it( *skinslist ); | 1398 | QFileInfoListIterator it( *skinslist ); |
1396 | QFileInfo *fi; | 1399 | QFileInfo *fi; |
1397 | while ( ( fi = it.current() ) ) { | 1400 | while ( ( fi = it.current() ) ) { |
1398 | skinName = fi->fileName(); | 1401 | skinName = fi->fileName(); |
1399 | // qDebug( fi->fileName() ); | 1402 | // qDebug( fi->fileName() ); |
1400 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1403 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1401 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1404 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1402 | } | 1405 | } |
1403 | if( skinName == "default" ) { | 1406 | if( skinName == "default" ) { |
1404 | defaultSkinIndex = item; | 1407 | defaultSkinIndex = item; |
1405 | } | 1408 | } |
1406 | if( skinName == skin ) { | 1409 | if( skinName == skin ) { |
1407 | skinsMenu->setItemChecked( item, TRUE ); | 1410 | skinsMenu->setItemChecked( item, TRUE ); |
1408 | } | 1411 | } |
1409 | ++it; | 1412 | ++it; |
1410 | } | 1413 | } |
1411 | } | 1414 | } |
1412 | 1415 | ||
1413 | void PlayListWidget::skinsMenuActivated( int item ) { | 1416 | void PlayListWidget::skinsMenuActivated( int item ) { |
1414 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1417 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1415 | skinsMenu->setItemChecked( i, FALSE ); | 1418 | skinsMenu->setItemChecked( i, FALSE ); |
1416 | } | 1419 | } |
1417 | skinsMenu->setItemChecked( item, TRUE ); | 1420 | skinsMenu->setItemChecked( item, TRUE ); |
1418 | 1421 | ||
1419 | Config cfg( "OpiePlayer" ); | 1422 | Config cfg( "OpiePlayer" ); |
1420 | cfg.setGroup("Options"); | 1423 | cfg.setGroup("Options"); |
1421 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1424 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1422 | } | 1425 | } |
1426 | |||
1427 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | ||
1428 | qDebug("qcop message "+msg ); | ||
1429 | QDataStream stream ( data, IO_ReadOnly ); | ||
1430 | if ( msg == "play()" ) { //plays current selection | ||
1431 | btnPlay( true); | ||
1432 | } else if ( msg == "stop()" ) { | ||
1433 | mediaPlayerState->setPlaying( false); | ||
1434 | } else if ( msg == "togglePause()" ) { | ||
1435 | mediaPlayerState->togglePaused(); | ||
1436 | } else if ( msg == "next()" ) { //select next in list | ||
1437 | mediaPlayerState->setNext(); | ||
1438 | } else if ( msg == "prev()" ) { //select previous in list | ||
1439 | mediaPlayerState->setPrev(); | ||
1440 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | ||
1441 | mediaPlayerState->toggleLooping(); | ||
1442 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | ||
1443 | mediaPlayerState->toggleShuffled(); | ||
1444 | } else if ( msg == "volUp()" ) { //volume more | ||
1445 | // emit moreClicked(); | ||
1446 | // emit moreReleased(); | ||
1447 | } else if ( msg == "volDown()" ) { //volume less | ||
1448 | // emit lessClicked(); | ||
1449 | // emit lessReleased(); | ||
1450 | } else if ( msg == "play(QString)" ) { //play this now | ||
1451 | QString file; | ||
1452 | stream >> file; | ||
1453 | setDocument( (const QString &) file); | ||
1454 | } else if ( msg == "add(QString)" ) { //add to playlist | ||
1455 | QString file; | ||
1456 | stream >> file; | ||
1457 | QFileInfo fileInfo(file); | ||
1458 | DocLnk lnk; | ||
1459 | lnk.setName( fileInfo.baseName() ); //sets name | ||
1460 | lnk.setFile( file ); //sets file name | ||
1461 | addToSelection( lnk ); | ||
1462 | } else if ( msg == "rem(QString)" ) { //remove from playlist | ||
1463 | QString file; | ||
1464 | stream >> file; | ||
1465 | |||
1466 | } | ||
1467 | |||
1468 | } | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 1118b76..e66bcb9 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -1,124 +1,128 @@ | |||
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 <qpe/qcopenvelope_qws.h> | ||
30 | |||
29 | #include "om3u.h" | 31 | #include "om3u.h" |
30 | /* #include <qtimer.h> */ | 32 | /* #include <qtimer.h> */ |
31 | 33 | ||
32 | 34 | ||
33 | class PlayListWidgetPrivate; | 35 | class PlayListWidgetPrivate; |
34 | class Config; | 36 | class Config; |
35 | class QListViewItem; | 37 | class QListViewItem; |
36 | class QListView; | 38 | class QListView; |
37 | class QPoint; | 39 | class QPoint; |
38 | class QAction; | 40 | class QAction; |
39 | class QLabel; | 41 | class QLabel; |
40 | class QPopupMenu; | 42 | class QPopupMenu; |
41 | 43 | ||
42 | class PlayListWidget : public QMainWindow { | 44 | class PlayListWidget : public QMainWindow { |
43 | Q_OBJECT | 45 | Q_OBJECT |
44 | public: | 46 | public: |
45 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 47 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
46 | ~PlayListWidget(); | 48 | ~PlayListWidget(); |
47 | QTabWidget * tabWidget; | 49 | QTabWidget * tabWidget; |
48 | QAction *fullScreenButton, *scaleButton; | 50 | QAction *fullScreenButton, *scaleButton; |
49 | DocLnkSet files; | 51 | DocLnkSet files; |
50 | DocLnkSet vFiles; | 52 | DocLnkSet vFiles; |
51 | QListView *audioView, *videoView, *playlistView; | 53 | QListView *audioView, *videoView, *playlistView; |
52 | QLabel *libString; | 54 | QLabel *libString; |
53 | bool fromSetDocument; | 55 | bool fromSetDocument; |
54 | bool insanityBool; | 56 | bool insanityBool; |
55 | QString setDocFileRef, currentPlayList; | 57 | QString setDocFileRef, currentPlayList; |
56 | // retrieve the current playlist entry (media file link) | 58 | // retrieve the current playlist entry (media file link) |
57 | const DocLnk *current(); | 59 | const DocLnk *current(); |
58 | void useSelectedDocument(); | 60 | void useSelectedDocument(); |
59 | /* QTimer * menuTimer; */ | 61 | /* QTimer * menuTimer; */ |
60 | FileSelector* playLists; | 62 | FileSelector* playLists; |
61 | QPushButton *tbDeletePlaylist; | 63 | QPushButton *tbDeletePlaylist; |
62 | int fd, selected; | 64 | int fd, selected; |
63 | public slots: | 65 | public slots: |
64 | bool first(); | 66 | bool first(); |
65 | bool last(); | 67 | bool last(); |
66 | bool next(); | 68 | bool next(); |
67 | bool prev(); | 69 | bool prev(); |
68 | /* void setFullScreen(); */ | 70 | /* void setFullScreen(); */ |
69 | /* void setScaled(); */ | 71 | /* void setScaled(); */ |
70 | protected: | 72 | protected: |
73 | QCopChannel * channel; | ||
71 | QPopupMenu *skinsMenu; | 74 | QPopupMenu *skinsMenu; |
72 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | 75 | /* void contentsMousePressEvent( QMouseEvent * e ); */ |
73 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | 76 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ |
74 | void keyReleaseEvent( QKeyEvent *e); | 77 | void keyReleaseEvent( QKeyEvent *e); |
75 | void keyPressEvent( QKeyEvent *e); | 78 | void keyPressEvent( QKeyEvent *e); |
76 | private: | 79 | private: |
77 | int defaultSkinIndex; | 80 | int defaultSkinIndex; |
78 | bool audioScan, videoScan; | 81 | bool audioScan, videoScan; |
79 | void doBlank(); | 82 | void doBlank(); |
80 | void doUnblank(); | 83 | void doUnblank(); |
81 | void readm3u(const QString &); | 84 | void readm3u(const QString &); |
82 | void readPls(const QString &); | 85 | void readPls(const QString &); |
83 | 86 | ||
84 | 87 | ||
85 | void initializeStates(); | 88 | void initializeStates(); |
86 | void readConfig( Config& cfg ); | 89 | void readConfig( Config& cfg ); |
87 | void writeConfig( Config& cfg ) const; | 90 | void writeConfig( Config& cfg ) const; |
88 | PlayListWidgetPrivate *d; // Private implementation data | 91 | PlayListWidgetPrivate *d; // Private implementation data |
89 | void populateAudioView(); | 92 | void populateAudioView(); |
90 | void populateVideoView(); | 93 | void populateVideoView(); |
91 | private slots: | 94 | private slots: |
92 | 95 | ||
96 | void qcopReceive(const QCString&, const QByteArray&); | ||
93 | void populateSkinsMenu(); | 97 | void populateSkinsMenu(); |
94 | void skinsMenuActivated(int); | 98 | void skinsMenuActivated(int); |
95 | void writem3u(); | 99 | void writem3u(); |
96 | void writeCurrentM3u(); | 100 | void writeCurrentM3u(); |
97 | void scanForAudio(); | 101 | void scanForAudio(); |
98 | void scanForVideo(); | 102 | void scanForVideo(); |
99 | void openFile(); | 103 | void openFile(); |
100 | void setDocument( const QString& fileref ); | 104 | void setDocument( const QString& fileref ); |
101 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 105 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
102 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 106 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
103 | void setActiveWindow(); // need to handle this to show the right view | 107 | void setActiveWindow(); // need to handle this to show the right view |
104 | void setPlaylist( bool ); // Show/Hide the playlist | 108 | void setPlaylist( bool ); // Show/Hide the playlist |
105 | void setView( char ); | 109 | void setView( char ); |
106 | void clearList(); | 110 | void clearList(); |
107 | void addAllToList(); | 111 | void addAllToList(); |
108 | void addAllMusicToList(); | 112 | void addAllMusicToList(); |
109 | void addAllVideoToList(); | 113 | void addAllVideoToList(); |
110 | void saveList(); // Save the playlist | 114 | void saveList(); // Save the playlist |
111 | void loadList( const DocLnk &); // Load a playlist | 115 | void loadList( const DocLnk &); // Load a playlist |
112 | void playIt( QListViewItem *); | 116 | void playIt( QListViewItem *); |
113 | 117 | ||
114 | void btnPlay(bool); | 118 | void btnPlay(bool); |
115 | void deletePlaylist(); | 119 | void deletePlaylist(); |
116 | void addSelected(); | 120 | void addSelected(); |
117 | void removeSelected(); | 121 | void removeSelected(); |
118 | void tabChanged(QWidget*); | 122 | void tabChanged(QWidget*); |
119 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 123 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
120 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 124 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
121 | void playSelected(); | 125 | void playSelected(); |
122 | void listDelete(); | 126 | void listDelete(); |
123 | 127 | ||
124 | protected slots: | 128 | protected slots: |