author | llornkcor <llornkcor> | 2002-11-12 02:48:15 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-12 02:48:15 (UTC) |
commit | ee4ec981207254f6541e080a62b91bae8c9f1726 (patch) (unidiff) | |
tree | 587a0f7e079193770f3c0bde6f381bb7acc55b33 | |
parent | c829e55b85c20034f0ae07336fd3f5b9a03d9a48 (diff) | |
download | opie-ee4ec981207254f6541e080a62b91bae8c9f1726.zip opie-ee4ec981207254f6541e080a62b91bae8c9f1726.tar.gz opie-ee4ec981207254f6541e080a62b91bae8c9f1726.tar.bz2 |
sync with op2
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 7 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 163 |
2 files changed, 74 insertions, 96 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index ef7c8dc..9a55608 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp | |||
@@ -1,221 +1,222 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | 23 | ||
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qpixmap.h> | 25 | #include <qpixmap.h> |
26 | #include <qbutton.h> | 26 | #include <qbutton.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | 30 | ||
31 | #include "audiowidget.h" | 31 | #include "audiowidget.h" |
32 | #include "mediaplayerstate.h" | 32 | #include "mediaplayerstate.h" |
33 | 33 | ||
34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | 36 | ||
37 | extern MediaPlayerState *mediaPlayerState; | 37 | extern MediaPlayerState *mediaPlayerState; |
38 | 38 | ||
39 | 39 | ||
40 | static const int xo = -2; // movable x offset | 40 | static const int xo = -2; // movable x offset |
41 | static const int yo = 22; // movable y offset | 41 | static const int yo = 22; // movable y offset |
42 | 42 | ||
43 | struct MediaButton { | 43 | struct MediaButton { |
44 | bool isToggle, isHeld, isDown; | 44 | bool isToggle, isHeld, isDown; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | //Layout information for the audioButtons (and if it is a toggle button or not) | 47 | //Layout information for the audioButtons (and if it is a toggle button or not) |
48 | MediaButton audioButtons[] = { | 48 | MediaButton audioButtons[] = { |
49 | { TRUE, FALSE, FALSE }, // play | 49 | { TRUE, FALSE, FALSE }, // play |
50 | { FALSE, FALSE, FALSE }, // stop | 50 | { FALSE, FALSE, FALSE }, // stop |
51 | { FALSE, FALSE, FALSE }, // next | 51 | { FALSE, FALSE, FALSE }, // next |
52 | { FALSE, FALSE, FALSE }, // previous | 52 | { FALSE, FALSE, FALSE }, // previous |
53 | { FALSE, FALSE, FALSE }, // volume up | 53 | { FALSE, FALSE, FALSE }, // volume up |
54 | { FALSE, FALSE, FALSE }, // volume down | 54 | { FALSE, FALSE, FALSE }, // volume down |
55 | { TRUE, FALSE, FALSE }, // repeat/loop | 55 | { TRUE, FALSE, FALSE }, // repeat/loop |
56 | { FALSE, FALSE, FALSE }, // playlist | 56 | { FALSE, FALSE, FALSE }, // playlist |
57 | { FALSE, FALSE, FALSE }, // forward | 57 | { FALSE, FALSE, FALSE }, // forward |
58 | { FALSE, FALSE, FALSE } // back | 58 | { FALSE, FALSE, FALSE } // back |
59 | }; | 59 | }; |
60 | 60 | ||
61 | const char *skin_mask_file_names[10] = { | 61 | const char *skin_mask_file_names[10] = { |
62 | "play", "stop", "next", "prev", "up", | 62 | "play", "stop", "next", "prev", "up", |
63 | "down", "loop", "playlist", "forward", "back" | 63 | "down", "loop", "playlist", "forward", "back" |
64 | }; | 64 | }; |
65 | 65 | ||
66 | static void changeTextColor( QWidget *w ) { | 66 | static void changeTextColor( QWidget *w ) { |
67 | QPalette p = w->palette(); | 67 | QPalette p = w->palette(); |
68 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 68 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
69 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 69 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
70 | w->setPalette( p ); | 70 | w->setPalette( p ); |
71 | } | 71 | } |
72 | 72 | ||
73 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 73 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
74 | 74 | ||
75 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 75 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
76 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) | 76 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) |
77 | { | 77 | { |
78 | setCaption( tr("OpiePlayer") ); | 78 | setCaption( tr("OpiePlayer") ); |
79 | qDebug("<<<<<audioWidget"); | 79 | qDebug("<<<<<audioWidget"); |
80 | 80 | ||
81 | Config cfg("OpiePlayer"); | 81 | Config cfg("OpiePlayer"); |
82 | cfg.setGroup("Options"); | 82 | cfg.setGroup("Options"); |
83 | skin = cfg.readEntry("Skin","default"); | 83 | skin = cfg.readEntry("Skin","default"); |
84 | //skin = "scaleTest"; | 84 | //skin = "scaleTest"; |
85 | // color of background, frame, degree of transparency | 85 | // color of background, frame, degree of transparency |
86 | 86 | ||
87 | // QString skinPath = "opieplayer/skins/" + skin; | ||
87 | QString skinPath = "opieplayer2/skins/" + skin; | 88 | QString skinPath = "opieplayer2/skins/" + skin; |
88 | qDebug("skin path "+skinPath); | 89 | qDebug("skin path "+skinPath); |
89 | 90 | ||
90 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 91 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
91 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 92 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
92 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 93 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
93 | 94 | ||
94 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 95 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
95 | imgButtonMask->fill( 0 ); | 96 | imgButtonMask->fill( 0 ); |
96 | 97 | ||
97 | for ( int i = 0; i < 10; i++ ) { | 98 | for ( int i = 0; i < 10; i++ ) { |
98 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; | 99 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; |
99 | masks[i] = new QBitmap( filename ); | 100 | masks[i] = new QBitmap( filename ); |
100 | 101 | ||
101 | if ( !masks[i]->isNull() ) { | 102 | if ( !masks[i]->isNull() ) { |
102 | QImage imgMask = masks[i]->convertToImage(); | 103 | QImage imgMask = masks[i]->convertToImage(); |
103 | uchar **dest = imgButtonMask->jumpTable(); | 104 | uchar **dest = imgButtonMask->jumpTable(); |
104 | for ( int y = 0; y < imgUp->height(); y++ ) { | 105 | for ( int y = 0; y < imgUp->height(); y++ ) { |
105 | uchar *line = dest[y]; | 106 | uchar *line = dest[y]; |
106 | for ( int x = 0; x < imgUp->width(); x++ ) | 107 | for ( int x = 0; x < imgUp->width(); x++ ) |
107 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 108 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
108 | line[x] = i + 1; | 109 | line[x] = i + 1; |
109 | } | 110 | } |
110 | } | 111 | } |
111 | 112 | ||
112 | } | 113 | } |
113 | 114 | ||
114 | for ( int i = 0; i < 11; i++ ) { | 115 | for ( int i = 0; i < 11; i++ ) { |
115 | buttonPixUp[i] = NULL; | 116 | buttonPixUp[i] = NULL; |
116 | buttonPixDown[i] = NULL; | 117 | buttonPixDown[i] = NULL; |
117 | } | 118 | } |
118 | 119 | ||
119 | setBackgroundPixmap( *pixBg ); | 120 | setBackgroundPixmap( *pixBg ); |
120 | 121 | ||
121 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 122 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
122 | 123 | ||
123 | changeTextColor( &songInfo ); | 124 | // changeTextColor( &songInfo ); |
124 | songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 125 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
125 | songInfo.setFrameStyle( QFrame::NoFrame); | 126 | // songInfo.setFrameStyle( QFrame::NoFrame); |
126 | // songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 127 | // songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
127 | //NoFrame | 128 | //NoFrame |
128 | // songInfo.setForegroundColor(Qt::white); | 129 | // songInfo.setForegroundColor(Qt::white); |
129 | 130 | ||
130 | slider.setFixedHeight( 20 ); | 131 | slider.setFixedHeight( 20 ); |
131 | slider.setMinValue( 0 ); | 132 | slider.setMinValue( 0 ); |
132 | slider.setMaxValue( 1 ); | 133 | slider.setMaxValue( 1 ); |
133 | slider.setFocusPolicy( QWidget::NoFocus ); | 134 | slider.setFocusPolicy( QWidget::NoFocus ); |
134 | slider.setBackgroundPixmap( *pixBg ); | 135 | slider.setBackgroundPixmap( *pixBg ); |
135 | 136 | ||
136 | time.setFocusPolicy( QWidget::NoFocus ); | 137 | time.setFocusPolicy( QWidget::NoFocus ); |
137 | time.setAlignment( Qt::AlignCenter ); | 138 | time.setAlignment( Qt::AlignCenter ); |
138 | time.setFrame(FALSE); | 139 | time.setFrame(FALSE); |
139 | changeTextColor( &time ); | 140 | changeTextColor( &time ); |
140 | 141 | ||
141 | resizeEvent( NULL ); | 142 | resizeEvent( NULL ); |
142 | 143 | ||
143 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 144 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
144 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 145 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
145 | 146 | ||
146 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 147 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
147 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 148 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
148 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 149 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
149 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 150 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
150 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 151 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
151 | 152 | ||
152 | // Intialise state | 153 | // Intialise state |
153 | setLength( mediaPlayerState->length() ); | 154 | setLength( mediaPlayerState->length() ); |
154 | setPosition( mediaPlayerState->position() ); | 155 | setPosition( mediaPlayerState->position() ); |
155 | setLooping( mediaPlayerState->fullscreen() ); | 156 | setLooping( mediaPlayerState->fullscreen() ); |
156 | // setPaused( mediaPlayerState->paused() ); | 157 | // setPaused( mediaPlayerState->paused() ); |
157 | setPlaying( mediaPlayerState->playing() ); | 158 | setPlaying( mediaPlayerState->playing() ); |
158 | 159 | ||
159 | } | 160 | } |
160 | 161 | ||
161 | 162 | ||
162 | AudioWidget::~AudioWidget() { | 163 | AudioWidget::~AudioWidget() { |
163 | 164 | ||
164 | for ( int i = 0; i < 10; i++ ) { | 165 | for ( int i = 0; i < 10; i++ ) { |
165 | delete buttonPixUp[i]; | 166 | delete buttonPixUp[i]; |
166 | delete buttonPixDown[i]; | 167 | delete buttonPixDown[i]; |
167 | } | 168 | } |
168 | delete pixBg; | 169 | delete pixBg; |
169 | delete imgUp; | 170 | delete imgUp; |
170 | delete imgDn; | 171 | delete imgDn; |
171 | delete imgButtonMask; | 172 | delete imgButtonMask; |
172 | for ( int i = 0; i < 10; i++ ) { | 173 | for ( int i = 0; i < 10; i++ ) { |
173 | delete masks[i]; | 174 | delete masks[i]; |
174 | } | 175 | } |
175 | } | 176 | } |
176 | 177 | ||
177 | 178 | ||
178 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 179 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
179 | QPixmap pix( img.width(), img.height() ); | 180 | QPixmap pix( img.width(), img.height() ); |
180 | QPainter p( &pix ); | 181 | QPainter p( &pix ); |
181 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 182 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
182 | p.drawImage( 0, 0, img ); | 183 | p.drawImage( 0, 0, img ); |
183 | return new QPixmap( pix ); | 184 | return new QPixmap( pix ); |
184 | } | 185 | } |
185 | 186 | ||
186 | 187 | ||
187 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) | 188 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) |
188 | { | 189 | { |
189 | QPixmap *pixmap = new QPixmap( pix ); | 190 | QPixmap *pixmap = new QPixmap( pix ); |
190 | pixmap->setMask( mask ); | 191 | pixmap->setMask( mask ); |
191 | return pixmap; | 192 | return pixmap; |
192 | } | 193 | } |
193 | 194 | ||
194 | 195 | ||
195 | 196 | ||
196 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 197 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
197 | int h = height(); | 198 | int h = height(); |
198 | int w = width(); | 199 | int w = width(); |
199 | 200 | ||
200 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | 201 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); |
201 | slider.setFixedWidth( w - 110 ); | 202 | slider.setFixedWidth( w - 110 ); |
202 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 203 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
203 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 204 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
204 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 205 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
205 | 206 | ||
206 | xoff = ( w - imgUp->width() ) / 2; | 207 | xoff = ( w - imgUp->width() ) / 2; |
207 | yoff = (( h - imgUp->height() ) / 2) - 10; | 208 | yoff = (( h - imgUp->height() ) / 2) - 10; |
208 | QPoint p( xoff, yoff ); | 209 | QPoint p( xoff, yoff ); |
209 | 210 | ||
210 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); | 211 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); |
211 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); | 212 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); |
212 | 213 | ||
213 | for ( int i = 0; i < 10; i++ ) { | 214 | for ( int i = 0; i < 10; i++ ) { |
214 | if ( !masks[i]->isNull() ) { | 215 | if ( !masks[i]->isNull() ) { |
215 | delete buttonPixUp[i]; | 216 | delete buttonPixUp[i]; |
216 | delete buttonPixDown[i]; | 217 | delete buttonPixDown[i]; |
217 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); | 218 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); |
218 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); | 219 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); |
219 | } | 220 | } |
220 | } | 221 | } |
221 | 222 | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index a937d7c..c28548c 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -151,387 +151,402 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
151 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 151 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
152 | menu->setMargin( 0 ); | 152 | menu->setMargin( 0 ); |
153 | 153 | ||
154 | QPEToolBar *bar = new QPEToolBar( this ); | 154 | QPEToolBar *bar = new QPEToolBar( this ); |
155 | bar->setLabel( tr( "Play Operations" ) ); | 155 | bar->setLabel( tr( "Play Operations" ) ); |
156 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 156 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
157 | // this , SLOT( addSelected()) ); | 157 | // this , SLOT( addSelected()) ); |
158 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 158 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
159 | tbDeletePlaylist->setFlat(TRUE); | 159 | tbDeletePlaylist->setFlat(TRUE); |
160 | tbDeletePlaylist->setFixedSize(20,20); | 160 | tbDeletePlaylist->setFixedSize(20,20); |
161 | 161 | ||
162 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 162 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
163 | this , SLOT(addSelected()) ); | 163 | this , SLOT(addSelected()) ); |
164 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 164 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
165 | this , SLOT(removeSelected()) ); | 165 | this , SLOT(removeSelected()) ); |
166 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 166 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
167 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 167 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
168 | this , SLOT( btnPlay(bool) ), TRUE ); | 168 | this , SLOT( btnPlay(bool) ), TRUE ); |
169 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 169 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
170 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 170 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
171 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 171 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
172 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 172 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
173 | tbDeletePlaylist->hide(); | 173 | tbDeletePlaylist->hide(); |
174 | 174 | ||
175 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 175 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
176 | menu->insertItem( tr( "File" ), pmPlayList ); | 176 | menu->insertItem( tr( "File" ), pmPlayList ); |
177 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 177 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
178 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 178 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
179 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 179 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
180 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 180 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
181 | pmPlayList->insertSeparator(-1); | 181 | pmPlayList->insertSeparator(-1); |
182 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 182 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
183 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 183 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
184 | pmPlayList->insertSeparator(-1); | 184 | pmPlayList->insertSeparator(-1); |
185 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 185 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
186 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 186 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
187 | 187 | ||
188 | QPopupMenu *pmView = new QPopupMenu( this ); | 188 | QPopupMenu *pmView = new QPopupMenu( this ); |
189 | menu->insertItem( tr( "View" ), pmView ); | 189 | menu->insertItem( tr( "View" ), pmView ); |
190 | 190 | ||
191 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 191 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
192 | fullScreenButton->addTo(pmView); | 192 | fullScreenButton->addTo(pmView); |
193 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 193 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
194 | scaleButton->addTo(pmView); | 194 | scaleButton->addTo(pmView); |
195 | 195 | ||
196 | 196 | ||
197 | skinsMenu = new QPopupMenu( this ); | 197 | skinsMenu = new QPopupMenu( this ); |
198 | menu->insertItem( tr( "Skins" ), skinsMenu ); | 198 | menu->insertItem( tr( "Skins" ), skinsMenu ); |
199 | skinsMenu->isCheckable(); | 199 | skinsMenu->isCheckable(); |
200 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 200 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
201 | this, SLOT( skinsMenuActivated( int ) ) ); | 201 | this, SLOT( skinsMenuActivated( int ) ) ); |
202 | populateSkinsMenu(); | 202 | populateSkinsMenu(); |
203 | 203 | ||
204 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 204 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
205 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 205 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
206 | 206 | ||
207 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 207 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
208 | 208 | ||
209 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 209 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
210 | tabWidget->setTabShape(QTabWidget::Triangular); | 210 | tabWidget->setTabShape(QTabWidget::Triangular); |
211 | 211 | ||
212 | QWidget *pTab; | 212 | QWidget *pTab; |
213 | pTab = new QWidget( tabWidget, "pTab" ); | 213 | pTab = new QWidget( tabWidget, "pTab" ); |
214 | // playlistView = new QListView( pTab, "playlistview" ); | 214 | // playlistView = new QListView( pTab, "playlistview" ); |
215 | // playlistView->setMinimumSize(236,260); | 215 | // playlistView->setMinimumSize(236,260); |
216 | tabWidget->insertTab( pTab,"Playlist"); | 216 | tabWidget->insertTab( pTab,"Playlist"); |
217 | 217 | ||
218 | 218 | ||
219 | // Add the playlist area | 219 | // Add the playlist area |
220 | 220 | ||
221 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 221 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
222 | d->playListFrame = vbox3; | 222 | d->playListFrame = vbox3; |
223 | d->playListFrame ->setMinimumSize(235,260); | 223 | d->playListFrame ->setMinimumSize(235,260); |
224 | 224 | ||
225 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 225 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
226 | 226 | ||
227 | d->selectedFiles = new PlayListSelection( hbox2); | 227 | d->selectedFiles = new PlayListSelection( hbox2); |
228 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 228 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
229 | 229 | ||
230 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 230 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
231 | 231 | ||
232 | 232 | ||
233 | 233 | ||
234 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 234 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
235 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 235 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
236 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 236 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
237 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 237 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
238 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 238 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
239 | 239 | ||
240 | QWidget *aTab; | 240 | QWidget *aTab; |
241 | aTab = new QWidget( tabWidget, "aTab" ); | 241 | aTab = new QWidget( tabWidget, "aTab" ); |
242 | audioView = new QListView( aTab, "Audioview" ); | 242 | audioView = new QListView( aTab, "Audioview" ); |
243 | audioView->setMinimumSize(233,260); | 243 | audioView->setMinimumSize(233,260); |
244 | audioView->addColumn( tr("Title"),140); | 244 | audioView->addColumn( tr("Title"),140); |
245 | audioView->addColumn(tr("Size"), -1); | 245 | audioView->addColumn(tr("Size"), -1); |
246 | audioView->addColumn(tr("Media"),-1); | 246 | audioView->addColumn(tr("Media"),-1); |
247 | audioView->addColumn( tr( "Path" ), 0 ); | ||
248 | |||
247 | audioView->setColumnAlignment(1, Qt::AlignRight); | 249 | audioView->setColumnAlignment(1, Qt::AlignRight); |
248 | audioView->setColumnAlignment(2, Qt::AlignRight); | 250 | audioView->setColumnAlignment(2, Qt::AlignRight); |
249 | audioView->setAllColumnsShowFocus(TRUE); | 251 | audioView->setAllColumnsShowFocus(TRUE); |
250 | 252 | ||
251 | audioView->setMultiSelection( TRUE ); | 253 | audioView->setMultiSelection( TRUE ); |
252 | audioView->setSelectionMode( QListView::Extended); | 254 | audioView->setSelectionMode( QListView::Extended); |
253 | 255 | ||
254 | tabWidget->insertTab(aTab,tr("Audio")); | 256 | tabWidget->insertTab(aTab,tr("Audio")); |
255 | 257 | ||
256 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 258 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
257 | 259 | ||
258 | // audioView | 260 | // audioView |
259 | // populateAudioView(); | 261 | // populateAudioView(); |
260 | // videowidget | 262 | // videowidget |
261 | 263 | ||
262 | QWidget *vTab; | 264 | QWidget *vTab; |
263 | vTab = new QWidget( tabWidget, "vTab" ); | 265 | vTab = new QWidget( tabWidget, "vTab" ); |
264 | videoView = new QListView( vTab, "Videoview" ); | 266 | videoView = new QListView( vTab, "Videoview" ); |
265 | videoView->setMinimumSize(233,260); | 267 | videoView->setMinimumSize(233,260); |
266 | 268 | ||
267 | videoView->addColumn(tr("Title"),140); | 269 | videoView->addColumn(tr("Title"),140); |
268 | videoView->addColumn(tr("Size"),-1); | 270 | videoView->addColumn(tr("Size"),-1); |
269 | videoView->addColumn(tr("Media"),-1); | 271 | videoView->addColumn(tr("Media"),-1); |
272 | videoView->addColumn(tr( "Path" ), 0 ); | ||
270 | videoView->setColumnAlignment(1, Qt::AlignRight); | 273 | videoView->setColumnAlignment(1, Qt::AlignRight); |
271 | videoView->setColumnAlignment(2, Qt::AlignRight); | 274 | videoView->setColumnAlignment(2, Qt::AlignRight); |
272 | videoView->setAllColumnsShowFocus(TRUE); | 275 | videoView->setAllColumnsShowFocus(TRUE); |
273 | videoView->setMultiSelection( TRUE ); | 276 | videoView->setMultiSelection( TRUE ); |
274 | videoView->setSelectionMode( QListView::Extended); | 277 | videoView->setSelectionMode( QListView::Extended); |
275 | 278 | ||
276 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 279 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
277 | 280 | ||
278 | tabWidget->insertTab( vTab,tr("Video")); | 281 | tabWidget->insertTab( vTab,tr("Video")); |
279 | 282 | ||
280 | QWidget *LTab; | 283 | QWidget *LTab; |
281 | LTab = new QWidget( tabWidget, "LTab" ); | 284 | LTab = new QWidget( tabWidget, "LTab" ); |
282 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 285 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
283 | playLists->setMinimumSize(233,260); | 286 | playLists->setMinimumSize(233,260); |
284 | tabWidget->insertTab(LTab,tr("Lists")); | 287 | tabWidget->insertTab(LTab,tr("Lists")); |
285 | 288 | ||
286 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 289 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
287 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 290 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
288 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 291 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
289 | 292 | ||
290 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 293 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
291 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 294 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
292 | 295 | ||
293 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 296 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
294 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 297 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
295 | 298 | ||
296 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 299 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
297 | this,SLOT( playIt( QListViewItem *)) ); | 300 | this,SLOT( playIt( QListViewItem *)) ); |
298 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 301 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
299 | 302 | ||
300 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 303 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
301 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 304 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
302 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 305 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
303 | this,SLOT( playIt( QListViewItem *)) ); | 306 | this,SLOT( playIt( QListViewItem *)) ); |
304 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 307 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
305 | 308 | ||
306 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 309 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
307 | 310 | ||
308 | 311 | ||
309 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 312 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
310 | 313 | ||
311 | // connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 314 | // connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
312 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 315 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
313 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 316 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
314 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 317 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
315 | 318 | ||
316 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 319 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
317 | 320 | ||
318 | setCentralWidget( vbox5 ); | 321 | setCentralWidget( vbox5 ); |
319 | 322 | ||
320 | Config cfg( "OpiePlayer" ); | 323 | Config cfg( "OpiePlayer" ); |
321 | readConfig( cfg ); | 324 | readConfig( cfg ); |
322 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 325 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
323 | loadList(DocLnk( currentPlaylist)); | 326 | loadList(DocLnk( currentPlaylist)); |
324 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 327 | setCaption(tr("OpiePlayer: ")+ QFileInfo(currentPlaylist).baseName()); |
325 | 328 | ||
326 | initializeStates(); | 329 | initializeStates(); |
327 | } | 330 | } |
328 | 331 | ||
329 | 332 | ||
330 | PlayListWidget::~PlayListWidget() { | 333 | PlayListWidget::~PlayListWidget() { |
331 | Config cfg( "OpiePlayer" ); | 334 | Config cfg( "OpiePlayer" ); |
332 | writeConfig( cfg ); | 335 | writeConfig( cfg ); |
333 | 336 | ||
334 | if ( d->current ) | 337 | if ( d->current ) |
335 | delete d->current; | 338 | delete d->current; |
336 | delete d; | 339 | delete d; |
337 | } | 340 | } |
338 | 341 | ||
339 | 342 | ||
340 | void PlayListWidget::initializeStates() { | 343 | void PlayListWidget::initializeStates() { |
341 | 344 | ||
342 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 345 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
343 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 346 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
344 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 347 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
345 | setPlaylist( true); | 348 | setPlaylist( true); |
346 | } | 349 | } |
347 | 350 | ||
348 | 351 | ||
349 | void PlayListWidget::readConfig( Config& cfg ) { | 352 | void PlayListWidget::readConfig( Config& cfg ) { |
350 | cfg.setGroup("PlayList"); | 353 | cfg.setGroup("PlayList"); |
351 | QString currentString = cfg.readEntry("current", "" ); | 354 | QString currentString = cfg.readEntry("current", "" ); |
352 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 355 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
353 | for ( int i = 0; i < noOfFiles; i++ ) { | 356 | for ( int i = 0; i < noOfFiles; i++ ) { |
354 | QString entryName; | 357 | QString entryName; |
355 | entryName.sprintf( "File%i", i + 1 ); | 358 | entryName.sprintf( "File%i", i + 1 ); |
356 | QString linkFile = cfg.readEntry( entryName ); | 359 | QString linkFile = cfg.readEntry( entryName ); |
357 | DocLnk lnk( linkFile ); | 360 | DocLnk lnk( linkFile ); |
358 | if ( lnk.isValid() ) { | 361 | if ( lnk.isValid() ) { |
359 | d->selectedFiles->addToSelection( lnk ); | 362 | d->selectedFiles->addToSelection( lnk ); |
360 | } | 363 | } |
361 | } | 364 | } |
362 | d->selectedFiles->setSelectedItem( currentString); | 365 | d->selectedFiles->setSelectedItem( currentString); |
363 | } | 366 | } |
364 | 367 | ||
365 | 368 | ||
366 | void PlayListWidget::writeConfig( Config& cfg ) const { | 369 | void PlayListWidget::writeConfig( Config& cfg ) const { |
367 | 370 | ||
368 | d->selectedFiles->writeCurrent( cfg); | 371 | d->selectedFiles->writeCurrent( cfg); |
369 | cfg.setGroup("PlayList"); | 372 | cfg.setGroup("PlayList"); |
370 | int noOfFiles = 0; | 373 | int noOfFiles = 0; |
371 | d->selectedFiles->first(); | 374 | d->selectedFiles->first(); |
372 | do { | 375 | do { |
373 | const DocLnk *lnk = d->selectedFiles->current(); | 376 | const DocLnk *lnk = d->selectedFiles->current(); |
374 | if ( lnk ) { | 377 | if ( lnk ) { |
375 | QString entryName; | 378 | QString entryName; |
376 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 379 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
377 | // qDebug(entryName); | 380 | // qDebug(entryName); |
378 | cfg.writeEntry( entryName, lnk->linkFile() ); | 381 | cfg.writeEntry( entryName, lnk->linkFile() ); |
379 | // if this link does exist, add it so we have the file | 382 | // if this link does exist, add it so we have the file |
380 | // next time... | 383 | // next time... |
381 | if ( !QFile::exists( lnk->linkFile() ) ) { | 384 | if ( !QFile::exists( lnk->linkFile() ) ) { |
382 | // the way writing lnks doesn't really check for out | 385 | // the way writing lnks doesn't really check for out |
383 | // of disk space, but check it anyway. | 386 | // of disk space, but check it anyway. |
384 | if ( !lnk->writeLink() ) { | 387 | if ( !lnk->writeLink() ) { |
385 | QMessageBox::critical( 0, tr("Out of space"), | 388 | QMessageBox::critical( 0, tr("Out of space"), |
386 | tr( "There was a problem saving " | 389 | tr( "There was a problem saving " |
387 | "the playlist.\n" | 390 | "the playlist.\n" |
388 | "Your playlist " | 391 | "Your playlist " |
389 | "may be missing some entries\n" | 392 | "may be missing some entries\n" |
390 | "the next time you start it." ) | 393 | "the next time you start it." ) |
391 | ); | 394 | ); |
392 | } | 395 | } |
393 | } | 396 | } |
394 | noOfFiles++; | 397 | noOfFiles++; |
395 | } | 398 | } |
396 | } | 399 | } |
397 | while ( d->selectedFiles->next() ); | 400 | while ( d->selectedFiles->next() ); |
398 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 401 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
399 | } | 402 | } |
400 | 403 | ||
401 | 404 | ||
402 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 405 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
403 | d->setDocumentUsed = false; | 406 | d->setDocumentUsed = false; |
404 | if ( mediaPlayerState->playlist() ) { | 407 | if ( mediaPlayerState->playlist() ) { |
405 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 408 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
406 | d->selectedFiles->addToSelection( lnk ); | 409 | d->selectedFiles->addToSelection( lnk ); |
407 | } | 410 | } |
408 | else | 411 | else |
409 | mediaPlayerState->setPlaying( true); | 412 | mediaPlayerState->setPlaying( true); |
410 | } | 413 | } |
411 | 414 | ||
412 | 415 | ||
413 | void PlayListWidget::clearList() { | 416 | void PlayListWidget::clearList() { |
414 | while ( first() ) | 417 | while ( first() ) |
415 | d->selectedFiles->removeSelected(); | 418 | d->selectedFiles->removeSelected(); |
416 | } | 419 | } |
417 | 420 | ||
418 | 421 | ||
419 | void PlayListWidget::addAllToList() { | 422 | void PlayListWidget::addAllToList() { |
420 | DocLnkSet filesAll; | 423 | DocLnkSet filesAll; |
421 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 424 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
422 | QListIterator<DocLnk> Adit( filesAll.children() ); | 425 | QListIterator<DocLnk> Adit( filesAll.children() ); |
423 | for ( ; Adit.current(); ++Adit ) | 426 | for ( ; Adit.current(); ++Adit ) |
424 | if(QFileInfo(Adit.current()->file()).exists()) | 427 | if(QFileInfo(Adit.current()->file()).exists()) |
425 | d->selectedFiles->addToSelection( **Adit ); | 428 | d->selectedFiles->addToSelection( **Adit ); |
429 | tabWidget->setCurrentPage(0); | ||
430 | |||
431 | writeCurrentM3u(); | ||
432 | d->selectedFiles->first(); | ||
426 | } | 433 | } |
427 | 434 | ||
428 | 435 | ||
429 | void PlayListWidget::addAllMusicToList() { | 436 | void PlayListWidget::addAllMusicToList() { |
430 | QListIterator<DocLnk> dit( files.children() ); | 437 | QListIterator<DocLnk> dit( files.children() ); |
431 | for ( ; dit.current(); ++dit ) | 438 | for ( ; dit.current(); ++dit ) |
432 | if(QFileInfo(dit.current()->file()).exists()) | 439 | if(QFileInfo(dit.current()->file()).exists()) |
433 | d->selectedFiles->addToSelection( **dit ); | 440 | d->selectedFiles->addToSelection( **dit ); |
441 | tabWidget->setCurrentPage(0); | ||
442 | |||
443 | writeCurrentM3u(); | ||
444 | d->selectedFiles->first(); | ||
434 | } | 445 | } |
435 | 446 | ||
436 | 447 | ||
437 | void PlayListWidget::addAllVideoToList() { | 448 | void PlayListWidget::addAllVideoToList() { |
438 | QListIterator<DocLnk> dit( vFiles.children() ); | 449 | QListIterator<DocLnk> dit( vFiles.children() ); |
439 | for ( ; dit.current(); ++dit ) | 450 | for ( ; dit.current(); ++dit ) |
440 | if(QFileInfo( dit.current()->file()).exists()) | 451 | if(QFileInfo( dit.current()->file()).exists()) |
441 | d->selectedFiles->addToSelection( **dit ); | 452 | d->selectedFiles->addToSelection( **dit ); |
453 | tabWidget->setCurrentPage(0); | ||
454 | |||
455 | writeCurrentM3u(); | ||
456 | d->selectedFiles->first(); | ||
442 | } | 457 | } |
443 | 458 | ||
444 | 459 | ||
445 | void PlayListWidget::setDocument(const QString& fileref) { | 460 | void PlayListWidget::setDocument(const QString& fileref) { |
446 | qDebug(fileref); | 461 | qDebug(fileref); |
447 | fromSetDocument = TRUE; | 462 | fromSetDocument = TRUE; |
448 | if ( fileref.isNull() ) { | 463 | if ( fileref.isNull() ) { |
449 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 464 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
450 | return; | 465 | return; |
451 | } | 466 | } |
452 | // qDebug("setDocument "+fileref); | 467 | // qDebug("setDocument "+fileref); |
453 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 468 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
454 | readm3u( fileref); | 469 | readm3u( fileref); |
455 | } | 470 | } |
456 | else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 471 | else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
457 | readPls( fileref); | 472 | readPls( fileref); |
458 | } | 473 | } |
459 | else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 474 | else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
460 | clearList(); | 475 | clearList(); |
461 | loadList(DocLnk(fileref)); | 476 | loadList(DocLnk(fileref)); |
462 | d->selectedFiles->first(); | 477 | d->selectedFiles->first(); |
463 | } else { | 478 | } else { |
464 | clearList(); | 479 | clearList(); |
465 | addToSelection( DocLnk( fileref ) ); | 480 | addToSelection( DocLnk( fileref ) ); |
466 | d->setDocumentUsed = TRUE; | 481 | d->setDocumentUsed = TRUE; |
467 | mediaPlayerState->setPlaying( FALSE ); | 482 | mediaPlayerState->setPlaying( FALSE ); |
468 | qApp->processEvents(); | 483 | qApp->processEvents(); |
469 | mediaPlayerState->setPlaying( TRUE ); | 484 | mediaPlayerState->setPlaying( TRUE ); |
470 | qApp->processEvents(); | 485 | qApp->processEvents(); |
471 | setCaption(tr("OpiePlayer")); | 486 | setCaption(tr("OpiePlayer")); |
472 | } | 487 | } |
473 | } | 488 | } |
474 | 489 | ||
475 | 490 | ||
476 | void PlayListWidget::setActiveWindow() { | 491 | void PlayListWidget::setActiveWindow() { |
477 | qDebug("SETTING active window"); | 492 | qDebug("SETTING active window"); |
478 | 493 | ||
479 | // When we get raised we need to ensure that it switches views | 494 | // When we get raised we need to ensure that it switches views |
480 | char origView = mediaPlayerState->view(); | 495 | char origView = mediaPlayerState->view(); |
481 | mediaPlayerState->setView( 'l' ); // invalidate | 496 | mediaPlayerState->setView( 'l' ); // invalidate |
482 | mediaPlayerState->setView( origView ); // now switch back | 497 | mediaPlayerState->setView( origView ); // now switch back |
483 | } | 498 | } |
484 | 499 | ||
485 | 500 | ||
486 | void PlayListWidget::useSelectedDocument() { | 501 | void PlayListWidget::useSelectedDocument() { |
487 | d->setDocumentUsed = FALSE; | 502 | d->setDocumentUsed = FALSE; |
488 | } | 503 | } |
489 | 504 | ||
490 | 505 | ||
491 | const DocLnk *PlayListWidget::current() { // this is fugly | 506 | const DocLnk *PlayListWidget::current() { // this is fugly |
492 | 507 | ||
493 | // if( fromSetDocument) { | 508 | // if( fromSetDocument) { |
494 | // qDebug("from setDoc"); | 509 | // qDebug("from setDoc"); |
495 | // DocLnkSet files; | 510 | // DocLnkSet files; |
496 | // Global::findDocuments(&files, "video/*;audio/*"); | 511 | // Global::findDocuments(&files, "video/*;audio/*"); |
497 | // QListIterator<DocLnk> dit( files.children() ); | 512 | // QListIterator<DocLnk> dit( files.children() ); |
498 | // for ( ; dit.current(); ++dit ) { | 513 | // for ( ; dit.current(); ++dit ) { |
499 | // if(dit.current()->linkFile() == setDocFileRef) { | 514 | // if(dit.current()->linkFile() == setDocFileRef) { |
500 | // qDebug(setDocFileRef); | 515 | // qDebug(setDocFileRef); |
501 | // return dit; | 516 | // return dit; |
502 | // } | 517 | // } |
503 | // } | 518 | // } |
504 | // } else | 519 | // } else |
505 | 520 | ||
506 | qDebug("current"); | 521 | qDebug("current"); |
507 | 522 | ||
508 | switch (tabWidget->currentPageIndex()) { | 523 | switch (tabWidget->currentPageIndex()) { |
509 | case 0: //playlist | 524 | case 0: //playlist |
510 | { | 525 | { |
511 | qDebug("playlist"); | 526 | qDebug("playlist"); |
512 | if ( mediaPlayerState->playlist() ) { | 527 | if ( mediaPlayerState->playlist() ) { |
513 | return d->selectedFiles->current(); | 528 | return d->selectedFiles->current(); |
514 | } | 529 | } |
515 | else if ( d->setDocumentUsed && d->current ) { | 530 | else if ( d->setDocumentUsed && d->current ) { |
516 | return d->current; | 531 | return d->current; |
517 | } else { | 532 | } else { |
518 | return &(d->files->selectedDocument()); | 533 | return &(d->files->selectedDocument()); |
519 | } | 534 | } |
520 | } | 535 | } |
521 | break; | 536 | break; |
522 | case 1://audio | 537 | case 1://audio |
523 | { | 538 | { |
524 | qDebug("audioView"); | 539 | qDebug("audioView"); |
525 | QListIterator<DocLnk> dit( files.children() ); | 540 | QListIterator<DocLnk> dit( files.children() ); |
526 | for ( ; dit.current(); ++dit ) { | 541 | for ( ; dit.current(); ++dit ) { |
527 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 542 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
528 | qDebug("here"); | 543 | qDebug("here"); |
529 | insanityBool=TRUE; | 544 | insanityBool=TRUE; |
530 | return dit; | 545 | return dit; |
531 | } | 546 | } |
532 | } | 547 | } |
533 | } | 548 | } |
534 | break; | 549 | break; |
535 | case 2: // video | 550 | case 2: // video |
536 | { | 551 | { |
537 | qDebug("videoView"); | 552 | qDebug("videoView"); |
@@ -552,296 +567,256 @@ bool PlayListWidget::prev() { | |||
552 | if ( mediaPlayerState->playlist() ) { | 567 | if ( mediaPlayerState->playlist() ) { |
553 | if ( mediaPlayerState->shuffled() ) { | 568 | if ( mediaPlayerState->shuffled() ) { |
554 | const DocLnk *cur = current(); | 569 | const DocLnk *cur = current(); |
555 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 570 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
556 | for ( int i = 0; i < j; i++ ) { | 571 | for ( int i = 0; i < j; i++ ) { |
557 | if ( !d->selectedFiles->next() ) | 572 | if ( !d->selectedFiles->next() ) |
558 | d->selectedFiles->first(); | 573 | d->selectedFiles->first(); |
559 | } | 574 | } |
560 | if ( cur == current() ) | 575 | if ( cur == current() ) |
561 | if ( !d->selectedFiles->next() ) | 576 | if ( !d->selectedFiles->next() ) |
562 | d->selectedFiles->first(); | 577 | d->selectedFiles->first(); |
563 | return TRUE; | 578 | return TRUE; |
564 | } else { | 579 | } else { |
565 | if ( !d->selectedFiles->prev() ) { | 580 | if ( !d->selectedFiles->prev() ) { |
566 | if ( mediaPlayerState->looping() ) { | 581 | if ( mediaPlayerState->looping() ) { |
567 | return d->selectedFiles->last(); | 582 | return d->selectedFiles->last(); |
568 | } else { | 583 | } else { |
569 | return FALSE; | 584 | return FALSE; |
570 | } | 585 | } |
571 | } | 586 | } |
572 | return TRUE; | 587 | return TRUE; |
573 | } | 588 | } |
574 | } else { | 589 | } else { |
575 | return mediaPlayerState->looping(); | 590 | return mediaPlayerState->looping(); |
576 | } | 591 | } |
577 | } | 592 | } |
578 | 593 | ||
579 | 594 | ||
580 | bool PlayListWidget::next() { | 595 | bool PlayListWidget::next() { |
581 | if ( mediaPlayerState->playlist() ) { | 596 | if ( mediaPlayerState->playlist() ) { |
582 | if ( mediaPlayerState->shuffled() ) { | 597 | if ( mediaPlayerState->shuffled() ) { |
583 | return prev(); | 598 | return prev(); |
584 | } else { | 599 | } else { |
585 | if ( !d->selectedFiles->next() ) { | 600 | if ( !d->selectedFiles->next() ) { |
586 | if ( mediaPlayerState->looping() ) { | 601 | if ( mediaPlayerState->looping() ) { |
587 | return d->selectedFiles->first(); | 602 | return d->selectedFiles->first(); |
588 | } else { | 603 | } else { |
589 | return FALSE; | 604 | return FALSE; |
590 | } | 605 | } |
591 | } | 606 | } |
592 | return TRUE; | 607 | return TRUE; |
593 | } | 608 | } |
594 | } else { | 609 | } else { |
595 | return mediaPlayerState->looping(); | 610 | return mediaPlayerState->looping(); |
596 | } | 611 | } |
597 | } | 612 | } |
598 | 613 | ||
599 | 614 | ||
600 | bool PlayListWidget::first() { | 615 | bool PlayListWidget::first() { |
601 | if ( mediaPlayerState->playlist() ) | 616 | if ( mediaPlayerState->playlist() ) |
602 | return d->selectedFiles->first(); | 617 | return d->selectedFiles->first(); |
603 | else | 618 | else |
604 | return mediaPlayerState->looping(); | 619 | return mediaPlayerState->looping(); |
605 | } | 620 | } |
606 | 621 | ||
607 | 622 | ||
608 | bool PlayListWidget::last() { | 623 | bool PlayListWidget::last() { |
609 | if ( mediaPlayerState->playlist() ) | 624 | if ( mediaPlayerState->playlist() ) |
610 | return d->selectedFiles->last(); | 625 | return d->selectedFiles->last(); |
611 | else | 626 | else |
612 | return mediaPlayerState->looping(); | 627 | return mediaPlayerState->looping(); |
613 | } | 628 | } |
614 | 629 | ||
615 | 630 | ||
616 | void PlayListWidget::saveList() { | 631 | void PlayListWidget::saveList() { |
617 | writem3u(); | 632 | writem3u(); |
618 | } | 633 | } |
619 | 634 | ||
620 | void PlayListWidget::loadList( const DocLnk & lnk) { | 635 | void PlayListWidget::loadList( const DocLnk & lnk) { |
621 | QString name = lnk.name(); | 636 | QString name = lnk.name(); |
622 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 637 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
623 | 638 | ||
624 | if( name.length()>0) { | 639 | if( name.length()>0) { |
625 | setCaption("OpiePlayer: "+name); | 640 | setCaption("OpiePlayer: "+name); |
626 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 641 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
627 | clearList(); | 642 | clearList(); |
628 | readm3u(lnk.file()); | 643 | readm3u(lnk.file()); |
629 | tabWidget->setCurrentPage(0); | 644 | tabWidget->setCurrentPage(0); |
630 | } | 645 | } |
631 | } | 646 | } |
632 | 647 | ||
633 | void PlayListWidget::setPlaylist( bool shown ) { | 648 | void PlayListWidget::setPlaylist( bool shown ) { |
634 | if ( shown ) | 649 | if ( shown ) |
635 | d->playListFrame->show(); | 650 | d->playListFrame->show(); |
636 | else | 651 | else |
637 | d->playListFrame->hide(); | 652 | d->playListFrame->hide(); |
638 | } | 653 | } |
639 | 654 | ||
640 | void PlayListWidget::setView( char view ) { | 655 | void PlayListWidget::setView( char view ) { |
641 | if ( view == 'l' ) | 656 | if ( view == 'l' ) |
642 | showMaximized(); | 657 | showMaximized(); |
643 | else | 658 | else |
644 | hide(); | 659 | hide(); |
645 | } | 660 | } |
646 | 661 | ||
647 | void PlayListWidget::addSelected() { | 662 | void PlayListWidget::addSelected() { |
663 | qDebug("addSelected"); | ||
664 | DocLnk lnk; | ||
665 | QString filename; | ||
666 | switch (tabWidget->currentPageIndex()) { | ||
648 | 667 | ||
649 | Config cfg( "OpiePlayer" ); | 668 | case 0: //playlist |
650 | cfg.setGroup("PlayList"); | 669 | return; |
651 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 670 | break; |
652 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 671 | case 1: { //audio |
672 | filename=audioView->currentItem()->text(3); | ||
673 | // d->selectedFiles->next(); | ||
674 | } | ||
675 | break; | ||
676 | |||
677 | case 2: { // video | ||
678 | filename=videoView->currentItem()->text(3); | ||
679 | // tabWidget->setCurrentPage(0); | ||
680 | |||
681 | } | ||
682 | break; | ||
683 | }; | ||
684 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | ||
685 | lnk.setFile( filename ); //sets file name | ||
686 | d->selectedFiles->addToSelection( lnk); | ||
687 | tabWidget->setCurrentPage(0); | ||
688 | writeCurrentM3u(); | ||
653 | 689 | ||
654 | switch (tabWidget->currentPageIndex()) { | ||
655 | case 0: //playlist | ||
656 | break; | ||
657 | case 1: { //audio | ||
658 | // QString entryName; | ||
659 | // entryName.sprintf( "File%i", i + 1 ); | ||
660 | // QString linkFile = cfg.readEntry( entryName ); | ||
661 | QListViewItemIterator it( audioView ); | ||
662 | // iterate through all items of the listview | ||
663 | for ( ; it.current(); ++it ) { | ||
664 | if ( it.current()->isSelected() ) { | ||
665 | QListIterator<DocLnk> dit( files.children() ); | ||
666 | for ( ; dit.current(); ++dit ) { | ||
667 | if( dit.current()->name() == it.current()->text(0) ) { | ||
668 | d->selectedFiles->addToSelection( **dit ); | ||
669 | } | ||
670 | } | ||
671 | audioView->setSelected( it.current(),FALSE); | ||
672 | } | ||
673 | } | ||
674 | tabWidget->setCurrentPage(0); | ||
675 | } | ||
676 | break; | ||
677 | case 2: { // video | ||
678 | QListViewItemIterator it( videoView ); | ||
679 | // iterate through all items of the listview | ||
680 | for ( ; it.current(); ++it ) { | ||
681 | if ( it.current()->isSelected() ) { | ||
682 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
683 | for ( ; dit.current(); ++dit ) { | ||
684 | if( dit.current()->name() == it.current()->text(0) ) { | ||
685 | d->selectedFiles->addToSelection( **dit ); | ||
686 | } | ||
687 | } | ||
688 | |||
689 | videoView->setSelected( it.current(),FALSE); | ||
690 | } | ||
691 | } | ||
692 | // for ( int i = 0; i < noOfFiles; i++ ) { | ||
693 | // QString entryName; | ||
694 | // entryName.sprintf( "File%i", i + 1 ); | ||
695 | // QString linkFile = cfg.readEntry( entryName ); | ||
696 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | ||
697 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), | ||
698 | // tr("This is all ready in your playlist.\nContinue?"), | ||
699 | // tr("Yes"),tr("No"),0,0,1); | ||
700 | // if (result !=0) | ||
701 | // return; | ||
702 | // } | ||
703 | // } | ||
704 | // addToSelection( videoView->selectedItem() ); | ||
705 | tabWidget->setCurrentPage(0); | ||
706 | } | ||
707 | break; | ||
708 | }; | ||
709 | } | 690 | } |
710 | 691 | ||
711 | void PlayListWidget::removeSelected() { | 692 | void PlayListWidget::removeSelected() { |
712 | d->selectedFiles->removeSelected( ); | 693 | d->selectedFiles->removeSelected( ); |
713 | } | 694 | } |
714 | 695 | ||
715 | void PlayListWidget::playIt( QListViewItem *) { | 696 | void PlayListWidget::playIt( QListViewItem *) { |
716 | // d->setDocumentUsed = FALSE; | 697 | // d->setDocumentUsed = FALSE; |
717 | // mediaPlayerState->curPosition =0; | 698 | // mediaPlayerState->curPosition =0; |
718 | qDebug("playIt"); | 699 | qDebug("playIt"); |
719 | mediaPlayerState->setPlaying(FALSE); | 700 | mediaPlayerState->setPlaying(FALSE); |
720 | mediaPlayerState->setPlaying(TRUE); | 701 | mediaPlayerState->setPlaying(TRUE); |
721 | d->selectedFiles->unSelect(); | 702 | d->selectedFiles->unSelect(); |
722 | } | 703 | } |
723 | 704 | ||
724 | void PlayListWidget::addToSelection( QListViewItem *it) { | 705 | void PlayListWidget::addToSelection( QListViewItem *it) { |
725 | d->setDocumentUsed = FALSE; | 706 | d->setDocumentUsed = FALSE; |
726 | 707 | ||
727 | if(it) { | 708 | if(it) { |
728 | switch (tabWidget->currentPageIndex()) { | 709 | switch ( tabWidget->currentPageIndex()) { |
729 | case 1: { | 710 | case 0: //playlist |
730 | QListIterator<DocLnk> dit( files.children() ); | 711 | return; |
731 | for ( ; dit.current(); ++dit ) { | 712 | break; |
732 | if( dit.current()->name() == it->text(0)) { | 713 | }; |
733 | d->selectedFiles->addToSelection( **dit ); | 714 | // case 1: { |
734 | } | 715 | DocLnk lnk; |
735 | } | 716 | QString filename; |
736 | } | 717 | |
737 | break; | 718 | filename=it->text(3); |
738 | case 2: { | 719 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
739 | QListIterator<DocLnk> dit( vFiles.children() ); | 720 | lnk.setFile( filename ); //sets file name |
740 | for ( ; dit.current(); ++dit ) { | 721 | d->selectedFiles->addToSelection( lnk); |
741 | if( dit.current()->name() == it->text(0)) { | 722 | |
742 | d->selectedFiles->addToSelection( **dit ); | 723 | writeCurrentM3u(); |
743 | } | 724 | tabWidget->setCurrentPage(0); |
744 | } | 725 | |
745 | } | 726 | } |
746 | break; | ||
747 | case 0: | ||
748 | break; | ||
749 | }; | ||
750 | tabWidget->setCurrentPage(0); | ||
751 | } | ||
752 | } | 727 | } |
753 | 728 | ||
754 | void PlayListWidget::tabChanged(QWidget *) { | 729 | void PlayListWidget::tabChanged(QWidget *) { |
755 | 730 | ||
756 | switch ( tabWidget->currentPageIndex()) { | 731 | switch ( tabWidget->currentPageIndex()) { |
757 | case 0: | 732 | case 0: |
758 | { | 733 | { |
759 | if( !tbDeletePlaylist->isHidden()) | 734 | if( !tbDeletePlaylist->isHidden()) |
760 | tbDeletePlaylist->hide(); | 735 | tbDeletePlaylist->hide(); |
761 | d->tbRemoveFromList->setEnabled(TRUE); | 736 | d->tbRemoveFromList->setEnabled(TRUE); |
762 | d->tbAddToList->setEnabled(FALSE); | 737 | d->tbAddToList->setEnabled(FALSE); |
763 | } | 738 | } |
764 | break; | 739 | break; |
765 | case 1: | 740 | case 1: |
766 | { | 741 | { |
767 | audioView->clear(); | 742 | audioView->clear(); |
768 | populateAudioView(); | 743 | populateAudioView(); |
769 | 744 | ||
770 | if( !tbDeletePlaylist->isHidden()) | 745 | if( !tbDeletePlaylist->isHidden()) |
771 | tbDeletePlaylist->hide(); | 746 | tbDeletePlaylist->hide(); |
772 | d->tbRemoveFromList->setEnabled(FALSE); | 747 | d->tbRemoveFromList->setEnabled(FALSE); |
773 | d->tbAddToList->setEnabled(TRUE); | 748 | d->tbAddToList->setEnabled(TRUE); |
774 | } | 749 | } |
775 | break; | 750 | break; |
776 | case 2: | 751 | case 2: |
777 | { | 752 | { |
778 | videoView->clear(); | 753 | videoView->clear(); |
779 | populateVideoView(); | 754 | populateVideoView(); |
780 | if( !tbDeletePlaylist->isHidden()) | 755 | if( !tbDeletePlaylist->isHidden()) |
781 | tbDeletePlaylist->hide(); | 756 | tbDeletePlaylist->hide(); |
782 | d->tbRemoveFromList->setEnabled(FALSE); | 757 | d->tbRemoveFromList->setEnabled(FALSE); |
783 | d->tbAddToList->setEnabled(TRUE); | 758 | d->tbAddToList->setEnabled(TRUE); |
784 | } | 759 | } |
785 | break; | 760 | break; |
786 | case 3: | 761 | case 3: |
787 | { | 762 | { |
788 | if( tbDeletePlaylist->isHidden()) | 763 | if( tbDeletePlaylist->isHidden()) |
789 | tbDeletePlaylist->show(); | 764 | tbDeletePlaylist->show(); |
790 | playLists->reread(); | 765 | playLists->reread(); |
791 | } | 766 | } |
792 | break; | 767 | break; |
793 | }; | 768 | }; |
794 | } | 769 | } |
795 | 770 | ||
796 | void PlayListWidget::btnPlay(bool b) { | 771 | void PlayListWidget::btnPlay(bool b) { |
797 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); | 772 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); |
798 | // mediaPlayerState->setPlaying(b); | 773 | // mediaPlayerState->setPlaying(b); |
799 | switch ( tabWidget->currentPageIndex()) { | 774 | switch ( tabWidget->currentPageIndex()) { |
800 | case 0: | 775 | case 0: |
801 | { | 776 | { |
802 | qDebug("1"); | 777 | qDebug("1"); |
803 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 778 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
804 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 779 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
805 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 780 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
806 | // } else { | 781 | // } else { |
807 | mediaPlayerState->setPlaying(b); | 782 | mediaPlayerState->setPlaying(b); |
808 | insanityBool=FALSE; | 783 | insanityBool=FALSE; |
809 | qDebug("insanity"); | 784 | qDebug("insanity"); |
810 | // } | 785 | // } |
811 | } | 786 | } |
812 | break; | 787 | break; |
813 | case 1: | 788 | case 1: |
814 | { | 789 | { |
815 | qDebug("2"); | 790 | qDebug("2"); |
816 | addToSelection( audioView->currentItem() ); | 791 | addToSelection( audioView->currentItem() ); |
817 | mediaPlayerState->setPlaying(b); | 792 | mediaPlayerState->setPlaying(b); |
818 | d->selectedFiles->removeSelected( ); | 793 | d->selectedFiles->removeSelected( ); |
819 | tabWidget->setCurrentPage(1); | 794 | tabWidget->setCurrentPage(1); |
820 | d->selectedFiles->unSelect(); | 795 | d->selectedFiles->unSelect(); |
821 | insanityBool=FALSE; | 796 | insanityBool=FALSE; |
822 | }// audioView->clearSelection(); | 797 | }// audioView->clearSelection(); |
823 | break; | 798 | break; |
824 | case 2: | 799 | case 2: |
825 | { | 800 | { |
826 | qDebug("3"); | 801 | qDebug("3"); |
827 | 802 | ||
828 | addToSelection( videoView->currentItem() ); | 803 | addToSelection( videoView->currentItem() ); |
829 | mediaPlayerState->setPlaying(b); | 804 | mediaPlayerState->setPlaying(b); |
830 | qApp->processEvents(); | 805 | qApp->processEvents(); |
831 | d->selectedFiles->removeSelected( ); | 806 | d->selectedFiles->removeSelected( ); |
832 | tabWidget->setCurrentPage(2); | 807 | tabWidget->setCurrentPage(2); |
833 | d->selectedFiles->unSelect(); | 808 | d->selectedFiles->unSelect(); |
834 | insanityBool=FALSE; | 809 | insanityBool=FALSE; |
835 | }// videoView->clearSelection(); | 810 | }// videoView->clearSelection(); |
836 | break; | 811 | break; |
837 | }; | 812 | }; |
838 | 813 | ||
839 | } | 814 | } |
840 | 815 | ||
841 | void PlayListWidget::deletePlaylist() { | 816 | void PlayListWidget::deletePlaylist() { |
842 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 817 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
843 | (tr("You really want to delete\nthis playlist?")), | 818 | (tr("You really want to delete\nthis playlist?")), |
844 | (tr("Yes")), (tr("No")), 0 )){ | 819 | (tr("Yes")), (tr("No")), 0 )){ |
845 | case 0: // Yes clicked, | 820 | case 0: // Yes clicked, |
846 | QFile().remove(playLists->selectedDocument().file()); | 821 | QFile().remove(playLists->selectedDocument().file()); |
847 | QFile().remove(playLists->selectedDocument().linkFile()); | 822 | QFile().remove(playLists->selectedDocument().linkFile()); |
@@ -896,385 +871,387 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoi | |||
896 | break; | 871 | break; |
897 | }; | 872 | }; |
898 | 873 | ||
899 | } | 874 | } |
900 | 875 | ||
901 | void PlayListWidget::listDelete() { | 876 | void PlayListWidget::listDelete() { |
902 | Config cfg( "OpiePlayer" ); | 877 | Config cfg( "OpiePlayer" ); |
903 | cfg.setGroup("PlayList"); | 878 | cfg.setGroup("PlayList"); |
904 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 879 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
905 | QString file; | 880 | QString file; |
906 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 881 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
907 | switch ( tabWidget->currentPageIndex()) { | 882 | switch ( tabWidget->currentPageIndex()) { |
908 | case 0: | 883 | case 0: |
909 | break; | 884 | break; |
910 | case 1: | 885 | case 1: |
911 | { | 886 | { |
912 | file = audioView->currentItem()->text(0); | 887 | file = audioView->currentItem()->text(0); |
913 | QListIterator<DocLnk> Pdit( files.children() ); | 888 | QListIterator<DocLnk> Pdit( files.children() ); |
914 | for ( ; Pdit.current(); ++Pdit ) { | 889 | for ( ; Pdit.current(); ++Pdit ) { |
915 | if( Pdit.current()->name() == file) { | 890 | if( Pdit.current()->name() == file) { |
916 | LnkProperties prop( Pdit.current() ); | 891 | LnkProperties prop( Pdit.current() ); |
917 | prop.showMaximized(); | 892 | prop.showMaximized(); |
918 | prop.exec(); | 893 | prop.exec(); |
919 | } | 894 | } |
920 | } | 895 | } |
921 | populateAudioView(); | 896 | populateAudioView(); |
922 | } | 897 | } |
923 | break; | 898 | break; |
924 | case 2: | 899 | case 2: |
925 | { | 900 | { |
926 | // file = videoView->selectedItem()->text(0); | 901 | // file = videoView->selectedItem()->text(0); |
927 | // for ( int i = 0; i < noOfFiles; i++ ) { | 902 | // for ( int i = 0; i < noOfFiles; i++ ) { |
928 | // QString entryName; | 903 | // QString entryName; |
929 | // entryName.sprintf( "File%i", i + 1 ); | 904 | // entryName.sprintf( "File%i", i + 1 ); |
930 | // QString linkFile = cfg.readEntry( entryName ); | 905 | // QString linkFile = cfg.readEntry( entryName ); |
931 | // AppLnk lnk( AppLnk(linkFile)); | 906 | // AppLnk lnk( AppLnk(linkFile)); |
932 | // if( lnk.name() == file ) { | 907 | // if( lnk.name() == file ) { |
933 | // LnkProperties prop( &lnk); | 908 | // LnkProperties prop( &lnk); |
934 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 909 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
935 | // prop.showMaximized(); | 910 | // prop.showMaximized(); |
936 | // prop.exec(); | 911 | // prop.exec(); |
937 | // } | 912 | // } |
938 | // } | 913 | // } |
939 | } | 914 | } |
940 | break; | 915 | break; |
941 | }; | 916 | }; |
942 | } | 917 | } |
943 | 918 | ||
944 | void PlayListWidget::scanForAudio() { | 919 | void PlayListWidget::scanForAudio() { |
945 | // qDebug("scan for audio"); | 920 | // qDebug("scan for audio"); |
946 | files.detachChildren(); | 921 | files.detachChildren(); |
947 | QListIterator<DocLnk> sdit( files.children() ); | 922 | QListIterator<DocLnk> sdit( files.children() ); |
948 | for ( ; sdit.current(); ++sdit ) { | 923 | for ( ; sdit.current(); ++sdit ) { |
949 | delete sdit.current(); | 924 | delete sdit.current(); |
950 | } | 925 | } |
951 | Global::findDocuments( &files, audioMimes); | 926 | Global::findDocuments( &files, audioMimes); |
952 | audioScan = true; | 927 | audioScan = true; |
953 | } | 928 | } |
954 | void PlayListWidget::scanForVideo() { | 929 | void PlayListWidget::scanForVideo() { |
955 | // qDebug("scan for video"); | 930 | // qDebug("scan for video"); |
956 | vFiles.detachChildren(); | 931 | vFiles.detachChildren(); |
957 | QListIterator<DocLnk> sdit( vFiles.children() ); | 932 | QListIterator<DocLnk> sdit( vFiles.children() ); |
958 | for ( ; sdit.current(); ++sdit ) { | 933 | for ( ; sdit.current(); ++sdit ) { |
959 | delete sdit.current(); | 934 | delete sdit.current(); |
960 | } | 935 | } |
961 | Global::findDocuments(&vFiles, "video/*"); | 936 | Global::findDocuments(&vFiles, "video/*"); |
962 | videoScan = true; | 937 | videoScan = true; |
963 | } | 938 | } |
964 | 939 | ||
965 | void PlayListWidget::populateAudioView() { | 940 | void PlayListWidget::populateAudioView() { |
966 | 941 | ||
967 | audioView->clear(); | 942 | audioView->clear(); |
968 | StorageInfo storageInfo; | 943 | StorageInfo storageInfo; |
969 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 944 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
970 | if(!audioScan) scanForAudio(); | 945 | if(!audioScan) scanForAudio(); |
971 | 946 | ||
972 | QListIterator<DocLnk> dit( files.children() ); | 947 | QListIterator<DocLnk> dit( files.children() ); |
973 | QListIterator<FileSystem> it ( fs ); | 948 | QListIterator<FileSystem> it ( fs ); |
974 | 949 | ||
975 | QString storage; | 950 | QString storage; |
976 | for ( ; dit.current(); ++dit ) { | 951 | for ( ; dit.current(); ++dit ) { |
977 | for( ; it.current(); ++it ){ | 952 | for( ; it.current(); ++it ){ |
978 | const QString name = (*it)->name(); | 953 | const QString name = (*it)->name(); |
979 | const QString path = (*it)->path(); | 954 | const QString path = (*it)->path(); |
980 | if(dit.current()->file().find(path) != -1 ) storage=name; | 955 | if(dit.current()->file().find(path) != -1 ) storage=name; |
981 | } | 956 | } |
982 | 957 | ||
983 | QListViewItem * newItem; | 958 | QListViewItem * newItem; |
984 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 959 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
985 | long size; | 960 | long size; |
986 | if( dit.current()->file().left(4) == "http" ) | 961 | if( dit.current()->file().left(4) == "http" ) |
987 | size=0; | 962 | size=0; |
988 | else | 963 | else |
989 | size = QFile( dit.current()->file() ).size(); | 964 | size = QFile( dit.current()->file() ).size(); |
990 | // qDebug(dit.current()->name()); | 965 | // qDebug(dit.current()->name()); |
991 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 966 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
992 | QString::number(size ), storage); | 967 | QString::number(size ), storage, dit.current()->file()); |
993 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 968 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
994 | } | 969 | } |
995 | } | 970 | } |
996 | 971 | ||
997 | } | 972 | } |
998 | 973 | ||
999 | void PlayListWidget::populateVideoView() { | 974 | void PlayListWidget::populateVideoView() { |
1000 | videoView->clear(); | 975 | videoView->clear(); |
1001 | StorageInfo storageInfo; | 976 | StorageInfo storageInfo; |
1002 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 977 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1003 | 978 | ||
1004 | if(!videoScan ) scanForVideo(); | 979 | if(!videoScan ) scanForVideo(); |
1005 | 980 | ||
1006 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 981 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1007 | QListIterator<FileSystem> it ( fs ); | 982 | QListIterator<FileSystem> it ( fs ); |
1008 | videoView->clear(); | 983 | videoView->clear(); |
1009 | QString storage; | 984 | QString storage; |
1010 | for ( ; Vdit.current(); ++Vdit ) { | 985 | for ( ; Vdit.current(); ++Vdit ) { |
1011 | for( ; it.current(); ++it ){ | 986 | for( ; it.current(); ++it ){ |
1012 | const QString name = (*it)->name(); | 987 | const QString name = (*it)->name(); |
1013 | const QString path = (*it)->path(); | 988 | const QString path = (*it)->path(); |
1014 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 989 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1015 | } | 990 | } |
1016 | 991 | ||
1017 | QListViewItem * newItem; | 992 | QListViewItem * newItem; |
1018 | if ( QFile( Vdit.current()->file()).exists() ) { | 993 | if ( QFile( Vdit.current()->file()).exists() ) { |
1019 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 994 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1020 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 995 | QString::number( QFile( Vdit.current()->file() ).size() ), |
996 | storage, Vdit.current()->file()); | ||
1021 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 997 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1022 | } | 998 | } |
1023 | } | 999 | } |
1024 | } | 1000 | } |
1025 | 1001 | ||
1026 | void PlayListWidget::openFile() { | 1002 | void PlayListWidget::openFile() { |
1027 | qDebug("<<<<<<<<<OPEN File"); | 1003 | qDebug("<<<<<<<<<OPEN File"); |
1028 | QString filename, name; | 1004 | QString filename, name; |
1029 | InputDialog *fileDlg; | 1005 | InputDialog *fileDlg; |
1030 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1006 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1031 | fileDlg->exec(); | 1007 | fileDlg->exec(); |
1032 | if( fileDlg->result() == 1 ) { | 1008 | if( fileDlg->result() == 1 ) { |
1033 | filename = fileDlg->text(); | 1009 | filename = fileDlg->text(); |
1034 | qDebug( "Selected filename is " + filename ); | 1010 | qDebug( "Selected filename is " + filename ); |
1035 | // Om3u *m3uList; | 1011 | // Om3u *m3uList; |
1036 | DocLnk lnk; | 1012 | DocLnk lnk; |
1037 | Config cfg( "OpiePlayer" ); | 1013 | Config cfg( "OpiePlayer" ); |
1038 | cfg.setGroup("PlayList"); | 1014 | cfg.setGroup("PlayList"); |
1039 | 1015 | ||
1040 | if(filename.left(4) == "http") { | 1016 | if(filename.left(4) == "http") { |
1041 | QString m3uFile, m3uFilePath; | 1017 | QString m3uFile, m3uFilePath; |
1042 | if(filename.find(":",8,TRUE) != -1) { //found a port | 1018 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1043 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 1019 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
1044 | m3uFile = m3uFile.right( 7); | 1020 | m3uFile = m3uFile.right( 7); |
1045 | } else if(filename.left(4) == "http"){ | 1021 | } else if(filename.left(4) == "http"){ |
1046 | m3uFile=filename; | 1022 | m3uFile=filename; |
1047 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 1023 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
1048 | } else{ | 1024 | } else{ |
1049 | m3uFile=filename; | 1025 | m3uFile=filename; |
1050 | } | 1026 | } |
1051 | 1027 | ||
1052 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 1028 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
1053 | lnk.setName( filename ); //sets name | 1029 | lnk.setName( filename ); //sets name |
1054 | lnk.setFile( filename ); //sets file name | 1030 | lnk.setFile( filename ); //sets file name |
1055 | lnk.setIcon("opieplayer2/musicfile"); | 1031 | lnk.setIcon("opieplayer2/musicfile"); |
1056 | d->selectedFiles->addToSelection( lnk ); | 1032 | d->selectedFiles->addToSelection( lnk ); |
1057 | writeCurrentM3u(); | 1033 | writeCurrentM3u(); |
1058 | } | 1034 | } |
1059 | else if( filename.right( 3) == "m3u" ) { | 1035 | else if( filename.right( 3) == "m3u" ) { |
1060 | readm3u( filename ); | 1036 | readm3u( filename ); |
1061 | 1037 | ||
1062 | } else if( filename.right(3) == "pls" ) { | 1038 | } else if( filename.right(3) == "pls" ) { |
1063 | readPls( filename ); | 1039 | readPls( filename ); |
1064 | } else { | 1040 | } else { |
1065 | d->selectedFiles->addToSelection( DocLnk(filename) ); | 1041 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
1042 | lnk.setFile( filename ); //sets file name | ||
1043 | d->selectedFiles->addToSelection( lnk); | ||
1066 | writeCurrentM3u(); | 1044 | writeCurrentM3u(); |
1067 | } | 1045 | } |
1068 | } | 1046 | } |
1069 | 1047 | ||
1070 | if( fileDlg ) { | 1048 | if( fileDlg ) { |
1071 | delete fileDlg; | 1049 | delete fileDlg; |
1072 | } | 1050 | } |
1073 | } | 1051 | } |
1074 | 1052 | ||
1075 | 1053 | ||
1076 | /* | 1054 | /* |
1077 | reads m3u and shows files/urls to playlist widget */ | 1055 | reads m3u and shows files/urls to playlist widget */ |
1078 | void PlayListWidget::readm3u( const QString &filename ) { | 1056 | void PlayListWidget::readm3u( const QString &filename ) { |
1079 | qDebug( "read m3u filename " + filename ); | 1057 | qDebug( "read m3u filename " + filename ); |
1080 | 1058 | ||
1081 | Om3u *m3uList; | 1059 | Om3u *m3uList; |
1082 | QString s, name; | 1060 | QString s, name; |
1083 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1061 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1084 | m3uList->readM3u(); | 1062 | m3uList->readM3u(); |
1085 | DocLnk lnk; | 1063 | DocLnk lnk; |
1086 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1064 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1087 | s = *it; | 1065 | s = *it; |
1088 | // qDebug("reading "+ s); | 1066 | // qDebug("reading "+ s); |
1089 | if(s.left(4)=="http") { | 1067 | if(s.left(4)=="http") { |
1090 | lnk.setName( s ); //sets file name | 1068 | lnk.setName( s ); //sets file name |
1091 | lnk.setIcon("opieplayer2/musicfile"); | 1069 | lnk.setIcon("opieplayer2/musicfile"); |
1092 | if(s.right(4) != '.' || s.right(5) != '.') | 1070 | if(s.right(4) != '.' || s.right(5) != '.') |
1093 | lnk.setFile( s+"/"); //if url with no extension | 1071 | lnk.setFile( s+"/"); //if url with no extension |
1094 | else | 1072 | else |
1095 | lnk.setFile( s ); //sets file name | 1073 | lnk.setFile( s ); //sets file name |
1096 | 1074 | ||
1097 | } else { | 1075 | } else { |
1098 | // if( QFileInfo( s ).exists() ) { | 1076 | // if( QFileInfo( s ).exists() ) { |
1099 | lnk.setName( QFileInfo(s).baseName()); | 1077 | lnk.setName( QFileInfo(s).baseName()); |
1100 | // if(s.right(4) == '.') {//if regular file | 1078 | // if(s.right(4) == '.') {//if regular file |
1101 | if(s.left(1) != "/") { | 1079 | if(s.left(1) != "/") { |
1102 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1080 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
1103 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1081 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1104 | lnk.setIcon("SoundPlayer"); | 1082 | lnk.setIcon("SoundPlayer"); |
1105 | } else { | 1083 | } else { |
1106 | // qDebug("set link2 "+s); | 1084 | // qDebug("set link2 "+s); |
1107 | lnk.setFile( s); | 1085 | lnk.setFile( s); |
1108 | lnk.setIcon("SoundPlayer"); | 1086 | lnk.setIcon("SoundPlayer"); |
1109 | } | 1087 | } |
1110 | } | 1088 | } |
1111 | d->selectedFiles->addToSelection( lnk ); | 1089 | d->selectedFiles->addToSelection( lnk ); |
1112 | } | 1090 | } |
1113 | Config config( "OpiePlayer" ); | 1091 | Config config( "OpiePlayer" ); |
1114 | config.setGroup( "PlayList" ); | 1092 | config.setGroup( "PlayList" ); |
1115 | 1093 | ||
1116 | config.writeEntry("CurrentPlaylist",filename); | 1094 | config.writeEntry("CurrentPlaylist",filename); |
1117 | config.write(); | 1095 | config.write(); |
1118 | currentPlayList=filename; | 1096 | currentPlayList=filename; |
1119 | 1097 | ||
1120 | // m3uList->write(); | 1098 | // m3uList->write(); |
1121 | m3uList->close(); | 1099 | m3uList->close(); |
1122 | if(m3uList) delete m3uList; | 1100 | if(m3uList) delete m3uList; |
1123 | 1101 | ||
1124 | d->selectedFiles->setSelectedItem( s); | 1102 | d->selectedFiles->setSelectedItem( s); |
1125 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 1103 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
1126 | 1104 | ||
1127 | } | 1105 | } |
1128 | 1106 | ||
1129 | /* | 1107 | /* |
1130 | reads pls and adds files/urls to playlist */ | 1108 | reads pls and adds files/urls to playlist */ |
1131 | void PlayListWidget::readPls( const QString &filename ) { | 1109 | void PlayListWidget::readPls( const QString &filename ) { |
1132 | 1110 | ||
1133 | qDebug( "pls filename is " + filename ); | 1111 | qDebug( "pls filename is " + filename ); |
1134 | Om3u *m3uList; | 1112 | Om3u *m3uList; |
1135 | QString s, name; | 1113 | QString s, name; |
1136 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1114 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1137 | m3uList->readPls(); | 1115 | m3uList->readPls(); |
1138 | 1116 | ||
1139 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1117 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1140 | s = *it; | 1118 | s = *it; |
1141 | // s.replace( QRegExp( "%20" )," " ); | 1119 | // s.replace( QRegExp( "%20" )," " ); |
1142 | DocLnk lnk( s ); | 1120 | DocLnk lnk( s ); |
1143 | QFileInfo f( s ); | 1121 | QFileInfo f( s ); |
1144 | QString name = f.baseName(); | 1122 | QString name = f.baseName(); |
1145 | 1123 | ||
1146 | if( name.left( 4 ) == "http" ) { | 1124 | if( name.left( 4 ) == "http" ) { |
1147 | name = s.right( s.length() - 7); | 1125 | name = s.right( s.length() - 7); |
1148 | } else { | 1126 | } else { |
1149 | name = s; | 1127 | name = s; |
1150 | } | 1128 | } |
1151 | 1129 | ||
1152 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 1130 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
1153 | 1131 | ||
1154 | lnk.setName( name ); | 1132 | lnk.setName( name ); |
1155 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 1133 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
1156 | lnk.setFile( s ); | 1134 | lnk.setFile( s ); |
1157 | } else { //if its a url | 1135 | } else { //if its a url |
1158 | if( name.right( 1 ).find( '/' ) == -1) { | 1136 | if( name.right( 1 ).find( '/' ) == -1) { |
1159 | s += "/"; | 1137 | s += "/"; |
1160 | } | 1138 | } |
1161 | lnk.setFile( s ); | 1139 | lnk.setFile( s ); |
1162 | } | 1140 | } |
1163 | lnk.setType( "audio/x-mpegurl" ); | 1141 | lnk.setType( "audio/x-mpegurl" ); |
1164 | 1142 | ||
1165 | lnk.writeLink(); | 1143 | lnk.writeLink(); |
1166 | d->selectedFiles->addToSelection( lnk ); | 1144 | d->selectedFiles->addToSelection( lnk ); |
1167 | } | 1145 | } |
1168 | 1146 | ||
1169 | m3uList->close(); | 1147 | m3uList->close(); |
1170 | if(m3uList) delete m3uList; | 1148 | if(m3uList) delete m3uList; |
1171 | } | 1149 | } |
1172 | 1150 | ||
1173 | /* | 1151 | /* |
1174 | writes current playlist to current m3u file */ | 1152 | writes current playlist to current m3u file */ |
1175 | void PlayListWidget::writeCurrentM3u() { | 1153 | void PlayListWidget::writeCurrentM3u() { |
1176 | qDebug("writing to current m3u"); | 1154 | qDebug("writing to current m3u"); |
1177 | Config cfg( "OpiePlayer" ); | 1155 | Config cfg( "OpiePlayer" ); |
1178 | cfg.setGroup("PlayList"); | 1156 | cfg.setGroup("PlayList"); |
1179 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 1157 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
1180 | |||
1181 | if( d->selectedFiles->first()) { | ||
1182 | Om3u *m3uList; | 1158 | Om3u *m3uList; |
1183 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 1159 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
1184 | 1160 | ||
1161 | if( d->selectedFiles->first()) { | ||
1185 | do { | 1162 | do { |
1186 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 1163 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
1187 | m3uList->add( d->selectedFiles->current()->file() ); | 1164 | m3uList->add( d->selectedFiles->current()->file() ); |
1188 | } | 1165 | } |
1189 | while ( d->selectedFiles->next() ); | 1166 | while ( d->selectedFiles->next() ); |
1190 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 1167 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
1191 | m3uList->write(); | 1168 | m3uList->write(); |
1192 | m3uList->close(); | 1169 | m3uList->close(); |
1193 | 1170 | ||
1194 | if(m3uList) delete m3uList; | 1171 | if(m3uList) delete m3uList; |
1195 | } | 1172 | } |
1196 | } | 1173 | } |
1197 | 1174 | ||
1198 | /* | 1175 | /* |
1199 | writes current playlist to m3u file */ | 1176 | writes current playlist to m3u file */ |
1200 | void PlayListWidget::writem3u() { | 1177 | void PlayListWidget::writem3u() { |
1201 | InputDialog *fileDlg; | 1178 | InputDialog *fileDlg; |
1202 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1179 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1203 | fileDlg->exec(); | 1180 | fileDlg->exec(); |
1204 | QString name, filename, list; | 1181 | QString name, filename, list; |
1205 | Om3u *m3uList; | 1182 | Om3u *m3uList; |
1206 | 1183 | ||
1207 | if( fileDlg->result() == 1 ) { | 1184 | if( fileDlg->result() == 1 ) { |
1208 | name = fileDlg->text(); | 1185 | name = fileDlg->text(); |
1209 | // qDebug( filename ); | 1186 | // qDebug( filename ); |
1210 | 1187 | ||
1211 | if( name.left( 1) != "/" ) { | 1188 | if( name.left( 1) != "/" ) { |
1212 | filename = QPEApplication::documentDir() + "/" + name; | 1189 | filename = QPEApplication::documentDir() + "/" + name; |
1213 | } | 1190 | } |
1214 | 1191 | ||
1215 | if( name.right( 3 ) != "m3u" ) { | 1192 | if( name.right( 3 ) != "m3u" ) { |
1216 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 1193 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
1217 | } | 1194 | } |
1218 | 1195 | ||
1219 | if( d->selectedFiles->first()) { | 1196 | if( d->selectedFiles->first()) { |
1220 | m3uList = new Om3u(filename, IO_ReadWrite); | 1197 | m3uList = new Om3u(filename, IO_ReadWrite); |
1221 | 1198 | ||
1222 | do { | 1199 | do { |
1223 | m3uList->add( d->selectedFiles->current()->file()); | 1200 | m3uList->add( d->selectedFiles->current()->file()); |
1224 | } | 1201 | } |
1225 | while ( d->selectedFiles->next() ); | 1202 | while ( d->selectedFiles->next() ); |
1226 | // qDebug( list ); | 1203 | // qDebug( list ); |
1227 | m3uList->write(); | 1204 | m3uList->write(); |
1228 | m3uList->close(); | 1205 | m3uList->close(); |
1229 | if(m3uList) delete m3uList; | 1206 | if(m3uList) delete m3uList; |
1230 | 1207 | ||
1231 | if(fileDlg) delete fileDlg; | 1208 | if(fileDlg) delete fileDlg; |
1232 | 1209 | ||
1233 | DocLnk lnk; | 1210 | DocLnk lnk; |
1234 | lnk.setFile( filename); | 1211 | lnk.setFile( filename); |
1235 | lnk.setIcon("opieplayer2/playlist2"); | 1212 | lnk.setIcon("opieplayer2/playlist2"); |
1236 | lnk.setName( name); //sets file name | 1213 | lnk.setName( name); //sets file name |
1237 | 1214 | ||
1238 | // qDebug(filename); | 1215 | // qDebug(filename); |
1239 | Config config( "OpiePlayer" ); | 1216 | Config config( "OpiePlayer" ); |
1240 | config.setGroup( "PlayList" ); | 1217 | config.setGroup( "PlayList" ); |
1241 | 1218 | ||
1242 | config.writeEntry("CurrentPlaylist",filename); | 1219 | config.writeEntry("CurrentPlaylist",filename); |
1243 | currentPlayList=filename; | 1220 | currentPlayList=filename; |
1244 | 1221 | ||
1245 | if(!lnk.writeLink()) { | 1222 | if(!lnk.writeLink()) { |
1246 | qDebug("Writing doclink did not work"); | 1223 | qDebug("Writing doclink did not work"); |
1247 | } | 1224 | } |
1248 | 1225 | ||
1249 | setCaption(tr("OpiePlayer: ") + name); | 1226 | setCaption(tr("OpiePlayer: ") + name); |
1250 | } | 1227 | } |
1251 | } | 1228 | } |
1252 | } | 1229 | } |
1253 | 1230 | ||
1254 | 1231 | ||
1255 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1232 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1256 | { | 1233 | { |
1257 | switch ( e->key() ) { | 1234 | switch ( e->key() ) { |
1258 | ////////////////////////////// Zaurus keys | 1235 | ////////////////////////////// Zaurus keys |
1259 | case Key_F9: //activity | 1236 | case Key_F9: //activity |
1260 | // if(audioUI->isHidden()) | 1237 | // if(audioUI->isHidden()) |
1261 | // audioUI->showMaximized(); | 1238 | // audioUI->showMaximized(); |
1262 | break; | 1239 | break; |
1263 | case Key_F10: //contacts | 1240 | case Key_F10: //contacts |
1264 | // if( videoUI->isHidden()) | 1241 | // if( videoUI->isHidden()) |
1265 | // videoUI->showMaximized(); | 1242 | // videoUI->showMaximized(); |
1266 | break; | 1243 | break; |
1267 | case Key_F11: //menu | 1244 | case Key_F11: //menu |
1268 | break; | 1245 | break; |
1269 | case Key_F12: //home | 1246 | case Key_F12: //home |
1270 | // doBlank(); | 1247 | // doBlank(); |
1271 | break; | 1248 | break; |
1272 | case Key_F13: //mail | 1249 | case Key_F13: //mail |
1273 | // doUnblank(); | 1250 | // doUnblank(); |
1274 | break; | 1251 | break; |
1275 | case Key_Q: //add to playlist | 1252 | case Key_Q: //add to playlist |
1276 | qDebug("Add"); | 1253 | qDebug("Add"); |
1277 | addSelected(); | 1254 | addSelected(); |
1278 | break; | 1255 | break; |
1279 | case Key_R: //remove from playlist | 1256 | case Key_R: //remove from playlist |
1280 | removeSelected(); | 1257 | removeSelected(); |