-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/main.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/showimg/main.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/showimg/showimg.cpp | 5 |
6 files changed, 13 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 452117c..28a42eb 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,324 +1,325 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | 34 | ||
35 | #include "audiowidget.h" | 35 | #include "audiowidget.h" |
36 | 36 | ||
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | 38 | ||
39 | using namespace Opie::Ui; | ||
39 | namespace | 40 | namespace |
40 | { | 41 | { |
41 | 42 | ||
42 | const int xo = -2; // movable x offset | 43 | const int xo = -2; // movable x offset |
43 | const int yo = 22; // movable y offset | 44 | const int yo = 22; // movable y offset |
44 | 45 | ||
45 | const MediaWidget::SkinButtonInfo skinInfo[] = | 46 | const MediaWidget::SkinButtonInfo skinInfo[] = |
46 | { | 47 | { |
47 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, | 48 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, |
48 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | 49 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, |
49 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, | 50 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, |
50 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, | 51 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, |
51 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | 52 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, |
52 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | 53 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, |
53 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, | 54 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, |
54 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, | 55 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, |
55 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, | 56 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, |
56 | { MediaWidget::Back, "back", MediaWidget::NormalButton } | 57 | { MediaWidget::Back, "back", MediaWidget::NormalButton } |
57 | }; | 58 | }; |
58 | 59 | ||
59 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | 60 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); |
60 | 61 | ||
61 | void changeTextColor( QWidget * w) { | 62 | void changeTextColor( QWidget * w) { |
62 | QPalette p = w->palette(); | 63 | QPalette p = w->palette(); |
63 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 64 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
64 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 65 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
65 | w->setPalette( p ); | 66 | w->setPalette( p ); |
66 | } | 67 | } |
67 | 68 | ||
68 | } | 69 | } |
69 | 70 | ||
70 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 71 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
71 | 72 | ||
72 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), | 73 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), |
73 | audioSliderBeingMoved( false ) | 74 | audioSliderBeingMoved( false ) |
74 | { | 75 | { |
75 | setCaption( tr("OpiePlayer") ); | 76 | setCaption( tr("OpiePlayer") ); |
76 | 77 | ||
77 | loadSkin(); | 78 | loadSkin(); |
78 | 79 | ||
79 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 80 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
80 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled(bool) ), this, SLOT( setSeekable(bool) ) ); | 81 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled(bool) ), this, SLOT( setSeekable(bool) ) ); |
81 | 82 | ||
82 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 83 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
83 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 84 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
84 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 85 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
85 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 86 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
86 | 87 | ||
87 | // Intialise state | 88 | // Intialise state |
88 | setLength( mediaPlayerState.length() ); | 89 | setLength( mediaPlayerState.length() ); |
89 | setPosition( mediaPlayerState.position() ); | 90 | setPosition( mediaPlayerState.position() ); |
90 | setLooping( mediaPlayerState.isFullscreen() ); | 91 | setLooping( mediaPlayerState.isFullscreen() ); |
91 | // setPaused( mediaPlayerState->paused() ); | 92 | // setPaused( mediaPlayerState->paused() ); |
92 | setPlaying( mediaPlayerState.isPlaying() ); | 93 | setPlaying( mediaPlayerState.isPlaying() ); |
93 | } | 94 | } |
94 | 95 | ||
95 | AudioWidget::~AudioWidget() { | 96 | AudioWidget::~AudioWidget() { |
96 | 97 | ||
97 | // mediaPlayerState->setPlaying(false); | 98 | // mediaPlayerState->setPlaying(false); |
98 | } | 99 | } |
99 | 100 | ||
100 | MediaWidget::GUIInfo AudioWidget::guiInfo() | 101 | MediaWidget::GUIInfo AudioWidget::guiInfo() |
101 | { | 102 | { |
102 | return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); | 103 | return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); |
103 | } | 104 | } |
104 | 105 | ||
105 | void AudioWidget::resizeEvent( QResizeEvent *e ) { | 106 | void AudioWidget::resizeEvent( QResizeEvent *e ) { |
106 | int h = height(); | 107 | int h = height(); |
107 | int w = width(); | 108 | int w = width(); |
108 | 109 | ||
109 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 110 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
110 | slider.setFixedWidth( w - 110 ); | 111 | slider.setFixedWidth( w - 110 ); |
111 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 112 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
112 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 113 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
113 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 114 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
114 | 115 | ||
115 | upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; | 116 | upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; |
116 | upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; | 117 | upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; |
117 | 118 | ||
118 | MediaWidget::resizeEvent( e ); | 119 | MediaWidget::resizeEvent( e ); |
119 | } | 120 | } |
120 | 121 | ||
121 | void AudioWidget::sliderPressed() { | 122 | void AudioWidget::sliderPressed() { |
122 | audioSliderBeingMoved = TRUE; | 123 | audioSliderBeingMoved = TRUE; |
123 | } | 124 | } |
124 | 125 | ||
125 | 126 | ||
126 | void AudioWidget::sliderReleased() { | 127 | void AudioWidget::sliderReleased() { |
127 | audioSliderBeingMoved = FALSE; | 128 | audioSliderBeingMoved = FALSE; |
128 | if ( slider.width() == 0 ) | 129 | if ( slider.width() == 0 ) |
129 | return; | 130 | return; |
130 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); | 131 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); |
131 | mediaPlayerState.setPosition( val ); | 132 | mediaPlayerState.setPosition( val ); |
132 | } | 133 | } |
133 | 134 | ||
134 | void AudioWidget::setPosition( long i ) { | 135 | void AudioWidget::setPosition( long i ) { |
135 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 136 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
136 | updateSlider( i, mediaPlayerState.length() ); | 137 | updateSlider( i, mediaPlayerState.length() ); |
137 | } | 138 | } |
138 | 139 | ||
139 | 140 | ||
140 | void AudioWidget::setLength( long max ) { | 141 | void AudioWidget::setLength( long max ) { |
141 | updateSlider( mediaPlayerState.position(), max ); | 142 | updateSlider( mediaPlayerState.position(), max ); |
142 | } | 143 | } |
143 | 144 | ||
144 | 145 | ||
145 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 146 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
146 | if ( mediaType == MediaPlayerState::Audio ) { | 147 | if ( mediaType == MediaPlayerState::Audio ) { |
147 | // startTimer( 150 ); | 148 | // startTimer( 150 ); |
148 | QPEApplication::showWidget( this ); | 149 | QPEApplication::showWidget( this ); |
149 | return; | 150 | return; |
150 | } | 151 | } |
151 | 152 | ||
152 | killTimers(); | 153 | killTimers(); |
153 | hide(); | 154 | hide(); |
154 | } | 155 | } |
155 | 156 | ||
156 | void AudioWidget::loadSkin() | 157 | void AudioWidget::loadSkin() |
157 | { | 158 | { |
158 | loadDefaultSkin( guiInfo() ); | 159 | loadDefaultSkin( guiInfo() ); |
159 | 160 | ||
160 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 161 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
161 | // changeTextColor( &songInfo ); | 162 | // changeTextColor( &songInfo ); |
162 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 163 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
163 | // songInfo.setFrameStyle( QFrame::NoFrame); | 164 | // songInfo.setFrameStyle( QFrame::NoFrame); |
164 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 165 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
165 | // songInfo.setForegroundColor(Qt::white); | 166 | // songInfo.setForegroundColor(Qt::white); |
166 | 167 | ||
167 | slider.setFixedHeight( 20 ); | 168 | slider.setFixedHeight( 20 ); |
168 | slider.setMinValue( 0 ); | 169 | slider.setMinValue( 0 ); |
169 | slider.setMaxValue( 1 ); | 170 | slider.setMaxValue( 1 ); |
170 | slider.setFocusPolicy( QWidget::NoFocus ); | 171 | slider.setFocusPolicy( QWidget::NoFocus ); |
171 | slider.setBackgroundPixmap( backgroundPixmap ); | 172 | slider.setBackgroundPixmap( backgroundPixmap ); |
172 | 173 | ||
173 | // Config cofg("qpe"); | 174 | // Config cofg("qpe"); |
174 | // cofg.setGroup("Appearance"); | 175 | // cofg.setGroup("Appearance"); |
175 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | 176 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); |
176 | 177 | ||
177 | time.setFocusPolicy( QWidget::NoFocus ); | 178 | time.setFocusPolicy( QWidget::NoFocus ); |
178 | time.setAlignment( Qt::AlignCenter ); | 179 | time.setAlignment( Qt::AlignCenter ); |
179 | 180 | ||
180 | // time.setFrame(FALSE); | 181 | // time.setFrame(FALSE); |
181 | // changeTextColor( &time ); | 182 | // changeTextColor( &time ); |
182 | 183 | ||
183 | resizeEvent( 0 ); | 184 | resizeEvent( 0 ); |
184 | } | 185 | } |
185 | 186 | ||
186 | void AudioWidget::setSeekable( bool isSeekable ) { | 187 | void AudioWidget::setSeekable( bool isSeekable ) { |
187 | 188 | ||
188 | if ( !isSeekable ) { | 189 | if ( !isSeekable ) { |
189 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 190 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
190 | if( !slider.isHidden()) { | 191 | if( !slider.isHidden()) { |
191 | slider.hide(); | 192 | slider.hide(); |
192 | } | 193 | } |
193 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 194 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
194 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 195 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
195 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 196 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
196 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 197 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
197 | } else { | 198 | } else { |
198 | // this stops the slider from being moved, thus | 199 | // this stops the slider from being moved, thus |
199 | // does not stop stream when it reaches the end | 200 | // does not stop stream when it reaches the end |
200 | slider.show(); | 201 | slider.show(); |
201 | qDebug( " CONNECT SET POSTION " ); | 202 | qDebug( " CONNECT SET POSTION " ); |
202 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 203 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
203 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 204 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
204 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 205 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
205 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 206 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
206 | } | 207 | } |
207 | } | 208 | } |
208 | 209 | ||
209 | 210 | ||
210 | static QString timeAsString( long length ) { | 211 | static QString timeAsString( long length ) { |
211 | int minutes = length / 60; | 212 | int minutes = length / 60; |
212 | int seconds = length % 60; | 213 | int seconds = length % 60; |
213 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 214 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
214 | } | 215 | } |
215 | 216 | ||
216 | void AudioWidget::updateSlider( long i, long max ) { | 217 | void AudioWidget::updateSlider( long i, long max ) { |
217 | 218 | ||
218 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 219 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
219 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 220 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
220 | 221 | ||
221 | if ( max == 0 ) { | 222 | if ( max == 0 ) { |
222 | return; | 223 | return; |
223 | } | 224 | } |
224 | // Will flicker too much if we don't do this | 225 | // Will flicker too much if we don't do this |
225 | // Scale to something reasonable | 226 | // Scale to something reasonable |
226 | int width = slider.width(); | 227 | int width = slider.width(); |
227 | int val = int((double)i * width / max); | 228 | int val = int((double)i * width / max); |
228 | if ( !audioSliderBeingMoved ) { | 229 | if ( !audioSliderBeingMoved ) { |
229 | if ( slider.value() != val ) { | 230 | if ( slider.value() != val ) { |
230 | slider.setValue( val ); | 231 | slider.setValue( val ); |
231 | } | 232 | } |
232 | 233 | ||
233 | if ( slider.maxValue() != width ) { | 234 | if ( slider.maxValue() != width ) { |
234 | slider.setMaxValue( width ); | 235 | slider.setMaxValue( width ); |
235 | } | 236 | } |
236 | } | 237 | } |
237 | } | 238 | } |
238 | 239 | ||
239 | void AudioWidget::skipFor() { | 240 | void AudioWidget::skipFor() { |
240 | skipDirection = +1; | 241 | skipDirection = +1; |
241 | startTimer( 50 ); | 242 | startTimer( 50 ); |
242 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 243 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
243 | } | 244 | } |
244 | 245 | ||
245 | void AudioWidget::skipBack() { | 246 | void AudioWidget::skipBack() { |
246 | skipDirection = -1; | 247 | skipDirection = -1; |
247 | startTimer( 50 ); | 248 | startTimer( 50 ); |
248 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 249 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
249 | } | 250 | } |
250 | 251 | ||
251 | 252 | ||
252 | 253 | ||
253 | void AudioWidget::stopSkip() { | 254 | void AudioWidget::stopSkip() { |
254 | killTimers(); | 255 | killTimers(); |
255 | } | 256 | } |
256 | 257 | ||
257 | 258 | ||
258 | void AudioWidget::timerEvent( QTimerEvent * ) { | 259 | void AudioWidget::timerEvent( QTimerEvent * ) { |
259 | if ( skipDirection == +1 ) { | 260 | if ( skipDirection == +1 ) { |
260 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 261 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
261 | } else if ( skipDirection == -1 ) { | 262 | } else if ( skipDirection == -1 ) { |
262 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 263 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
263 | } | 264 | } |
264 | } | 265 | } |
265 | 266 | ||
266 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 267 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
267 | switch ( e->key() ) { | 268 | switch ( e->key() ) { |
268 | ////////////////////////////// Zaurus keys | 269 | ////////////////////////////// Zaurus keys |
269 | case Key_Home: | 270 | case Key_Home: |
270 | break; | 271 | break; |
271 | case Key_F9: //activity | 272 | case Key_F9: //activity |
272 | hide(); | 273 | hide(); |
273 | // qDebug("Audio F9"); | 274 | // qDebug("Audio F9"); |
274 | e->accept(); | 275 | e->accept(); |
275 | break; | 276 | break; |
276 | case Key_F10: //contacts | 277 | case Key_F10: //contacts |
277 | break; | 278 | break; |
278 | case Key_F11: //menu | 279 | case Key_F11: //menu |
279 | mediaPlayerState.toggleBlank(); | 280 | mediaPlayerState.toggleBlank(); |
280 | e->accept(); | 281 | e->accept(); |
281 | break; | 282 | break; |
282 | case Key_F12: //home | 283 | case Key_F12: //home |
283 | break; | 284 | break; |
284 | case Key_F13: //mail | 285 | case Key_F13: //mail |
285 | mediaPlayerState.toggleBlank(); | 286 | mediaPlayerState.toggleBlank(); |
286 | e->accept(); | 287 | e->accept(); |
287 | break; | 288 | break; |
288 | case Key_Space: { | 289 | case Key_Space: { |
289 | e->accept(); | 290 | e->accept(); |
290 | mediaPlayerState.togglePaused(); | 291 | mediaPlayerState.togglePaused(); |
291 | } | 292 | } |
292 | break; | 293 | break; |
293 | case Key_Down: | 294 | case Key_Down: |
294 | // toggleButton(6); | 295 | // toggleButton(6); |
295 | emit lessClicked(); | 296 | emit lessClicked(); |
296 | emit lessReleased(); | 297 | emit lessReleased(); |
297 | // toggleButton(6); | 298 | // toggleButton(6); |
298 | e->accept(); | 299 | e->accept(); |
299 | break; | 300 | break; |
300 | case Key_Up: | 301 | case Key_Up: |
301 | // toggleButton(5); | 302 | // toggleButton(5); |
302 | emit moreClicked(); | 303 | emit moreClicked(); |
303 | emit moreReleased(); | 304 | emit moreReleased(); |
304 | // toggleButton(5); | 305 | // toggleButton(5); |
305 | e->accept(); | 306 | e->accept(); |
306 | break; | 307 | break; |
307 | case Key_Right: | 308 | case Key_Right: |
308 | // toggleButton(3); | 309 | // toggleButton(3); |
309 | mediaPlayerState.setNext(); | 310 | mediaPlayerState.setNext(); |
310 | // toggleButton(3); | 311 | // toggleButton(3); |
311 | e->accept(); | 312 | e->accept(); |
312 | break; | 313 | break; |
313 | case Key_Left: | 314 | case Key_Left: |
314 | // toggleButton(4); | 315 | // toggleButton(4); |
315 | mediaPlayerState.setPrev(); | 316 | mediaPlayerState.setPrev(); |
316 | // toggleButton(4); | 317 | // toggleButton(4); |
317 | e->accept(); | 318 | e->accept(); |
318 | break; | 319 | break; |
319 | case Key_Escape: { | 320 | case Key_Escape: { |
320 | } | 321 | } |
321 | break; | 322 | break; |
322 | 323 | ||
323 | }; | 324 | }; |
324 | } | 325 | } |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index b436239..aea4146 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -1,95 +1,95 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef AUDIO_WIDGET_H | 34 | #ifndef AUDIO_WIDGET_H |
35 | #define AUDIO_WIDGET_H | 35 | #define AUDIO_WIDGET_H |
36 | 36 | ||
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | 38 | ||
39 | #include <opie/oticker.h> | 39 | #include <opie2/oticker.h> |
40 | 40 | ||
41 | #include "mediawidget.h" | 41 | #include "mediawidget.h" |
42 | 42 | ||
43 | class QPixmap; | 43 | class QPixmap; |
44 | 44 | ||
45 | class AudioWidget : public MediaWidget { | 45 | class AudioWidget : public MediaWidget { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | public: | 47 | public: |
48 | AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 48 | AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
49 | ~AudioWidget(); | 49 | ~AudioWidget(); |
50 | void setTickerText( const QString &text ) { songInfo.setText( text ); } | 50 | void setTickerText( const QString &text ) { songInfo.setText( text ); } |
51 | 51 | ||
52 | static MediaWidget::GUIInfo guiInfo(); | 52 | static MediaWidget::GUIInfo guiInfo(); |
53 | 53 | ||
54 | public slots: | 54 | public slots: |
55 | void updateSlider( long, long ); | 55 | void updateSlider( long, long ); |
56 | void sliderPressed( ); | 56 | void sliderPressed( ); |
57 | void sliderReleased( ); | 57 | void sliderReleased( ); |
58 | void setLooping( bool b) { setToggleButton( Loop, b ); } | 58 | void setLooping( bool b) { setToggleButton( Loop, b ); } |
59 | void setPosition( long ); | 59 | void setPosition( long ); |
60 | void setSeekable( bool ); | 60 | void setSeekable( bool ); |
61 | 61 | ||
62 | public: | 62 | public: |
63 | virtual void setLength( long ); | 63 | virtual void setLength( long ); |
64 | virtual void setPlaying( bool b) { setToggleButton( Play, b ); } | 64 | virtual void setPlaying( bool b) { setToggleButton( Play, b ); } |
65 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 65 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
66 | 66 | ||
67 | virtual void loadSkin(); | 67 | virtual void loadSkin(); |
68 | 68 | ||
69 | signals: | 69 | signals: |
70 | void sliderMoved(long); | 70 | void sliderMoved(long); |
71 | 71 | ||
72 | protected: | 72 | protected: |
73 | void doBlank(); | 73 | void doBlank(); |
74 | void doUnblank(); | 74 | void doUnblank(); |
75 | void resizeEvent( QResizeEvent *re ); | 75 | void resizeEvent( QResizeEvent *re ); |
76 | void timerEvent( QTimerEvent *event ); | 76 | void timerEvent( QTimerEvent *event ); |
77 | void keyReleaseEvent( QKeyEvent *e); | 77 | void keyReleaseEvent( QKeyEvent *e); |
78 | private slots: | 78 | private slots: |
79 | void skipFor(); | 79 | void skipFor(); |
80 | void skipBack(); | 80 | void skipBack(); |
81 | void stopSkip(); | 81 | void stopSkip(); |
82 | private: | 82 | private: |
83 | int skipDirection; | 83 | int skipDirection; |
84 | QString skin; | 84 | QString skin; |
85 | 85 | ||
86 | OTicker songInfo; | 86 | Opie::Ui::OTicker songInfo; |
87 | QSlider slider; | 87 | QSlider slider; |
88 | QLineEdit time; | 88 | QLineEdit time; |
89 | bool isStreaming : 1; | 89 | bool isStreaming : 1; |
90 | bool audioSliderBeingMoved : 1; | 90 | bool audioSliderBeingMoved : 1; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | 93 | ||
94 | #endif // AUDIO_WIDGET_H | 94 | #endif // AUDIO_WIDGET_H |
95 | 95 | ||
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp index 00f72d1..6283ae3 100644 --- a/noncore/multimedia/opieplayer2/main.cpp +++ b/noncore/multimedia/opieplayer2/main.cpp | |||
@@ -1,26 +1,28 @@ | |||
1 | 1 | ||
2 | #include "mediaplayer.h" | 2 | #include "mediaplayer.h" |
3 | 3 | ||
4 | 4 | ||
5 | 5 | ||
6 | #include <opie/oapplicationfactory.h> | 6 | #include <opie2/oapplicationfactory.h> |
7 | 7 | ||
8 | using namespace Opie::Core; | ||
8 | OPIE_EXPORT_APP( OApplicationFactory<PlayListWidget> ) | 9 | OPIE_EXPORT_APP( OApplicationFactory<PlayListWidget> ) |
9 | 10 | ||
10 | #if 0 | 11 | #if 0 |
12 | using namespace Opie::Core; | ||
11 | int main(int argc, char **argv) { | 13 | int main(int argc, char **argv) { |
12 | QPEApplication a(argc,argv); | 14 | QPEApplication a(argc,argv); |
13 | 15 | ||
14 | MediaPlayerState st( 0, "mediaPlayerState" ); | 16 | MediaPlayerState st( 0, "mediaPlayerState" ); |
15 | PlayListWidget pl( st, 0, "playList" ); | 17 | PlayListWidget pl( st, 0, "playList" ); |
16 | pl.showMaximized(); | 18 | pl.showMaximized(); |
17 | MediaPlayer mp( pl, st, 0, "mediaPlayer" ); | 19 | MediaPlayer mp( pl, st, 0, "mediaPlayer" ); |
18 | QObject::connect( &pl, SIGNAL( skinSelected() ), | 20 | QObject::connect( &pl, SIGNAL( skinSelected() ), |
19 | &mp, SLOT( reloadSkins() ) ); | 21 | &mp, SLOT( reloadSkins() ) ); |
20 | 22 | ||
21 | a.showMainDocumentWidget(&pl); | 23 | a.showMainDocumentWidget(&pl); |
22 | 24 | ||
23 | return a.exec(); | 25 | return a.exec(); |
24 | } | 26 | } |
25 | #endif | 27 | #endif |
26 | 28 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 84aba55..1a5e474 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1042 +1,1043 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qtoolbar.h> | 34 | #include <qtoolbar.h> |
35 | 35 | ||
36 | #include <opie/ofiledialog.h> | 36 | #include <opie2/ofiledialog.h> |
37 | 37 | ||
38 | #include <qmessagebox.h> | 38 | #include <qmessagebox.h> |
39 | 39 | ||
40 | #include "playlistselection.h" | 40 | #include "playlistselection.h" |
41 | #include "playlistwidget.h" | 41 | #include "playlistwidget.h" |
42 | #include "mediaplayer.h" | 42 | #include "mediaplayer.h" |
43 | #include "inputDialog.h" | 43 | #include "inputDialog.h" |
44 | #include "om3u.h" | 44 | #include "om3u.h" |
45 | #include "playlistfileview.h" | 45 | #include "playlistfileview.h" |
46 | 46 | ||
47 | //only needed for the random play | 47 | //only needed for the random play |
48 | #include <assert.h> | 48 | #include <assert.h> |
49 | 49 | ||
50 | using namespace Opie::Ui; | ||
50 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) | 51 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) |
51 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) | 52 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) |
52 | { | 53 | { |
53 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); | 54 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); |
54 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); | 55 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); |
55 | 56 | ||
56 | 57 | ||
57 | 58 | ||
58 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 59 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
59 | "opieplayer2/add_to_playlist", | 60 | "opieplayer2/add_to_playlist", |
60 | this , SLOT(addSelected() ) ); | 61 | this , SLOT(addSelected() ) ); |
61 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 62 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
62 | "opieplayer2/remove_from_playlist", | 63 | "opieplayer2/remove_from_playlist", |
63 | this , SLOT(removeSelected() ) ); | 64 | this , SLOT(removeSelected() ) ); |
64 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 65 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
65 | this , SLOT( btnPlay(bool) ), TRUE ); | 66 | this , SLOT( btnPlay(bool) ), TRUE ); |
66 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 67 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
67 | mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); | 68 | mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); |
68 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 69 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
69 | mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); | 70 | mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); |
70 | 71 | ||
71 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 72 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
72 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 73 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
73 | this, SLOT( addAllMusicToList() ) ); | 74 | this, SLOT( addAllMusicToList() ) ); |
74 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 75 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
75 | this, SLOT( addAllVideoToList() ) ); | 76 | this, SLOT( addAllVideoToList() ) ); |
76 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 77 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
77 | this, SLOT( addAllToList() ) ); | 78 | this, SLOT( addAllToList() ) ); |
78 | pmPlayList->insertSeparator(-1); | 79 | pmPlayList->insertSeparator(-1); |
79 | (void)new MenuItem( pmPlayList, tr( "Add File" ), | 80 | (void)new MenuItem( pmPlayList, tr( "Add File" ), |
80 | this,SLOT( openFile() ) ); | 81 | this,SLOT( openFile() ) ); |
81 | (void)new MenuItem( pmPlayList, tr("Add URL"), | 82 | (void)new MenuItem( pmPlayList, tr("Add URL"), |
82 | this,SLOT( openURL() ) ); | 83 | this,SLOT( openURL() ) ); |
83 | pmPlayList->insertSeparator(-1); | 84 | pmPlayList->insertSeparator(-1); |
84 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
85 | this, SLOT(writem3u() ) ); | 86 | this, SLOT(writem3u() ) ); |
86 | pmPlayList->insertSeparator(-1); | 87 | pmPlayList->insertSeparator(-1); |
87 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 88 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
88 | audioView, SLOT( scanFiles() ) ); | 89 | audioView, SLOT( scanFiles() ) ); |
89 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 90 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
90 | videoView, SLOT( scanFiles() ) ); | 91 | videoView, SLOT( scanFiles() ) ); |
91 | 92 | ||
92 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 93 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
93 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 94 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
94 | 95 | ||
95 | Config cfg( "OpiePlayer" ); | 96 | Config cfg( "OpiePlayer" ); |
96 | bool b= cfg.readBoolEntry("FullScreen", 0); | 97 | bool b= cfg.readBoolEntry("FullScreen", 0); |
97 | mediaPlayerState->setFullscreen( b ); | 98 | mediaPlayerState->setFullscreen( b ); |
98 | pmView->setItemChecked( -16, b ); | 99 | pmView->setItemChecked( -16, b ); |
99 | 100 | ||
100 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 101 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
101 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 102 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
102 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 103 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
103 | d->selectedFiles, SLOT(removeSelected() ) ); | 104 | d->selectedFiles, SLOT(removeSelected() ) ); |
104 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 105 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
105 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 106 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
106 | QVBox *stretch2 = new QVBox( vbox1 ); | 107 | QVBox *stretch2 = new QVBox( vbox1 ); |
107 | 108 | ||
108 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 109 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
109 | SLOT( deletePlaylist() ) ); | 110 | SLOT( deletePlaylist() ) ); |
110 | connect( pmView, SIGNAL( activated(int) ), | 111 | connect( pmView, SIGNAL( activated(int) ), |
111 | this, SLOT( pmViewActivated(int) ) ); | 112 | this, SLOT( pmViewActivated(int) ) ); |
112 | connect( skinsMenu, SIGNAL( activated(int) ) , | 113 | connect( skinsMenu, SIGNAL( activated(int) ) , |
113 | this, SLOT( skinsMenuActivated(int) ) ); | 114 | this, SLOT( skinsMenuActivated(int) ) ); |
114 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 115 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
115 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 116 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
116 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 117 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
117 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 118 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
118 | connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), | 119 | connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), |
119 | this,SLOT( playIt(QListViewItem*) ) ); | 120 | this,SLOT( playIt(QListViewItem*) ) ); |
120 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), | 121 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), |
121 | this, SLOT( addToSelection(QListViewItem*) ) ); | 122 | this, SLOT( addToSelection(QListViewItem*) ) ); |
122 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 123 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
123 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 124 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
124 | connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), | 125 | connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), |
125 | this,SLOT( playIt(QListViewItem*) ) ); | 126 | this,SLOT( playIt(QListViewItem*) ) ); |
126 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), | 127 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), |
127 | this, SLOT( addToSelection(QListViewItem*) ) ); | 128 | this, SLOT( addToSelection(QListViewItem*) ) ); |
128 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), | 129 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), |
129 | this, SLOT( loadList(const DocLnk&) ) ); | 130 | this, SLOT( loadList(const DocLnk&) ) ); |
130 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 131 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
131 | this, SLOT( tabChanged(QWidget*) ) ); | 132 | this, SLOT( tabChanged(QWidget*) ) ); |
132 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), | 133 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), |
133 | d->tbPlay, SLOT( setOn(bool) ) ); | 134 | d->tbPlay, SLOT( setOn(bool) ) ); |
134 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), | 135 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), |
135 | d->tbLoop, SLOT( setOn(bool) ) ); | 136 | d->tbLoop, SLOT( setOn(bool) ) ); |
136 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), | 137 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), |
137 | d->tbShuffle, SLOT( setOn(bool) ) ); | 138 | d->tbShuffle, SLOT( setOn(bool) ) ); |
138 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), | 139 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), |
139 | this, SLOT( playIt(QListViewItem*) ) ); | 140 | this, SLOT( playIt(QListViewItem*) ) ); |
140 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), | 141 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), |
141 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); | 142 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); |
142 | 143 | ||
143 | connect( this, SIGNAL(skinSelected() ), | 144 | connect( this, SIGNAL(skinSelected() ), |
144 | m_mp, SLOT( reloadSkins() ) ); | 145 | m_mp, SLOT( reloadSkins() ) ); |
145 | 146 | ||
146 | // see which skins are installed | 147 | // see which skins are installed |
147 | populateSkinsMenu(); | 148 | populateSkinsMenu(); |
148 | initializeStates(); | 149 | initializeStates(); |
149 | 150 | ||
150 | channel = new QCopChannel( "QPE/Application/opieplayer2", this ); | 151 | channel = new QCopChannel( "QPE/Application/opieplayer2", this ); |
151 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 152 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
152 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); | 153 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); |
153 | 154 | ||
154 | 155 | ||
155 | cfg.setGroup("PlayList"); | 156 | cfg.setGroup("PlayList"); |
156 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 157 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
157 | loadList(DocLnk( currentPlaylist ) ); | 158 | loadList(DocLnk( currentPlaylist ) ); |
158 | 159 | ||
159 | tabWidget->showPage( playListTab ); | 160 | tabWidget->showPage( playListTab ); |
160 | } | 161 | } |
161 | 162 | ||
162 | 163 | ||
163 | PlayListWidget::~PlayListWidget() { | 164 | PlayListWidget::~PlayListWidget() { |
164 | delete d; | 165 | delete d; |
165 | delete m_mp; | 166 | delete m_mp; |
166 | } | 167 | } |
167 | 168 | ||
168 | 169 | ||
169 | void PlayListWidget::initializeStates() { | 170 | void PlayListWidget::initializeStates() { |
170 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); | 171 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); |
171 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); | 172 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); |
172 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); | 173 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); |
173 | d->playListFrame->show(); | 174 | d->playListFrame->show(); |
174 | } | 175 | } |
175 | 176 | ||
176 | void PlayListWidget::writeDefaultPlaylist() { | 177 | void PlayListWidget::writeDefaultPlaylist() { |
177 | 178 | ||
178 | Config config( "OpiePlayer" ); | 179 | Config config( "OpiePlayer" ); |
179 | config.setGroup( "PlayList" ); | 180 | config.setGroup( "PlayList" ); |
180 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 181 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
181 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 182 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
182 | if( currentString == filename) { | 183 | if( currentString == filename) { |
183 | Om3u *m3uList; | 184 | Om3u *m3uList; |
184 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 185 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
185 | if( d->selectedFiles->first() ) { | 186 | if( d->selectedFiles->first() ) { |
186 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 187 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
187 | do { | 188 | do { |
188 | // qDebug(d->selectedFiles->current()->file()); | 189 | // qDebug(d->selectedFiles->current()->file()); |
189 | m3uList->add( d->selectedFiles->current()->file() ); | 190 | m3uList->add( d->selectedFiles->current()->file() ); |
190 | } | 191 | } |
191 | while ( d->selectedFiles->next() ); | 192 | while ( d->selectedFiles->next() ); |
192 | 193 | ||
193 | m3uList->write(); | 194 | m3uList->write(); |
194 | m3uList->close(); | 195 | m3uList->close(); |
195 | delete m3uList; | 196 | delete m3uList; |
196 | 197 | ||
197 | } | 198 | } |
198 | } | 199 | } |
199 | } | 200 | } |
200 | 201 | ||
201 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 202 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
202 | d->setDocumentUsed = FALSE; | 203 | d->setDocumentUsed = FALSE; |
203 | if( QFileInfo( lnk.file() ).exists() || | 204 | if( QFileInfo( lnk.file() ).exists() || |
204 | lnk.file().left(4) == "http" ) { | 205 | lnk.file().left(4) == "http" ) { |
205 | d->selectedFiles->addToSelection( lnk ); | 206 | d->selectedFiles->addToSelection( lnk ); |
206 | } | 207 | } |
207 | // writeCurrentM3u(); | 208 | // writeCurrentM3u(); |
208 | } | 209 | } |
209 | 210 | ||
210 | 211 | ||
211 | void PlayListWidget::clearList() { | 212 | void PlayListWidget::clearList() { |
212 | while ( first() ) { | 213 | while ( first() ) { |
213 | d->selectedFiles->removeSelected(); | 214 | d->selectedFiles->removeSelected(); |
214 | } | 215 | } |
215 | Config cfg( "OpiePlayer" ); | 216 | Config cfg( "OpiePlayer" ); |
216 | cfg.setGroup("PlayList"); | 217 | cfg.setGroup("PlayList"); |
217 | cfg.writeEntry("CurrentPlaylist","default"); | 218 | cfg.writeEntry("CurrentPlaylist","default"); |
218 | setCaption("OpiePlayer"); | 219 | setCaption("OpiePlayer"); |
219 | } | 220 | } |
220 | 221 | ||
221 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
222 | switch (mouse) { | 223 | switch (mouse) { |
223 | case LeftButton: | 224 | case LeftButton: |
224 | break; | 225 | break; |
225 | case RightButton: | 226 | case RightButton: |
226 | { | 227 | { |
227 | QPopupMenu m; | 228 | QPopupMenu m; |
228 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
229 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
230 | m.exec( QCursor::pos() ); | 231 | m.exec( QCursor::pos() ); |
231 | } | 232 | } |
232 | break; | 233 | break; |
233 | } | 234 | } |
234 | } | 235 | } |
235 | 236 | ||
236 | 237 | ||
237 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 238 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
238 | switch (mouse) { | 239 | switch (mouse) { |
239 | case LeftButton: | 240 | case LeftButton: |
240 | break; | 241 | break; |
241 | case RightButton: | 242 | case RightButton: |
242 | { | 243 | { |
243 | QPopupMenu m; | 244 | QPopupMenu m; |
244 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 245 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
245 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 246 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
246 | m.exec( QCursor::pos() ); | 247 | m.exec( QCursor::pos() ); |
247 | } | 248 | } |
248 | break; | 249 | break; |
249 | } | 250 | } |
250 | } | 251 | } |
251 | 252 | ||
252 | 253 | ||
253 | void PlayListWidget::addAllToList() { | 254 | void PlayListWidget::addAllToList() { |
254 | 255 | ||
255 | 256 | ||
256 | audioView->populateView(); | 257 | audioView->populateView(); |
257 | 258 | ||
258 | QListViewItemIterator audioIt( audioView ); | 259 | QListViewItemIterator audioIt( audioView ); |
259 | DocLnk lnk; | 260 | DocLnk lnk; |
260 | QString filename; | 261 | QString filename; |
261 | // iterate through all items of the listview | 262 | // iterate through all items of the listview |
262 | for ( ; audioIt.current(); ++audioIt ) { | 263 | for ( ; audioIt.current(); ++audioIt ) { |
263 | filename = audioIt.current()->text(3); | 264 | filename = audioIt.current()->text(3); |
264 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 265 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
265 | lnk.setFile( filename ); //sets file name | 266 | lnk.setFile( filename ); //sets file name |
266 | d->selectedFiles->addToSelection( lnk); | 267 | d->selectedFiles->addToSelection( lnk); |
267 | } | 268 | } |
268 | 269 | ||
269 | videoView->populateView(); | 270 | videoView->populateView(); |
270 | 271 | ||
271 | QListViewItemIterator videoIt( videoView ); | 272 | QListViewItemIterator videoIt( videoView ); |
272 | for ( ; videoIt.current(); ++videoIt ) { | 273 | for ( ; videoIt.current(); ++videoIt ) { |
273 | filename = videoIt.current()->text(3); | 274 | filename = videoIt.current()->text(3); |
274 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 275 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
275 | lnk.setFile( filename ); //sets file name | 276 | lnk.setFile( filename ); //sets file name |
276 | d->selectedFiles->addToSelection( lnk); | 277 | d->selectedFiles->addToSelection( lnk); |
277 | } | 278 | } |
278 | 279 | ||
279 | tabWidget->setCurrentPage(0); | 280 | tabWidget->setCurrentPage(0); |
280 | 281 | ||
281 | writeCurrentM3u(); | 282 | writeCurrentM3u(); |
282 | d->selectedFiles->first(); | 283 | d->selectedFiles->first(); |
283 | } | 284 | } |
284 | 285 | ||
285 | 286 | ||
286 | void PlayListWidget::addAllMusicToList() { | 287 | void PlayListWidget::addAllMusicToList() { |
287 | 288 | ||
288 | audioView->populateView(); | 289 | audioView->populateView(); |
289 | 290 | ||
290 | QListViewItemIterator audioIt( audioView ); | 291 | QListViewItemIterator audioIt( audioView ); |
291 | DocLnk lnk; | 292 | DocLnk lnk; |
292 | QString filename; | 293 | QString filename; |
293 | // iterate through all items of the listview | 294 | // iterate through all items of the listview |
294 | for ( ; audioIt.current(); ++audioIt ) { | 295 | for ( ; audioIt.current(); ++audioIt ) { |
295 | filename = audioIt.current()->text(3); | 296 | filename = audioIt.current()->text(3); |
296 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 297 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
297 | lnk.setFile( filename ); //sets file name | 298 | lnk.setFile( filename ); //sets file name |
298 | d->selectedFiles->addToSelection( lnk); | 299 | d->selectedFiles->addToSelection( lnk); |
299 | } | 300 | } |
300 | 301 | ||
301 | tabWidget->setCurrentPage(0); | 302 | tabWidget->setCurrentPage(0); |
302 | writeCurrentM3u(); | 303 | writeCurrentM3u(); |
303 | d->selectedFiles->first(); | 304 | d->selectedFiles->first(); |
304 | } | 305 | } |
305 | 306 | ||
306 | 307 | ||
307 | void PlayListWidget::addAllVideoToList() { | 308 | void PlayListWidget::addAllVideoToList() { |
308 | 309 | ||
309 | videoView->populateView(); | 310 | videoView->populateView(); |
310 | 311 | ||
311 | QListViewItemIterator videoIt( videoView ); | 312 | QListViewItemIterator videoIt( videoView ); |
312 | DocLnk lnk; | 313 | DocLnk lnk; |
313 | QString filename; | 314 | QString filename; |
314 | for ( ; videoIt.current(); ++videoIt ) { | 315 | for ( ; videoIt.current(); ++videoIt ) { |
315 | filename = videoIt.current()->text(3); | 316 | filename = videoIt.current()->text(3); |
316 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 317 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
317 | lnk.setFile( filename ); //sets file name | 318 | lnk.setFile( filename ); //sets file name |
318 | d->selectedFiles->addToSelection( lnk); | 319 | d->selectedFiles->addToSelection( lnk); |
319 | } | 320 | } |
320 | tabWidget->setCurrentPage(0); | 321 | tabWidget->setCurrentPage(0); |
321 | writeCurrentM3u(); | 322 | writeCurrentM3u(); |
322 | d->selectedFiles->first(); | 323 | d->selectedFiles->first(); |
323 | } | 324 | } |
324 | 325 | ||
325 | 326 | ||
326 | void PlayListWidget::setDocument( const QString& fileref ) { | 327 | void PlayListWidget::setDocument( const QString& fileref ) { |
327 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 328 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
328 | fromSetDocument = TRUE; | 329 | fromSetDocument = TRUE; |
329 | QFileInfo fileInfo(fileref); | 330 | QFileInfo fileInfo(fileref); |
330 | 331 | ||
331 | if ( !fileInfo.exists() ) { | 332 | if ( !fileInfo.exists() ) { |
332 | QMessageBox::warning( this, tr( "Invalid File" ), | 333 | QMessageBox::warning( this, tr( "Invalid File" ), |
333 | tr( "There was a problem in getting the file." ) ); | 334 | tr( "There was a problem in getting the file." ) ); |
334 | return; | 335 | return; |
335 | } | 336 | } |
336 | 337 | ||
337 | clearList(); | 338 | clearList(); |
338 | QString extension = fileInfo.extension(false); | 339 | QString extension = fileInfo.extension(false); |
339 | 340 | ||
340 | if( extension.find( "m3u", 0, false) != -1 | 341 | if( extension.find( "m3u", 0, false) != -1 |
341 | || extension.find( "pls", 0, false) != -1 ) { | 342 | || extension.find( "pls", 0, false) != -1 ) { |
342 | readListFromFile( fileref ); | 343 | readListFromFile( fileref ); |
343 | } else { | 344 | } else { |
344 | clearList(); | 345 | clearList(); |
345 | DocLnk lnk; | 346 | DocLnk lnk; |
346 | lnk.setName( fileInfo.baseName() ); //sets name | 347 | lnk.setName( fileInfo.baseName() ); //sets name |
347 | lnk.setFile( fileref ); //sets file name | 348 | lnk.setFile( fileref ); //sets file name |
348 | addToSelection( lnk ); | 349 | addToSelection( lnk ); |
349 | writeCurrentM3u(); | 350 | writeCurrentM3u(); |
350 | 351 | ||
351 | d->setDocumentUsed = TRUE; | 352 | d->setDocumentUsed = TRUE; |
352 | mediaPlayerState->setPlaying( FALSE ); | 353 | mediaPlayerState->setPlaying( FALSE ); |
353 | mediaPlayerState->setPlaying( TRUE ); | 354 | mediaPlayerState->setPlaying( TRUE ); |
354 | } | 355 | } |
355 | } | 356 | } |
356 | 357 | ||
357 | 358 | ||
358 | void PlayListWidget::useSelectedDocument() { | 359 | void PlayListWidget::useSelectedDocument() { |
359 | d->setDocumentUsed = FALSE; | 360 | d->setDocumentUsed = FALSE; |
360 | } | 361 | } |
361 | 362 | ||
362 | 363 | ||
363 | const DocLnk *PlayListWidget::current() const { // this is fugly | 364 | const DocLnk *PlayListWidget::current() const { // this is fugly |
364 | assert( currentTab() == CurrentPlayList ); | 365 | assert( currentTab() == CurrentPlayList ); |
365 | 366 | ||
366 | const DocLnk *lnk = d->selectedFiles->current(); | 367 | const DocLnk *lnk = d->selectedFiles->current(); |
367 | if ( !lnk ) { | 368 | if ( !lnk ) { |
368 | d->selectedFiles->first(); | 369 | d->selectedFiles->first(); |
369 | lnk = d->selectedFiles->current(); | 370 | lnk = d->selectedFiles->current(); |
370 | } | 371 | } |
371 | assert( lnk ); | 372 | assert( lnk ); |
372 | return lnk; | 373 | return lnk; |
373 | } | 374 | } |
374 | 375 | ||
375 | 376 | ||
376 | bool PlayListWidget::prev() { | 377 | bool PlayListWidget::prev() { |
377 | if ( mediaPlayerState->isShuffled() ) { | 378 | if ( mediaPlayerState->isShuffled() ) { |
378 | const DocLnk *cur = current(); | 379 | const DocLnk *cur = current(); |
379 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 380 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
380 | for ( int i = 0; i < j; i++ ) { | 381 | for ( int i = 0; i < j; i++ ) { |
381 | if ( !d->selectedFiles->next() ) | 382 | if ( !d->selectedFiles->next() ) |
382 | d->selectedFiles->first(); | 383 | d->selectedFiles->first(); |
383 | } | 384 | } |
384 | if ( cur == current() ) | 385 | if ( cur == current() ) |
385 | if ( !d->selectedFiles->next() ) { | 386 | if ( !d->selectedFiles->next() ) { |
386 | d->selectedFiles->first(); | 387 | d->selectedFiles->first(); |
387 | } | 388 | } |
388 | return TRUE; | 389 | return TRUE; |
389 | } else { | 390 | } else { |
390 | if ( !d->selectedFiles->prev() ) { | 391 | if ( !d->selectedFiles->prev() ) { |
391 | if ( mediaPlayerState->isLooping() ) { | 392 | if ( mediaPlayerState->isLooping() ) { |
392 | return d->selectedFiles->last(); | 393 | return d->selectedFiles->last(); |
393 | } else { | 394 | } else { |
394 | return FALSE; | 395 | return FALSE; |
395 | } | 396 | } |
396 | } | 397 | } |
397 | return TRUE; | 398 | return TRUE; |
398 | } | 399 | } |
399 | } | 400 | } |
400 | 401 | ||
401 | 402 | ||
402 | bool PlayListWidget::next() { | 403 | bool PlayListWidget::next() { |
403 | //qDebug("<<<<<<<<<<<<next()"); | 404 | //qDebug("<<<<<<<<<<<<next()"); |
404 | if ( mediaPlayerState->isShuffled() ) { | 405 | if ( mediaPlayerState->isShuffled() ) { |
405 | return prev(); | 406 | return prev(); |
406 | } else { | 407 | } else { |
407 | if ( !d->selectedFiles->next() ) { | 408 | if ( !d->selectedFiles->next() ) { |
408 | if ( mediaPlayerState->isLooping() ) { | 409 | if ( mediaPlayerState->isLooping() ) { |
409 | return d->selectedFiles->first(); | 410 | return d->selectedFiles->first(); |
410 | } else { | 411 | } else { |
411 | return FALSE; | 412 | return FALSE; |
412 | } | 413 | } |
413 | } | 414 | } |
414 | return TRUE; | 415 | return TRUE; |
415 | } | 416 | } |
416 | } | 417 | } |
417 | 418 | ||
418 | 419 | ||
419 | bool PlayListWidget::first() { | 420 | bool PlayListWidget::first() { |
420 | return d->selectedFiles->first(); | 421 | return d->selectedFiles->first(); |
421 | } | 422 | } |
422 | 423 | ||
423 | 424 | ||
424 | bool PlayListWidget::last() { | 425 | bool PlayListWidget::last() { |
425 | return d->selectedFiles->last(); | 426 | return d->selectedFiles->last(); |
426 | } | 427 | } |
427 | 428 | ||
428 | 429 | ||
429 | void PlayListWidget::saveList() { | 430 | void PlayListWidget::saveList() { |
430 | writem3u(); | 431 | writem3u(); |
431 | } | 432 | } |
432 | 433 | ||
433 | 434 | ||
434 | void PlayListWidget::loadList( const DocLnk & lnk) { | 435 | void PlayListWidget::loadList( const DocLnk & lnk) { |
435 | QString name = lnk.name(); | 436 | QString name = lnk.name(); |
436 | 437 | ||
437 | if( name.length()>0) { | 438 | if( name.length()>0) { |
438 | setCaption("OpiePlayer: "+name); | 439 | setCaption("OpiePlayer: "+name); |
439 | clearList(); | 440 | clearList(); |
440 | readListFromFile(lnk.file()); | 441 | readListFromFile(lnk.file()); |
441 | tabWidget->setCurrentPage(0); | 442 | tabWidget->setCurrentPage(0); |
442 | } | 443 | } |
443 | } | 444 | } |
444 | 445 | ||
445 | void PlayListWidget::addSelected() { | 446 | void PlayListWidget::addSelected() { |
446 | assert( inFileListMode() ); | 447 | assert( inFileListMode() ); |
447 | 448 | ||
448 | QListViewItemIterator it( currentFileListView ); | 449 | QListViewItemIterator it( currentFileListView ); |
449 | for ( ; it.current(); ++it ) | 450 | for ( ; it.current(); ++it ) |
450 | if ( it.current()->isSelected() ) { | 451 | if ( it.current()->isSelected() ) { |
451 | QString filename = it.current()->text(3); | 452 | QString filename = it.current()->text(3); |
452 | 453 | ||
453 | DocLnk lnk; | 454 | DocLnk lnk; |
454 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 455 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
455 | lnk.setFile( filename ); //sets file name | 456 | lnk.setFile( filename ); //sets file name |
456 | 457 | ||
457 | d->selectedFiles->addToSelection( lnk ); | 458 | d->selectedFiles->addToSelection( lnk ); |
458 | } | 459 | } |
459 | 460 | ||
460 | currentFileListView->clearSelection(); | 461 | currentFileListView->clearSelection(); |
461 | 462 | ||
462 | writeCurrentM3u(); | 463 | writeCurrentM3u(); |
463 | } | 464 | } |
464 | 465 | ||
465 | 466 | ||
466 | void PlayListWidget::removeSelected() { | 467 | void PlayListWidget::removeSelected() { |
467 | d->selectedFiles->removeSelected( ); | 468 | d->selectedFiles->removeSelected( ); |
468 | writeCurrentM3u(); | 469 | writeCurrentM3u(); |
469 | } | 470 | } |
470 | 471 | ||
471 | 472 | ||
472 | void PlayListWidget::playIt( QListViewItem *it) { | 473 | void PlayListWidget::playIt( QListViewItem *it) { |
473 | if(!it) return; | 474 | if(!it) return; |
474 | mediaPlayerState->setPlaying(FALSE); | 475 | mediaPlayerState->setPlaying(FALSE); |
475 | mediaPlayerState->setPlaying(TRUE); | 476 | mediaPlayerState->setPlaying(TRUE); |
476 | d->selectedFiles->unSelect(); | 477 | d->selectedFiles->unSelect(); |
477 | } | 478 | } |
478 | 479 | ||
479 | 480 | ||
480 | void PlayListWidget::addToSelection( QListViewItem *it) { | 481 | void PlayListWidget::addToSelection( QListViewItem *it) { |
481 | d->setDocumentUsed = FALSE; | 482 | d->setDocumentUsed = FALSE; |
482 | 483 | ||
483 | if(it) { | 484 | if(it) { |
484 | if ( currentTab() == CurrentPlayList ) | 485 | if ( currentTab() == CurrentPlayList ) |
485 | return; | 486 | return; |
486 | DocLnk lnk; | 487 | DocLnk lnk; |
487 | QString filename; | 488 | QString filename; |
488 | 489 | ||
489 | filename=it->text(3); | 490 | filename=it->text(3); |
490 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 491 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
491 | lnk.setFile( filename ); //sets file name | 492 | lnk.setFile( filename ); //sets file name |
492 | d->selectedFiles->addToSelection( lnk); | 493 | d->selectedFiles->addToSelection( lnk); |
493 | 494 | ||
494 | writeCurrentM3u(); | 495 | writeCurrentM3u(); |
495 | // tabWidget->setCurrentPage(0); | 496 | // tabWidget->setCurrentPage(0); |
496 | 497 | ||
497 | } | 498 | } |
498 | } | 499 | } |
499 | 500 | ||
500 | 501 | ||
501 | void PlayListWidget::tabChanged(QWidget *) { | 502 | void PlayListWidget::tabChanged(QWidget *) { |
502 | 503 | ||
503 | d->tbPlay->setEnabled( true ); | 504 | d->tbPlay->setEnabled( true ); |
504 | 505 | ||
505 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), | 506 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), |
506 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 507 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
507 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), | 508 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), |
508 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 509 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
509 | 510 | ||
510 | currentFileListView = 0; | 511 | currentFileListView = 0; |
511 | 512 | ||
512 | switch ( currentTab() ) { | 513 | switch ( currentTab() ) { |
513 | case CurrentPlayList: | 514 | case CurrentPlayList: |
514 | { | 515 | { |
515 | if( !tbDeletePlaylist->isHidden() ) { | 516 | if( !tbDeletePlaylist->isHidden() ) { |
516 | tbDeletePlaylist->hide(); | 517 | tbDeletePlaylist->hide(); |
517 | } | 518 | } |
518 | d->tbRemoveFromList->setEnabled(TRUE); | 519 | d->tbRemoveFromList->setEnabled(TRUE); |
519 | d->tbAddToList->setEnabled(FALSE); | 520 | d->tbAddToList->setEnabled(FALSE); |
520 | 521 | ||
521 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 522 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
522 | } | 523 | } |
523 | break; | 524 | break; |
524 | case AudioFiles: | 525 | case AudioFiles: |
525 | { | 526 | { |
526 | audioView->populateView(); | 527 | audioView->populateView(); |
527 | 528 | ||
528 | if( !tbDeletePlaylist->isHidden() ) { | 529 | if( !tbDeletePlaylist->isHidden() ) { |
529 | tbDeletePlaylist->hide(); | 530 | tbDeletePlaylist->hide(); |
530 | } | 531 | } |
531 | d->tbRemoveFromList->setEnabled(FALSE); | 532 | d->tbRemoveFromList->setEnabled(FALSE); |
532 | d->tbAddToList->setEnabled(TRUE); | 533 | d->tbAddToList->setEnabled(TRUE); |
533 | 534 | ||
534 | connect( audioView, SIGNAL( itemsSelected(bool) ), | 535 | connect( audioView, SIGNAL( itemsSelected(bool) ), |
535 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 536 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
536 | 537 | ||
537 | d->tbPlay->setEnabled( audioView->hasSelection() ); | 538 | d->tbPlay->setEnabled( audioView->hasSelection() ); |
538 | 539 | ||
539 | currentFileListView = audioView; | 540 | currentFileListView = audioView; |
540 | } | 541 | } |
541 | break; | 542 | break; |
542 | case VideoFiles: | 543 | case VideoFiles: |
543 | { | 544 | { |
544 | videoView->populateView(); | 545 | videoView->populateView(); |
545 | if( !tbDeletePlaylist->isHidden() ) { | 546 | if( !tbDeletePlaylist->isHidden() ) { |
546 | tbDeletePlaylist->hide(); | 547 | tbDeletePlaylist->hide(); |
547 | } | 548 | } |
548 | d->tbRemoveFromList->setEnabled(FALSE); | 549 | d->tbRemoveFromList->setEnabled(FALSE); |
549 | d->tbAddToList->setEnabled(TRUE); | 550 | d->tbAddToList->setEnabled(TRUE); |
550 | 551 | ||
551 | connect( videoView, SIGNAL( itemsSelected(bool) ), | 552 | connect( videoView, SIGNAL( itemsSelected(bool) ), |
552 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 553 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
553 | 554 | ||
554 | d->tbPlay->setEnabled( videoView->hasSelection() ); | 555 | d->tbPlay->setEnabled( videoView->hasSelection() ); |
555 | 556 | ||
556 | currentFileListView = videoView; | 557 | currentFileListView = videoView; |
557 | } | 558 | } |
558 | break; | 559 | break; |
559 | case PlayLists: | 560 | case PlayLists: |
560 | { | 561 | { |
561 | if( tbDeletePlaylist->isHidden() ) { | 562 | if( tbDeletePlaylist->isHidden() ) { |
562 | tbDeletePlaylist->show(); | 563 | tbDeletePlaylist->show(); |
563 | } | 564 | } |
564 | playLists->reread(); | 565 | playLists->reread(); |
565 | d->tbAddToList->setEnabled(FALSE); | 566 | d->tbAddToList->setEnabled(FALSE); |
566 | 567 | ||
567 | d->tbPlay->setEnabled( false ); | 568 | d->tbPlay->setEnabled( false ); |
568 | } | 569 | } |
569 | break; | 570 | break; |
570 | }; | 571 | }; |
571 | } | 572 | } |
572 | 573 | ||
573 | 574 | ||
574 | void PlayListWidget::btnPlay(bool b) { | 575 | void PlayListWidget::btnPlay(bool b) { |
575 | // mediaPlayerState->setPlaying(false); | 576 | // mediaPlayerState->setPlaying(false); |
576 | mediaPlayerState->setPlaying(b); | 577 | mediaPlayerState->setPlaying(b); |
577 | insanityBool=FALSE; | 578 | insanityBool=FALSE; |
578 | } | 579 | } |
579 | 580 | ||
580 | void PlayListWidget::deletePlaylist() { | 581 | void PlayListWidget::deletePlaylist() { |
581 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 582 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
582 | (tr("You really want to delete\nthis playlist?")), | 583 | (tr("You really want to delete\nthis playlist?")), |
583 | (tr("Yes")), (tr("No")), 0 )){ | 584 | (tr("Yes")), (tr("No")), 0 )){ |
584 | case 0: // Yes clicked, | 585 | case 0: // Yes clicked, |
585 | QFile().remove(playLists->selectedDocument().file()); | 586 | QFile().remove(playLists->selectedDocument().file()); |
586 | QFile().remove(playLists->selectedDocument().linkFile()); | 587 | QFile().remove(playLists->selectedDocument().linkFile()); |
587 | playLists->reread(); | 588 | playLists->reread(); |
588 | break; | 589 | break; |
589 | case 1: // Cancel | 590 | case 1: // Cancel |
590 | break; | 591 | break; |
591 | }; | 592 | }; |
592 | } | 593 | } |
593 | 594 | ||
594 | 595 | ||
595 | void PlayListWidget::playSelected() { | 596 | void PlayListWidget::playSelected() { |
596 | btnPlay( TRUE); | 597 | btnPlay( TRUE); |
597 | } | 598 | } |
598 | 599 | ||
599 | bool PlayListWidget::inFileListMode() const | 600 | bool PlayListWidget::inFileListMode() const |
600 | { | 601 | { |
601 | TabType tab = currentTab(); | 602 | TabType tab = currentTab(); |
602 | return tab == AudioFiles || tab == VideoFiles; | 603 | return tab == AudioFiles || tab == VideoFiles; |
603 | } | 604 | } |
604 | 605 | ||
605 | void PlayListWidget::openURL() { | 606 | void PlayListWidget::openURL() { |
606 | // http://66.28.164.33:2080 | 607 | // http://66.28.164.33:2080 |
607 | // http://somafm.com/star0242.m3u | 608 | // http://somafm.com/star0242.m3u |
608 | QString filename, name; | 609 | QString filename, name; |
609 | InputDialog *fileDlg; | 610 | InputDialog *fileDlg; |
610 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); | 611 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); |
611 | fileDlg->exec(); | 612 | fileDlg->exec(); |
612 | if( fileDlg->result() == 1 ) { | 613 | if( fileDlg->result() == 1 ) { |
613 | filename = fileDlg->text(); | 614 | filename = fileDlg->text(); |
614 | qDebug( "Selected filename is " + filename ); | 615 | qDebug( "Selected filename is " + filename ); |
615 | // Om3u *m3uList; | 616 | // Om3u *m3uList; |
616 | DocLnk lnk; | 617 | DocLnk lnk; |
617 | Config cfg( "OpiePlayer" ); | 618 | Config cfg( "OpiePlayer" ); |
618 | cfg.setGroup("PlayList"); | 619 | cfg.setGroup("PlayList"); |
619 | 620 | ||
620 | if(filename.left(4) == "http") { | 621 | if(filename.left(4) == "http") { |
621 | QString m3uFile, m3uFilePath; | 622 | QString m3uFile, m3uFilePath; |
622 | if(filename.find(":",8,TRUE) != -1) { //found a port | 623 | if(filename.find(":",8,TRUE) != -1) { //found a port |
623 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 624 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
624 | m3uFile = m3uFile.right( 7); | 625 | m3uFile = m3uFile.right( 7); |
625 | } else if(filename.left(4) == "http"){ | 626 | } else if(filename.left(4) == "http"){ |
626 | m3uFile=filename; | 627 | m3uFile=filename; |
627 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 628 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
628 | } else{ | 629 | } else{ |
629 | m3uFile=filename; | 630 | m3uFile=filename; |
630 | } | 631 | } |
631 | 632 | ||
632 | lnk.setName( filename ); //sets name | 633 | lnk.setName( filename ); //sets name |
633 | lnk.setFile( filename ); //sets file name | 634 | lnk.setFile( filename ); //sets file name |
634 | 635 | ||
635 | // lnk.setIcon("opieplayer2/musicfile"); | 636 | // lnk.setIcon("opieplayer2/musicfile"); |
636 | 637 | ||
637 | d->selectedFiles->addToSelection( lnk ); | 638 | d->selectedFiles->addToSelection( lnk ); |
638 | writeCurrentM3u(); | 639 | writeCurrentM3u(); |
639 | d->selectedFiles->setSelectedItem( lnk.name()); | 640 | d->selectedFiles->setSelectedItem( lnk.name()); |
640 | } | 641 | } |
641 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 642 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
642 | readListFromFile( filename ); | 643 | readListFromFile( filename ); |
643 | } else { | 644 | } else { |
644 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 645 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
645 | lnk.setFile( filename ); //sets file name | 646 | lnk.setFile( filename ); //sets file name |
646 | d->selectedFiles->addToSelection( lnk); | 647 | d->selectedFiles->addToSelection( lnk); |
647 | writeCurrentM3u(); | 648 | writeCurrentM3u(); |
648 | d->selectedFiles->setSelectedItem( lnk.name()); | 649 | d->selectedFiles->setSelectedItem( lnk.name()); |
649 | } | 650 | } |
650 | } | 651 | } |
651 | 652 | ||
652 | 653 | ||
653 | delete fileDlg; | 654 | delete fileDlg; |
654 | } | 655 | } |
655 | 656 | ||
656 | 657 | ||
657 | void PlayListWidget::openFile() { | 658 | void PlayListWidget::openFile() { |
658 | 659 | ||
659 | QString filename, name; | 660 | QString filename, name; |
660 | 661 | ||
661 | Config cfg( "OpiePlayer" ); | 662 | Config cfg( "OpiePlayer" ); |
662 | cfg.setGroup("Dialog"); | 663 | cfg.setGroup("Dialog"); |
663 | MimeTypes types; | 664 | MimeTypes types; |
664 | QStringList audio, video, all; | 665 | QStringList audio, video, all; |
665 | audio << "audio/*"; | 666 | audio << "audio/*"; |
666 | audio << "playlist/plain"; | 667 | audio << "playlist/plain"; |
667 | audio << "application/ogg"; | 668 | audio << "application/ogg"; |
668 | audio << "audio/x-mpegurl"; | 669 | audio << "audio/x-mpegurl"; |
669 | 670 | ||
670 | video << "video/*"; | 671 | video << "video/*"; |
671 | video << "playlist/plain"; | 672 | video << "playlist/plain"; |
672 | 673 | ||
673 | all += audio; | 674 | all += audio; |
674 | all += video; | 675 | all += video; |
675 | types.insert("All Media Files", all ); | 676 | types.insert("All Media Files", all ); |
676 | types.insert("Audio", audio ); | 677 | types.insert("Audio", audio ); |
677 | types.insert("Video", video ); | 678 | types.insert("Video", video ); |
678 | 679 | ||
679 | QString str = OFileDialog::getOpenFileName( 1, | 680 | QString str = OFileDialog::getOpenFileName( 1, |
680 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 681 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
681 | types, 0 ); | 682 | types, 0 ); |
682 | 683 | ||
683 | if(str.left(2) == "//") { | 684 | if(str.left(2) == "//") { |
684 | str=str.right(str.length()-1); | 685 | str=str.right(str.length()-1); |
685 | } | 686 | } |
686 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); | 687 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); |
687 | 688 | ||
688 | if( !str.isEmpty() ) { | 689 | if( !str.isEmpty() ) { |
689 | 690 | ||
690 | qDebug( "Selected filename is " + str ); | 691 | qDebug( "Selected filename is " + str ); |
691 | filename = str; | 692 | filename = str; |
692 | DocLnk lnk; | 693 | DocLnk lnk; |
693 | 694 | ||
694 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 695 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
695 | readListFromFile( filename ); | 696 | readListFromFile( filename ); |
696 | } else { | 697 | } else { |
697 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 698 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
698 | lnk.setFile( filename ); //sets file name | 699 | lnk.setFile( filename ); //sets file name |
699 | d->selectedFiles->addToSelection( lnk ); | 700 | d->selectedFiles->addToSelection( lnk ); |
700 | writeCurrentM3u(); | 701 | writeCurrentM3u(); |
701 | d->selectedFiles->setSelectedItem( lnk.name() ); | 702 | d->selectedFiles->setSelectedItem( lnk.name() ); |
702 | } | 703 | } |
703 | } | 704 | } |
704 | } | 705 | } |
705 | 706 | ||
706 | 707 | ||
707 | void PlayListWidget::readListFromFile( const QString &filename ) { | 708 | void PlayListWidget::readListFromFile( const QString &filename ) { |
708 | qDebug( "read list filename " + filename ); | 709 | qDebug( "read list filename " + filename ); |
709 | QFileInfo fi(filename); | 710 | QFileInfo fi(filename); |
710 | Om3u *m3uList; | 711 | Om3u *m3uList; |
711 | QString s, name; | 712 | QString s, name; |
712 | m3uList = new Om3u( filename, IO_ReadOnly ); | 713 | m3uList = new Om3u( filename, IO_ReadOnly ); |
713 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 714 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
714 | m3uList->readM3u(); | 715 | m3uList->readM3u(); |
715 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 716 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
716 | m3uList->readPls(); | 717 | m3uList->readPls(); |
717 | 718 | ||
718 | DocLnk lnk; | 719 | DocLnk lnk; |
719 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 720 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
720 | s = *it; | 721 | s = *it; |
721 | // qDebug(s); | 722 | // qDebug(s); |
722 | if(s.left(4)=="http") { | 723 | if(s.left(4)=="http") { |
723 | lnk.setName( s ); //sets file name | 724 | lnk.setName( s ); //sets file name |
724 | lnk.setIcon("opieplayer2/musicfile"); | 725 | lnk.setIcon("opieplayer2/musicfile"); |
725 | lnk.setFile( s ); //sets file name | 726 | lnk.setFile( s ); //sets file name |
726 | 727 | ||
727 | } else { //is file | 728 | } else { //is file |
728 | lnk.setName( QFileInfo(s).baseName()); | 729 | lnk.setName( QFileInfo(s).baseName()); |
729 | if(s.left(1) != "/") { | 730 | if(s.left(1) != "/") { |
730 | 731 | ||
731 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 732 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
732 | } else { | 733 | } else { |
733 | lnk.setFile( s); | 734 | lnk.setFile( s); |
734 | } | 735 | } |
735 | } | 736 | } |
736 | d->selectedFiles->addToSelection( lnk ); | 737 | d->selectedFiles->addToSelection( lnk ); |
737 | } | 738 | } |
738 | Config config( "OpiePlayer" ); | 739 | Config config( "OpiePlayer" ); |
739 | config.setGroup( "PlayList" ); | 740 | config.setGroup( "PlayList" ); |
740 | 741 | ||
741 | config.writeEntry("CurrentPlaylist",filename); | 742 | config.writeEntry("CurrentPlaylist",filename); |
742 | config.write(); | 743 | config.write(); |
743 | currentPlayList=filename; | 744 | currentPlayList=filename; |
744 | 745 | ||
745 | m3uList->close(); | 746 | m3uList->close(); |
746 | delete m3uList; | 747 | delete m3uList; |
747 | 748 | ||
748 | d->selectedFiles->setSelectedItem( s); | 749 | d->selectedFiles->setSelectedItem( s); |
749 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 750 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
750 | 751 | ||
751 | } | 752 | } |
752 | 753 | ||
753 | // writes current playlist to current m3u file */ | 754 | // writes current playlist to current m3u file */ |
754 | void PlayListWidget::writeCurrentM3u() { | 755 | void PlayListWidget::writeCurrentM3u() { |
755 | qDebug("writing to current m3u"); | 756 | qDebug("writing to current m3u"); |
756 | Config cfg( "OpiePlayer" ); | 757 | Config cfg( "OpiePlayer" ); |
757 | cfg.setGroup("PlayList"); | 758 | cfg.setGroup("PlayList"); |
758 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 759 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
759 | 760 | ||
760 | Om3u *m3uList; | 761 | Om3u *m3uList; |
761 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 762 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
762 | if( d->selectedFiles->first()) { | 763 | if( d->selectedFiles->first()) { |
763 | 764 | ||
764 | do { | 765 | do { |
765 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 766 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
766 | m3uList->add( d->selectedFiles->current()->file() ); | 767 | m3uList->add( d->selectedFiles->current()->file() ); |
767 | } | 768 | } |
768 | while ( d->selectedFiles->next() ); | 769 | while ( d->selectedFiles->next() ); |
769 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 770 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
770 | m3uList->write(); | 771 | m3uList->write(); |
771 | m3uList->close(); | 772 | m3uList->close(); |
772 | } | 773 | } |
773 | delete m3uList; | 774 | delete m3uList; |
774 | 775 | ||
775 | } | 776 | } |
776 | 777 | ||
777 | /* | 778 | /* |
778 | writes current playlist to m3u file */ | 779 | writes current playlist to m3u file */ |
779 | void PlayListWidget::writem3u() { | 780 | void PlayListWidget::writem3u() { |
780 | //InputDilog *fileDlg; | 781 | //InputDilog *fileDlg; |
781 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 782 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
782 | //fileDlg->exec(); | 783 | //fileDlg->exec(); |
783 | 784 | ||
784 | Config cfg( "OpiePlayer" ); | 785 | Config cfg( "OpiePlayer" ); |
785 | cfg.setGroup("Dialog"); | 786 | cfg.setGroup("Dialog"); |
786 | MimeTypes types; | 787 | MimeTypes types; |
787 | QStringList audio, video, all; | 788 | QStringList audio, video, all; |
788 | audio << "audio/*"; | 789 | audio << "audio/*"; |
789 | audio << "playlist/plain"; | 790 | audio << "playlist/plain"; |
790 | audio << "audio/x-mpegurl"; | 791 | audio << "audio/x-mpegurl"; |
791 | 792 | ||
792 | video << "video/*"; | 793 | video << "video/*"; |
793 | video << "playlist/plain"; | 794 | video << "playlist/plain"; |
794 | 795 | ||
795 | all += audio; | 796 | all += audio; |
796 | all += video; | 797 | all += video; |
797 | types.insert("All Media Files", all ); | 798 | types.insert("All Media Files", all ); |
798 | types.insert("Audio", audio ); | 799 | types.insert("Audio", audio ); |
799 | types.insert("Video", video ); | 800 | types.insert("Video", video ); |
800 | 801 | ||
801 | QString str = OFileDialog::getOpenFileName( 1, | 802 | QString str = OFileDialog::getOpenFileName( 1, |
802 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 803 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
803 | types, 0 ); | 804 | types, 0 ); |
804 | if(str.left(2) == "//") str=str.right(str.length()-1); | 805 | if(str.left(2) == "//") str=str.right(str.length()-1); |
805 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); | 806 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); |
806 | 807 | ||
807 | 808 | ||
808 | QString name, filename, list; | 809 | QString name, filename, list; |
809 | Om3u *m3uList; | 810 | Om3u *m3uList; |
810 | 811 | ||
811 | if( !str.isEmpty() ) { | 812 | if( !str.isEmpty() ) { |
812 | name = str; | 813 | name = str; |
813 | // name = fileDlg->text(); | 814 | // name = fileDlg->text(); |
814 | // qDebug( filename ); | 815 | // qDebug( filename ); |
815 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 816 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
816 | filename = name; | 817 | filename = name; |
817 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 818 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
818 | } | 819 | } |
819 | else //otherwise dump it somewhere noticable | 820 | else //otherwise dump it somewhere noticable |
820 | filename = QPEApplication::documentDir() + "/" + name; | 821 | filename = QPEApplication::documentDir() + "/" + name; |
821 | 822 | ||
822 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 823 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
823 | filename += ".m3u"; | 824 | filename += ".m3u"; |
824 | 825 | ||
825 | if( d->selectedFiles->first()) { //ramble through playlist view | 826 | if( d->selectedFiles->first()) { //ramble through playlist view |
826 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); | 827 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
827 | 828 | ||
828 | do { | 829 | do { |
829 | m3uList->add( d->selectedFiles->current()->file()); | 830 | m3uList->add( d->selectedFiles->current()->file()); |
830 | } | 831 | } |
831 | while ( d->selectedFiles->next() ); | 832 | while ( d->selectedFiles->next() ); |
832 | // qDebug( list ); | 833 | // qDebug( list ); |
833 | m3uList->write(); | 834 | m3uList->write(); |
834 | m3uList->close(); | 835 | m3uList->close(); |
835 | delete m3uList; | 836 | delete m3uList; |
836 | 837 | ||
837 | //delete fileDlg; | 838 | //delete fileDlg; |
838 | 839 | ||
839 | DocLnk lnk; | 840 | DocLnk lnk; |
840 | lnk.setFile( filename); | 841 | lnk.setFile( filename); |
841 | lnk.setIcon("opieplayer2/playlist2"); | 842 | lnk.setIcon("opieplayer2/playlist2"); |
842 | lnk.setName( name); //sets file name | 843 | lnk.setName( name); //sets file name |
843 | 844 | ||
844 | // qDebug(filename); | 845 | // qDebug(filename); |
845 | Config config( "OpiePlayer" ); | 846 | Config config( "OpiePlayer" ); |
846 | config.setGroup( "PlayList" ); | 847 | config.setGroup( "PlayList" ); |
847 | 848 | ||
848 | config.writeEntry("CurrentPlaylist",filename); | 849 | config.writeEntry("CurrentPlaylist",filename); |
849 | currentPlayList=filename; | 850 | currentPlayList=filename; |
850 | 851 | ||
851 | if(!lnk.writeLink()) { | 852 | if(!lnk.writeLink()) { |
852 | qDebug("Writing doclink did not work"); | 853 | qDebug("Writing doclink did not work"); |
853 | } | 854 | } |
854 | 855 | ||
855 | setCaption(tr("OpiePlayer: ") + name); | 856 | setCaption(tr("OpiePlayer: ") + name); |
856 | } | 857 | } |
857 | } | 858 | } |
858 | } | 859 | } |
859 | 860 | ||
860 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 861 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
861 | switch ( e->key() ) { | 862 | switch ( e->key() ) { |
862 | ////////////////////////////// Zaurus keys | 863 | ////////////////////////////// Zaurus keys |
863 | case Key_F9: //activity | 864 | case Key_F9: //activity |
864 | // if(audioUI->isHidden()) | 865 | // if(audioUI->isHidden()) |
865 | // audioUI->showMaximized(); | 866 | // audioUI->showMaximized(); |
866 | break; | 867 | break; |
867 | case Key_F10: //contacts | 868 | case Key_F10: //contacts |
868 | // if( videoUI->isHidden()) | 869 | // if( videoUI->isHidden()) |
869 | // videoUI->showMaximized(); | 870 | // videoUI->showMaximized(); |
870 | break; | 871 | break; |
871 | case Key_F11: //menu | 872 | case Key_F11: //menu |
872 | break; | 873 | break; |
873 | case Key_F12: //home | 874 | case Key_F12: //home |
874 | // doBlank(); | 875 | // doBlank(); |
875 | break; | 876 | break; |
876 | case Key_F13: //mail | 877 | case Key_F13: //mail |
877 | // doUnblank(); | 878 | // doUnblank(); |
878 | break; | 879 | break; |
879 | case Key_Q: //add to playlist | 880 | case Key_Q: //add to playlist |
880 | addSelected(); | 881 | addSelected(); |
881 | break; | 882 | break; |
882 | case Key_R: //remove from playlist | 883 | case Key_R: //remove from playlist |
883 | removeSelected(); | 884 | removeSelected(); |
884 | break; | 885 | break; |
885 | // case Key_P: //play | 886 | // case Key_P: //play |
886 | // qDebug("Play"); | 887 | // qDebug("Play"); |
887 | // playSelected(); | 888 | // playSelected(); |
888 | // break; | 889 | // break; |
889 | case Key_Space: | 890 | case Key_Space: |
890 | // playSelected(); puh | 891 | // playSelected(); puh |
891 | break; | 892 | break; |
892 | case Key_1: | 893 | case Key_1: |
893 | tabWidget->setCurrentPage( 0 ); | 894 | tabWidget->setCurrentPage( 0 ); |
894 | break; | 895 | break; |
895 | case Key_2: | 896 | case Key_2: |
896 | tabWidget->setCurrentPage( 1 ); | 897 | tabWidget->setCurrentPage( 1 ); |
897 | break; | 898 | break; |
898 | case Key_3: | 899 | case Key_3: |
899 | tabWidget->setCurrentPage( 2 ); | 900 | tabWidget->setCurrentPage( 2 ); |
900 | break; | 901 | break; |
901 | case Key_4: | 902 | case Key_4: |
902 | tabWidget->setCurrentPage( 3 ); | 903 | tabWidget->setCurrentPage( 3 ); |
903 | break; | 904 | break; |
904 | case Key_Down: | 905 | case Key_Down: |
905 | if ( !d->selectedFiles->next() ) | 906 | if ( !d->selectedFiles->next() ) |
906 | d->selectedFiles->first(); | 907 | d->selectedFiles->first(); |
907 | break; | 908 | break; |
908 | case Key_Up: | 909 | case Key_Up: |
909 | if ( !d->selectedFiles->prev() ) | 910 | if ( !d->selectedFiles->prev() ) |
910 | // d->selectedFiles->last(); | 911 | // d->selectedFiles->last(); |
911 | break; | 912 | break; |
912 | } | 913 | } |
913 | } | 914 | } |
914 | 915 | ||
915 | void PlayListWidget::pmViewActivated(int index) { | 916 | void PlayListWidget::pmViewActivated(int index) { |
916 | // qDebug("%d", index); | 917 | // qDebug("%d", index); |
917 | switch(index) { | 918 | switch(index) { |
918 | case -16: | 919 | case -16: |
919 | { | 920 | { |
920 | mediaPlayerState->toggleFullscreen(); | 921 | mediaPlayerState->toggleFullscreen(); |
921 | bool b=mediaPlayerState->isFullscreen(); | 922 | bool b=mediaPlayerState->isFullscreen(); |
922 | pmView->setItemChecked( index, b); | 923 | pmView->setItemChecked( index, b); |
923 | Config cfg( "OpiePlayer" ); | 924 | Config cfg( "OpiePlayer" ); |
924 | cfg.writeEntry( "FullScreen", b ); | 925 | cfg.writeEntry( "FullScreen", b ); |
925 | } | 926 | } |
926 | break; | 927 | break; |
927 | }; | 928 | }; |
928 | } | 929 | } |
929 | 930 | ||
930 | void PlayListWidget::populateSkinsMenu() { | 931 | void PlayListWidget::populateSkinsMenu() { |
931 | int item = 0; | 932 | int item = 0; |
932 | defaultSkinIndex = 0; | 933 | defaultSkinIndex = 0; |
933 | QString skinName; | 934 | QString skinName; |
934 | Config cfg( "OpiePlayer" ); | 935 | Config cfg( "OpiePlayer" ); |
935 | cfg.setGroup("Options" ); | 936 | cfg.setGroup("Options" ); |
936 | QString skin = cfg.readEntry( "Skin", "default" ); | 937 | QString skin = cfg.readEntry( "Skin", "default" ); |
937 | 938 | ||
938 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 939 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
939 | skinsDir.setFilter( QDir::Dirs ); | 940 | skinsDir.setFilter( QDir::Dirs ); |
940 | skinsDir.setSorting(QDir::Name ); | 941 | skinsDir.setSorting(QDir::Name ); |
941 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 942 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
942 | QFileInfoListIterator it( *skinslist ); | 943 | QFileInfoListIterator it( *skinslist ); |
943 | QFileInfo *fi; | 944 | QFileInfo *fi; |
944 | while ( ( fi = it.current() ) ) { | 945 | while ( ( fi = it.current() ) ) { |
945 | skinName = fi->fileName(); | 946 | skinName = fi->fileName(); |
946 | // qDebug( fi->fileName() ); | 947 | // qDebug( fi->fileName() ); |
947 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 948 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
948 | item = skinsMenu->insertItem( fi->fileName() ) ; | 949 | item = skinsMenu->insertItem( fi->fileName() ) ; |
949 | } | 950 | } |
950 | if( skinName == "default" ) { | 951 | if( skinName == "default" ) { |
951 | defaultSkinIndex = item; | 952 | defaultSkinIndex = item; |
952 | } | 953 | } |
953 | if( skinName == skin ) { | 954 | if( skinName == skin ) { |
954 | skinsMenu->setItemChecked( item, TRUE ); | 955 | skinsMenu->setItemChecked( item, TRUE ); |
955 | } | 956 | } |
956 | ++it; | 957 | ++it; |
957 | } | 958 | } |
958 | } | 959 | } |
959 | 960 | ||
960 | void PlayListWidget::skinsMenuActivated( int item ) { | 961 | void PlayListWidget::skinsMenuActivated( int item ) { |
961 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 962 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
962 | skinsMenu->setItemChecked( i, FALSE ); | 963 | skinsMenu->setItemChecked( i, FALSE ); |
963 | } | 964 | } |
964 | skinsMenu->setItemChecked( item, TRUE ); | 965 | skinsMenu->setItemChecked( item, TRUE ); |
965 | 966 | ||
966 | { | 967 | { |
967 | Config cfg( "OpiePlayer" ); | 968 | Config cfg( "OpiePlayer" ); |
968 | cfg.setGroup("Options"); | 969 | cfg.setGroup("Options"); |
969 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 970 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
970 | } | 971 | } |
971 | 972 | ||
972 | emit skinSelected(); | 973 | emit skinSelected(); |
973 | } | 974 | } |
974 | 975 | ||
975 | PlayListWidget::TabType PlayListWidget::currentTab() const | 976 | PlayListWidget::TabType PlayListWidget::currentTab() const |
976 | { | 977 | { |
977 | static const TabType indexToTabType[ TabTypeCount ] = | 978 | static const TabType indexToTabType[ TabTypeCount ] = |
978 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 979 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
979 | 980 | ||
980 | int index = tabWidget->currentPageIndex(); | 981 | int index = tabWidget->currentPageIndex(); |
981 | assert( index < TabTypeCount && index >= 0 ); | 982 | assert( index < TabTypeCount && index >= 0 ); |
982 | 983 | ||
983 | return indexToTabType[ index ]; | 984 | return indexToTabType[ index ]; |
984 | } | 985 | } |
985 | 986 | ||
986 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 987 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
987 | { | 988 | { |
988 | if ( currentTab() == CurrentPlayList ) { | 989 | if ( currentTab() == CurrentPlayList ) { |
989 | const DocLnk *lnk = current(); | 990 | const DocLnk *lnk = current(); |
990 | return Entry( lnk->name(), lnk->file() ); | 991 | return Entry( lnk->name(), lnk->file() ); |
991 | } | 992 | } |
992 | 993 | ||
993 | return Entry( currentFileListPathName() ); | 994 | return Entry( currentFileListPathName() ); |
994 | } | 995 | } |
995 | 996 | ||
996 | QString PlayListWidget::currentFileListPathName() const { | 997 | QString PlayListWidget::currentFileListPathName() const { |
997 | return currentFileListView->currentItem()->text( 3 ); | 998 | return currentFileListView->currentItem()->text( 3 ); |
998 | } | 999 | } |
999 | 1000 | ||
1000 | 1001 | ||
1001 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1002 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1002 | qDebug("qcop message "+msg ); | 1003 | qDebug("qcop message "+msg ); |
1003 | QDataStream stream ( data, IO_ReadOnly ); | 1004 | QDataStream stream ( data, IO_ReadOnly ); |
1004 | if ( msg == "play()" ) { //plays current selection | 1005 | if ( msg == "play()" ) { //plays current selection |
1005 | btnPlay( true); | 1006 | btnPlay( true); |
1006 | } else if ( msg == "stop()" ) { | 1007 | } else if ( msg == "stop()" ) { |
1007 | mediaPlayerState->setPlaying( false); | 1008 | mediaPlayerState->setPlaying( false); |
1008 | } else if ( msg == "togglePause()" ) { | 1009 | } else if ( msg == "togglePause()" ) { |
1009 | mediaPlayerState->togglePaused(); | 1010 | mediaPlayerState->togglePaused(); |
1010 | } else if ( msg == "next()" ) { //select next in list | 1011 | } else if ( msg == "next()" ) { //select next in list |
1011 | mediaPlayerState->setNext(); | 1012 | mediaPlayerState->setNext(); |
1012 | } else if ( msg == "prev()" ) { //select previous in list | 1013 | } else if ( msg == "prev()" ) { //select previous in list |
1013 | mediaPlayerState->setPrev(); | 1014 | mediaPlayerState->setPrev(); |
1014 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1015 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1015 | mediaPlayerState->toggleLooping(); | 1016 | mediaPlayerState->toggleLooping(); |
1016 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1017 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1017 | mediaPlayerState->toggleShuffled(); | 1018 | mediaPlayerState->toggleShuffled(); |
1018 | } else if ( msg == "volUp()" ) { //volume more | 1019 | } else if ( msg == "volUp()" ) { //volume more |
1019 | // emit moreClicked(); | 1020 | // emit moreClicked(); |
1020 | // emit moreReleased(); | 1021 | // emit moreReleased(); |
1021 | } else if ( msg == "volDown()" ) { //volume less | 1022 | } else if ( msg == "volDown()" ) { //volume less |
1022 | // emit lessClicked(); | 1023 | // emit lessClicked(); |
1023 | // emit lessReleased(); | 1024 | // emit lessReleased(); |
1024 | } else if ( msg == "play(QString)" ) { //play this now | 1025 | } else if ( msg == "play(QString)" ) { //play this now |
1025 | QString file; | 1026 | QString file; |
1026 | stream >> file; | 1027 | stream >> file; |
1027 | setDocument( (const QString &) file); | 1028 | setDocument( (const QString &) file); |
1028 | } else if ( msg == "add(QString)" ) { //add to playlist | 1029 | } else if ( msg == "add(QString)" ) { //add to playlist |
1029 | QString file; | 1030 | QString file; |
1030 | stream >> file; | 1031 | stream >> file; |
1031 | QFileInfo fileInfo(file); | 1032 | QFileInfo fileInfo(file); |
1032 | DocLnk lnk; | 1033 | DocLnk lnk; |
1033 | lnk.setName( fileInfo.baseName() ); //sets name | 1034 | lnk.setName( fileInfo.baseName() ); //sets name |
1034 | lnk.setFile( file ); //sets file name | 1035 | lnk.setFile( file ); //sets file name |
1035 | addToSelection( lnk ); | 1036 | addToSelection( lnk ); |
1036 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1037 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1037 | QString file; | 1038 | QString file; |
1038 | stream >> file; | 1039 | stream >> file; |
1039 | 1040 | ||
1040 | } | 1041 | } |
1041 | 1042 | ||
1042 | } | 1043 | } |
diff --git a/noncore/multimedia/showimg/main.cpp b/noncore/multimedia/showimg/main.cpp index b61cffb..b7ea071 100644 --- a/noncore/multimedia/showimg/main.cpp +++ b/noncore/multimedia/showimg/main.cpp | |||
@@ -1,26 +1,28 @@ | |||
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 | 20 | ||
21 | #include "showimg.h" | 21 | #include "showimg.h" |
22 | 22 | ||
23 | 23 | ||
24 | #include <opie2/oapplicationfactory.h> | 24 | #include <opie2/oapplicationfactory.h> |
25 | 25 | ||
26 | using namespace Opie::Core; | ||
27 | using namespace Opie::Core; | ||
26 | OPIE_EXPORT_APP( OApplicationFactory<ImageViewer> ) | 28 | OPIE_EXPORT_APP( OApplicationFactory<ImageViewer> ) |
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp index 6c0c4db..696a57b 100644 --- a/noncore/multimedia/showimg/showimg.cpp +++ b/noncore/multimedia/showimg/showimg.cpp | |||
@@ -1,1239 +1,1240 @@ | |||
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 | 20 | ||
21 | // | 21 | // |
22 | // Full-screen and rotation options contributed by Robert Wittams <robert@wittams.com> | 22 | // Full-screen and rotation options contributed by Robert Wittams <robert@wittams.com> |
23 | // | 23 | // |
24 | 24 | ||
25 | #include "showimg.h" | 25 | #include "showimg.h" |
26 | #include "ImageFileSelector.h" | 26 | #include "ImageFileSelector.h" |
27 | #include "settingsdialog.h" | 27 | #include "settingsdialog.h" |
28 | 28 | ||
29 | 29 | ||
30 | #include <opie2/ofiledialog.h> | 30 | #include <opie2/ofiledialog.h> |
31 | 31 | ||
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/qpetoolbar.h> | 35 | #include <qtoolbar.h> |
36 | 36 | ||
37 | #include <qaction.h> | 37 | #include <qaction.h> |
38 | #include <qfiledialog.h> | 38 | #include <qfiledialog.h> |
39 | #include <qmenubar.h> | 39 | #include <qmenubar.h> |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | 41 | ||
42 | #include <math.h> | 42 | #include <math.h> |
43 | 43 | ||
44 | 44 | ||
45 | using namespace Opie::Ui; | ||
45 | ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) | 46 | ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) |
46 | : QDialog(parent,0,true) | 47 | : QDialog(parent,0,true) |
47 | { | 48 | { |
48 | setCaption(caption); | 49 | setCaption(caption); |
49 | 50 | ||
50 | if ( parent ) { | 51 | if ( parent ) { |
51 | setPalette(parent->palette()); | 52 | setPalette(parent->palette()); |
52 | } | 53 | } |
53 | 54 | ||
54 | b=brightness; | 55 | b=brightness; |
55 | img=image; | 56 | img=image; |
56 | 57 | ||
57 | setMinimumSize(140,80); | 58 | setMinimumSize(140,80); |
58 | 59 | ||
59 | QGridLayout *gl= new QGridLayout(this,2,2,4,4); | 60 | QGridLayout *gl= new QGridLayout(this,2,2,4,4); |
60 | 61 | ||
61 | pixmap =new ImageWidget(this);; | 62 | pixmap =new ImageWidget(this);; |
62 | QPixmap pm; | 63 | QPixmap pm; |
63 | pm.convertFromImage(img); | 64 | pm.convertFromImage(img); |
64 | pixmap->setPixmap(pm); | 65 | pixmap->setPixmap(pm); |
65 | pixmap->setMinimumSize(pm.width(),pm.height()); | 66 | pixmap->setMinimumSize(pm.width(),pm.height()); |
66 | gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); | 67 | gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); |
67 | QLabel *l=new QLabel(tr("Brightness")+":",this); | 68 | QLabel *l=new QLabel(tr("Brightness")+":",this); |
68 | gl->addWidget(l,1,0,AlignLeft); | 69 | gl->addWidget(l,1,0,AlignLeft); |
69 | spb=new QSpinBox(-100,100,2,this); | 70 | spb=new QSpinBox(-100,100,2,this); |
70 | gl->addWidget(spb,1,1,AlignRight); | 71 | gl->addWidget(spb,1,1,AlignRight); |
71 | 72 | ||
72 | spb->setValue(0); | 73 | spb->setValue(0); |
73 | 74 | ||
74 | connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); | 75 | connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); |
75 | 76 | ||
76 | } | 77 | } |
77 | 78 | ||
78 | void ControlsDialog::bValueChanged(int value) | 79 | void ControlsDialog::bValueChanged(int value) |
79 | { | 80 | { |
80 | QImage nImage=img; | 81 | QImage nImage=img; |
81 | nImage.detach(); | 82 | nImage.detach(); |
82 | ImageViewer::intensity(nImage, (float)value/100); | 83 | ImageViewer::intensity(nImage, (float)value/100); |
83 | QPixmap pm; | 84 | QPixmap pm; |
84 | pm.convertFromImage(nImage); | 85 | pm.convertFromImage(nImage); |
85 | pixmap->setPixmap(pm); | 86 | pixmap->setPixmap(pm); |
86 | pixmap->repaint(false); | 87 | pixmap->repaint(false); |
87 | 88 | ||
88 | 89 | ||
89 | } | 90 | } |
90 | 91 | ||
91 | void ControlsDialog::accept() | 92 | void ControlsDialog::accept() |
92 | { | 93 | { |
93 | *b=spb->value(); | 94 | *b=spb->value(); |
94 | done(1); | 95 | done(1); |
95 | } | 96 | } |
96 | 97 | ||
97 | //=========================================================================== | 98 | //=========================================================================== |
98 | 99 | ||
99 | InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) | 100 | InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) |
100 | : QDialog(parent,0,true) | 101 | : QDialog(parent,0,true) |
101 | { | 102 | { |
102 | setCaption(caption); | 103 | setCaption(caption); |
103 | 104 | ||
104 | if ( parent ) | 105 | if ( parent ) |
105 | { | 106 | { |
106 | setPalette(parent->palette()); | 107 | setPalette(parent->palette()); |
107 | } | 108 | } |
108 | 109 | ||
109 | 110 | ||
110 | 111 | ||
111 | QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; | 112 | QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; |
112 | 113 | ||
113 | setMinimumSize(180,80); | 114 | setMinimumSize(180,80); |
114 | int num=ImageViewer::LAST+1; | 115 | int num=ImageViewer::LAST+1; |
115 | if ( text[ImageViewer::ALPHA].isEmpty() ) | 116 | if ( text[ImageViewer::ALPHA].isEmpty() ) |
116 | num--; | 117 | num--; |
117 | QGridLayout *gl= new QGridLayout(this,num,2,4,2); | 118 | QGridLayout *gl= new QGridLayout(this,num,2,4,2); |
118 | QLabel *l; | 119 | QLabel *l; |
119 | int count=0; | 120 | int count=0; |
120 | for ( int i=0;i<num;i++ ) | 121 | for ( int i=0;i<num;i++ ) |
121 | { | 122 | { |
122 | if ( i==1 ) | 123 | if ( i==1 ) |
123 | { | 124 | { |
124 | QFrame *frm=new QFrame(this); | 125 | QFrame *frm=new QFrame(this); |
125 | frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); | 126 | frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); |
126 | gl->addMultiCellWidget(frm,i,i,0,1); | 127 | gl->addMultiCellWidget(frm,i,i,0,1); |
127 | } | 128 | } |
128 | else | 129 | else |
129 | { | 130 | { |
130 | l=new QLabel( tr( labels[count] )+":",this); | 131 | l=new QLabel( tr( labels[count] )+":",this); |
131 | gl->addWidget(l,i,0,AlignLeft); | 132 | gl->addWidget(l,i,0,AlignLeft); |
132 | l=new QLabel(text[count],this); | 133 | l=new QLabel(text[count],this); |
133 | gl->addWidget(l,i,1,AlignRight); | 134 | gl->addWidget(l,i,1,AlignRight); |
134 | count++; | 135 | count++; |
135 | } | 136 | } |
136 | 137 | ||
137 | } | 138 | } |
138 | 139 | ||
139 | } | 140 | } |
140 | 141 | ||
141 | void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) | 142 | void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) |
142 | { | 143 | { |
143 | InfoDialog *dlg=new InfoDialog(caption,text,parent); | 144 | InfoDialog *dlg=new InfoDialog(caption,text,parent); |
144 | dlg->exec(); | 145 | dlg->exec(); |
145 | delete dlg; | 146 | delete dlg; |
146 | } | 147 | } |
147 | 148 | ||
148 | //=========================================================================== | 149 | //=========================================================================== |
149 | 150 | ||
150 | 151 | ||
151 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) | 152 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) |
152 | { | 153 | { |
153 | vb = new QVBoxLayout( this ); | 154 | vb = new QVBoxLayout( this ); |
154 | 155 | ||
155 | image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); | 156 | image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); |
156 | pic=new ImageWidget(image); | 157 | pic=new ImageWidget(image); |
157 | image->addChild(pic); | 158 | image->addChild(pic); |
158 | 159 | ||
159 | connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); | 160 | connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); |
160 | 161 | ||
161 | vb->addWidget( image ); | 162 | vb->addWidget( image ); |
162 | 163 | ||
163 | } | 164 | } |
164 | 165 | ||
165 | void ImagePane::setPixmap( const QPixmap &pm ) | 166 | void ImagePane::setPixmap( const QPixmap &pm ) |
166 | { | 167 | { |
167 | pic->setPixmap( pm ); | 168 | pic->setPixmap( pm ); |
168 | pic->resize(pm.width(),pm.height()); | 169 | pic->resize(pm.width(),pm.height()); |
169 | image->updateScrollBars (); | 170 | image->updateScrollBars (); |
170 | pic->repaint(false); | 171 | pic->repaint(false); |
171 | } | 172 | } |
172 | 173 | ||
173 | void ImagePane::imageClicked() | 174 | void ImagePane::imageClicked() |
174 | { | 175 | { |
175 | emit clicked(); | 176 | emit clicked(); |
176 | } | 177 | } |
177 | //=========================================================================== | 178 | //=========================================================================== |
178 | /* | 179 | /* |
179 | Draws the portion of the scaled pixmap that needs to be updated | 180 | Draws the portion of the scaled pixmap that needs to be updated |
180 | */ | 181 | */ |
181 | 182 | ||
182 | void ImageWidget::paintEvent( QPaintEvent *e ) | 183 | void ImageWidget::paintEvent( QPaintEvent *e ) |
183 | { | 184 | { |
184 | QPainter painter(this); | 185 | QPainter painter(this); |
185 | 186 | ||
186 | painter.setClipRect(e->rect()); | 187 | painter.setClipRect(e->rect()); |
187 | painter.fillRect(0,0,width(),height(),QColor(0,0,0)); | 188 | painter.fillRect(0,0,width(),height(),QColor(0,0,0)); |
188 | 189 | ||
189 | if ( pixmap.size() != QSize( 0, 0 ) ) | 190 | if ( pixmap.size() != QSize( 0, 0 ) ) |
190 | { // is an image loaded? | 191 | { // is an image loaded? |
191 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); | 192 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); |
192 | } | 193 | } |
193 | } | 194 | } |
194 | 195 | ||
195 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) | 196 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) |
196 | { | 197 | { |
197 | emit clicked(); | 198 | emit clicked(); |
198 | } | 199 | } |
199 | 200 | ||
200 | //=========================================================================== | 201 | //=========================================================================== |
201 | 202 | ||
202 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int /*wFlags*/ ) | 203 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int /*wFlags*/ ) |
203 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) | 204 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) |
204 | { | 205 | { |
205 | setCaption( tr("Image Viewer") ); | 206 | setCaption( tr("Image Viewer") ); |
206 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); | 207 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); |
207 | 208 | ||
208 | 209 | ||
209 | Config cfg("Image Viewer"); | 210 | Config cfg("Image Viewer"); |
210 | cfg.setGroup("Image Viewer"); | 211 | cfg.setGroup("Image Viewer"); |
211 | 212 | ||
212 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); | 213 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); |
213 | isSized=cfg.readBoolEntry("SizeToScreen",true); | 214 | isSized=cfg.readBoolEntry("SizeToScreen",true); |
214 | 215 | ||
215 | isFullScreen = FALSE; | 216 | isFullScreen = FALSE; |
216 | 217 | ||
217 | setToolBarsMovable( FALSE ); | 218 | setToolBarsMovable( FALSE ); |
218 | 219 | ||
219 | toolBar = new QToolBar( this ); | 220 | toolBar = new QToolBar( this ); |
220 | toolBar->setHorizontalStretchable( TRUE ); | 221 | toolBar->setHorizontalStretchable( TRUE ); |
221 | 222 | ||
222 | menuBar = new QMenuBar( toolBar ); | 223 | menuBar = new QMenuBar( toolBar ); |
223 | 224 | ||
224 | current=menuBar; | 225 | current=menuBar; |
225 | 226 | ||
226 | 227 | ||
227 | 228 | ||
228 | fileMenuFile = new QPopupMenu(this); | 229 | fileMenuFile = new QPopupMenu(this); |
229 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); | 230 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); |
230 | fileMenuFile->insertItem(tr("Open"), | 231 | fileMenuFile->insertItem(tr("Open"), |
231 | this, SLOT(openFile()), 0); | 232 | this, SLOT(openFile()), 0); |
232 | 233 | ||
233 | viewMenuFile = new QPopupMenu( this ); | 234 | viewMenuFile = new QPopupMenu( this ); |
234 | //menubarFile->insertItem( tr("View"), viewMenu ); | 235 | //menubarFile->insertItem( tr("View"), viewMenu ); |
235 | viewMenuFile->insertItem( tr("Thumbnail View"), | 236 | viewMenuFile->insertItem( tr("Thumbnail View"), |
236 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); | 237 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); |
237 | 238 | ||
238 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 239 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
239 | 240 | ||
240 | 241 | ||
241 | 242 | ||
242 | 243 | ||
243 | optionsMenuFile = new QPopupMenu( this); | 244 | optionsMenuFile = new QPopupMenu( this); |
244 | //menubarFile->insertItem( tr("Options"),optionsMenu ); | 245 | //menubarFile->insertItem( tr("Options"),optionsMenu ); |
245 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), | 246 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), |
246 | QString::null, 0, this, 0 ); | 247 | QString::null, 0, this, 0 ); |
247 | slideAction->setToggleAction( TRUE ); | 248 | slideAction->setToggleAction( TRUE ); |
248 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); | 249 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); |
249 | slideAction->addTo( optionsMenuFile); | 250 | slideAction->addTo( optionsMenuFile); |
250 | // slideAction->addTo( toolBar ); | 251 | // slideAction->addTo( toolBar ); |
251 | 252 | ||
252 | 253 | ||
253 | // optionsMenuFile->insertItem( tr("Slideshow") ); | 254 | // optionsMenuFile->insertItem( tr("Slideshow") ); |
254 | optionsMenuFile->insertSeparator(); | 255 | optionsMenuFile->insertSeparator(); |
255 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); | 256 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); |
256 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); | 257 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); |
257 | 258 | ||
258 | QStrList fmt = QImage::outputFormats(); | 259 | QStrList fmt = QImage::outputFormats(); |
259 | 260 | ||
260 | 261 | ||
261 | fileMenuView = new QPopupMenu( this ); | 262 | fileMenuView = new QPopupMenu( this ); |
262 | //menubarView->insertItem( tr("File"),fileMenu ); | 263 | //menubarView->insertItem( tr("File"),fileMenu ); |
263 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); | 264 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); |
264 | fileMenuView->insertSeparator(); | 265 | fileMenuView->insertSeparator(); |
265 | 266 | ||
266 | viewMenuView = new QPopupMenu(this ); | 267 | viewMenuView = new QPopupMenu(this ); |
267 | viewMenuView->setCheckable ( true ); | 268 | viewMenuView->setCheckable ( true ); |
268 | 269 | ||
269 | //menubarView->insertItem( tr("View"),viewMenu ); | 270 | //menubarView->insertItem( tr("View"),viewMenu ); |
270 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); | 271 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); |
271 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); | 272 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); |
272 | 273 | ||
273 | stack = new QWidgetStack( this ); | 274 | stack = new QWidgetStack( this ); |
274 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 275 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
275 | setCentralWidget( stack ); | 276 | setCentralWidget( stack ); |
276 | 277 | ||
277 | 278 | ||
278 | imagePanel = new ImagePane( stack ); | 279 | imagePanel = new ImagePane( stack ); |
279 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); | 280 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); |
280 | 281 | ||
281 | 282 | ||
282 | ImageFileSelector::CURRENT_VIEW cv; | 283 | ImageFileSelector::CURRENT_VIEW cv; |
283 | if(showThumbView) | 284 | if(showThumbView) |
284 | cv=ImageFileSelector::THUMBNAIL; | 285 | cv=ImageFileSelector::THUMBNAIL; |
285 | else | 286 | else |
286 | cv=ImageFileSelector::DETAILED; | 287 | cv=ImageFileSelector::DETAILED; |
287 | 288 | ||
288 | qDebug("cv = %d",cv); | 289 | qDebug("cv = %d",cv); |
289 | 290 | ||
290 | fileSelector = new ImageFileSelector( cv,stack, "fs"); | 291 | fileSelector = new ImageFileSelector( cv,stack, "fs"); |
291 | 292 | ||
292 | //switchThumbView(); | 293 | //switchThumbView(); |
293 | 294 | ||
294 | 295 | ||
295 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); | 296 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); |
296 | //fileSelector->setNewVisible(FALSE); | 297 | //fileSelector->setNewVisible(FALSE); |
297 | //fileSelector->setCloseVisible(FALSE); | 298 | //fileSelector->setCloseVisible(FALSE); |
298 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); | 299 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); |
299 | connect( fileSelector, SIGNAL( fileSelected(const DocLnk&) ), | 300 | connect( fileSelector, SIGNAL( fileSelected(const DocLnk&) ), |
300 | this, SLOT( openFile(const DocLnk&) ) ); | 301 | this, SLOT( openFile(const DocLnk&) ) ); |
301 | 302 | ||
302 | imageList = fileSelector->fileList(); | 303 | imageList = fileSelector->fileList(); |
303 | slideAction->setEnabled( imageList.count() != 0); | 304 | slideAction->setEnabled( imageList.count() != 0); |
304 | 305 | ||
305 | iconToolBar = new QToolBar(this); | 306 | iconToolBar = new QToolBar(this); |
306 | 307 | ||
307 | QAction *a; | 308 | QAction *a; |
308 | 309 | ||
309 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 310 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
310 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); | 311 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); |
311 | a->addTo( fileMenuView); | 312 | a->addTo( fileMenuView); |
312 | a->addTo( iconToolBar ); | 313 | a->addTo( iconToolBar ); |
313 | 314 | ||
314 | 315 | ||
315 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); | 316 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); |
316 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); | 317 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); |
317 | a->addTo( iconToolBar ); | 318 | a->addTo( iconToolBar ); |
318 | a->addTo( viewMenuView ); | 319 | a->addTo( viewMenuView ); |
319 | 320 | ||
320 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); | 321 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); |
321 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); | 322 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); |
322 | a->addTo( iconToolBar ); | 323 | a->addTo( iconToolBar ); |
323 | a->addTo( viewMenuView ); | 324 | a->addTo( viewMenuView ); |
324 | 325 | ||
325 | 326 | ||
326 | a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); | 327 | a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); |
327 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); | 328 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); |
328 | //a->addTo( iconToolBar ); | 329 | //a->addTo( iconToolBar ); |
329 | a->addTo( viewMenuView ); | 330 | a->addTo( viewMenuView ); |
330 | 331 | ||
331 | 332 | ||
332 | 333 | ||
333 | viewMenuView->insertSeparator(); | 334 | viewMenuView->insertSeparator(); |
334 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); | 335 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); |
335 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); | 336 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); |
336 | viewMenuView->insertSeparator(); | 337 | viewMenuView->insertSeparator(); |
337 | 338 | ||
338 | 339 | ||
339 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); | 340 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); |
340 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); | 341 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); |
341 | sss->addTo( iconToolBar ); | 342 | sss->addTo( iconToolBar ); |
342 | sss->addTo( viewMenuView ); | 343 | sss->addTo( viewMenuView ); |
343 | 344 | ||
344 | sss->setOn(isSized); | 345 | sss->setOn(isSized); |
345 | viewMenuView->insertSeparator(); | 346 | viewMenuView->insertSeparator(); |
346 | 347 | ||
347 | 348 | ||
348 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), | 349 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), |
349 | QString::null, 0, this, 0 ); | 350 | QString::null, 0, this, 0 ); |
350 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); | 351 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); |
351 | a->addTo( iconToolBar ); | 352 | a->addTo( iconToolBar ); |
352 | a->addTo( viewMenuView); | 353 | a->addTo( viewMenuView); |
353 | 354 | ||
354 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), | 355 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), |
355 | QString::null, 0, this, 0 ); | 356 | QString::null, 0, this, 0 ); |
356 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); | 357 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); |
357 | a->addTo( iconToolBar ); | 358 | a->addTo( iconToolBar ); |
358 | a->addTo( viewMenuView); | 359 | a->addTo( viewMenuView); |
359 | 360 | ||
360 | 361 | ||
361 | Config config( "ImageViewer" ); | 362 | Config config( "ImageViewer" ); |
362 | config.setGroup( "SlideShow" ); | 363 | config.setGroup( "SlideShow" ); |
363 | slideDelay = config.readNumEntry( "Delay", 2); | 364 | slideDelay = config.readNumEntry( "Delay", 2); |
364 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); | 365 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); |
365 | slideReverse = config.readBoolEntry("Reverse", FALSE); | 366 | slideReverse = config.readBoolEntry("Reverse", FALSE); |
366 | 367 | ||
367 | config.setGroup("Default"); | 368 | config.setGroup("Default"); |
368 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); | 369 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); |
369 | fastLoad = config.readBoolEntry("FastLoad", TRUE); | 370 | fastLoad = config.readBoolEntry("FastLoad", TRUE); |
370 | slideTimer = new QTimer( this ); | 371 | slideTimer = new QTimer( this ); |
371 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); | 372 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); |
372 | 373 | ||
373 | switchToFileSelector(); | 374 | switchToFileSelector(); |
374 | 375 | ||
375 | setMouseTracking( TRUE ); | 376 | setMouseTracking( TRUE ); |
376 | 377 | ||
377 | 378 | ||
378 | } | 379 | } |
379 | 380 | ||
380 | ImageViewer::~ImageViewer() | 381 | ImageViewer::~ImageViewer() |
381 | { | 382 | { |
382 | Config cfg("Image Viewer"); | 383 | Config cfg("Image Viewer"); |
383 | cfg.setGroup("Image Viewer"); | 384 | cfg.setGroup("Image Viewer"); |
384 | 385 | ||
385 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); | 386 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); |
386 | cfg.writeEntry("SizeToScreen",(int)isSized); | 387 | cfg.writeEntry("SizeToScreen",(int)isSized); |
387 | 388 | ||
388 | cfg.setGroup( "SlideShow" ); | 389 | cfg.setGroup( "SlideShow" ); |
389 | cfg.writeEntry( "Delay", slideDelay); | 390 | cfg.writeEntry( "Delay", slideDelay); |
390 | cfg.writeEntry( "Repeat", slideRepeat ); | 391 | cfg.writeEntry( "Repeat", slideRepeat ); |
391 | cfg.writeEntry("Reverse", slideReverse); | 392 | cfg.writeEntry("Reverse", slideReverse); |
392 | 393 | ||
393 | cfg.setGroup("Default"); | 394 | cfg.setGroup("Default"); |
394 | cfg.writeEntry("Rotate", rotateOnLoad); | 395 | cfg.writeEntry("Rotate", rotateOnLoad); |
395 | cfg.writeEntry("FastLoad", fastLoad); | 396 | cfg.writeEntry("FastLoad", fastLoad); |
396 | 397 | ||
397 | delete imagePanel; // in case it is fullscreen | 398 | delete imagePanel; // in case it is fullscreen |
398 | } | 399 | } |
399 | 400 | ||
400 | void ImageViewer::help() { | 401 | void ImageViewer::help() { |
401 | 402 | ||
402 | } | 403 | } |
403 | 404 | ||
404 | 405 | ||
405 | void ImageViewer::settings() | 406 | void ImageViewer::settings() |
406 | { | 407 | { |
407 | SettingsDialog dlg( this, 0, TRUE ); | 408 | SettingsDialog dlg( this, 0, TRUE ); |
408 | dlg.setDelay( slideDelay ); | 409 | dlg.setDelay( slideDelay ); |
409 | dlg.setRepeat( slideRepeat ); | 410 | dlg.setRepeat( slideRepeat ); |
410 | dlg.setReverse( slideReverse ); | 411 | dlg.setReverse( slideReverse ); |
411 | dlg.setRotate(rotateOnLoad); | 412 | dlg.setRotate(rotateOnLoad); |
412 | dlg.setFastLoad(fastLoad); | 413 | dlg.setFastLoad(fastLoad); |
413 | 414 | ||
414 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { | 415 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { |
415 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); | 416 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); |
416 | slideDelay = dlg.delay(); | 417 | slideDelay = dlg.delay(); |
417 | slideRepeat = dlg.repeat(); | 418 | slideRepeat = dlg.repeat(); |
418 | slideReverse = dlg.reverse(); | 419 | slideReverse = dlg.reverse(); |
419 | rotateOnLoad = dlg.rotate(); | 420 | rotateOnLoad = dlg.rotate(); |
420 | fastLoad = dlg.fastLoad(); | 421 | fastLoad = dlg.fastLoad(); |
421 | 422 | ||
422 | Config config( "ImageViewer" ); | 423 | Config config( "ImageViewer" ); |
423 | config.setGroup( "SlideShow" ); | 424 | config.setGroup( "SlideShow" ); |
424 | config.writeEntry( "Delay", slideDelay ); | 425 | config.writeEntry( "Delay", slideDelay ); |
425 | config.writeEntry( "Repeat", slideRepeat ); | 426 | config.writeEntry( "Repeat", slideRepeat ); |
426 | config.writeEntry("Reverse", slideReverse); | 427 | config.writeEntry("Reverse", slideReverse); |
427 | 428 | ||
428 | config.setGroup("Default"); | 429 | config.setGroup("Default"); |
429 | config.writeEntry("Rotate", rotateOnLoad); | 430 | config.writeEntry("Rotate", rotateOnLoad); |
430 | config.writeEntry("FastLoad", fastLoad); | 431 | config.writeEntry("FastLoad", fastLoad); |
431 | } | 432 | } |
432 | } | 433 | } |
433 | 434 | ||
434 | void ImageViewer::switchSizeToScreen() | 435 | void ImageViewer::switchSizeToScreen() |
435 | { | 436 | { |
436 | isSized=!isSized; | 437 | isSized=!isSized; |
437 | sss->setOn(isSized); | 438 | sss->setOn(isSized); |
438 | updateImage(); | 439 | updateImage(); |
439 | } | 440 | } |
440 | 441 | ||
441 | void ImageViewer::updateImage() | 442 | void ImageViewer::updateImage() |
442 | { | 443 | { |
443 | if ( isSized ) { | 444 | if ( isSized ) { |
444 | imagePanel->setPixmap(pmScaled); | 445 | imagePanel->setPixmap(pmScaled); |
445 | } else { | 446 | } else { |
446 | imagePanel->setPixmap(pm); | 447 | imagePanel->setPixmap(pm); |
447 | } | 448 | } |
448 | } | 449 | } |
449 | 450 | ||
450 | void ImageViewer::switchThumbView() | 451 | void ImageViewer::switchThumbView() |
451 | { | 452 | { |
452 | 453 | ||
453 | showThumbView=!showThumbView; | 454 | showThumbView=!showThumbView; |
454 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 455 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
455 | fileSelector->switchView(); | 456 | fileSelector->switchView(); |
456 | 457 | ||
457 | } | 458 | } |
458 | 459 | ||
459 | void ImageViewer::switchToFileSelector() | 460 | void ImageViewer::switchToFileSelector() |
460 | { | 461 | { |
461 | stack->raiseWidget(fileSelector); | 462 | stack->raiseWidget(fileSelector); |
462 | menuBar->clear(); | 463 | menuBar->clear(); |
463 | menuBar->insertItem( tr("File"), fileMenuFile ); | 464 | menuBar->insertItem( tr("File"), fileMenuFile ); |
464 | menuBar->insertItem( tr("View"), viewMenuFile ); | 465 | menuBar->insertItem( tr("View"), viewMenuFile ); |
465 | menuBar->insertItem( tr("Options"), optionsMenuFile ); | 466 | menuBar->insertItem( tr("Options"), optionsMenuFile ); |
466 | iconToolBar->hide(); | 467 | iconToolBar->hide(); |
467 | imagePanel->disable(); | 468 | imagePanel->disable(); |
468 | slideShow(false); | 469 | slideShow(false); |
469 | 470 | ||
470 | } | 471 | } |
471 | 472 | ||
472 | void ImageViewer::switchToImageView() | 473 | void ImageViewer::switchToImageView() |
473 | { | 474 | { |
474 | stack->raiseWidget(imagePanel); | 475 | stack->raiseWidget(imagePanel); |
475 | 476 | ||
476 | menuBar->clear(); | 477 | menuBar->clear(); |
477 | menuBar->insertItem( tr("File"), fileMenuView ); | 478 | menuBar->insertItem( tr("File"), fileMenuView ); |
478 | menuBar->insertItem( tr("View"), viewMenuView ); | 479 | menuBar->insertItem( tr("View"), viewMenuView ); |
479 | viewMenuView->setItemEnabled(BLACKANDWHITE,true); | 480 | viewMenuView->setItemEnabled(BLACKANDWHITE,true); |
480 | iconToolBar->show(); | 481 | iconToolBar->show(); |
481 | 482 | ||
482 | imagePanel->setPosition(0,0); | 483 | imagePanel->setPosition(0,0); |
483 | 484 | ||
484 | } | 485 | } |
485 | 486 | ||
486 | 487 | ||
487 | void ImageViewer::setDocument(const QString& fileref) | 488 | void ImageViewer::setDocument(const QString& fileref) |
488 | { | 489 | { |
489 | delayLoad = fileref; | 490 | delayLoad = fileref; |
490 | switchToImageView(); | 491 | switchToImageView(); |
491 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); | 492 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); |
492 | } | 493 | } |
493 | 494 | ||
494 | void ImageViewer::doDelayedLoad() | 495 | void ImageViewer::doDelayedLoad() |
495 | { | 496 | { |
496 | show(delayLoad); | 497 | show(delayLoad); |
497 | } | 498 | } |
498 | 499 | ||
499 | void ImageViewer::show() | 500 | void ImageViewer::show() |
500 | { | 501 | { |
501 | normalView(); | 502 | normalView(); |
502 | QMainWindow::show(); | 503 | QMainWindow::show(); |
503 | } | 504 | } |
504 | 505 | ||
505 | void ImageViewer::show(const QString& fileref) | 506 | void ImageViewer::show(const QString& fileref) |
506 | { | 507 | { |
507 | // qDebug("Show "+fileref); | 508 | // qDebug("Show "+fileref); |
508 | bFromDocView = TRUE; | 509 | bFromDocView = TRUE; |
509 | closeFileSelector(); | 510 | closeFileSelector(); |
510 | DocLnk link(fileref); | 511 | DocLnk link(fileref); |
511 | if ( link.isValid() ) { | 512 | if ( link.isValid() ) { |
512 | openFile(link); | 513 | openFile(link); |
513 | } else { | 514 | } else { |
514 | filename = fileref; | 515 | filename = fileref; |
515 | updateCaption( fileref ); | 516 | updateCaption( fileref ); |
516 | loadImage( fileref ); | 517 | loadImage( fileref ); |
517 | } | 518 | } |
518 | } | 519 | } |
519 | 520 | ||
520 | void ImageViewer::openFile() { | 521 | void ImageViewer::openFile() { |
521 | MimeTypes types; | 522 | MimeTypes types; |
522 | QStringList image; | 523 | QStringList image; |
523 | image << "image/*"; | 524 | image << "image/*"; |
524 | types.insert("Images", image); | 525 | types.insert("Images", image); |
525 | 526 | ||
526 | QString str = Opie::OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); | 527 | QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); |
527 | DocLnk link(str); | 528 | DocLnk link(str); |
528 | // if ( link.isValid() ) | 529 | // if ( link.isValid() ) |
529 | openFile(link); | 530 | openFile(link); |
530 | 531 | ||
531 | } | 532 | } |
532 | 533 | ||
533 | void ImageViewer::openFile( const DocLnk &link ) | 534 | void ImageViewer::openFile( const DocLnk &link ) |
534 | { | 535 | { |
535 | closeFileSelector(); | 536 | closeFileSelector(); |
536 | // DocLnk link(file); | 537 | // DocLnk link(file); |
537 | qDebug("open "+link.name()); | 538 | qDebug("open "+link.name()); |
538 | updateCaption( link.name() ); | 539 | updateCaption( link.name() ); |
539 | loadImage( link.file() ); | 540 | loadImage( link.file() ); |
540 | if (slideTimer->isActive()) { | 541 | if (slideTimer->isActive()) { |
541 | slideTimer->start(slideDelay * 1000, FALSE); | 542 | slideTimer->start(slideDelay * 1000, FALSE); |
542 | } | 543 | } |
543 | 544 | ||
544 | } | 545 | } |
545 | 546 | ||
546 | void ImageViewer::open() | 547 | void ImageViewer::open() |
547 | { | 548 | { |
548 | switchToFileSelector(); | 549 | switchToFileSelector(); |
549 | } | 550 | } |
550 | 551 | ||
551 | void ImageViewer::closeFileSelector() | 552 | void ImageViewer::closeFileSelector() |
552 | { | 553 | { |
553 | switchToImageView(); | 554 | switchToImageView(); |
554 | } | 555 | } |
555 | 556 | ||
556 | void ImageViewer::updateCaption( QString name ) | 557 | void ImageViewer::updateCaption( QString name ) |
557 | { | 558 | { |
558 | int sep = name.findRev( '/' ); | 559 | int sep = name.findRev( '/' ); |
559 | if ( sep >= 0 ) | 560 | if ( sep >= 0 ) |
560 | name = name.mid( sep+1 ); | 561 | name = name.mid( sep+1 ); |
561 | setCaption( name + tr(" - Image Viewer") ); | 562 | setCaption( name + tr(" - Image Viewer") ); |
562 | } | 563 | } |
563 | 564 | ||
564 | /* | 565 | /* |
565 | This function loads an image from a file. | 566 | This function loads an image from a file. |
566 | */ | 567 | */ |
567 | 568 | ||
568 | void ImageViewer::loadImage( const char *fileName ) | 569 | void ImageViewer::loadImage( const char *fileName ) |
569 | { | 570 | { |
570 | filename = fileName; | 571 | filename = fileName; |
571 | if ( filename ) { | 572 | if ( filename ) { |
572 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 573 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
573 | //imagePanel->statusLabel()->setText( tr("Loading image...") ); | 574 | //imagePanel->statusLabel()->setText( tr("Loading image...") ); |
574 | qApp->processEvents(); | 575 | qApp->processEvents(); |
575 | bool ok = image.load(filename, 0); | 576 | bool ok = image.load(filename, 0); |
576 | if ( ok ) { | 577 | if ( ok ) { |
577 | ok = reconvertImage(); | 578 | ok = reconvertImage(); |
578 | updateImageInfo(filename); | 579 | updateImageInfo(filename); |
579 | } | 580 | } |
580 | if ( !ok ) { | 581 | if ( !ok ) { |
581 | pm.resize(0,0); // couldn't load image | 582 | pm.resize(0,0); // couldn't load image |
582 | update(); | 583 | update(); |
583 | } | 584 | } |
584 | QApplication::restoreOverrideCursor(); // restore original cursor | 585 | QApplication::restoreOverrideCursor(); // restore original cursor |
585 | } | 586 | } |
586 | 587 | ||
587 | // fastLoad ? ", Fast" : "", | 588 | // fastLoad ? ", Fast" : "", |
588 | // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); | 589 | // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); |
589 | 590 | ||
590 | 591 | ||
591 | // matrix.reset(); | 592 | // matrix.reset(); |
592 | rotated90 = FALSE; | 593 | rotated90 = FALSE; |
593 | 594 | ||
594 | if (rotateOnLoad) { | 595 | if (rotateOnLoad) { |
595 | rotated90 = TRUE; | 596 | rotated90 = TRUE; |
596 | rot90(); | 597 | rot90(); |
597 | // matrix.rotate( -90.0 ); | 598 | // matrix.rotate( -90.0 ); |
598 | } | 599 | } |
599 | 600 | ||
600 | switchToImageView(); | 601 | switchToImageView(); |
601 | updateImage(); | 602 | updateImage(); |
602 | 603 | ||
603 | } | 604 | } |
604 | 605 | ||
605 | bool ImageViewer::loadSelected() | 606 | bool ImageViewer::loadSelected() |
606 | { | 607 | { |
607 | bool ok = false; | 608 | bool ok = false; |
608 | if ( stack->visibleWidget() == fileSelector ) | 609 | if ( stack->visibleWidget() == fileSelector ) |
609 | { | 610 | { |
610 | const DocLnk *link = fileSelector->selected(); | 611 | const DocLnk *link = fileSelector->selected(); |
611 | if ( link ) | 612 | if ( link ) |
612 | { | 613 | { |
613 | if ( link->file() != filename ) | 614 | if ( link->file() != filename ) |
614 | { | 615 | { |
615 | updateCaption( link->name() ); | 616 | updateCaption( link->name() ); |
616 | filename = link->file(); | 617 | filename = link->file(); |
617 | qApp->processEvents(); | 618 | qApp->processEvents(); |
618 | ok = image.load(filename, 0); | 619 | ok = image.load(filename, 0); |
619 | if ( ok ) | 620 | if ( ok ) |
620 | { | 621 | { |
621 | updateImageInfo(filename); | 622 | updateImageInfo(filename); |
622 | ok = reconvertImage(); | 623 | ok = reconvertImage(); |
623 | } | 624 | } |
624 | if ( !ok ) | 625 | if ( !ok ) |
625 | pm.resize(0,0); | 626 | pm.resize(0,0); |
626 | } | 627 | } |
627 | } | 628 | } |
628 | } | 629 | } |
629 | if ( !image.isNull() ) | 630 | if ( !image.isNull() ) |
630 | { | 631 | { |
631 | ok = true; | 632 | ok = true; |
632 | closeFileSelector(); | 633 | closeFileSelector(); |
633 | } | 634 | } |
634 | 635 | ||
635 | return ok; | 636 | return ok; |
636 | } | 637 | } |
637 | 638 | ||
638 | bool ImageViewer::reconvertImage() | 639 | bool ImageViewer::reconvertImage() |
639 | { | 640 | { |
640 | bool success = FALSE; | 641 | bool success = FALSE; |
641 | 642 | ||
642 | if ( image.isNull() ) return FALSE; | 643 | if ( image.isNull() ) return FALSE; |
643 | 644 | ||
644 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 645 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
645 | if ( pm.convertFromImage(image /*, conversion_flags */ ) ) | 646 | if ( pm.convertFromImage(image /*, conversion_flags */ ) ) |
646 | { | 647 | { |
647 | pmScaled = QPixmap(); | 648 | pmScaled = QPixmap(); |
648 | scale(); | 649 | scale(); |
649 | success = TRUE; // load successful | 650 | success = TRUE; // load successful |
650 | } | 651 | } |
651 | else | 652 | else |
652 | { | 653 | { |
653 | pm.resize(0,0); // couldn't load image | 654 | pm.resize(0,0); // couldn't load image |
654 | } | 655 | } |
655 | QApplication::restoreOverrideCursor(); // restore original cursor | 656 | QApplication::restoreOverrideCursor(); // restore original cursor |
656 | 657 | ||
657 | return success; // TRUE if loaded OK | 658 | return success; // TRUE if loaded OK |
658 | } | 659 | } |
659 | 660 | ||
660 | 661 | ||
661 | int ImageViewer::calcHeight() | 662 | int ImageViewer::calcHeight() |
662 | { | 663 | { |
663 | if ( !isFullScreen ) | 664 | if ( !isFullScreen ) |
664 | return imagePanel->paneHeight(); | 665 | return imagePanel->paneHeight(); |
665 | else | 666 | else |
666 | return qApp->desktop()->height(); | 667 | return qApp->desktop()->height(); |
667 | } | 668 | } |
668 | /* | 669 | /* |
669 | This functions scales the pixmap in the member variable "pm" to fit the | 670 | This functions scales the pixmap in the member variable "pm" to fit the |
670 | widget size and puts the resulting pixmap in the member variable "pmScaled". | 671 | widget size and puts the resulting pixmap in the member variable "pmScaled". |
671 | */ | 672 | */ |
672 | void ImageViewer::scale() | 673 | void ImageViewer::scale() |
673 | { | 674 | { |
674 | int h = calcHeight(); | 675 | int h = calcHeight(); |
675 | if ( image.isNull() ) return; | 676 | if ( image.isNull() ) return; |
676 | 677 | ||
677 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 678 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
678 | if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) | 679 | if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) |
679 | { // no need to scale if widget | 680 | { // no need to scale if widget |
680 | pmScaled = pm; // size equals pixmap size | 681 | pmScaled = pm; // size equals pixmap size |
681 | } | 682 | } |
682 | else | 683 | else |
683 | { | 684 | { |
684 | double hs = (double)h / (double)image.height(); | 685 | double hs = (double)h / (double)image.height(); |
685 | double ws = (double)imagePanel->paneWidth() / (double)image.width(); | 686 | double ws = (double)imagePanel->paneWidth() / (double)image.width(); |
686 | double scaleFactor = (hs > ws) ? ws : hs; | 687 | double scaleFactor = (hs > ws) ? ws : hs; |
687 | int smoothW = (int)(scaleFactor * image.width()); | 688 | int smoothW = (int)(scaleFactor * image.width()); |
688 | int smoothH = (int)(scaleFactor * image.height()); | 689 | int smoothH = (int)(scaleFactor * image.height()); |
689 | 690 | ||
690 | pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); | 691 | pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); |
691 | } | 692 | } |
692 | QApplication::restoreOverrideCursor(); // restore original cursor | 693 | QApplication::restoreOverrideCursor(); // restore original cursor |
693 | } | 694 | } |
694 | 695 | ||
695 | /* | 696 | /* |
696 | The resize event handler, if a valid pixmap was loaded it will call | 697 | The resize event handler, if a valid pixmap was loaded it will call |
697 | scale() to fit the pixmap to the new widget size. | 698 | scale() to fit the pixmap to the new widget size. |
698 | */ | 699 | */ |
699 | 700 | ||
700 | void ImageViewer::resizeEvent( QResizeEvent * ) | 701 | void ImageViewer::resizeEvent( QResizeEvent * ) |
701 | { | 702 | { |
702 | 703 | ||
703 | if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image | 704 | if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image |
704 | return; | 705 | return; |
705 | 706 | ||
706 | int h = calcHeight(); | 707 | int h = calcHeight(); |
707 | 708 | ||
708 | if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) | 709 | if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) |
709 | { // if new size, | 710 | { // if new size, |
710 | scale(); // scale pmScaled to window | 711 | scale(); // scale pmScaled to window |
711 | } | 712 | } |
712 | if ( image.hasAlphaBuffer() ) | 713 | if ( image.hasAlphaBuffer() ) |
713 | erase(); | 714 | erase(); |
714 | } | 715 | } |
715 | 716 | ||
716 | 717 | ||
717 | void ImageViewer::hFlip() | 718 | void ImageViewer::hFlip() |
718 | { | 719 | { |
719 | // matrix.scale( -1.0, 1.0 ); | 720 | // matrix.scale( -1.0, 1.0 ); |
720 | 721 | ||
721 | setImage(image.mirror(TRUE,FALSE)); | 722 | setImage(image.mirror(TRUE,FALSE)); |
722 | } | 723 | } |
723 | 724 | ||
724 | void ImageViewer::vFlip() | 725 | void ImageViewer::vFlip() |
725 | { | 726 | { |
726 | // matrix.scale( 1.0, -1.0 ); | 727 | // matrix.scale( 1.0, -1.0 ); |
727 | setImage(image.mirror(FALSE,TRUE)); | 728 | setImage(image.mirror(FALSE,TRUE)); |
728 | } | 729 | } |
729 | 730 | ||
730 | void ImageViewer::rot180() | 731 | void ImageViewer::rot180() |
731 | { | 732 | { |
732 | // matrix.rotate( 180.0 ); | 733 | // matrix.rotate( 180.0 ); |
733 | setImage(image.mirror(TRUE,TRUE)); | 734 | setImage(image.mirror(TRUE,TRUE)); |
734 | } | 735 | } |
735 | 736 | ||
736 | void ImageViewer::rot90() | 737 | void ImageViewer::rot90() |
737 | { | 738 | { |
738 | QImage oldimage; | 739 | QImage oldimage; |
739 | oldimage = image.convertDepth(32); | 740 | oldimage = image.convertDepth(32); |
740 | // matrix.rotate( -90.0 ); | 741 | // matrix.rotate( -90.0 ); |
741 | setImage(rotate(oldimage,Rotate90)); | 742 | setImage(rotate(oldimage,Rotate90)); |
742 | 743 | ||
743 | } | 744 | } |
744 | void ImageViewer::rot270() | 745 | void ImageViewer::rot270() |
745 | { | 746 | { |
746 | 747 | ||
747 | QImage oldimage; | 748 | QImage oldimage; |
748 | oldimage = image.convertDepth(32); | 749 | oldimage = image.convertDepth(32); |
749 | // matrix.rotate(90.0); | 750 | // matrix.rotate(90.0); |
750 | setImage(rotate(oldimage,Rotate270)); | 751 | setImage(rotate(oldimage,Rotate270)); |
751 | 752 | ||
752 | } | 753 | } |
753 | 754 | ||
754 | void ImageViewer::blackAndWhite() | 755 | void ImageViewer::blackAndWhite() |
755 | { | 756 | { |
756 | 757 | ||
757 | viewMenuView->setItemEnabled(BLACKANDWHITE,false); | 758 | viewMenuView->setItemEnabled(BLACKANDWHITE,false); |
758 | setImage(toGray(image,false)); | 759 | setImage(toGray(image,false)); |
759 | } | 760 | } |
760 | 761 | ||
761 | void ImageViewer::displayControlsDialog() | 762 | void ImageViewer::displayControlsDialog() |
762 | { | 763 | { |
763 | int w=80; | 764 | int w=80; |
764 | int h=w; | 765 | int h=w; |
765 | QImage small; | 766 | QImage small; |
766 | 767 | ||
767 | if ( image.width()<w ||image.height()<h ) | 768 | if ( image.width()<w ||image.height()<h ) |
768 | small=image.smoothScale(w,h); | 769 | small=image.smoothScale(w,h); |
769 | else | 770 | else |
770 | small=image.copy(0,0,w,h); | 771 | small=image.copy(0,0,w,h); |
771 | 772 | ||
772 | int newB=0; | 773 | int newB=0; |
773 | ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this); | 774 | ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this); |
774 | dlg->exec(); | 775 | dlg->exec(); |
775 | if ( newB ) { | 776 | if ( newB ) { |
776 | intensity(image,(float)newB/100); | 777 | intensity(image,(float)newB/100); |
777 | setImage(image); | 778 | setImage(image); |
778 | } | 779 | } |
779 | 780 | ||
780 | } | 781 | } |
781 | 782 | ||
782 | 783 | ||
783 | void ImageViewer::displayInfoDialog() | 784 | void ImageViewer::displayInfoDialog() |
784 | { | 785 | { |
785 | 786 | ||
786 | QStringList ls; | 787 | QStringList ls; |
787 | 788 | ||
788 | for ( int i=0;i<LAST;i++ ) | 789 | for ( int i=0;i<LAST;i++ ) |
789 | ls.append(imageInfo[i]); | 790 | ls.append(imageInfo[i]); |
790 | 791 | ||
791 | InfoDialog::displayInfo("Image Viewer",ls,this); | 792 | InfoDialog::displayInfo("Image Viewer",ls,this); |
792 | } | 793 | } |
793 | void ImageViewer::normalView() | 794 | void ImageViewer::normalView() |
794 | { | 795 | { |
795 | if ( !imagePanel->parentWidget() ) | 796 | if ( !imagePanel->parentWidget() ) |
796 | { | 797 | { |
797 | 798 | ||
798 | isFullScreen = FALSE; | 799 | isFullScreen = FALSE; |
799 | stack->addWidget( imagePanel, 1 ); | 800 | stack->addWidget( imagePanel, 1 ); |
800 | switchToImageView(); | 801 | switchToImageView(); |
801 | if ( isSized ) | 802 | if ( isSized ) |
802 | scale(); | 803 | scale(); |
803 | 804 | ||
804 | updateImage(); | 805 | updateImage(); |
805 | 806 | ||
806 | } | 807 | } |
807 | } | 808 | } |
808 | 809 | ||
809 | void ImageViewer::stopSlideShow() { | 810 | void ImageViewer::stopSlideShow() { |
810 | if (slideTimer->isActive()) | 811 | if (slideTimer->isActive()) |
811 | slideTimer->stop(); | 812 | slideTimer->stop(); |
812 | } | 813 | } |
813 | 814 | ||
814 | void ImageViewer::fullScreen() | 815 | void ImageViewer::fullScreen() |
815 | { | 816 | { |
816 | // Full-screen option | 817 | // Full-screen option |
817 | // contributed by Robert Wittams <robert@wittams.com> | 818 | // contributed by Robert Wittams <robert@wittams.com> |
818 | if ( imagePanel->parentWidget() && loadSelected() ) | 819 | if ( imagePanel->parentWidget() && loadSelected() ) |
819 | { | 820 | { |
820 | isFullScreen = TRUE; | 821 | isFullScreen = TRUE; |
821 | imagePanel->reparent(0,QPoint(0,0)); | 822 | imagePanel->reparent(0,QPoint(0,0)); |
822 | imagePanel->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 823 | imagePanel->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
823 | 824 | ||
824 | if ( isSized ) | 825 | if ( isSized ) |
825 | scale(); | 826 | scale(); |
826 | updateImage(); | 827 | updateImage(); |
827 | imagePanel->showFullScreen(); | 828 | imagePanel->showFullScreen(); |
828 | } | 829 | } |
829 | } | 830 | } |
830 | 831 | ||
831 | void ImageViewer::setImage(const QImage& newimage) | 832 | void ImageViewer::setImage(const QImage& newimage) |
832 | { | 833 | { |
833 | image = newimage; | 834 | image = newimage; |
834 | reconvertImage(); | 835 | reconvertImage(); |
835 | updateImage(); | 836 | updateImage(); |
836 | } | 837 | } |
837 | 838 | ||
838 | void ImageViewer::updateImageInfo(QString &filePath) | 839 | void ImageViewer::updateImageInfo(QString &filePath) |
839 | { | 840 | { |
840 | 841 | ||
841 | for ( int i=0;i<LAST;i++ ) | 842 | for ( int i=0;i<LAST;i++ ) |
842 | { | 843 | { |
843 | imageInfo[i]=""; | 844 | imageInfo[i]=""; |
844 | } | 845 | } |
845 | 846 | ||
846 | imageInfo[FORMAT]=QImage::imageFormat (filePath ); | 847 | imageInfo[FORMAT]=QImage::imageFormat (filePath ); |
847 | QFileInfo fi(filePath); | 848 | QFileInfo fi(filePath); |
848 | imageInfo[PATH]=fi.fileName(); | 849 | imageInfo[PATH]=fi.fileName(); |
849 | imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)"; | 850 | imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)"; |
850 | QString message("%1x%2"); | 851 | QString message("%1x%2"); |
851 | imageInfo[SIZE]=QString("%1x%2"); | 852 | imageInfo[SIZE]=QString("%1x%2"); |
852 | imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height()); | 853 | imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height()); |
853 | if ( image.numColors() > 0 ) | 854 | if ( image.numColors() > 0 ) |
854 | { | 855 | { |
855 | imageInfo[COLORS]=tr("%1 colors").arg(image.numColors()); | 856 | imageInfo[COLORS]=tr("%1 colors").arg(image.numColors()); |
856 | } | 857 | } |
857 | else if ( image.depth() >= 16 ) | 858 | else if ( image.depth() >= 16 ) |
858 | { | 859 | { |
859 | imageInfo[COLORS]=tr(" True color"); | 860 | imageInfo[COLORS]=tr(" True color"); |
860 | } | 861 | } |
861 | if ( image.hasAlphaBuffer() ) | 862 | if ( image.hasAlphaBuffer() ) |
862 | { | 863 | { |
863 | if ( image.depth() == 8 ) | 864 | if ( image.depth() == 8 ) |
864 | { | 865 | { |
865 | int i; | 866 | int i; |
866 | bool alpha[256]; | 867 | bool alpha[256]; |
867 | int nalpha=0; | 868 | int nalpha=0; |
868 | 869 | ||
869 | for ( i=0; i<256; i++ ) | 870 | for ( i=0; i<256; i++ ) |
870 | alpha[i] = FALSE; | 871 | alpha[i] = FALSE; |
871 | 872 | ||
872 | for ( i=0; i<image.numColors(); i++ ) | 873 | for ( i=0; i<image.numColors(); i++ ) |
873 | { | 874 | { |
874 | int alevel = image.color(i) >> 24; | 875 | int alevel = image.color(i) >> 24; |
875 | if ( !alpha[alevel] ) | 876 | if ( !alpha[alevel] ) |
876 | { | 877 | { |
877 | alpha[alevel] = TRUE; | 878 | alpha[alevel] = TRUE; |
878 | nalpha++; | 879 | nalpha++; |
879 | } | 880 | } |
880 | } | 881 | } |
881 | imageInfo[ALPHA]=tr("%1 alpha levels").arg(nalpha); | 882 | imageInfo[ALPHA]=tr("%1 alpha levels").arg(nalpha); |
882 | } | 883 | } |
883 | else | 884 | else |
884 | { | 885 | { |
885 | imageInfo[ALPHA]=tr("8-bit alpha channel"); | 886 | imageInfo[ALPHA]=tr("8-bit alpha channel"); |
886 | } | 887 | } |
887 | } | 888 | } |
888 | 889 | ||
889 | } | 890 | } |
890 | 891 | ||
891 | void ImageViewer::closeEvent( QCloseEvent *e ) | 892 | void ImageViewer::closeEvent( QCloseEvent *e ) |
892 | { | 893 | { |
893 | if ( stack->visibleWidget() == imagePanel && !bFromDocView ) | 894 | if ( stack->visibleWidget() == imagePanel && !bFromDocView ) |
894 | { | 895 | { |
895 | e->ignore(); | 896 | e->ignore(); |
896 | open(); | 897 | open(); |
897 | } | 898 | } |
898 | else | 899 | else |
899 | { | 900 | { |
900 | bFromDocView = FALSE; | 901 | bFromDocView = FALSE; |
901 | e->accept(); | 902 | e->accept(); |
902 | } | 903 | } |
903 | } | 904 | } |
904 | 905 | ||
905 | // Intensity,toGray and rotate code courtesy of KDE project. | 906 | // Intensity,toGray and rotate code courtesy of KDE project. |
906 | 907 | ||
907 | 908 | ||
908 | QImage& ImageViewer::intensity(QImage &image, float percent) | 909 | QImage& ImageViewer::intensity(QImage &image, float percent) |
909 | { | 910 | { |
910 | 911 | ||
911 | int segColors = image.depth() > 8 ? 256 : image.numColors(); | 912 | int segColors = image.depth() > 8 ? 256 : image.numColors(); |
912 | unsigned char *segTbl = new unsigned char[segColors]; | 913 | unsigned char *segTbl = new unsigned char[segColors]; |
913 | int pixels = image.depth() > 8 ? image.width()*image.height() : | 914 | int pixels = image.depth() > 8 ? image.width()*image.height() : |
914 | image.numColors(); | 915 | image.numColors(); |
915 | unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : | 916 | unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : |
916 | (unsigned int *)image.colorTable(); | 917 | (unsigned int *)image.colorTable(); |
917 | 918 | ||
918 | bool brighten = (percent >= 0); | 919 | bool brighten = (percent >= 0); |
919 | if ( percent < 0 ) | 920 | if ( percent < 0 ) |
920 | percent = -percent; | 921 | percent = -percent; |
921 | 922 | ||
922 | if ( brighten ) | 923 | if ( brighten ) |
923 | { // keep overflow check out of loops | 924 | { // keep overflow check out of loops |
924 | for ( int i=0; i < segColors; ++i ) | 925 | for ( int i=0; i < segColors; ++i ) |
925 | { | 926 | { |
926 | int tmp = (int)(i*percent); | 927 | int tmp = (int)(i*percent); |
927 | if ( tmp > 255 ) | 928 | if ( tmp > 255 ) |
928 | tmp = 255; | 929 | tmp = 255; |
929 | segTbl[i] = tmp; | 930 | segTbl[i] = tmp; |
930 | } | 931 | } |
931 | } | 932 | } |
932 | else | 933 | else |
933 | { | 934 | { |
934 | for ( int i=0; i < segColors; ++i ) | 935 | for ( int i=0; i < segColors; ++i ) |
935 | { | 936 | { |
936 | int tmp = (int)(i*percent); | 937 | int tmp = (int)(i*percent); |
937 | if ( tmp < 0 ) | 938 | if ( tmp < 0 ) |
938 | tmp = 0; | 939 | tmp = 0; |
939 | segTbl[i] = tmp; | 940 | segTbl[i] = tmp; |
940 | } | 941 | } |
941 | } | 942 | } |
942 | 943 | ||
943 | if ( brighten ) | 944 | if ( brighten ) |
944 | { // same here | 945 | { // same here |
945 | for ( int i=0; i < pixels; ++i ) | 946 | for ( int i=0; i < pixels; ++i ) |
946 | { | 947 | { |
947 | int r = qRed(data[i]); | 948 | int r = qRed(data[i]); |
948 | int g = qGreen(data[i]); | 949 | int g = qGreen(data[i]); |
949 | int b = qBlue(data[i]); | 950 | int b = qBlue(data[i]); |
950 | int a = qAlpha(data[i]); | 951 | int a = qAlpha(data[i]); |
951 | r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; | 952 | r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; |
952 | g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; | 953 | g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; |
953 | b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; | 954 | b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; |
954 | data[i] = qRgba(r, g, b,a); | 955 | data[i] = qRgba(r, g, b,a); |
955 | } | 956 | } |
956 | } | 957 | } |
957 | else | 958 | else |
958 | { | 959 | { |
959 | for ( int i=0; i < pixels; ++i ) | 960 | for ( int i=0; i < pixels; ++i ) |
960 | { | 961 | { |
961 | int r = qRed(data[i]); | 962 | int r = qRed(data[i]); |
962 | int g = qGreen(data[i]); | 963 | int g = qGreen(data[i]); |
963 | int b = qBlue(data[i]); | 964 | int b = qBlue(data[i]); |
964 | int a = qAlpha(data[i]); | 965 | int a = qAlpha(data[i]); |
965 | r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; | 966 | r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; |
966 | g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; | 967 | g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; |
967 | b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; | 968 | b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; |
968 | data[i] = qRgba(r, g, b, a); | 969 | data[i] = qRgba(r, g, b, a); |
969 | } | 970 | } |
970 | } | 971 | } |
971 | delete [] segTbl; | 972 | delete [] segTbl; |
972 | 973 | ||
973 | return image; | 974 | return image; |
974 | } | 975 | } |
975 | 976 | ||
976 | QImage& ImageViewer::toGray(QImage &img, bool fast) | 977 | QImage& ImageViewer::toGray(QImage &img, bool fast) |
977 | { | 978 | { |
978 | if ( img.width() == 0 || img.height() == 0 ) | 979 | if ( img.width() == 0 || img.height() == 0 ) |
979 | return img; | 980 | return img; |
980 | 981 | ||
981 | if ( fast ) | 982 | if ( fast ) |
982 | { | 983 | { |
983 | if ( img.depth() == 32 ) | 984 | if ( img.depth() == 32 ) |
984 | { | 985 | { |
985 | register uchar * r(img.bits()); | 986 | register uchar * r(img.bits()); |
986 | register uchar * g(img.bits() + 1); | 987 | register uchar * g(img.bits() + 1); |
987 | register uchar * b(img.bits() + 2); | 988 | register uchar * b(img.bits() + 2); |
988 | 989 | ||
989 | uchar * end(img.bits() + img.numBytes()); | 990 | uchar * end(img.bits() + img.numBytes()); |
990 | 991 | ||
991 | while ( r != end ) | 992 | while ( r != end ) |
992 | { | 993 | { |
993 | 994 | ||
994 | *r = *g = *b = (((*r + *g) >> 1) + *b) >> 1; // (r + b + g) / 3 | 995 | *r = *g = *b = (((*r + *g) >> 1) + *b) >> 1; // (r + b + g) / 3 |
995 | 996 | ||
996 | r += 4; | 997 | r += 4; |
997 | g += 4; | 998 | g += 4; |
998 | b += 4; | 999 | b += 4; |
999 | } | 1000 | } |
1000 | } | 1001 | } |
1001 | else | 1002 | else |
1002 | { | 1003 | { |
1003 | for ( int i = 0; i < img.numColors(); i++ ) | 1004 | for ( int i = 0; i < img.numColors(); i++ ) |
1004 | { | 1005 | { |
1005 | register uint r = qRed(img.color(i)); | 1006 | register uint r = qRed(img.color(i)); |
1006 | register uint g = qGreen(img.color(i)); | 1007 | register uint g = qGreen(img.color(i)); |
1007 | register uint b = qBlue(img.color(i)); | 1008 | register uint b = qBlue(img.color(i)); |
1008 | 1009 | ||
1009 | register uint gray = (((r + g) >> 1) + b) >> 1; | 1010 | register uint gray = (((r + g) >> 1) + b) >> 1; |
1010 | img.setColor(i, qRgba(gray, gray, gray, qAlpha(img.color(i)))); | 1011 | img.setColor(i, qRgba(gray, gray, gray, qAlpha(img.color(i)))); |
1011 | } | 1012 | } |
1012 | } | 1013 | } |
1013 | } | 1014 | } |
1014 | else | 1015 | else |
1015 | { | 1016 | { |
1016 | int pixels = img.depth() > 8 ? img.width()*img.height() : | 1017 | int pixels = img.depth() > 8 ? img.width()*img.height() : |
1017 | img.numColors(); | 1018 | img.numColors(); |
1018 | unsigned int *data = img.depth() > 8 ? (unsigned int *)img.bits() : | 1019 | unsigned int *data = img.depth() > 8 ? (unsigned int *)img.bits() : |
1019 | (unsigned int *)img.colorTable(); | 1020 | (unsigned int *)img.colorTable(); |
1020 | int val, i; | 1021 | int val, i; |
1021 | for ( i=0; i < pixels; ++i ) | 1022 | for ( i=0; i < pixels; ++i ) |
1022 | { | 1023 | { |
1023 | val = qGray(data[i]); | 1024 | val = qGray(data[i]); |
1024 | data[i] = qRgba(val, val, val, qAlpha(data[i])); | 1025 | data[i] = qRgba(val, val, val, qAlpha(data[i])); |
1025 | } | 1026 | } |
1026 | } | 1027 | } |
1027 | return img; | 1028 | return img; |
1028 | } | 1029 | } |
1029 | 1030 | ||
1030 | 1031 | ||
1031 | QImage ImageViewer::rotate(QImage &img, RotateDirection r) | 1032 | QImage ImageViewer::rotate(QImage &img, RotateDirection r) |
1032 | { | 1033 | { |
1033 | QImage dest; | 1034 | QImage dest; |
1034 | int x, y; | 1035 | int x, y; |
1035 | if ( img.depth() > 8 ) | 1036 | if ( img.depth() > 8 ) |
1036 | { | 1037 | { |
1037 | unsigned int *srcData, *destData; | 1038 | unsigned int *srcData, *destData; |
1038 | switch ( r ) | 1039 | switch ( r ) |
1039 | { | 1040 | { |
1040 | case Rotate90: | 1041 | case Rotate90: |
1041 | dest.create(img.height(), img.width(), img.depth()); | 1042 | dest.create(img.height(), img.width(), img.depth()); |
1042 | for ( y=0; y < img.height(); ++y ) | 1043 | for ( y=0; y < img.height(); ++y ) |
1043 | { | 1044 | { |
1044 | srcData = (unsigned int *)img.scanLine(y); | 1045 | srcData = (unsigned int *)img.scanLine(y); |
1045 | for ( x=0; x < img.width(); ++x ) | 1046 | for ( x=0; x < img.width(); ++x ) |
1046 | { | 1047 | { |
1047 | destData = (unsigned int *)dest.scanLine(x); | 1048 | destData = (unsigned int *)dest.scanLine(x); |
1048 | destData[img.height()-y-1] = srcData[x]; | 1049 | destData[img.height()-y-1] = srcData[x]; |
1049 | } | 1050 | } |
1050 | } | 1051 | } |
1051 | break; | 1052 | break; |
1052 | case Rotate180: | 1053 | case Rotate180: |
1053 | dest.create(img.width(), img.height(), img.depth()); | 1054 | dest.create(img.width(), img.height(), img.depth()); |
1054 | for ( y=0; y < img.height(); ++y ) | 1055 | for ( y=0; y < img.height(); ++y ) |
1055 | { | 1056 | { |
1056 | srcData = (unsigned int *)img.scanLine(y); | 1057 | srcData = (unsigned int *)img.scanLine(y); |
1057 | destData = (unsigned int *)dest.scanLine(img.height()-y-1); | 1058 | destData = (unsigned int *)dest.scanLine(img.height()-y-1); |
1058 | for ( x=0; x < img.width(); ++x ) | 1059 | for ( x=0; x < img.width(); ++x ) |
1059 | destData[img.width()-x-1] = srcData[x]; | 1060 | destData[img.width()-x-1] = srcData[x]; |
1060 | } | 1061 | } |
1061 | break; | 1062 | break; |
1062 | case Rotate270: | 1063 | case Rotate270: |
1063 | dest.create(img.height(), img.width(), img.depth()); | 1064 | dest.create(img.height(), img.width(), img.depth()); |
1064 | for ( y=0; y < img.height(); ++y ) | 1065 | for ( y=0; y < img.height(); ++y ) |
1065 | { | 1066 | { |
1066 | srcData = (unsigned int *)img.scanLine(y); | 1067 | srcData = (unsigned int *)img.scanLine(y); |
1067 | for ( x=0; x < img.width(); ++x ) | 1068 | for ( x=0; x < img.width(); ++x ) |
1068 | { | 1069 | { |
1069 | destData = (unsigned int *)dest.scanLine(img.width()-x-1); | 1070 | destData = (unsigned int *)dest.scanLine(img.width()-x-1); |
1070 | destData[y] = srcData[x]; | 1071 | destData[y] = srcData[x]; |
1071 | } | 1072 | } |
1072 | } | 1073 | } |
1073 | break; | 1074 | break; |
1074 | default: | 1075 | default: |
1075 | dest = img; | 1076 | dest = img; |
1076 | break; | 1077 | break; |
1077 | } | 1078 | } |
1078 | } | 1079 | } |
1079 | else | 1080 | else |
1080 | { | 1081 | { |
1081 | unsigned char *srcData, *destData; | 1082 | unsigned char *srcData, *destData; |
1082 | unsigned int *srcTable, *destTable; | 1083 | unsigned int *srcTable, *destTable; |
1083 | switch ( r ) | 1084 | switch ( r ) |
1084 | { | 1085 | { |
1085 | case Rotate90: | 1086 | case Rotate90: |
1086 | dest.create(img.height(), img.width(), img.depth()); | 1087 | dest.create(img.height(), img.width(), img.depth()); |
1087 | dest.setNumColors(img.numColors()); | 1088 | dest.setNumColors(img.numColors()); |
1088 | srcTable = (unsigned int *)img.colorTable(); | 1089 | srcTable = (unsigned int *)img.colorTable(); |
1089 | destTable = (unsigned int *)dest.colorTable(); | 1090 | destTable = (unsigned int *)dest.colorTable(); |
1090 | for ( x=0; x < img.numColors(); ++x ) | 1091 | for ( x=0; x < img.numColors(); ++x ) |
1091 | destTable[x] = srcTable[x]; | 1092 | destTable[x] = srcTable[x]; |
1092 | for ( y=0; y < img.height(); ++y ) | 1093 | for ( y=0; y < img.height(); ++y ) |
1093 | { | 1094 | { |
1094 | srcData = (unsigned char *)img.scanLine(y); | 1095 | srcData = (unsigned char *)img.scanLine(y); |
1095 | for ( x=0; x < img.width(); ++x ) | 1096 | for ( x=0; x < img.width(); ++x ) |
1096 | { | 1097 | { |
1097 | destData = (unsigned char *)dest.scanLine(x); | 1098 | destData = (unsigned char *)dest.scanLine(x); |
1098 | destData[img.height()-y-1] = srcData[x]; | 1099 | destData[img.height()-y-1] = srcData[x]; |
1099 | } | 1100 | } |
1100 | } | 1101 | } |
1101 | break; | 1102 | break; |
1102 | case Rotate180: | 1103 | case Rotate180: |
1103 | dest.create(img.width(), img.height(), img.depth()); | 1104 | dest.create(img.width(), img.height(), img.depth()); |
1104 | dest.setNumColors(img.numColors()); | 1105 | dest.setNumColors(img.numColors()); |
1105 | srcTable = (unsigned int *)img.colorTable(); | 1106 | srcTable = (unsigned int *)img.colorTable(); |
1106 | destTable = (unsigned int *)dest.colorTable(); | 1107 | destTable = (unsigned int *)dest.colorTable(); |
1107 | for ( x=0; x < img.numColors(); ++x ) | 1108 | for ( x=0; x < img.numColors(); ++x ) |
1108 | destTable[x] = srcTable[x]; | 1109 | destTable[x] = srcTable[x]; |
1109 | for ( y=0; y < img.height(); ++y ) | 1110 | for ( y=0; y < img.height(); ++y ) |
1110 | { | 1111 | { |
1111 | srcData = (unsigned char *)img.scanLine(y); | 1112 | srcData = (unsigned char *)img.scanLine(y); |
1112 | destData = (unsigned char *)dest.scanLine(img.height()-y-1); | 1113 | destData = (unsigned char *)dest.scanLine(img.height()-y-1); |
1113 | for ( x=0; x < img.width(); ++x ) | 1114 | for ( x=0; x < img.width(); ++x ) |
1114 | destData[img.width()-x-1] = srcData[x]; | 1115 | destData[img.width()-x-1] = srcData[x]; |
1115 | } | 1116 | } |
1116 | break; | 1117 | break; |
1117 | case Rotate270: | 1118 | case Rotate270: |
1118 | dest.create(img.height(), img.width(), img.depth()); | 1119 | dest.create(img.height(), img.width(), img.depth()); |
1119 | dest.setNumColors(img.numColors()); | 1120 | dest.setNumColors(img.numColors()); |
1120 | srcTable = (unsigned int *)img.colorTable(); | 1121 | srcTable = (unsigned int *)img.colorTable(); |
1121 | destTable = (unsigned int *)dest.colorTable(); | 1122 | destTable = (unsigned int *)dest.colorTable(); |
1122 | for ( x=0; x < img.numColors(); ++x ) | 1123 | for ( x=0; x < img.numColors(); ++x ) |
1123 | destTable[x] = srcTable[x]; | 1124 | destTable[x] = srcTable[x]; |
1124 | for ( y=0; y < img.height(); ++y ) | 1125 | for ( y=0; y < img.height(); ++y ) |
1125 | { | 1126 | { |
1126 | srcData = (unsigned char *)img.scanLine(y); | 1127 | srcData = (unsigned char *)img.scanLine(y); |
1127 | for ( x=0; x < img.width(); ++x ) | 1128 | for ( x=0; x < img.width(); ++x ) |
1128 | { | 1129 | { |
1129 | destData = (unsigned char *)dest.scanLine(img.width()-x-1); | 1130 | destData = (unsigned char *)dest.scanLine(img.width()-x-1); |
1130 | destData[y] = srcData[x]; | 1131 | destData[y] = srcData[x]; |
1131 | } | 1132 | } |
1132 | } | 1133 | } |
1133 | break; | 1134 | break; |
1134 | default: | 1135 | default: |
1135 | dest = img; | 1136 | dest = img; |
1136 | break; | 1137 | break; |
1137 | } | 1138 | } |
1138 | 1139 | ||
1139 | } | 1140 | } |
1140 | return (dest); | 1141 | return (dest); |
1141 | } | 1142 | } |
1142 | 1143 | ||
1143 | void ImageViewer::slideShow( bool on ) | 1144 | void ImageViewer::slideShow( bool on ) |
1144 | { | 1145 | { |
1145 | if (on) { | 1146 | if (on) { |
1146 | if (!imageList.isEmpty()) { | 1147 | if (!imageList.isEmpty()) { |
1147 | slideTimer->start(slideDelay * 1000, FALSE); | 1148 | slideTimer->start(slideDelay * 1000, FALSE); |
1148 | filename = ""; // force restart | 1149 | filename = ""; // force restart |
1149 | slideReverse ? prevImage() : nextImage(); | 1150 | slideReverse ? prevImage() : nextImage(); |
1150 | } | 1151 | } |
1151 | } else { | 1152 | } else { |
1152 | slideTimer->stop(); | 1153 | slideTimer->stop(); |
1153 | slideAction->setOn( false); | 1154 | slideAction->setOn( false); |
1154 | } | 1155 | } |
1155 | } | 1156 | } |
1156 | 1157 | ||
1157 | void ImageViewer::slideUpdate() | 1158 | void ImageViewer::slideUpdate() |
1158 | { | 1159 | { |
1159 | bool final_image = slideReverse ? prevImage() : nextImage(); | 1160 | bool final_image = slideReverse ? prevImage() : nextImage(); |
1160 | 1161 | ||
1161 | if (final_image && !slideRepeat) { | 1162 | if (final_image && !slideRepeat) { |
1162 | slideTimer->stop(); | 1163 | slideTimer->stop(); |
1163 | slideAction->setOn(FALSE); | 1164 | slideAction->setOn(FALSE); |
1164 | } | 1165 | } |
1165 | } | 1166 | } |
1166 | 1167 | ||
1167 | // | 1168 | // |
1168 | // Display the image after the current one in the image list. | 1169 | // Display the image after the current one in the image list. |
1169 | // Return TRUE if the next call to nextImage() will wrap around to the | 1170 | // Return TRUE if the next call to nextImage() will wrap around to the |
1170 | // first image in the list (ie. we're now viewing the last image in the list). | 1171 | // first image in the list (ie. we're now viewing the last image in the list). |
1171 | // | 1172 | // |
1172 | bool ImageViewer::nextImage(void) | 1173 | bool ImageViewer::nextImage(void) |
1173 | { | 1174 | { |
1174 | int idx = 0; | 1175 | int idx = 0; |
1175 | 1176 | ||
1176 | if (imageList.count() > 0) { | 1177 | if (imageList.count() > 0) { |
1177 | idx = imageIndex(); | 1178 | idx = imageIndex(); |
1178 | if (idx != -1) { | 1179 | if (idx != -1) { |
1179 | if (idx == int(imageList.count() - 1)) { | 1180 | if (idx == int(imageList.count() - 1)) { |
1180 | idx = 0; | 1181 | idx = 0; |
1181 | } else { | 1182 | } else { |
1182 | idx++; | 1183 | idx++; |
1183 | } | 1184 | } |
1184 | } else { | 1185 | } else { |
1185 | idx = 0; | 1186 | idx = 0; |
1186 | } | 1187 | } |
1187 | openFile(imageList[idx]); | 1188 | openFile(imageList[idx]); |
1188 | } | 1189 | } |
1189 | 1190 | ||
1190 | return idx == int(imageList.count() - 1) ? TRUE : FALSE; | 1191 | return idx == int(imageList.count() - 1) ? TRUE : FALSE; |
1191 | } | 1192 | } |
1192 | 1193 | ||
1193 | // | 1194 | // |
1194 | // Display the image preceeding the current one in the image list. | 1195 | // Display the image preceeding the current one in the image list. |
1195 | // Return TRUE if the next call to prevImage() will wrap around to the last | 1196 | // Return TRUE if the next call to prevImage() will wrap around to the last |
1196 | // image in the list (ie. we're now viewing the first image in the list). | 1197 | // image in the list (ie. we're now viewing the first image in the list). |
1197 | // | 1198 | // |
1198 | bool ImageViewer::prevImage(void) | 1199 | bool ImageViewer::prevImage(void) |
1199 | { | 1200 | { |
1200 | int idx = -1; | 1201 | int idx = -1; |
1201 | 1202 | ||
1202 | if (imageList.count() > 0) { | 1203 | if (imageList.count() > 0) { |
1203 | idx = imageIndex(); | 1204 | idx = imageIndex(); |
1204 | if (idx != -1) { | 1205 | if (idx != -1) { |
1205 | if (idx == 0) { | 1206 | if (idx == 0) { |
1206 | idx = imageList.count() - 1; | 1207 | idx = imageList.count() - 1; |
1207 | } else { | 1208 | } else { |
1208 | idx--; | 1209 | idx--; |
1209 | } | 1210 | } |
1210 | } else { | 1211 | } else { |
1211 | idx = imageList.count() - 1; | 1212 | idx = imageList.count() - 1; |
1212 | } | 1213 | } |
1213 | openFile(imageList[idx]); | 1214 | openFile(imageList[idx]); |
1214 | } | 1215 | } |
1215 | 1216 | ||
1216 | return idx == 0 ? TRUE : FALSE; | 1217 | return idx == 0 ? TRUE : FALSE; |
1217 | } | 1218 | } |
1218 | 1219 | ||
1219 | // | 1220 | // |
1220 | // Return the index into the imageList of the currently viewed | 1221 | // Return the index into the imageList of the currently viewed |
1221 | // image (ie. ImageViewer::filename in ImageViewer::imageList). | 1222 | // image (ie. ImageViewer::filename in ImageViewer::imageList). |
1222 | // | 1223 | // |
1223 | int ImageViewer::imageIndex(void) | 1224 | int ImageViewer::imageIndex(void) |
1224 | { | 1225 | { |
1225 | QValueListConstIterator<DocLnk> i; | 1226 | QValueListConstIterator<DocLnk> i; |
1226 | int index; | 1227 | int index; |
1227 | 1228 | ||
1228 | if (imageList.count() == 0) { | 1229 | if (imageList.count() == 0) { |
1229 | return -1; | 1230 | return -1; |
1230 | } | 1231 | } |
1231 | 1232 | ||
1232 | for (index = 0, i = imageList.begin(); i != imageList.end(); ++i, index++) { | 1233 | for (index = 0, i = imageList.begin(); i != imageList.end(); ++i, index++) { |
1233 | if ((*i).file() == filename) { | 1234 | if ((*i).file() == filename) { |
1234 | return index; | 1235 | return index; |
1235 | } | 1236 | } |
1236 | } | 1237 | } |
1237 | 1238 | ||
1238 | return -1; | 1239 | return -1; |
1239 | } | 1240 | } |