summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-18 17:35:58 (UTC)
committer harlekin <harlekin>2002-08-18 17:35:58 (UTC)
commita5c95b42314fe8f7bdcfe2644e980d43c257fee0 (patch) (unidiff)
treedc27b266a5e1e60fa269e2182a9cfd36507b12ca
parent6171a4b58f242c75e9ce02728651ca4fb743e747 (diff)
downloadopie-a5c95b42314fe8f7bdcfe2644e980d43c257fee0.zip
opie-a5c95b42314fe8f7bdcfe2644e980d43c257fee0.tar.gz
opie-a5c95b42314fe8f7bdcfe2644e980d43c257fee0.tar.bz2
hack to make startup faster, still need sanity checks
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/main.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp3
5 files changed, 13 insertions, 7 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 604ed3a..6d867e5 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -3,256 +3,259 @@
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#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38#include <qwidget.h> 38#include <qwidget.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qbutton.h> 40#include <qbutton.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qframe.h> 42#include <qframe.h>
43#include <qlayout.h> 43#include <qlayout.h>
44 44
45#include <stdlib.h> 45#include <stdlib.h>
46#include <stdio.h> 46#include <stdio.h>
47 47
48#include "audiowidget.h" 48#include "audiowidget.h"
49#include "mediaplayerstate.h" 49#include "mediaplayerstate.h"
50 50
51extern MediaPlayerState *mediaPlayerState; 51extern MediaPlayerState *mediaPlayerState;
52 52
53static const int xo = -2; // movable x offset 53static const int xo = -2; // movable x offset
54static const int yo = 22; // movable y offset 54static const int yo = 22; // movable y offset
55 55
56 56
57Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { 57Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
58 setFrameStyle( WinPanel | Sunken ); 58 setFrameStyle( WinPanel | Sunken );
59 setText( "No Song" ); 59 setText( "No Song" );
60} 60}
61 61
62Ticker::~Ticker() { 62Ticker::~Ticker() {
63} 63}
64 64
65void Ticker::setText( const QString& text ) { 65void Ticker::setText( const QString& text ) {
66 pos = 0; // reset it everytime the text is changed 66 pos = 0; // reset it everytime the text is changed
67 scrollText = text; 67 scrollText = text;
68 pixelLen = fontMetrics().width( scrollText ); 68 pixelLen = fontMetrics().width( scrollText );
69 killTimers(); 69 killTimers();
70 if ( pixelLen > width() ) { 70 if ( pixelLen > width() ) {
71 startTimer( 50 ); 71 startTimer( 50 );
72 } 72 }
73 update(); 73 update();
74} 74}
75 75
76 76
77void Ticker::timerEvent( QTimerEvent * ) { 77void Ticker::timerEvent( QTimerEvent * ) {
78 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 78 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
79 scroll( -1, 0, contentsRect() ); 79 scroll( -1, 0, contentsRect() );
80 repaint( FALSE ); 80 repaint( FALSE );
81} 81}
82 82
83void Ticker::drawContents( QPainter *p ) { 83void Ticker::drawContents( QPainter *p ) {
84 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) 84 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
85 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 85 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
86 QPixmap pm( width(), height() ); 86 QPixmap pm( width(), height() );
87 pm.fill( colorGroup().base() ); 87 pm.fill( colorGroup().base() );
88 QPainter pmp( &pm ); 88 QPainter pmp( &pm );
89 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 89 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
90 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 90 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
91 } 91 }
92 p->drawPixmap( 0, 0, pm ); 92 p->drawPixmap( 0, 0, pm );
93} 93}
94 94
95struct MediaButton { 95struct MediaButton {
96 bool isToggle, isHeld, isDown; 96 bool isToggle, isHeld, isDown;
97}; 97};
98 98
99//Layout information for the audioButtons (and if it is a toggle button or not) 99//Layout information for the audioButtons (and if it is a toggle button or not)
100MediaButton audioButtons[] = { 100MediaButton audioButtons[] = {
101 { TRUE, FALSE, FALSE }, // play 101 { TRUE, FALSE, FALSE }, // play
102 { FALSE, FALSE, FALSE }, // stop 102 { FALSE, FALSE, FALSE }, // stop
103 { FALSE, FALSE, FALSE }, // next 103 { FALSE, FALSE, FALSE }, // next
104 { FALSE, FALSE, FALSE }, // previous 104 { FALSE, FALSE, FALSE }, // previous
105 { FALSE, FALSE, FALSE }, // volume up 105 { FALSE, FALSE, FALSE }, // volume up
106 { FALSE, FALSE, FALSE }, // volume down 106 { FALSE, FALSE, FALSE }, // volume down
107 { TRUE, FALSE, FALSE }, // repeat/loop 107 { TRUE, FALSE, FALSE }, // repeat/loop
108 { FALSE, FALSE, FALSE }, // playlist 108 { FALSE, FALSE, FALSE }, // playlist
109 { FALSE, FALSE, FALSE }, // forward 109 { FALSE, FALSE, FALSE }, // forward
110 { FALSE, FALSE, FALSE } // back 110 { FALSE, FALSE, FALSE } // back
111}; 111};
112 112
113const char *skin_mask_file_names[10] = { 113const char *skin_mask_file_names[10] = {
114 "play", "stop", "next", "prev", "up", 114 "play", "stop", "next", "prev", "up",
115 "down", "loop", "playlist", "forward", "back" 115 "down", "loop", "playlist", "forward", "back"
116}; 116};
117 117
118 118
119static void changeTextColor( QWidget *w ) { 119static void changeTextColor( QWidget *w ) {
120 QPalette p = w->palette(); 120 QPalette p = w->palette();
121 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 121 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
122 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 122 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
123 w->setPalette( p ); 123 w->setPalette( p );
124} 124}
125 125
126static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 126static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
127 127
128 128
129AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 129AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
130 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { 130 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
131
132
133
131 setCaption( tr("OpiePlayer") ); 134 setCaption( tr("OpiePlayer") );
132 135
133 Config cfg("OpiePlayer"); 136 Config cfg("OpiePlayer");
134 cfg.setGroup("Options"); 137 cfg.setGroup("Options");
135 skin = cfg.readEntry("Skin","default"); 138 skin = cfg.readEntry("Skin","default");
136 //skin = "scaleTest"; 139 //skin = "scaleTest";
137// color of background, frame, degree of transparency 140// color of background, frame, degree of transparency
138 141
139 QString skinPath = "opieplayer2/skins/" + skin; 142 QString skinPath = "opieplayer2/skins/" + skin;
140 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 143 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
141 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 144 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
142 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 145 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
143 146
144 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 147 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
145 imgButtonMask->fill( 0 ); 148 imgButtonMask->fill( 0 );
146 149
147 for ( int i = 0; i < 10; i++ ) { 150 for ( int i = 0; i < 10; i++ ) {
148 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 151 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
149 masks[i] = new QBitmap( filename ); 152 masks[i] = new QBitmap( filename );
150 153
151 if ( !masks[i]->isNull() ) { 154 if ( !masks[i]->isNull() ) {
152 QImage imgMask = masks[i]->convertToImage(); 155 QImage imgMask = masks[i]->convertToImage();
153 uchar **dest = imgButtonMask->jumpTable(); 156 uchar **dest = imgButtonMask->jumpTable();
154 for ( int y = 0; y < imgUp->height(); y++ ) { 157 for ( int y = 0; y < imgUp->height(); y++ ) {
155 uchar *line = dest[y]; 158 uchar *line = dest[y];
156 for ( int x = 0; x < imgUp->width(); x++ ) 159 for ( int x = 0; x < imgUp->width(); x++ )
157 if ( !qRed( imgMask.pixel( x, y ) ) ) 160 if ( !qRed( imgMask.pixel( x, y ) ) )
158 line[x] = i + 1; 161 line[x] = i + 1;
159 } 162 }
160 } 163 }
161 164
162 } 165 }
163 166
164 for ( int i = 0; i < 10; i++ ) { 167 for ( int i = 0; i < 10; i++ ) {
165 buttonPixUp[i] = NULL; 168 buttonPixUp[i] = NULL;
166 buttonPixDown[i] = NULL; 169 buttonPixDown[i] = NULL;
167 } 170 }
168 171
169 setBackgroundPixmap( *pixBg ); 172 setBackgroundPixmap( *pixBg );
170 173
171 songInfo.setFocusPolicy( QWidget::NoFocus ); 174 songInfo.setFocusPolicy( QWidget::NoFocus );
172 changeTextColor( &songInfo ); 175 changeTextColor( &songInfo );
173 176
174 slider.setFixedHeight( 20 ); 177 slider.setFixedHeight( 20 );
175 slider.setMinValue( 0 ); 178 slider.setMinValue( 0 );
176 slider.setMaxValue( 1 ); 179 slider.setMaxValue( 1 );
177 slider.setFocusPolicy( QWidget::NoFocus ); 180 slider.setFocusPolicy( QWidget::NoFocus );
178 slider.setBackgroundPixmap( *pixBg ); 181 slider.setBackgroundPixmap( *pixBg );
179 182
180 time.setFocusPolicy( QWidget::NoFocus ); 183 time.setFocusPolicy( QWidget::NoFocus );
181 time.setAlignment( Qt::AlignCenter ); 184 time.setAlignment( Qt::AlignCenter );
182 time.setFrame(FALSE); 185 time.setFrame(FALSE);
183 changeTextColor( &time ); 186 changeTextColor( &time );
184 187
185 resizeEvent( NULL ); 188 resizeEvent( NULL );
186 189
187 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 190 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
188 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 191 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
189 192
190 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 193 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
191 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 194 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
192 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 195 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
193// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 196// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
194 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 197 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
195 198
196 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 199 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
197 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 200 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
198 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 201 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
199 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 202 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
200 203
201 204
202 205
203 // Intialise state 206 // Intialise state
204 setLength( mediaPlayerState->length() ); 207 setLength( mediaPlayerState->length() );
205 setPosition( mediaPlayerState->position() ); 208 setPosition( mediaPlayerState->position() );
206 setLooping( mediaPlayerState->fullscreen() ); 209 setLooping( mediaPlayerState->fullscreen() );
207// setPaused( mediaPlayerState->paused() ); 210// setPaused( mediaPlayerState->paused() );
208 setPlaying( mediaPlayerState->playing() ); 211 setPlaying( mediaPlayerState->playing() );
209 212
210} 213}
211 214
212AudioWidget::~AudioWidget() { 215AudioWidget::~AudioWidget() {
213 216
214 for ( int i = 0; i < 10; i++ ) { 217 for ( int i = 0; i < 10; i++ ) {
215 delete buttonPixUp[i]; 218 delete buttonPixUp[i];
216 delete buttonPixDown[i]; 219 delete buttonPixDown[i];
217 } 220 }
218 delete pixBg; 221 delete pixBg;
219 delete imgUp; 222 delete imgUp;
220 delete imgDn; 223 delete imgDn;
221 delete imgButtonMask; 224 delete imgButtonMask;
222 for ( int i = 0; i < 10; i++ ) { 225 for ( int i = 0; i < 10; i++ ) {
223 delete masks[i]; 226 delete masks[i];
224 } 227 }
225} 228}
226 229
227QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 230QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
228 QPixmap pix( img.width(), img.height() ); 231 QPixmap pix( img.width(), img.height() );
229 QPainter p( &pix ); 232 QPainter p( &pix );
230 p.drawTiledPixmap( pix.rect(), bg, offset ); 233 p.drawTiledPixmap( pix.rect(), bg, offset );
231 p.drawImage( 0, 0, img ); 234 p.drawImage( 0, 0, img );
232 return new QPixmap( pix ); 235 return new QPixmap( pix );
233} 236}
234 237
235 238
236QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 239QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
237{ 240{
238 QPixmap *pixmap = new QPixmap( pix ); 241 QPixmap *pixmap = new QPixmap( pix );
239 pixmap->setMask( mask ); 242 pixmap->setMask( mask );
240 return pixmap; 243 return pixmap;
241} 244}
242 245
243 246
244 247
245void AudioWidget::resizeEvent( QResizeEvent * ) { 248void AudioWidget::resizeEvent( QResizeEvent * ) {
246 int h = height(); 249 int h = height();
247 int w = width(); 250 int w = width();
248 251
249 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 252 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
250 slider.setFixedWidth( w - 110 ); 253 slider.setFixedWidth( w - 110 );
251 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 254 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
252 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 255 slider.setBackgroundOrigin( QWidget::ParentOrigin );
253 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 256 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
254 257
255 xoff = ( w - imgUp->width() ) / 2; 258 xoff = ( w - imgUp->width() ) / 2;
256 yoff = (( h - imgUp->height() ) / 2) - 10; 259 yoff = (( h - imgUp->height() ) / 2) - 10;
257 QPoint p( xoff, yoff ); 260 QPoint p( xoff, yoff );
258 261
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp
index 827f773..e951554 100644
--- a/noncore/multimedia/opieplayer2/main.cpp
+++ b/noncore/multimedia/opieplayer2/main.cpp
@@ -1,33 +1,34 @@
1 1
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include "mediaplayerstate.h" 3#include "mediaplayerstate.h"
4#include "playlistwidget.h" 4#include "playlistwidget.h"
5#include "audiowidget.h" 5#include "audiowidget.h"
6#include "videowidget.h" 6#include "videowidget.h"
7#include "mediaplayer.h" 7#include "mediaplayer.h"
8 8
9MediaPlayerState *mediaPlayerState; 9MediaPlayerState *mediaPlayerState;
10PlayListWidget *playList; 10PlayListWidget *playList;
11AudioWidget *audioUI; 11AudioWidget *audioUI;
12VideoWidget *videoUI; 12VideoWidget *videoUI;
13 13
14int main(int argc, char **argv) { 14int main(int argc, char **argv) {
15 QPEApplication a(argc,argv); 15 QPEApplication a(argc,argv);
16 16
17 MediaPlayerState st( 0, "mediaPlayerState" ); 17 MediaPlayerState st( 0, "mediaPlayerState" );
18 mediaPlayerState = &st; 18 mediaPlayerState = &st;
19 PlayListWidget pl( 0, "playList" ); 19 PlayListWidget pl( 0, "playList" );
20 playList = &pl; 20 playList = &pl;
21 pl.showMaximized();
21 AudioWidget aw( 0, "audioUI" ); 22 AudioWidget aw( 0, "audioUI" );
22 audioUI = &aw; 23 audioUI = &aw;
23 VideoWidget vw( 0, "videoUI" ); 24 VideoWidget vw( 0, "videoUI" );
24 videoUI = &vw; 25 videoUI = &vw;
25 26 a.processEvents();
26 MediaPlayer mp( 0, "mediaPlayer" ); 27 MediaPlayer mp( 0, "mediaPlayer" );
27 28
28 a.showMainDocumentWidget(&pl); 29 a.showMainDocumentWidget(&pl);
29 30
30 return a.exec(); 31 return a.exec();
31} 32}
32 33
33 34
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 87f4f0c..5531e81 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,167 +1,166 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6 6
7#include <qmainwindow.h> 7#include <qmainwindow.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qwidgetstack.h> 9#include <qwidgetstack.h>
10#include <qfile.h> 10#include <qfile.h>
11 11
12#include "mediaplayer.h" 12#include "mediaplayer.h"
13#include "playlistwidget.h" 13#include "playlistwidget.h"
14#include "audiowidget.h" 14#include "audiowidget.h"
15#include "videowidget.h" 15#include "videowidget.h"
16#include "volumecontrol.h" 16#include "volumecontrol.h"
17 17
18#include "mediaplayerstate.h" 18#include "mediaplayerstate.h"
19 19
20// for setBacklight() 20// for setBacklight()
21#include <linux/fb.h> 21#include <linux/fb.h>
22#include <sys/file.h> 22#include <sys/file.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24 24
25 25
26extern AudioWidget *audioUI; 26extern AudioWidget *audioUI;
27extern VideoWidget *videoUI; 27extern VideoWidget *videoUI;
28extern PlayListWidget *playList; 28extern PlayListWidget *playList;
29extern MediaPlayerState *mediaPlayerState; 29extern MediaPlayerState *mediaPlayerState;
30 30
31 31
32#define FBIOBLANK 0x4611 32#define FBIOBLANK 0x4611
33 33
34MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 34MediaPlayer::MediaPlayer( QObject *parent, const char *name )
35 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 35 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
36 36
37 37 qApp->processEvents();
38 // xineControl = new XineControl(); 38 // QPEApplication::grabKeyboard(); // EVIL
39// QPEApplication::grabKeyboard(); // EVIL
40 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 39 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
41 40
42 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 41 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
43 42
44 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 43 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
45 44
46 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 45 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
47 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 46 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
48 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 47 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
49 48
50 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 49 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
51 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 50 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
52 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 51 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
53 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 52 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
54 53
55 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 54 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
56 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 55 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
57 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 56 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
58 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 57 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
59 58
60 volControl = new VolumeControl; 59 volControl = new VolumeControl;
61 xineControl = new XineControl(); 60 xineControl = new XineControl();
62} 61}
63 62
64MediaPlayer::~MediaPlayer() { 63MediaPlayer::~MediaPlayer() {
65 delete xineControl; 64 delete xineControl;
66 delete volControl; 65 delete volControl;
67} 66}
68 67
69void MediaPlayer::pauseCheck( bool b ) { 68void MediaPlayer::pauseCheck( bool b ) {
70 if ( b && !mediaPlayerState->playing() ) { 69 if ( b && !mediaPlayerState->playing() ) {
71 mediaPlayerState->setPaused( FALSE ); 70 mediaPlayerState->setPaused( FALSE );
72 } 71 }
73} 72}
74 73
75void MediaPlayer::play() { 74void MediaPlayer::play() {
76 mediaPlayerState->setPlaying( FALSE ); 75 mediaPlayerState->setPlaying( FALSE );
77 mediaPlayerState->setPlaying( TRUE ); 76 mediaPlayerState->setPlaying( TRUE );
78} 77}
79 78
80void MediaPlayer::setPlaying( bool play ) { 79void MediaPlayer::setPlaying( bool play ) {
81 if ( !play ) { 80 if ( !play ) {
82 return; 81 return;
83 } 82 }
84 83
85 if ( mediaPlayerState->paused() ) { 84 if ( mediaPlayerState->paused() ) {
86 mediaPlayerState->setPaused( FALSE ); 85 mediaPlayerState->setPaused( FALSE );
87 return; 86 return;
88 } 87 }
89 88
90 const DocLnk *playListCurrent = playList->current(); 89 const DocLnk *playListCurrent = playList->current();
91 if ( playListCurrent != NULL ) { 90 if ( playListCurrent != NULL ) {
92 currentFile = playListCurrent; 91 currentFile = playListCurrent;
93 } 92 }
94 93
95 xineControl->play( currentFile->file() ); 94 xineControl->play( currentFile->file() );
96 95
97 xineControl->length(); 96 xineControl->length();
98 long seconds = mediaPlayerState->length();// 97 long seconds = mediaPlayerState->length();//
99 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 98 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
100 qDebug(time); 99 qDebug(time);
101 100
102 QString tickerText; 101 QString tickerText;
103 if( currentFile->file().left(4) == "http" ) 102 if( currentFile->file().left(4) == "http" )
104 tickerText= tr( " File: " ) + currentFile->name(); 103 tickerText= tr( " File: " ) + currentFile->name();
105 else 104 else
106 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; 105 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
107 106
108 audioUI->setTickerText( currentFile->file( ) ); 107 audioUI->setTickerText( currentFile->file( ) );
109 108
110} 109}
111 110
112 111
113void MediaPlayer::prev() { 112void MediaPlayer::prev() {
114 if ( playList->prev() ) { 113 if ( playList->prev() ) {
115 play(); 114 play();
116 } else if ( mediaPlayerState->looping() ) { 115 } else if ( mediaPlayerState->looping() ) {
117 if ( playList->last() ) { 116 if ( playList->last() ) {
118 play(); 117 play();
119 } 118 }
120 } else { 119 } else {
121 mediaPlayerState->setList(); 120 mediaPlayerState->setList();
122 } 121 }
123} 122}
124 123
125 124
126void MediaPlayer::next() { 125void MediaPlayer::next() {
127 if ( playList->next() ) { 126 if ( playList->next() ) {
128 play(); 127 play();
129 } else if ( mediaPlayerState->looping() ) { 128 } else if ( mediaPlayerState->looping() ) {
130 if ( playList->first() ) { 129 if ( playList->first() ) {
131 play(); 130 play();
132 } 131 }
133 } else { 132 } else {
134 mediaPlayerState->setList(); 133 mediaPlayerState->setList();
135 } 134 }
136} 135}
137 136
138 137
139void MediaPlayer::startDecreasingVolume() { 138void MediaPlayer::startDecreasingVolume() {
140 volumeDirection = -1; 139 volumeDirection = -1;
141 startTimer( 100 ); 140 startTimer( 100 );
142 volControl->decVol(2); 141 volControl->decVol(2);
143} 142}
144 143
145 144
146void MediaPlayer::startIncreasingVolume() { 145void MediaPlayer::startIncreasingVolume() {
147 volumeDirection = +1; 146 volumeDirection = +1;
148 startTimer( 100 ); 147 startTimer( 100 );
149 volControl->incVol(2); 148 volControl->incVol(2);
150} 149}
151 150
152 151
153bool drawnOnScreenDisplay = FALSE; 152bool drawnOnScreenDisplay = FALSE;
154unsigned int onScreenDisplayVolume = 0; 153unsigned int onScreenDisplayVolume = 0;
155const int yoff = 110; 154const int yoff = 110;
156 155
157void MediaPlayer::stopChangingVolume() { 156void MediaPlayer::stopChangingVolume() {
158 killTimers(); 157 killTimers();
159 // Get rid of the on-screen display stuff 158 // Get rid of the on-screen display stuff
160 drawnOnScreenDisplay = FALSE; 159 drawnOnScreenDisplay = FALSE;
161 onScreenDisplayVolume = 0; 160 onScreenDisplayVolume = 0;
162 int w=0; 161 int w=0;
163 int h=0; 162 int h=0;
164 if( !xineControl->hasVideo()) { 163 if( !xineControl->hasVideo()) {
165 w = audioUI->width(); 164 w = audioUI->width();
166 h = audioUI->height(); 165 h = audioUI->height();
167 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 166 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 874800a..39f5090 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -77,301 +77,301 @@ public:
77 77
78 78
79class MenuItem : public QAction { 79class MenuItem : public QAction {
80public: 80public:
81 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 81 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
82 : QAction( text, QString::null, 0, 0 ) { 82 : QAction( text, QString::null, 0, 0 ) {
83 connect( this, SIGNAL( activated() ), handler, slot ); 83 connect( this, SIGNAL( activated() ), handler, slot );
84 addTo( parent ); 84 addTo( parent );
85 } 85 }
86}; 86};
87 87
88 88
89PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 89PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
90 : QMainWindow( parent, name, fl ) { 90 : QMainWindow( parent, name, fl ) {
91 91
92 d = new PlayListWidgetPrivate; 92 d = new PlayListWidgetPrivate;
93 d->setDocumentUsed = FALSE; 93 d->setDocumentUsed = FALSE;
94 d->current = NULL; 94 d->current = NULL;
95 fromSetDocument = FALSE; 95 fromSetDocument = FALSE;
96 insanityBool=FALSE; 96 insanityBool=FALSE;
97 audioScan = FALSE; 97 audioScan = FALSE;
98 videoScan = FALSE; 98 videoScan = FALSE;
99 99
100 setBackgroundMode( PaletteButton ); 100 setBackgroundMode( PaletteButton );
101 101
102 setCaption( tr("OpiePlayer") ); 102 setCaption( tr("OpiePlayer") );
103 setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) ); 103 setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) );
104 104
105 setToolBarsMovable( FALSE ); 105 setToolBarsMovable( FALSE );
106 106
107 // Create Toolbar 107 // Create Toolbar
108 QPEToolBar *toolbar = new QPEToolBar( this ); 108 QPEToolBar *toolbar = new QPEToolBar( this );
109 toolbar->setHorizontalStretchable( TRUE ); 109 toolbar->setHorizontalStretchable( TRUE );
110 110
111 // Create Menubar 111 // Create Menubar
112 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 112 QPEMenuBar *menu = new QPEMenuBar( toolbar );
113 menu->setMargin( 0 ); 113 menu->setMargin( 0 );
114 114
115 QPEToolBar *bar = new QPEToolBar( this ); 115 QPEToolBar *bar = new QPEToolBar( this );
116 bar->setLabel( tr( "Play Operations" ) ); 116 bar->setLabel( tr( "Play Operations" ) );
117 117
118 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 118 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
119 tbDeletePlaylist->setFlat(TRUE); 119 tbDeletePlaylist->setFlat(TRUE);
120 tbDeletePlaylist->setFixedSize(20,20); 120 tbDeletePlaylist->setFixedSize(20,20);
121 121
122 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", 122 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist",
123 this , SLOT(addSelected()) ); 123 this , SLOT(addSelected()) );
124 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", 124 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist",
125 this , SLOT(removeSelected()) ); 125 this , SLOT(removeSelected()) );
126 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 126 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
127 this , SLOT( btnPlay(bool) ), TRUE ); 127 this , SLOT( btnPlay(bool) ), TRUE );
128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
130 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", 130 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop",
131 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 131 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
132 tbDeletePlaylist->hide(); 132 tbDeletePlaylist->hide();
133 133
134 QPopupMenu *pmPlayList = new QPopupMenu( this ); 134 QPopupMenu *pmPlayList = new QPopupMenu( this );
135 menu->insertItem( tr( "File" ), pmPlayList ); 135 menu->insertItem( tr( "File" ), pmPlayList );
136 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 136 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
137 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 137 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
138 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 138 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
139 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 139 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
140 pmPlayList->insertSeparator(-1); 140 pmPlayList->insertSeparator(-1);
141 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 141 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
142 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 142 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
143 pmPlayList->insertSeparator(-1); 143 pmPlayList->insertSeparator(-1);
144 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 144 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
145 pmPlayList->insertSeparator(-1); 145 pmPlayList->insertSeparator(-1);
146 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 146 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
147 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 147 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
148 148
149 149
150 pmView = new QPopupMenu( this ); 150 pmView = new QPopupMenu( this );
151 menu->insertItem( tr( "View" ), pmView ); 151 menu->insertItem( tr( "View" ), pmView );
152 pmView->isCheckable(); 152 pmView->isCheckable();
153 153
154 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); 154 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) );
155 155
156 Config cfg( "OpiePlayer" ); 156 Config cfg( "OpiePlayer" );
157 bool b= cfg.readBoolEntry("FullScreen", 0); 157 bool b= cfg.readBoolEntry("FullScreen", 0);
158 mediaPlayerState->setFullscreen( b ); 158 mediaPlayerState->setFullscreen( b );
159 pmView->setItemChecked( -16, b ); 159 pmView->setItemChecked( -16, b );
160 160
161 // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); 161 // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) );
162 162
163 pmView->insertSeparator(-1); 163 pmView->insertSeparator(-1);
164 164
165 skinsMenu = new QPopupMenu( this ); 165 skinsMenu = new QPopupMenu( this );
166 pmView->insertItem( tr( "Skins" ), skinsMenu ); 166 pmView->insertItem( tr( "Skins" ), skinsMenu );
167 skinsMenu->isCheckable(); 167 skinsMenu->isCheckable();
168 populateSkinsMenu(); 168 populateSkinsMenu();
169 169
170 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 170 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
171 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 171 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
172 172
173 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 173 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
174 174
175 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 175 tabWidget = new QTabWidget( hbox6, "tabWidget" );
176 // tabWidget->setTabShape(QTabWidget::Triangular); 176 // tabWidget->setTabShape(QTabWidget::Triangular);
177 177
178 QWidget *pTab; 178 QWidget *pTab;
179 pTab = new QWidget( tabWidget, "pTab" ); 179 pTab = new QWidget( tabWidget, "pTab" );
180 tabWidget->insertTab( pTab,"Playlist"); 180 tabWidget->insertTab( pTab,"Playlist");
181 181
182 182
183 QGridLayout *Playout = new QGridLayout( pTab ); 183 QGridLayout *Playout = new QGridLayout( pTab );
184 Playout->setSpacing( 2); 184 Playout->setSpacing( 2);
185 Playout->setMargin( 2); 185 Playout->setMargin( 2);
186 186
187 // Add the playlist area 187 // Add the playlist area
188 188
189 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 189 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
190 d->playListFrame = vbox3; 190 d->playListFrame = vbox3;
191 191
192 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 192 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
193 193
194 d->selectedFiles = new PlayListSelection( hbox2); 194 d->selectedFiles = new PlayListSelection( hbox2);
195 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 195 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
196 196
197 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 197 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
198 198
199 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 199 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
200 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 200 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) );
201 new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); 201 new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) );
202 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 202 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) );
203 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 203 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
204 204
205 205
206 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); 206 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
207 207
208 QWidget *aTab; 208 QWidget *aTab;
209 aTab = new QWidget( tabWidget, "aTab" ); 209 aTab = new QWidget( tabWidget, "aTab" );
210 210
211 QGridLayout *Alayout = new QGridLayout( aTab ); 211 QGridLayout *Alayout = new QGridLayout( aTab );
212 Alayout->setSpacing( 2); 212 Alayout->setSpacing( 2);
213 Alayout->setMargin( 2); 213 Alayout->setMargin( 2);
214 214
215 audioView = new QListView( aTab, "Audioview" ); 215 audioView = new QListView( aTab, "Audioview" );
216 audioView->addColumn( tr("Title"),140); 216 audioView->addColumn( tr("Title"),140);
217 audioView->addColumn(tr("Size"), -1); 217 audioView->addColumn(tr("Size"), -1);
218 audioView->addColumn(tr("Media"),-1); 218 audioView->addColumn(tr("Media"),-1);
219 audioView->setColumnAlignment(1, Qt::AlignRight); 219 audioView->setColumnAlignment(1, Qt::AlignRight);
220 audioView->setColumnAlignment(2, Qt::AlignRight); 220 audioView->setColumnAlignment(2, Qt::AlignRight);
221 audioView->setAllColumnsShowFocus(TRUE); 221 audioView->setAllColumnsShowFocus(TRUE);
222 audioView->setSorting(0,TRUE); 222 audioView->setSorting(0,TRUE);
223 223
224 audioView->setMultiSelection( TRUE ); 224 audioView->setMultiSelection( TRUE );
225 audioView->setSelectionMode( QListView::Extended); 225 audioView->setSelectionMode( QListView::Extended);
226 226
227 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 227 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
228 228
229 tabWidget->insertTab(aTab,tr("Audio")); 229 tabWidget->insertTab(aTab,tr("Audio"));
230 230
231 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 231 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
232 232
233 QWidget *vTab; 233 QWidget *vTab;
234 vTab = new QWidget( tabWidget, "vTab" ); 234 vTab = new QWidget( tabWidget, "vTab" );
235 235
236 QGridLayout *Vlayout = new QGridLayout( vTab ); 236 QGridLayout *Vlayout = new QGridLayout( vTab );
237 Vlayout->setSpacing( 2); 237 Vlayout->setSpacing( 2);
238 Vlayout->setMargin( 2); 238 Vlayout->setMargin( 2);
239 239
240 videoView = new QListView( vTab, "Videoview" ); 240 videoView = new QListView( vTab, "Videoview" );
241 241
242 videoView->addColumn(tr("Title"),140); 242 videoView->addColumn(tr("Title"),140);
243 videoView->addColumn(tr("Size"),-1); 243 videoView->addColumn(tr("Size"),-1);
244 videoView->addColumn(tr("Media"),-1); 244 videoView->addColumn(tr("Media"),-1);
245 videoView->setColumnAlignment(1, Qt::AlignRight); 245 videoView->setColumnAlignment(1, Qt::AlignRight);
246 videoView->setColumnAlignment(2, Qt::AlignRight); 246 videoView->setColumnAlignment(2, Qt::AlignRight);
247 videoView->setAllColumnsShowFocus(TRUE); 247 videoView->setAllColumnsShowFocus(TRUE);
248 videoView->setSorting(0,TRUE); 248 videoView->setSorting(0,TRUE);
249 249
250 videoView->setMultiSelection( TRUE ); 250 videoView->setMultiSelection( TRUE );
251 videoView->setSelectionMode( QListView::Extended); 251 videoView->setSelectionMode( QListView::Extended);
252 252
253 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 253 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
254 254
255 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 255 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
256 256
257 tabWidget->insertTab( vTab,tr("Video")); 257 tabWidget->insertTab( vTab,tr("Video"));
258 258
259 //playlists list 259 //playlists list
260 QWidget *LTab; 260 QWidget *LTab;
261 LTab = new QWidget( tabWidget, "LTab" ); 261 LTab = new QWidget( tabWidget, "LTab" );
262 QGridLayout *Llayout = new QGridLayout( LTab ); 262 QGridLayout *Llayout = new QGridLayout( LTab );
263 Llayout->setSpacing( 2); 263 Llayout->setSpacing( 2);
264 Llayout->setMargin( 2); 264 Llayout->setMargin( 2);
265 265
266 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 266 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
267 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 267 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
268 268
269 tabWidget->insertTab(LTab,tr("Lists")); 269 tabWidget->insertTab(LTab,tr("Lists"));
270 270
271 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 271 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
272 272
273 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); 273 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) );
274 274
275 connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); 275 connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) );
276 276
277 // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); 277 // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) );
278 278
279 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 279 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
280 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 280 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
281 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 281 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
282 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 282 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
283 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 283 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
284 this,SLOT( playIt( QListViewItem *)) ); 284 this,SLOT( playIt( QListViewItem *)) );
285 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 285 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
286 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 286 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
287 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 287 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
288 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 288 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
289 this,SLOT( playIt( QListViewItem *)) ); 289 this,SLOT( playIt( QListViewItem *)) );
290 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 290 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
291 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 291 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
292 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 292 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
293 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 293 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
294 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 294 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
295 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 295 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
296 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 296 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
297 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 297 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
298 298
299 setCentralWidget( vbox5 ); 299 setCentralWidget( vbox5 );
300 300
301 readConfig( cfg ); 301 readConfig( cfg );
302 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 302 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
303 loadList(DocLnk( currentPlaylist)); 303 loadList(DocLnk( currentPlaylist));
304 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 304 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
305 305
306 initializeStates(); 306 initializeStates();
307} 307}
308 308
309 309
310PlayListWidget::~PlayListWidget() { 310PlayListWidget::~PlayListWidget() {
311 Config cfg( "OpiePlayer" ); 311 Config cfg( "OpiePlayer" );
312 writeConfig( cfg ); 312 writeConfig( cfg );
313 313
314 if ( d->current ) { 314 if ( d->current ) {
315 delete d->current; 315 delete d->current;
316 } 316 }
317 delete d; 317 delete d;
318} 318}
319 319
320 320
321void PlayListWidget::initializeStates() { 321void PlayListWidget::initializeStates() {
322 322
323 d->tbPlay->setOn( mediaPlayerState->playing() ); 323 d->tbPlay->setOn( mediaPlayerState->playing() );
324 d->tbLoop->setOn( mediaPlayerState->looping() ); 324 d->tbLoop->setOn( mediaPlayerState->looping() );
325 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 325 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
326 setPlaylist( true); 326 setPlaylist( true);
327} 327}
328 328
329 329
330void PlayListWidget::readConfig( Config& cfg ) { 330void PlayListWidget::readConfig( Config& cfg ) {
331 cfg.setGroup("PlayList"); 331 cfg.setGroup("PlayList");
332 QString currentString = cfg.readEntry("current", "" ); 332 QString currentString = cfg.readEntry("current", "" );
333 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 333 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
334 for ( int i = 0; i < noOfFiles; i++ ) { 334 for ( int i = 0; i < noOfFiles; i++ ) {
335 QString entryName; 335 QString entryName;
336 entryName.sprintf( "File%i", i + 1 ); 336 entryName.sprintf( "File%i", i + 1 );
337 QString linkFile = cfg.readEntry( entryName ); 337 QString linkFile = cfg.readEntry( entryName );
338 if(QFileInfo( linkFile).exists() ) { 338 if(QFileInfo( linkFile).exists() ) {
339 DocLnk lnk( linkFile ); 339 DocLnk lnk( linkFile );
340 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { 340 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) {
341 d->selectedFiles->addToSelection( lnk ); 341 d->selectedFiles->addToSelection( lnk );
342 } 342 }
343 } 343 }
344 } 344 }
345 d->selectedFiles->setSelectedItem( currentString); 345 d->selectedFiles->setSelectedItem( currentString);
346} 346}
347 347
348 348
349void PlayListWidget::writeConfig( Config& cfg ) const { 349void PlayListWidget::writeConfig( Config& cfg ) const {
350 350
351 d->selectedFiles->writeCurrent( cfg); 351 d->selectedFiles->writeCurrent( cfg);
352 cfg.setGroup("PlayList"); 352 cfg.setGroup("PlayList");
353 int noOfFiles = 0; 353 int noOfFiles = 0;
354 d->selectedFiles->first(); 354 d->selectedFiles->first();
355 do { 355 do {
356 const DocLnk *lnk = d->selectedFiles->current(); 356 const DocLnk *lnk = d->selectedFiles->current();
357 if ( lnk ) { 357 if ( lnk ) {
358 QString entryName; 358 QString entryName;
359 entryName.sprintf( "File%i", noOfFiles + 1 ); 359 entryName.sprintf( "File%i", noOfFiles + 1 );
360 cfg.writeEntry( entryName, lnk->linkFile() ); 360 cfg.writeEntry( entryName, lnk->linkFile() );
361 // if this link does exist, add it so we have the file 361 // if this link does exist, add it so we have the file
362 // next time... 362 // next time...
363 if ( !QFile::exists( lnk->linkFile() ) ) { 363 if ( !QFile::exists( lnk->linkFile() ) ) {
364 // the way writing lnks doesn't really check for out 364 // the way writing lnks doesn't really check for out
365 // of disk space, but check it anyway. 365 // of disk space, but check it anyway.
366 if ( !lnk->writeLink() ) { 366 if ( !lnk->writeLink() ) {
367 QMessageBox::critical( 0, tr("Out of space"), 367 QMessageBox::critical( 0, tr("Out of space"),
368 tr( "There was a problem saving " 368 tr( "There was a problem saving "
369 "the playlist.\n" 369 "the playlist.\n"
370 "Your playlist " 370 "Your playlist "
371 "may be missing some entries\n" 371 "may be missing some entries\n"
372 "the next time you start it." ) 372 "the next time you start it." )
373 ); 373 );
374 } 374 }
375 } 375 }
376 noOfFiles++; 376 noOfFiles++;
377 } 377 }
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index ddb4d74..60a3563 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,211 +1,214 @@
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#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/mediaplayerplugininterface.h> 35#include <qpe/mediaplayerplugininterface.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38
38#include <qwidget.h> 39#include <qwidget.h>
39#include <qpainter.h> 40#include <qpainter.h>
40#include <qpixmap.h> 41#include <qpixmap.h>
41#include <qslider.h> 42#include <qslider.h>
42#include <qdrawutil.h> 43#include <qdrawutil.h>
43#include "videowidget.h" 44#include "videowidget.h"
44#include "mediaplayerstate.h" 45#include "mediaplayerstate.h"
45 46
46 47
47#ifdef Q_WS_QWS 48#ifdef Q_WS_QWS
48# define USE_DIRECT_PAINTER 49# define USE_DIRECT_PAINTER
49# include <qdirectpainter_qws.h> 50# include <qdirectpainter_qws.h>
50# include <qgfxraster_qws.h> 51# include <qgfxraster_qws.h>
51#endif 52#endif
52 53
53 54
54extern MediaPlayerState *mediaPlayerState; 55extern MediaPlayerState *mediaPlayerState;
55 56
56 57
57static const int xo = 2; // movable x offset 58static const int xo = 2; // movable x offset
58static const int yo = 0; // movable y offset 59static const int yo = 0; // movable y offset
59 60
60 61
61struct MediaButton { 62struct MediaButton {
62 bool isToggle, isHeld, isDown; 63 bool isToggle, isHeld, isDown;
63}; 64};
64 65
65MediaButton videoButtons[] = { 66MediaButton videoButtons[] = {
66 { FALSE, FALSE, FALSE }, // stop 67 { FALSE, FALSE, FALSE }, // stop
67 { TRUE, FALSE, FALSE }, // play 68 { TRUE, FALSE, FALSE }, // play
68 { FALSE, FALSE, FALSE }, // previous 69 { FALSE, FALSE, FALSE }, // previous
69 { FALSE, FALSE, FALSE }, // next 70 { FALSE, FALSE, FALSE }, // next
70 { FALSE, FALSE, FALSE }, // volUp 71 { FALSE, FALSE, FALSE }, // volUp
71 { FALSE, FALSE, FALSE }, // volDown 72 { FALSE, FALSE, FALSE }, // volDown
72 { TRUE, FALSE, FALSE } // fullscreen 73 { TRUE, FALSE, FALSE } // fullscreen
73}; 74};
74 75
75const char *skinV_mask_file_names[7] = { 76const char *skinV_mask_file_names[7] = {
76"stop","play","back","fwd","up","down","full" 77"stop","play","back","fwd","up","down","full"
77}; 78};
78 79
79static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 80static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
80 81
81 82
82VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 83VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
83QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 84QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
85
86
84 setCaption( tr("OpiePlayer - Video") ); 87 setCaption( tr("OpiePlayer - Video") );
85 88
86 videoFrame = new XineVideoWidget ( this, "Video frame" ); 89 videoFrame = new XineVideoWidget ( this, "Video frame" );
87 90
88 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 91 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
89 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 92 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
90 93
91 Config cfg("OpiePlayer"); 94 Config cfg("OpiePlayer");
92 cfg.setGroup("Options"); 95 cfg.setGroup("Options");
93 skin = cfg.readEntry("Skin","default"); 96 skin = cfg.readEntry("Skin","default");
94 97
95 QString skinPath = "opieplayer2/skins/" + skin; 98 QString skinPath = "opieplayer2/skins/" + skin;
96 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 99 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
97 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 100 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
98 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 101 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
99 102
100 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 103 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
101 imgButtonMask->fill( 0 ); 104 imgButtonMask->fill( 0 );
102 105
103 for ( int i = 0; i < 7; i++ ) { 106 for ( int i = 0; i < 7; i++ ) {
104 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; 107 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png";
105 masks[i] = new QBitmap( filename ); 108 masks[i] = new QBitmap( filename );
106 109
107 if ( !masks[i]->isNull() ) { 110 if ( !masks[i]->isNull() ) {
108 QImage imgMask = masks[i]->convertToImage(); 111 QImage imgMask = masks[i]->convertToImage();
109 uchar **dest = imgButtonMask->jumpTable(); 112 uchar **dest = imgButtonMask->jumpTable();
110 for ( int y = 0; y < imgUp->height(); y++ ) { 113 for ( int y = 0; y < imgUp->height(); y++ ) {
111 uchar *line = dest[y]; 114 uchar *line = dest[y];
112 for ( int x = 0; x < imgUp->width(); x++ ) { 115 for ( int x = 0; x < imgUp->width(); x++ ) {
113 if ( !qRed( imgMask.pixel( x, y ) ) ) 116 if ( !qRed( imgMask.pixel( x, y ) ) )
114 line[x] = i + 1; 117 line[x] = i + 1;
115 } 118 }
116 } 119 }
117 } 120 }
118 } 121 }
119 122
120 for ( int i = 0; i < 7; i++ ) { 123 for ( int i = 0; i < 7; i++ ) {
121 buttonPixUp[i] = NULL; 124 buttonPixUp[i] = NULL;
122 buttonPixDown[i] = NULL; 125 buttonPixDown[i] = NULL;
123 } 126 }
124 127
125 setBackgroundPixmap( *pixBg ); 128 setBackgroundPixmap( *pixBg );
126 129
127 slider = new QSlider( Qt::Horizontal, this ); 130 slider = new QSlider( Qt::Horizontal, this );
128 slider->setMinValue( 0 ); 131 slider->setMinValue( 0 );
129 slider->setMaxValue( 1 ); 132 slider->setMaxValue( 1 );
130 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 133 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
131 slider->setFocusPolicy( QWidget::NoFocus ); 134 slider->setFocusPolicy( QWidget::NoFocus );
132 135
133 resizeEvent( NULL ); 136 resizeEvent( NULL );
134 137
135 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 138 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
136 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 139 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
137 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 140 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
138 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 141 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
139 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 142 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
140 143
141 setLength( mediaPlayerState->length() ); 144 setLength( mediaPlayerState->length() );
142 setPosition( mediaPlayerState->position() ); 145 setPosition( mediaPlayerState->position() );
143 setFullscreen( mediaPlayerState->fullscreen() ); 146 setFullscreen( mediaPlayerState->fullscreen() );
144 setPlaying( mediaPlayerState->playing() ); 147 setPlaying( mediaPlayerState->playing() );
145} 148}
146 149
147 150
148VideoWidget::~VideoWidget() { 151VideoWidget::~VideoWidget() {
149 152
150 for ( int i = 0; i < 7; i++ ) { 153 for ( int i = 0; i < 7; i++ ) {
151 delete buttonPixUp[i]; 154 delete buttonPixUp[i];
152 delete buttonPixDown[i]; 155 delete buttonPixDown[i];
153 } 156 }
154 157
155 delete pixBg; 158 delete pixBg;
156 delete imgUp; 159 delete imgUp;
157 delete imgDn; 160 delete imgDn;
158 delete imgButtonMask; 161 delete imgButtonMask;
159 for ( int i = 0; i < 7; i++ ) { 162 for ( int i = 0; i < 7; i++ ) {
160 delete masks[i]; 163 delete masks[i];
161 } 164 }
162 165
163} 166}
164 167
165QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 168QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
166 QPixmap pix( img.width(), img.height() ); 169 QPixmap pix( img.width(), img.height() );
167 QPainter p( &pix ); 170 QPainter p( &pix );
168 p.drawTiledPixmap( pix.rect(), bg, offset ); 171 p.drawTiledPixmap( pix.rect(), bg, offset );
169 p.drawImage( 0, 0, img ); 172 p.drawImage( 0, 0, img );
170 return new QPixmap( pix ); 173 return new QPixmap( pix );
171} 174}
172 175
173QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 176QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
174 QPixmap *pixmap = new QPixmap( pix ); 177 QPixmap *pixmap = new QPixmap( pix );
175 pixmap->setMask( mask ); 178 pixmap->setMask( mask );
176 return pixmap; 179 return pixmap;
177} 180}
178 181
179void VideoWidget::resizeEvent( QResizeEvent * ) { 182void VideoWidget::resizeEvent( QResizeEvent * ) {
180 int h = height(); 183 int h = height();
181 int w = width(); 184 int w = width();
182 int Vh = 160; 185 int Vh = 160;
183 int Vw = 220; 186 int Vw = 220;
184 187
185 slider->setFixedWidth( w - 20 ); 188 slider->setFixedWidth( w - 20 );
186 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 189 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
187 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 190 slider->setBackgroundOrigin( QWidget::ParentOrigin );
188 slider->setFocusPolicy( QWidget::NoFocus ); 191 slider->setFocusPolicy( QWidget::NoFocus );
189 slider->setBackgroundPixmap( *pixBg ); 192 slider->setBackgroundPixmap( *pixBg );
190 193
191 xoff = 0;// ( imgUp->width() ) / 2; 194 xoff = 0;// ( imgUp->width() ) / 2;
192 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 195 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
193 QPoint p( xoff, yoff ); 196 QPoint p( xoff, yoff );
194 197
195 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 198 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
196 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 199 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
197 200
198 for ( int i = 0; i < 7; i++ ) { 201 for ( int i = 0; i < 7; i++ ) {
199 if ( !masks[i]->isNull() ) { 202 if ( !masks[i]->isNull() ) {
200 delete buttonPixUp[i]; 203 delete buttonPixUp[i];
201 delete buttonPixDown[i]; 204 delete buttonPixDown[i];
202 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 205 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
203 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 206 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
204 } 207 }
205 } 208 }
206 209
207 delete pixUp; 210 delete pixUp;
208 delete pixDn; 211 delete pixDn;
209} 212}
210 213
211static bool videoSliderBeingMoved = FALSE; 214static bool videoSliderBeingMoved = FALSE;