-rw-r--r-- | noncore/multimedia/opieplayer2/playlistselection.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 16 |
2 files changed, 8 insertions, 11 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistselection.cpp b/noncore/multimedia/opieplayer2/playlistselection.cpp index 975dec3..2019b3a 100644 --- a/noncore/multimedia/opieplayer2/playlistselection.cpp +++ b/noncore/multimedia/opieplayer2/playlistselection.cpp | |||
@@ -21,194 +21,193 @@ | |||
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | 23 | ||
24 | #include <qpainter.h> | 24 | #include <qpainter.h> |
25 | #include <qimage.h> | 25 | #include <qimage.h> |
26 | #include <qheader.h> | 26 | #include <qheader.h> |
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | #include <qlist.h> | 28 | #include <qlist.h> |
29 | #include <qpixmap.h> | 29 | #include <qpixmap.h> |
30 | 30 | ||
31 | #include "playlistselection.h" | 31 | #include "playlistselection.h" |
32 | 32 | ||
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | 34 | ||
35 | class PlayListSelectionItem : public QListViewItem { | 35 | class PlayListSelectionItem : public QListViewItem { |
36 | public: | 36 | public: |
37 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 37 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
38 | setText( 0, f->name() ); | 38 | setText( 0, f->name() ); |
39 | setPixmap( 0, f->pixmap() ); | 39 | setPixmap( 0, f->pixmap() ); |
40 | } | 40 | } |
41 | 41 | ||
42 | ~PlayListSelectionItem() { | 42 | ~PlayListSelectionItem() { |
43 | }; | 43 | }; |
44 | 44 | ||
45 | const DocLnk *file() const { return fl; } | 45 | const DocLnk *file() const { return fl; } |
46 | 46 | ||
47 | private: | 47 | private: |
48 | const DocLnk *fl; | 48 | const DocLnk *fl; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | 51 | ||
52 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 52 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
53 | : QListView( parent, name ) | 53 | : QListView( parent, name ) |
54 | { | 54 | { |
55 | // qDebug("starting playlistselector"); | 55 | // qDebug("starting playlistselector"); |
56 | // #ifdef USE_PLAYLIST_BACKGROUND | 56 | // #ifdef USE_PLAYLIST_BACKGROUND |
57 | // setStaticBackground( TRUE ); | 57 | // setStaticBackground( TRUE ); |
58 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); | 58 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); |
59 | 59 | ||
60 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); | 60 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); |
61 | // #endif | 61 | // #endif |
62 | // addColumn("Title",236); | 62 | // addColumn("Title",236); |
63 | // setAllColumnsShowFocus( TRUE ); | 63 | // setAllColumnsShowFocus( TRUE ); |
64 | addColumn( tr( "Playlist Selection" ) ); | 64 | addColumn( tr( "Playlist Selection" ) ); |
65 | header()->hide(); | 65 | header()->hide(); |
66 | setSorting( -1, FALSE ); | 66 | setSorting( -1, FALSE ); |
67 | } | 67 | } |
68 | 68 | ||
69 | 69 | ||
70 | PlayListSelection::~PlayListSelection() { | 70 | PlayListSelection::~PlayListSelection() { |
71 | } | 71 | } |
72 | 72 | ||
73 | 73 | ||
74 | // #ifdef USE_PLAYLIST_BACKGROUND | 74 | // #ifdef USE_PLAYLIST_BACKGROUND |
75 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 75 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
76 | // qDebug("drawBackground"); | 76 | // qDebug("drawBackground"); |
77 | p->fillRect( r, QBrush( white ) ); | 77 | p->fillRect( r, QBrush( white ) ); |
78 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); | 78 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); |
79 | // if ( !logo.isNull() ) | 79 | // if ( !logo.isNull() ) |
80 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 80 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
81 | } | 81 | } |
82 | // #endif | 82 | // #endif |
83 | 83 | ||
84 | 84 | ||
85 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 85 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
86 | if ( event->state() == QMouseEvent::LeftButton ) { | 86 | if ( event->state() == QMouseEvent::LeftButton ) { |
87 | QListViewItem *currentItem = selectedItem(); | 87 | QListViewItem *currentItem = selectedItem(); |
88 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 88 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
89 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 89 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
90 | moveSelectedUp(); | 90 | moveSelectedUp(); |
91 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 91 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
92 | moveSelectedDown(); | 92 | moveSelectedDown(); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | const DocLnk *PlayListSelection::current() { | 97 | const DocLnk *PlayListSelection::current() { |
98 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 98 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
99 | if ( item ) | 99 | if ( item ) |
100 | return item->file(); | 100 | return item->file(); |
101 | return NULL; | 101 | return NULL; |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 105 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
106 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 106 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
107 | QListViewItem *current = selectedItem(); | 107 | QListViewItem *current = selectedItem(); |
108 | if ( current ) | 108 | if ( current ) |
109 | item->moveItem( current ); | 109 | item->moveItem( current ); |
110 | setSelected( item, TRUE ); | 110 | setSelected( item, TRUE ); |
111 | ensureItemVisible( selectedItem() ); | 111 | ensureItemVisible( selectedItem() ); |
112 | } | 112 | } |
113 | 113 | ||
114 | 114 | ||
115 | void PlayListSelection::removeSelected() { | 115 | void PlayListSelection::removeSelected() { |
116 | QListViewItem *item = selectedItem(); | 116 | QListViewItem *item = selectedItem(); |
117 | if ( item ) | 117 | delete item; |
118 | delete item; | ||
119 | setSelected( currentItem(), TRUE ); | 118 | setSelected( currentItem(), TRUE ); |
120 | ensureItemVisible( selectedItem() ); | 119 | ensureItemVisible( selectedItem() ); |
121 | } | 120 | } |
122 | 121 | ||
123 | 122 | ||
124 | void PlayListSelection::moveSelectedUp() { | 123 | void PlayListSelection::moveSelectedUp() { |
125 | QListViewItem *item = selectedItem(); | 124 | QListViewItem *item = selectedItem(); |
126 | if ( item && item->itemAbove() ) | 125 | if ( item && item->itemAbove() ) |
127 | item->itemAbove()->moveItem( item ); | 126 | item->itemAbove()->moveItem( item ); |
128 | ensureItemVisible( selectedItem() ); | 127 | ensureItemVisible( selectedItem() ); |
129 | } | 128 | } |
130 | 129 | ||
131 | 130 | ||
132 | void PlayListSelection::moveSelectedDown() { | 131 | void PlayListSelection::moveSelectedDown() { |
133 | QListViewItem *item = selectedItem(); | 132 | QListViewItem *item = selectedItem(); |
134 | if ( item && item->itemBelow() ) | 133 | if ( item && item->itemBelow() ) |
135 | item->moveItem( item->itemBelow() ); | 134 | item->moveItem( item->itemBelow() ); |
136 | ensureItemVisible( selectedItem() ); | 135 | ensureItemVisible( selectedItem() ); |
137 | } | 136 | } |
138 | 137 | ||
139 | 138 | ||
140 | bool PlayListSelection::prev() { | 139 | bool PlayListSelection::prev() { |
141 | QListViewItem *item = selectedItem(); | 140 | QListViewItem *item = selectedItem(); |
142 | if ( item && item->itemAbove() ) | 141 | if ( item && item->itemAbove() ) |
143 | setSelected( item->itemAbove(), TRUE ); | 142 | setSelected( item->itemAbove(), TRUE ); |
144 | else | 143 | else |
145 | return FALSE; | 144 | return FALSE; |
146 | ensureItemVisible( selectedItem() ); | 145 | ensureItemVisible( selectedItem() ); |
147 | return TRUE; | 146 | return TRUE; |
148 | } | 147 | } |
149 | 148 | ||
150 | bool PlayListSelection::next() { | 149 | bool PlayListSelection::next() { |
151 | QListViewItem *item = selectedItem(); | 150 | QListViewItem *item = selectedItem(); |
152 | if ( item && item->itemBelow() ) | 151 | if ( item && item->itemBelow() ) |
153 | setSelected( item->itemBelow(), TRUE ); | 152 | setSelected( item->itemBelow(), TRUE ); |
154 | else | 153 | else |
155 | return FALSE; | 154 | return FALSE; |
156 | ensureItemVisible( selectedItem() ); | 155 | ensureItemVisible( selectedItem() ); |
157 | return TRUE; | 156 | return TRUE; |
158 | } | 157 | } |
159 | 158 | ||
160 | 159 | ||
161 | bool PlayListSelection::first() { | 160 | bool PlayListSelection::first() { |
162 | QListViewItem *item = firstChild(); | 161 | QListViewItem *item = firstChild(); |
163 | if ( item ) | 162 | if ( item ) |
164 | setSelected( item, TRUE ); | 163 | setSelected( item, TRUE ); |
165 | else | 164 | else |
166 | return FALSE; | 165 | return FALSE; |
167 | ensureItemVisible( selectedItem() ); | 166 | ensureItemVisible( selectedItem() ); |
168 | return TRUE; | 167 | return TRUE; |
169 | } | 168 | } |
170 | 169 | ||
171 | 170 | ||
172 | bool PlayListSelection::last() { | 171 | bool PlayListSelection::last() { |
173 | QListViewItem *prevItem = NULL; | 172 | QListViewItem *prevItem = NULL; |
174 | QListViewItem *item = firstChild(); | 173 | QListViewItem *item = firstChild(); |
175 | while ( ( item = item->nextSibling() ) ) | 174 | while ( ( item = item->nextSibling() ) ) |
176 | prevItem = item; | 175 | prevItem = item; |
177 | if ( prevItem ) | 176 | if ( prevItem ) |
178 | setSelected( prevItem, TRUE ); | 177 | setSelected( prevItem, TRUE ); |
179 | else | 178 | else |
180 | return FALSE; | 179 | return FALSE; |
181 | ensureItemVisible( selectedItem() ); | 180 | ensureItemVisible( selectedItem() ); |
182 | return TRUE; | 181 | return TRUE; |
183 | } | 182 | } |
184 | 183 | ||
185 | void PlayListSelection::unSelect() | 184 | void PlayListSelection::unSelect() |
186 | { | 185 | { |
187 | //QListViewItem *item = selectedItem(); | 186 | //QListViewItem *item = selectedItem(); |
188 | setSelected( currentItem(), FALSE); | 187 | setSelected( currentItem(), FALSE); |
189 | } | 188 | } |
190 | 189 | ||
191 | void PlayListSelection::writeCurrent( Config& cfg ) { | 190 | void PlayListSelection::writeCurrent( Config& cfg ) { |
192 | cfg.setGroup("PlayList"); | 191 | cfg.setGroup("PlayList"); |
193 | QListViewItem *item = selectedItem(); | 192 | QListViewItem *item = selectedItem(); |
194 | if ( item ) | 193 | if ( item ) |
195 | cfg.writeEntry("current", item->text(0) ); | 194 | cfg.writeEntry("current", item->text(0) ); |
196 | qDebug(item->text(0)); | 195 | qDebug(item->text(0)); |
197 | 196 | ||
198 | } | 197 | } |
199 | 198 | ||
200 | void PlayListSelection::setSelectedItem(const QString &strk ) { | 199 | void PlayListSelection::setSelectedItem(const QString &strk ) { |
201 | 200 | ||
202 | unSelect(); | 201 | unSelect(); |
203 | QListViewItemIterator it( this ); | 202 | QListViewItemIterator it( this ); |
204 | for ( ; it.current(); ++it ) { | 203 | for ( ; it.current(); ++it ) { |
205 | // qDebug( it.current()->text(0)); | 204 | // qDebug( it.current()->text(0)); |
206 | if( strk == it.current()->text(0)) { | 205 | if( strk == it.current()->text(0)) { |
207 | // qDebug( "We have a match "+strk); | 206 | // qDebug( "We have a match "+strk); |
208 | setSelected( it.current(), TRUE); | 207 | setSelected( it.current(), TRUE); |
209 | ensureItemVisible( it.current() ); | 208 | ensureItemVisible( it.current() ); |
210 | return; | 209 | return; |
211 | } | 210 | } |
212 | } | 211 | } |
213 | // setSelected( item, TRUE ); | 212 | // setSelected( item, TRUE ); |
214 | // ensureItemVisible( selectedItem() ); | 213 | // ensureItemVisible( selectedItem() ); |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 86b3424..ac52b07 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -98,193 +98,193 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par | |||
98 | audioView, SLOT( scanFiles() ) ); | 98 | audioView, SLOT( scanFiles() ) ); |
99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
100 | videoView, SLOT( scanFiles() ) ); | 100 | videoView, SLOT( scanFiles() ) ); |
101 | 101 | ||
102 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 102 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
103 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); | 103 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); |
104 | 104 | ||
105 | Config cfg( "OpiePlayer" ); | 105 | Config cfg( "OpiePlayer" ); |
106 | bool b= cfg.readBoolEntry("FullScreen", 0); | 106 | bool b= cfg.readBoolEntry("FullScreen", 0); |
107 | mediaPlayerState.setFullscreen( b ); | 107 | mediaPlayerState.setFullscreen( b ); |
108 | pmView->setItemChecked( -16, b ); | 108 | pmView->setItemChecked( -16, b ); |
109 | 109 | ||
110 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 110 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
111 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 111 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
112 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 112 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
113 | d->selectedFiles, SLOT(removeSelected() ) ); | 113 | d->selectedFiles, SLOT(removeSelected() ) ); |
114 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 114 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
115 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 115 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
116 | // QVBox *stretch2 = new QVBox( vbox1 ); | 116 | // QVBox *stretch2 = new QVBox( vbox1 ); |
117 | 117 | ||
118 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 118 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
119 | SLOT( deletePlaylist() ) ); | 119 | SLOT( deletePlaylist() ) ); |
120 | connect( pmView, SIGNAL( activated( int ) ), | 120 | connect( pmView, SIGNAL( activated( int ) ), |
121 | this, SLOT( pmViewActivated( int ) ) ); | 121 | this, SLOT( pmViewActivated( int ) ) ); |
122 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 122 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
123 | this, SLOT( skinsMenuActivated( int ) ) ); | 123 | this, SLOT( skinsMenuActivated( int ) ) ); |
124 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 124 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
125 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 125 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
126 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 126 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
128 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 128 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
129 | this,SLOT( playIt( QListViewItem *) ) ); | 129 | this,SLOT( playIt( QListViewItem *) ) ); |
130 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 130 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
131 | this, SLOT( addToSelection( QListViewItem *) ) ); | 131 | this, SLOT( addToSelection( QListViewItem *) ) ); |
132 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 132 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
133 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 133 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
134 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 134 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
135 | this,SLOT( playIt( QListViewItem *) ) ); | 135 | this,SLOT( playIt( QListViewItem *) ) ); |
136 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 136 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
137 | this, SLOT( addToSelection( QListViewItem *) ) ); | 137 | this, SLOT( addToSelection( QListViewItem *) ) ); |
138 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 138 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
139 | this, SLOT( loadList( const DocLnk & ) ) ); | 139 | this, SLOT( loadList( const DocLnk & ) ) ); |
140 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 140 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
141 | this, SLOT( tabChanged( QWidget* ) ) ); | 141 | this, SLOT( tabChanged( QWidget* ) ) ); |
142 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 142 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
143 | d->tbPlay, SLOT( setOn( bool ) ) ); | 143 | d->tbPlay, SLOT( setOn( bool ) ) ); |
144 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 144 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
145 | d->tbLoop, SLOT( setOn( bool ) ) ); | 145 | d->tbLoop, SLOT( setOn( bool ) ) ); |
146 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 146 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
147 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 147 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
148 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 148 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
149 | this, SLOT( playIt( QListViewItem *) ) ); | 149 | this, SLOT( playIt( QListViewItem *) ) ); |
150 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 150 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
151 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 151 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
152 | 152 | ||
153 | // see which skins are installed | 153 | // see which skins are installed |
154 | populateSkinsMenu(); | 154 | populateSkinsMenu(); |
155 | initializeStates(); | 155 | initializeStates(); |
156 | 156 | ||
157 | cfg.setGroup("PlayList"); | 157 | cfg.setGroup("PlayList"); |
158 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 158 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
159 | loadList(DocLnk( currentPlaylist ) ); | 159 | loadList(DocLnk( currentPlaylist ) ); |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | PlayListWidget::~PlayListWidget() { | 163 | PlayListWidget::~PlayListWidget() { |
164 | delete d; | 164 | delete d; |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | void PlayListWidget::initializeStates() { | 168 | void PlayListWidget::initializeStates() { |
169 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); | 169 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); |
170 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); | 170 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); |
171 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); | 171 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); |
172 | d->playListFrame->show(); | 172 | d->playListFrame->show(); |
173 | } | 173 | } |
174 | 174 | ||
175 | void PlayListWidget::writeDefaultPlaylist() { | 175 | void PlayListWidget::writeDefaultPlaylist() { |
176 | 176 | ||
177 | Config config( "OpiePlayer" ); | 177 | Config config( "OpiePlayer" ); |
178 | config.setGroup( "PlayList" ); | 178 | config.setGroup( "PlayList" ); |
179 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 179 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
180 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 180 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
181 | if( currentString == filename) { | 181 | if( currentString == filename) { |
182 | Om3u *m3uList; | 182 | Om3u *m3uList; |
183 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 183 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
184 | if( d->selectedFiles->first() ) { | 184 | if( d->selectedFiles->first() ) { |
185 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 185 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
186 | do { | 186 | do { |
187 | // qDebug(d->selectedFiles->current()->file()); | 187 | // qDebug(d->selectedFiles->current()->file()); |
188 | m3uList->add( d->selectedFiles->current()->file() ); | 188 | m3uList->add( d->selectedFiles->current()->file() ); |
189 | } | 189 | } |
190 | while ( d->selectedFiles->next() ); | 190 | while ( d->selectedFiles->next() ); |
191 | 191 | ||
192 | m3uList->write(); | 192 | m3uList->write(); |
193 | m3uList->close(); | 193 | m3uList->close(); |
194 | if(m3uList) delete m3uList; | 194 | delete m3uList; |
195 | 195 | ||
196 | } | 196 | } |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 200 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
201 | d->setDocumentUsed = FALSE; | 201 | d->setDocumentUsed = FALSE; |
202 | if( QFileInfo( lnk.file() ).exists() || | 202 | if( QFileInfo( lnk.file() ).exists() || |
203 | lnk.file().left(4) == "http" ) { | 203 | lnk.file().left(4) == "http" ) { |
204 | d->selectedFiles->addToSelection( lnk ); | 204 | d->selectedFiles->addToSelection( lnk ); |
205 | } | 205 | } |
206 | // writeCurrentM3u(); | 206 | // writeCurrentM3u(); |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | void PlayListWidget::clearList() { | 210 | void PlayListWidget::clearList() { |
211 | while ( first() ) { | 211 | while ( first() ) { |
212 | d->selectedFiles->removeSelected(); | 212 | d->selectedFiles->removeSelected(); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
217 | switch (mouse) { | 217 | switch (mouse) { |
218 | case 1: | 218 | case 1: |
219 | break; | 219 | break; |
220 | case 2: | 220 | case 2: |
221 | { | 221 | { |
222 | QPopupMenu m; | 222 | QPopupMenu m; |
223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
225 | m.exec( QCursor::pos() ); | 225 | m.exec( QCursor::pos() ); |
226 | } | 226 | } |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
233 | switch (mouse) { | 233 | switch (mouse) { |
234 | case 1: | 234 | case 1: |
235 | break; | 235 | break; |
236 | case 2: | 236 | case 2: |
237 | { | 237 | { |
238 | QPopupMenu m; | 238 | QPopupMenu m; |
239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
241 | m.exec( QCursor::pos() ); | 241 | m.exec( QCursor::pos() ); |
242 | } | 242 | } |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | void PlayListWidget::addAllToList() { | 248 | void PlayListWidget::addAllToList() { |
249 | 249 | ||
250 | // QTime t; | 250 | // QTime t; |
251 | // t.start(); | 251 | // t.start(); |
252 | 252 | ||
253 | audioView->populateView(); | 253 | audioView->populateView(); |
254 | 254 | ||
255 | QListViewItemIterator audioIt( audioView ); | 255 | QListViewItemIterator audioIt( audioView ); |
256 | DocLnk lnk; | 256 | DocLnk lnk; |
257 | QString filename; | 257 | QString filename; |
258 | // iterate through all items of the listview | 258 | // iterate through all items of the listview |
259 | for ( ; audioIt.current(); ++audioIt ) { | 259 | for ( ; audioIt.current(); ++audioIt ) { |
260 | filename = audioIt.current()->text(3); | 260 | filename = audioIt.current()->text(3); |
261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
262 | lnk.setFile( filename ); //sets file name | 262 | lnk.setFile( filename ); //sets file name |
263 | d->selectedFiles->addToSelection( lnk); | 263 | d->selectedFiles->addToSelection( lnk); |
264 | } | 264 | } |
265 | 265 | ||
266 | videoView->populateView(); | 266 | videoView->populateView(); |
267 | 267 | ||
268 | QListViewItemIterator videoIt( videoView ); | 268 | QListViewItemIterator videoIt( videoView ); |
269 | for ( ; videoIt.current(); ++videoIt ) { | 269 | for ( ; videoIt.current(); ++videoIt ) { |
270 | filename = videoIt.current()->text(3); | 270 | filename = videoIt.current()->text(3); |
271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
272 | lnk.setFile( filename ); //sets file name | 272 | lnk.setFile( filename ); //sets file name |
273 | d->selectedFiles->addToSelection( lnk); | 273 | d->selectedFiles->addToSelection( lnk); |
274 | } | 274 | } |
275 | 275 | ||
276 | // d->selectedFiles->addToSelection( ); | 276 | // d->selectedFiles->addToSelection( ); |
277 | // if ( it.current()->isSelected() ) | 277 | // if ( it.current()->isSelected() ) |
278 | // lst->append( audioIt.current() ); | 278 | // lst->append( audioIt.current() ); |
279 | // } | 279 | // } |
280 | 280 | ||
281 | 281 | ||
282 | // if(!audioScan) | 282 | // if(!audioScan) |
283 | // scanForAudio(); | 283 | // scanForAudio(); |
284 | // if(!videoScan) | 284 | // if(!videoScan) |
285 | // scanForVideo(); | 285 | // scanForVideo(); |
286 | 286 | ||
287 | // DocLnkSet filesAll; | 287 | // DocLnkSet filesAll; |
288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
289 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 289 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
290 | // for ( ; Adit.current(); ++Adit ) { | 290 | // for ( ; Adit.current(); ++Adit ) { |
@@ -591,353 +591,351 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
591 | }; | 591 | }; |
592 | } | 592 | } |
593 | 593 | ||
594 | 594 | ||
595 | void PlayListWidget::btnPlay(bool b) { | 595 | void PlayListWidget::btnPlay(bool b) { |
596 | // mediaPlayerState->setPlaying(false); | 596 | // mediaPlayerState->setPlaying(false); |
597 | mediaPlayerState.setPlaying(b); | 597 | mediaPlayerState.setPlaying(b); |
598 | insanityBool=FALSE; | 598 | insanityBool=FALSE; |
599 | } | 599 | } |
600 | 600 | ||
601 | void PlayListWidget::deletePlaylist() { | 601 | void PlayListWidget::deletePlaylist() { |
602 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 602 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
603 | (tr("You really want to delete\nthis playlist?")), | 603 | (tr("You really want to delete\nthis playlist?")), |
604 | (tr("Yes")), (tr("No")), 0 )){ | 604 | (tr("Yes")), (tr("No")), 0 )){ |
605 | case 0: // Yes clicked, | 605 | case 0: // Yes clicked, |
606 | QFile().remove(playLists->selectedDocument().file()); | 606 | QFile().remove(playLists->selectedDocument().file()); |
607 | QFile().remove(playLists->selectedDocument().linkFile()); | 607 | QFile().remove(playLists->selectedDocument().linkFile()); |
608 | playLists->reread(); | 608 | playLists->reread(); |
609 | break; | 609 | break; |
610 | case 1: // Cancel | 610 | case 1: // Cancel |
611 | break; | 611 | break; |
612 | }; | 612 | }; |
613 | } | 613 | } |
614 | 614 | ||
615 | 615 | ||
616 | void PlayListWidget::playSelected() { | 616 | void PlayListWidget::playSelected() { |
617 | btnPlay( TRUE); | 617 | btnPlay( TRUE); |
618 | } | 618 | } |
619 | 619 | ||
620 | QListView *PlayListWidget::currentFileListView() const | 620 | QListView *PlayListWidget::currentFileListView() const |
621 | { | 621 | { |
622 | switch ( currentTab() ) { | 622 | switch ( currentTab() ) { |
623 | case AudioFiles: return audioView; | 623 | case AudioFiles: return audioView; |
624 | case VideoFiles: return videoView; | 624 | case VideoFiles: return videoView; |
625 | default: assert( false ); | 625 | default: assert( false ); |
626 | } | 626 | } |
627 | return 0; | 627 | return 0; |
628 | } | 628 | } |
629 | 629 | ||
630 | bool PlayListWidget::inFileListMode() const | 630 | bool PlayListWidget::inFileListMode() const |
631 | { | 631 | { |
632 | TabType tab = currentTab(); | 632 | TabType tab = currentTab(); |
633 | return tab == AudioFiles || tab == VideoFiles; | 633 | return tab == AudioFiles || tab == VideoFiles; |
634 | } | 634 | } |
635 | 635 | ||
636 | void PlayListWidget::openFile() { | 636 | void PlayListWidget::openFile() { |
637 | // http://66.28.164.33:2080 | 637 | // http://66.28.164.33:2080 |
638 | // http://somafm.com/star0242.m3u | 638 | // http://somafm.com/star0242.m3u |
639 | QString filename, name; | 639 | QString filename, name; |
640 | InputDialog *fileDlg; | 640 | InputDialog *fileDlg; |
641 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 641 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
642 | fileDlg->exec(); | 642 | fileDlg->exec(); |
643 | if( fileDlg->result() == 1 ) { | 643 | if( fileDlg->result() == 1 ) { |
644 | filename = fileDlg->text(); | 644 | filename = fileDlg->text(); |
645 | qDebug( "Selected filename is " + filename ); | 645 | qDebug( "Selected filename is " + filename ); |
646 | // Om3u *m3uList; | 646 | // Om3u *m3uList; |
647 | DocLnk lnk; | 647 | DocLnk lnk; |
648 | Config cfg( "OpiePlayer" ); | 648 | Config cfg( "OpiePlayer" ); |
649 | cfg.setGroup("PlayList"); | 649 | cfg.setGroup("PlayList"); |
650 | 650 | ||
651 | if(filename.left(4) == "http") { | 651 | if(filename.left(4) == "http") { |
652 | QString m3uFile, m3uFilePath; | 652 | QString m3uFile, m3uFilePath; |
653 | if(filename.find(":",8,TRUE) != -1) { //found a port | 653 | if(filename.find(":",8,TRUE) != -1) { //found a port |
654 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 654 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
655 | m3uFile = m3uFile.right( 7); | 655 | m3uFile = m3uFile.right( 7); |
656 | } else if(filename.left(4) == "http"){ | 656 | } else if(filename.left(4) == "http"){ |
657 | m3uFile=filename; | 657 | m3uFile=filename; |
658 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 658 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
659 | } else{ | 659 | } else{ |
660 | m3uFile=filename; | 660 | m3uFile=filename; |
661 | } | 661 | } |
662 | 662 | ||
663 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 663 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
664 | lnk.setName( filename ); //sets name | 664 | lnk.setName( filename ); //sets name |
665 | lnk.setFile( filename ); //sets file name | 665 | lnk.setFile( filename ); //sets file name |
666 | 666 | ||
667 | // lnk.setIcon("opieplayer2/musicfile"); | 667 | // lnk.setIcon("opieplayer2/musicfile"); |
668 | 668 | ||
669 | d->selectedFiles->addToSelection( lnk ); | 669 | d->selectedFiles->addToSelection( lnk ); |
670 | writeCurrentM3u(); | 670 | writeCurrentM3u(); |
671 | d->selectedFiles->setSelectedItem( lnk.name()); | 671 | d->selectedFiles->setSelectedItem( lnk.name()); |
672 | } | 672 | } |
673 | else if( filename.right( 3) == "m3u" ) { | 673 | else if( filename.right( 3) == "m3u" ) { |
674 | readm3u( filename ); | 674 | readm3u( filename ); |
675 | 675 | ||
676 | } else if( filename.right(3) == "pls" ) { | 676 | } else if( filename.right(3) == "pls" ) { |
677 | readPls( filename ); | 677 | readPls( filename ); |
678 | } else { | 678 | } else { |
679 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 679 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
680 | lnk.setFile( filename ); //sets file name | 680 | lnk.setFile( filename ); //sets file name |
681 | d->selectedFiles->addToSelection( lnk); | 681 | d->selectedFiles->addToSelection( lnk); |
682 | writeCurrentM3u(); | 682 | writeCurrentM3u(); |
683 | d->selectedFiles->setSelectedItem( lnk.name()); | 683 | d->selectedFiles->setSelectedItem( lnk.name()); |
684 | } | 684 | } |
685 | } | 685 | } |
686 | 686 | ||
687 | if( fileDlg ) { | 687 | delete fileDlg; |
688 | delete fileDlg; | ||
689 | } | ||
690 | } | 688 | } |
691 | 689 | ||
692 | /* | 690 | /* |
693 | reads m3u and shows files/urls to playlist widget */ | 691 | reads m3u and shows files/urls to playlist widget */ |
694 | void PlayListWidget::readm3u( const QString &filename ) { | 692 | void PlayListWidget::readm3u( const QString &filename ) { |
695 | qDebug( "read m3u filename " + filename ); | 693 | qDebug( "read m3u filename " + filename ); |
696 | 694 | ||
697 | Om3u *m3uList; | 695 | Om3u *m3uList; |
698 | QString s, name; | 696 | QString s, name; |
699 | m3uList = new Om3u( filename, IO_ReadOnly ); | 697 | m3uList = new Om3u( filename, IO_ReadOnly ); |
700 | m3uList->readM3u(); | 698 | m3uList->readM3u(); |
701 | DocLnk lnk; | 699 | DocLnk lnk; |
702 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 700 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
703 | s = *it; | 701 | s = *it; |
704 | // qDebug("reading "+ s); | 702 | // qDebug("reading "+ s); |
705 | if(s.left(4)=="http") { | 703 | if(s.left(4)=="http") { |
706 | lnk.setName( s ); //sets file name | 704 | lnk.setName( s ); //sets file name |
707 | lnk.setIcon("opieplayer2/musicfile"); | 705 | lnk.setIcon("opieplayer2/musicfile"); |
708 | lnk.setFile( s ); //sets file name | 706 | lnk.setFile( s ); //sets file name |
709 | 707 | ||
710 | } else { | 708 | } else { |
711 | // if( QFileInfo( s ).exists() ) { | 709 | // if( QFileInfo( s ).exists() ) { |
712 | lnk.setName( QFileInfo(s).baseName()); | 710 | lnk.setName( QFileInfo(s).baseName()); |
713 | // if(s.right(4) == '.') {//if regular file | 711 | // if(s.right(4) == '.') {//if regular file |
714 | if(s.left(1) != "/") { | 712 | if(s.left(1) != "/") { |
715 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 713 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
716 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 714 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
717 | // lnk.setIcon(MimeType(s).pixmap() ); | 715 | // lnk.setIcon(MimeType(s).pixmap() ); |
718 | // lnk.setIcon("SoundPlayer"); | 716 | // lnk.setIcon("SoundPlayer"); |
719 | } else { | 717 | } else { |
720 | // qDebug("set link2 "+s); | 718 | // qDebug("set link2 "+s); |
721 | lnk.setFile( s); | 719 | lnk.setFile( s); |
722 | // lnk.setIcon(MimeType(s).pixmap() ); | 720 | // lnk.setIcon(MimeType(s).pixmap() ); |
723 | // lnk.setIcon("SoundPlayer"); | 721 | // lnk.setIcon("SoundPlayer"); |
724 | } | 722 | } |
725 | } | 723 | } |
726 | d->selectedFiles->addToSelection( lnk ); | 724 | d->selectedFiles->addToSelection( lnk ); |
727 | } | 725 | } |
728 | Config config( "OpiePlayer" ); | 726 | Config config( "OpiePlayer" ); |
729 | config.setGroup( "PlayList" ); | 727 | config.setGroup( "PlayList" ); |
730 | 728 | ||
731 | config.writeEntry("CurrentPlaylist",filename); | 729 | config.writeEntry("CurrentPlaylist",filename); |
732 | config.write(); | 730 | config.write(); |
733 | currentPlayList=filename; | 731 | currentPlayList=filename; |
734 | 732 | ||
735 | // m3uList->write(); | 733 | // m3uList->write(); |
736 | m3uList->close(); | 734 | m3uList->close(); |
737 | if(m3uList) delete m3uList; | 735 | delete m3uList; |
738 | 736 | ||
739 | d->selectedFiles->setSelectedItem( s); | 737 | d->selectedFiles->setSelectedItem( s); |
740 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 738 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
741 | 739 | ||
742 | } | 740 | } |
743 | 741 | ||
744 | /* | 742 | /* |
745 | reads pls and adds files/urls to playlist */ | 743 | reads pls and adds files/urls to playlist */ |
746 | void PlayListWidget::readPls( const QString &filename ) { | 744 | void PlayListWidget::readPls( const QString &filename ) { |
747 | 745 | ||
748 | qDebug( "pls filename is " + filename ); | 746 | qDebug( "pls filename is " + filename ); |
749 | Om3u *m3uList; | 747 | Om3u *m3uList; |
750 | QString s, name; | 748 | QString s, name; |
751 | m3uList = new Om3u( filename, IO_ReadOnly ); | 749 | m3uList = new Om3u( filename, IO_ReadOnly ); |
752 | m3uList->readPls(); | 750 | m3uList->readPls(); |
753 | 751 | ||
754 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 752 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
755 | s = *it; | 753 | s = *it; |
756 | // s.replace( QRegExp( "%20" )," " ); | 754 | // s.replace( QRegExp( "%20" )," " ); |
757 | DocLnk lnk( s ); | 755 | DocLnk lnk( s ); |
758 | QFileInfo f( s ); | 756 | QFileInfo f( s ); |
759 | QString name = f.baseName(); | 757 | QString name = f.baseName(); |
760 | 758 | ||
761 | if( name.left( 4 ) == "http" ) { | 759 | if( name.left( 4 ) == "http" ) { |
762 | name = s.right( s.length() - 7); | 760 | name = s.right( s.length() - 7); |
763 | } else { | 761 | } else { |
764 | name = s; | 762 | name = s; |
765 | } | 763 | } |
766 | 764 | ||
767 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 765 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
768 | 766 | ||
769 | lnk.setName( name ); | 767 | lnk.setName( name ); |
770 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 768 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
771 | lnk.setFile( s ); | 769 | lnk.setFile( s ); |
772 | } else { //if its a url | 770 | } else { //if its a url |
773 | // if( name.right( 1 ).find( '/' ) == -1) { | 771 | // if( name.right( 1 ).find( '/' ) == -1) { |
774 | // s += "/"; | 772 | // s += "/"; |
775 | // } | 773 | // } |
776 | lnk.setFile( s ); | 774 | lnk.setFile( s ); |
777 | } | 775 | } |
778 | lnk.setType( "audio/x-mpegurl" ); | 776 | lnk.setType( "audio/x-mpegurl" ); |
779 | 777 | ||
780 | lnk.writeLink(); | 778 | lnk.writeLink(); |
781 | d->selectedFiles->addToSelection( lnk ); | 779 | d->selectedFiles->addToSelection( lnk ); |
782 | } | 780 | } |
783 | 781 | ||
784 | m3uList->close(); | 782 | m3uList->close(); |
785 | if(m3uList) delete m3uList; | 783 | delete m3uList; |
786 | } | 784 | } |
787 | 785 | ||
788 | /* | 786 | /* |
789 | writes current playlist to current m3u file */ | 787 | writes current playlist to current m3u file */ |
790 | void PlayListWidget::writeCurrentM3u() { | 788 | void PlayListWidget::writeCurrentM3u() { |
791 | qDebug("writing to current m3u"); | 789 | qDebug("writing to current m3u"); |
792 | Config cfg( "OpiePlayer" ); | 790 | Config cfg( "OpiePlayer" ); |
793 | cfg.setGroup("PlayList"); | 791 | cfg.setGroup("PlayList"); |
794 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 792 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
795 | 793 | ||
796 | Om3u *m3uList; | 794 | Om3u *m3uList; |
797 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 795 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
798 | if( d->selectedFiles->first()) { | 796 | if( d->selectedFiles->first()) { |
799 | 797 | ||
800 | do { | 798 | do { |
801 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 799 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
802 | m3uList->add( d->selectedFiles->current()->file() ); | 800 | m3uList->add( d->selectedFiles->current()->file() ); |
803 | } | 801 | } |
804 | while ( d->selectedFiles->next() ); | 802 | while ( d->selectedFiles->next() ); |
805 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 803 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
806 | m3uList->write(); | 804 | m3uList->write(); |
807 | m3uList->close(); | 805 | m3uList->close(); |
808 | 806 | ||
809 | if(m3uList) delete m3uList; | 807 | delete m3uList; |
810 | } | 808 | } |
811 | 809 | ||
812 | } | 810 | } |
813 | 811 | ||
814 | /* | 812 | /* |
815 | writes current playlist to m3u file */ | 813 | writes current playlist to m3u file */ |
816 | void PlayListWidget::writem3u() { | 814 | void PlayListWidget::writem3u() { |
817 | InputDialog *fileDlg; | 815 | InputDialog *fileDlg; |
818 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 816 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
819 | fileDlg->exec(); | 817 | fileDlg->exec(); |
820 | QString name, filename, list; | 818 | QString name, filename, list; |
821 | Om3u *m3uList; | 819 | Om3u *m3uList; |
822 | 820 | ||
823 | if( fileDlg->result() == 1 ) { | 821 | if( fileDlg->result() == 1 ) { |
824 | name = fileDlg->text(); | 822 | name = fileDlg->text(); |
825 | // qDebug( filename ); | 823 | // qDebug( filename ); |
826 | 824 | ||
827 | if( name.left( 1) != "/" ) { | 825 | if( name.left( 1) != "/" ) { |
828 | filename = QPEApplication::documentDir() + "/" + name; | 826 | filename = QPEApplication::documentDir() + "/" + name; |
829 | } | 827 | } |
830 | 828 | ||
831 | if( name.right( 3 ) != "m3u" ) { | 829 | if( name.right( 3 ) != "m3u" ) { |
832 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 830 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
833 | } | 831 | } |
834 | 832 | ||
835 | if( d->selectedFiles->first()) { | 833 | if( d->selectedFiles->first()) { |
836 | m3uList = new Om3u(filename, IO_ReadWrite); | 834 | m3uList = new Om3u(filename, IO_ReadWrite); |
837 | 835 | ||
838 | do { | 836 | do { |
839 | m3uList->add( d->selectedFiles->current()->file()); | 837 | m3uList->add( d->selectedFiles->current()->file()); |
840 | } | 838 | } |
841 | while ( d->selectedFiles->next() ); | 839 | while ( d->selectedFiles->next() ); |
842 | // qDebug( list ); | 840 | // qDebug( list ); |
843 | m3uList->write(); | 841 | m3uList->write(); |
844 | m3uList->close(); | 842 | m3uList->close(); |
845 | if(m3uList) delete m3uList; | 843 | delete m3uList; |
846 | 844 | ||
847 | if(fileDlg) delete fileDlg; | 845 | delete fileDlg; |
848 | 846 | ||
849 | DocLnk lnk; | 847 | DocLnk lnk; |
850 | lnk.setFile( filename); | 848 | lnk.setFile( filename); |
851 | lnk.setIcon("opieplayer2/playlist2"); | 849 | lnk.setIcon("opieplayer2/playlist2"); |
852 | lnk.setName( name); //sets file name | 850 | lnk.setName( name); //sets file name |
853 | 851 | ||
854 | // qDebug(filename); | 852 | // qDebug(filename); |
855 | Config config( "OpiePlayer" ); | 853 | Config config( "OpiePlayer" ); |
856 | config.setGroup( "PlayList" ); | 854 | config.setGroup( "PlayList" ); |
857 | 855 | ||
858 | config.writeEntry("CurrentPlaylist",filename); | 856 | config.writeEntry("CurrentPlaylist",filename); |
859 | currentPlayList=filename; | 857 | currentPlayList=filename; |
860 | 858 | ||
861 | if(!lnk.writeLink()) { | 859 | if(!lnk.writeLink()) { |
862 | qDebug("Writing doclink did not work"); | 860 | qDebug("Writing doclink did not work"); |
863 | } | 861 | } |
864 | 862 | ||
865 | setCaption(tr("OpiePlayer: ") + name); | 863 | setCaption(tr("OpiePlayer: ") + name); |
866 | } | 864 | } |
867 | } | 865 | } |
868 | } | 866 | } |
869 | 867 | ||
870 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 868 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
871 | switch ( e->key() ) { | 869 | switch ( e->key() ) { |
872 | ////////////////////////////// Zaurus keys | 870 | ////////////////////////////// Zaurus keys |
873 | case Key_F9: //activity | 871 | case Key_F9: //activity |
874 | // if(audioUI->isHidden()) | 872 | // if(audioUI->isHidden()) |
875 | // audioUI->showMaximized(); | 873 | // audioUI->showMaximized(); |
876 | break; | 874 | break; |
877 | case Key_F10: //contacts | 875 | case Key_F10: //contacts |
878 | // if( videoUI->isHidden()) | 876 | // if( videoUI->isHidden()) |
879 | // videoUI->showMaximized(); | 877 | // videoUI->showMaximized(); |
880 | break; | 878 | break; |
881 | case Key_F11: //menu | 879 | case Key_F11: //menu |
882 | break; | 880 | break; |
883 | case Key_F12: //home | 881 | case Key_F12: //home |
884 | // doBlank(); | 882 | // doBlank(); |
885 | break; | 883 | break; |
886 | case Key_F13: //mail | 884 | case Key_F13: //mail |
887 | // doUnblank(); | 885 | // doUnblank(); |
888 | break; | 886 | break; |
889 | case Key_Q: //add to playlist | 887 | case Key_Q: //add to playlist |
890 | addSelected(); | 888 | addSelected(); |
891 | break; | 889 | break; |
892 | case Key_R: //remove from playlist | 890 | case Key_R: //remove from playlist |
893 | removeSelected(); | 891 | removeSelected(); |
894 | break; | 892 | break; |
895 | // case Key_P: //play | 893 | // case Key_P: //play |
896 | // qDebug("Play"); | 894 | // qDebug("Play"); |
897 | // playSelected(); | 895 | // playSelected(); |
898 | // break; | 896 | // break; |
899 | case Key_Space: | 897 | case Key_Space: |
900 | // playSelected(); puh | 898 | // playSelected(); puh |
901 | break; | 899 | break; |
902 | case Key_1: | 900 | case Key_1: |
903 | tabWidget->setCurrentPage( 0 ); | 901 | tabWidget->setCurrentPage( 0 ); |
904 | break; | 902 | break; |
905 | case Key_2: | 903 | case Key_2: |
906 | tabWidget->setCurrentPage( 1 ); | 904 | tabWidget->setCurrentPage( 1 ); |
907 | break; | 905 | break; |
908 | case Key_3: | 906 | case Key_3: |
909 | tabWidget->setCurrentPage( 2 ); | 907 | tabWidget->setCurrentPage( 2 ); |
910 | break; | 908 | break; |
911 | case Key_4: | 909 | case Key_4: |
912 | tabWidget->setCurrentPage( 3 ); | 910 | tabWidget->setCurrentPage( 3 ); |
913 | break; | 911 | break; |
914 | case Key_Down: | 912 | case Key_Down: |
915 | if ( !d->selectedFiles->next() ) | 913 | if ( !d->selectedFiles->next() ) |
916 | d->selectedFiles->first(); | 914 | d->selectedFiles->first(); |
917 | break; | 915 | break; |
918 | case Key_Up: | 916 | case Key_Up: |
919 | if ( !d->selectedFiles->prev() ) | 917 | if ( !d->selectedFiles->prev() ) |
920 | // d->selectedFiles->last(); | 918 | // d->selectedFiles->last(); |
921 | break; | 919 | break; |
922 | } | 920 | } |
923 | } | 921 | } |
924 | 922 | ||
925 | void PlayListWidget::pmViewActivated(int index) { | 923 | void PlayListWidget::pmViewActivated(int index) { |
926 | // qDebug("%d", index); | 924 | // qDebug("%d", index); |
927 | switch(index) { | 925 | switch(index) { |
928 | case -16: | 926 | case -16: |
929 | { | 927 | { |
930 | mediaPlayerState.toggleFullscreen(); | 928 | mediaPlayerState.toggleFullscreen(); |
931 | bool b=mediaPlayerState.isFullscreen(); | 929 | bool b=mediaPlayerState.isFullscreen(); |
932 | pmView->setItemChecked( index, b); | 930 | pmView->setItemChecked( index, b); |
933 | Config cfg( "OpiePlayer" ); | 931 | Config cfg( "OpiePlayer" ); |
934 | cfg.writeEntry( "FullScreen", b ); | 932 | cfg.writeEntry( "FullScreen", b ); |
935 | } | 933 | } |
936 | break; | 934 | break; |
937 | }; | 935 | }; |
938 | } | 936 | } |
939 | 937 | ||
940 | void PlayListWidget::populateSkinsMenu() { | 938 | void PlayListWidget::populateSkinsMenu() { |
941 | int item = 0; | 939 | int item = 0; |
942 | defaultSkinIndex = 0; | 940 | defaultSkinIndex = 0; |
943 | QString skinName; | 941 | QString skinName; |