Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index fd18dbb..0516089 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -67,103 +67,64 @@ const MediaWidget::SkinButtonInfo skinInfo[] = | |||
67 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, | 67 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, |
68 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, | 68 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, |
69 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, | 69 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, |
70 | { MediaWidget::Back, "back", MediaWidget::NormalButton } | 70 | { MediaWidget::Back, "back", MediaWidget::NormalButton } |
71 | }; | 71 | }; |
72 | 72 | ||
73 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | 73 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); |
74 | 74 | ||
75 | void changeTextColor( QWidget * w) { | 75 | void changeTextColor( QWidget * w) { |
76 | QPalette p = w->palette(); | 76 | QPalette p = w->palette(); |
77 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 77 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
78 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 78 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
79 | w->setPalette( p ); | 79 | w->setPalette( p ); |
80 | } | 80 | } |
81 | 81 | ||
82 | } | 82 | } |
83 | 83 | ||
84 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 84 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
85 | 85 | ||
86 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), | 86 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), |
87 | audioSliderBeingMoved( false ) | 87 | audioSliderBeingMoved( false ) |
88 | { | 88 | { |
89 | setCaption( tr("OpiePlayer") ); | 89 | setCaption( tr("OpiePlayer") ); |
90 | 90 | ||
91 | Config cfg("OpiePlayer"); | 91 | loadSkin(); |
92 | cfg.setGroup("Options"); | ||
93 | skin = cfg.readEntry("Skin","default"); | ||
94 | //skin = "scaleTest"; | ||
95 | // color of background, frame, degree of transparency | ||
96 | |||
97 | QString skinPath = "opieplayer2/skins/" + skin; | ||
98 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | ||
99 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | ||
100 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | ||
101 | |||
102 | setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_", imgUp.size() ); | ||
103 | |||
104 | setBackgroundPixmap( backgroundPixmap ); | ||
105 | |||
106 | songInfo.setFocusPolicy( QWidget::NoFocus ); | ||
107 | // changeTextColor( &songInfo ); | ||
108 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | ||
109 | // songInfo.setFrameStyle( QFrame::NoFrame); | ||
110 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | ||
111 | // songInfo.setForegroundColor(Qt::white); | ||
112 | |||
113 | slider.setFixedHeight( 20 ); | ||
114 | slider.setMinValue( 0 ); | ||
115 | slider.setMaxValue( 1 ); | ||
116 | slider.setFocusPolicy( QWidget::NoFocus ); | ||
117 | slider.setBackgroundPixmap( backgroundPixmap ); | ||
118 | |||
119 | // Config cofg("qpe"); | ||
120 | // cofg.setGroup("Appearance"); | ||
121 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | ||
122 | |||
123 | time.setFocusPolicy( QWidget::NoFocus ); | ||
124 | time.setAlignment( Qt::AlignCenter ); | ||
125 | |||
126 | // time.setFrame(FALSE); | ||
127 | // changeTextColor( &time ); | ||
128 | |||
129 | resizeEvent( NULL ); | ||
130 | 92 | ||
131 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 93 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
132 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); | 94 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); |
133 | 95 | ||
134 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 96 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
135 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 97 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
136 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 98 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
137 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 99 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
138 | 100 | ||
139 | // Intialise state | 101 | // Intialise state |
140 | setLength( mediaPlayerState.length() ); | 102 | setLength( mediaPlayerState.length() ); |
141 | setPosition( mediaPlayerState.position() ); | 103 | setPosition( mediaPlayerState.position() ); |
142 | setLooping( mediaPlayerState.isFullscreen() ); | 104 | setLooping( mediaPlayerState.isFullscreen() ); |
143 | // setPaused( mediaPlayerState->paused() ); | 105 | // setPaused( mediaPlayerState->paused() ); |
144 | setPlaying( mediaPlayerState.isPlaying() ); | 106 | setPlaying( mediaPlayerState.isPlaying() ); |
145 | |||
146 | } | 107 | } |
147 | 108 | ||
148 | AudioWidget::~AudioWidget() { | 109 | AudioWidget::~AudioWidget() { |
149 | 110 | ||
150 | // mediaPlayerState->setPlaying(false); | 111 | // mediaPlayerState->setPlaying(false); |
151 | } | 112 | } |
152 | 113 | ||
153 | namespace { | 114 | namespace { |
154 | 115 | ||
155 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 116 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
156 | QPixmap pix( img.width(), img.height() ); | 117 | QPixmap pix( img.width(), img.height() ); |
157 | QPainter p( &pix ); | 118 | QPainter p( &pix ); |
158 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 119 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
159 | p.drawImage( 0, 0, img ); | 120 | p.drawImage( 0, 0, img ); |
160 | return pix; | 121 | return pix; |
161 | } | 122 | } |
162 | 123 | ||
163 | 124 | ||
164 | QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { | 125 | QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { |
165 | QPixmap pixmap( pix ); | 126 | QPixmap pixmap( pix ); |
166 | pixmap.setMask( mask ); | 127 | pixmap.setMask( mask ); |
167 | return pixmap; | 128 | return pixmap; |
168 | } | 129 | } |
169 | 130 | ||
@@ -208,48 +169,90 @@ void AudioWidget::sliderReleased() { | |||
208 | } | 169 | } |
209 | 170 | ||
210 | void AudioWidget::setPosition( long i ) { | 171 | void AudioWidget::setPosition( long i ) { |
211 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 172 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
212 | updateSlider( i, mediaPlayerState.length() ); | 173 | updateSlider( i, mediaPlayerState.length() ); |
213 | } | 174 | } |
214 | 175 | ||
215 | 176 | ||
216 | void AudioWidget::setLength( long max ) { | 177 | void AudioWidget::setLength( long max ) { |
217 | updateSlider( mediaPlayerState.position(), max ); | 178 | updateSlider( mediaPlayerState.position(), max ); |
218 | } | 179 | } |
219 | 180 | ||
220 | 181 | ||
221 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 182 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
222 | if ( mediaType == MediaPlayerState::Audio ) { | 183 | if ( mediaType == MediaPlayerState::Audio ) { |
223 | // startTimer( 150 ); | 184 | // startTimer( 150 ); |
224 | showMaximized(); | 185 | showMaximized(); |
225 | return; | 186 | return; |
226 | } | 187 | } |
227 | 188 | ||
228 | killTimers(); | 189 | killTimers(); |
229 | hide(); | 190 | hide(); |
230 | } | 191 | } |
231 | 192 | ||
193 | void AudioWidget::loadSkin() | ||
194 | { | ||
195 | Config cfg("OpiePlayer"); | ||
196 | cfg.setGroup("Options"); | ||
197 | skin = cfg.readEntry("Skin","default"); | ||
198 | //skin = "scaleTest"; | ||
199 | // color of background, frame, degree of transparency | ||
200 | |||
201 | QString skinPath = "opieplayer2/skins/" + skin; | ||
202 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | ||
203 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | ||
204 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | ||
205 | |||
206 | setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_", imgUp.size() ); | ||
207 | |||
208 | setBackgroundPixmap( backgroundPixmap ); | ||
209 | |||
210 | songInfo.setFocusPolicy( QWidget::NoFocus ); | ||
211 | // changeTextColor( &songInfo ); | ||
212 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | ||
213 | // songInfo.setFrameStyle( QFrame::NoFrame); | ||
214 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | ||
215 | // songInfo.setForegroundColor(Qt::white); | ||
216 | |||
217 | slider.setFixedHeight( 20 ); | ||
218 | slider.setMinValue( 0 ); | ||
219 | slider.setMaxValue( 1 ); | ||
220 | slider.setFocusPolicy( QWidget::NoFocus ); | ||
221 | slider.setBackgroundPixmap( backgroundPixmap ); | ||
222 | |||
223 | // Config cofg("qpe"); | ||
224 | // cofg.setGroup("Appearance"); | ||
225 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | ||
226 | |||
227 | time.setFocusPolicy( QWidget::NoFocus ); | ||
228 | time.setAlignment( Qt::AlignCenter ); | ||
229 | |||
230 | // time.setFrame(FALSE); | ||
231 | // changeTextColor( &time ); | ||
232 | |||
233 | resizeEvent( 0 ); | ||
234 | } | ||
232 | 235 | ||
233 | void AudioWidget::setSeekable( bool isSeekable ) { | 236 | void AudioWidget::setSeekable( bool isSeekable ) { |
234 | 237 | ||
235 | if ( !isSeekable ) { | 238 | if ( !isSeekable ) { |
236 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 239 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
237 | if( !slider.isHidden()) { | 240 | if( !slider.isHidden()) { |
238 | slider.hide(); | 241 | slider.hide(); |
239 | } | 242 | } |
240 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 243 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
241 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 244 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
242 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 245 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
243 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 246 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
244 | } else { | 247 | } else { |
245 | // this stops the slider from being moved, thus | 248 | // this stops the slider from being moved, thus |
246 | // does not stop stream when it reaches the end | 249 | // does not stop stream when it reaches the end |
247 | slider.show(); | 250 | slider.show(); |
248 | qDebug( " CONNECT SET POSTION " ); | 251 | qDebug( " CONNECT SET POSTION " ); |
249 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 252 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
250 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 253 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
251 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 254 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
252 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 255 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
253 | } | 256 | } |
254 | } | 257 | } |
255 | 258 | ||