summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/videowidget.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/videowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index 3bce996..97997f9 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -1,103 +1,114 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/mediaplayerplugininterface.h> 21#include <qpe/mediaplayerplugininterface.h>
22#include <qpe/config.h>
23
22#include <qwidget.h> 24#include <qwidget.h>
23#include <qpainter.h> 25#include <qpainter.h>
24#include <qpixmap.h> 26#include <qpixmap.h>
25#include <qslider.h> 27#include <qslider.h>
26#include <qdrawutil.h> 28#include <qdrawutil.h>
27#include "videowidget.h" 29#include "videowidget.h"
28#include "mediaplayerstate.h" 30#include "mediaplayerstate.h"
29 31
30 32
31#ifdef Q_WS_QWS 33#ifdef Q_WS_QWS
32# define USE_DIRECT_PAINTER 34# define USE_DIRECT_PAINTER
33# include <qdirectpainter_qws.h> 35# include <qdirectpainter_qws.h>
34# include <qgfxraster_qws.h> 36# include <qgfxraster_qws.h>
35#endif 37#endif
36 38
37 39
38extern MediaPlayerState *mediaPlayerState; 40extern MediaPlayerState *mediaPlayerState;
39 41
40 42
41static const int xo = 2; // movable x offset 43static const int xo = 2; // movable x offset
42static const int yo = 0; // movable y offset 44static const int yo = 0; // movable y offset
43 45
44 46
45struct MediaButton { 47struct MediaButton {
46 int xPos, yPos; 48 int xPos, yPos;
47 bool isToggle, isHeld, isDown; 49 bool isToggle, isHeld, isDown;
48 int controlType; 50 int controlType;
49}; 51};
50 52
51 53
52// Layout information for the videoButtons (and if it is a toggle button or not) 54// Layout information for the videoButtons (and if it is a toggle button or not)
53MediaButton videoButtons[] = { 55MediaButton videoButtons[] = {
54 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous 56 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous
55 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop 57 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop
56 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play 58 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play
57 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause 59 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause
58 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next 60 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next
59 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist 61 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist
60 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen 62 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen
61}; 63};
62 64
63 65
64static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 66static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
65 67
66 68
67VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 69VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
68 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 70 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
69 setCaption( tr("OpiePlayer") ); 71 setCaption( tr("OpiePlayer") );
70 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 72 Config cfg("OpiePlayer");
71 pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0a" ) ); 73 cfg.setGroup("VideoWidget");
72 pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0b" ) ); 74
73 pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls0" ) ); 75 QString backgroundPix, Button0aPix, Button0bPix, controlsPix;
76 backgroundPix=cfg.readEntry( "backgroundPix", "opieplayer/metalFinish");
77 Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a");
78 Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b");
79 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" );
80
81 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) );
82 pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) );
83 pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) );
84 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) );
74 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 85 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
75 86
76 slider = new QSlider( Qt::Horizontal, this ); 87 slider = new QSlider( Qt::Horizontal, this );
77 slider->setMinValue( 0 ); 88 slider->setMinValue( 0 );
78 slider->setMaxValue( 1 ); 89 slider->setMaxValue( 1 );
79 slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 90 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
80 slider->setFocusPolicy( QWidget::NoFocus ); 91 slider->setFocusPolicy( QWidget::NoFocus );
81 slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 92 slider->setGeometry( QRect( 7, 250, 220, 20 ) );
82 93
83 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 94 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
84 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 95 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
85 96
86 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 97 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
87 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 98 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
88 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 99 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
89 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 100 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
90 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 101 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
91 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 102 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
92 103
93 // Intialise state 104 // Intialise state
94 setLength( mediaPlayerState->length() ); 105 setLength( mediaPlayerState->length() );
95 setPosition( mediaPlayerState->position() ); 106 setPosition( mediaPlayerState->position() );
96 setFullscreen( mediaPlayerState->fullscreen() ); 107 setFullscreen( mediaPlayerState->fullscreen() );
97 setPaused( mediaPlayerState->paused() ); 108 setPaused( mediaPlayerState->paused() );
98 setPlaying( mediaPlayerState->playing() ); 109 setPlaying( mediaPlayerState->playing() );
99} 110}
100 111
101 112
102VideoWidget::~VideoWidget() { 113VideoWidget::~VideoWidget() {
103 for ( int i = 0; i < 3; i++ ) 114 for ( int i = 0; i < 3; i++ )