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