author | harlekin <harlekin> | 2002-07-03 15:42:34 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-07-03 15:42:34 (UTC) |
commit | 3035c46ce448317f786d974094f78ce43e594a57 (patch) (unidiff) | |
tree | f0c84f34ee2ecbae4d00ed6cfde3cb955802a470 /noncore/multimedia/opieplayer2/audiowidget.cpp | |
parent | e1e4956ec7ffa9a07f98b03e831f0f9627556a6c (diff) | |
download | opie-3035c46ce448317f786d974094f78ce43e594a57.zip opie-3035c46ce448317f786d974094f78ce43e594a57.tar.gz opie-3035c46ce448317f786d974094f78ce43e594a57.tar.bz2 |
even more code cleanups .-)
Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 1b0de5d..125fd72 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -46,54 +46,49 @@ void Ticker::timerEvent( QTimerEvent * ) { | |||
46 | 46 | ||
47 | void Ticker::drawContents( QPainter *p ) { | 47 | void Ticker::drawContents( QPainter *p ) { |
48 | QPixmap pm( width(), height() ); | 48 | QPixmap pm( width(), height() ); |
49 | pm.fill( colorGroup().base() ); | 49 | pm.fill( colorGroup().base() ); |
50 | QPainter pmp( &pm ); | 50 | QPainter pmp( &pm ); |
51 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | 51 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { |
52 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 52 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
53 | } | 53 | } |
54 | p->drawPixmap( 0, 0, pm ); | 54 | p->drawPixmap( 0, 0, pm ); |
55 | } | 55 | } |
56 | 56 | ||
57 | 57 | ||
58 | |||
59 | |||
60 | struct MediaButton { | 58 | struct MediaButton { |
61 | int xPos, yPos; | 59 | int xPos, yPos; |
62 | int color; | 60 | int color; |
63 | bool isToggle, isBig, isHeld, isDown; | 61 | bool isToggle, isBig, isHeld, isDown; |
64 | }; | 62 | }; |
65 | 63 | ||
66 | 64 | ||
67 | |||
68 | |||
69 | // Layout information for the audioButtons (and if it is a toggle button or not) | 65 | // Layout information for the audioButtons (and if it is a toggle button or not) |
70 | MediaButton audioButtons[] = { | 66 | MediaButton audioButtons[] = { |
71 | { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play | 67 | { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play |
72 | { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop | 68 | { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop |
73 | { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause | 69 | { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause |
74 | { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next | 70 | { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next |
75 | { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous | 71 | { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous |
76 | { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up | 72 | { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up |
77 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down | 73 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down |
78 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop | 74 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop |
79 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist | 75 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist |
80 | }; | 76 | }; |
81 | 77 | ||
82 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 78 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
83 | 79 | ||
84 | 80 | ||
85 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 81 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
86 | QWidget( parent, name, f ) | 82 | QWidget( parent, name, f ) { |
87 | { | ||
88 | setCaption( tr("OpiePlayer - Audio") ); | 83 | setCaption( tr("OpiePlayer - Audio") ); |
89 | Config cfg("OpiePlayer"); | 84 | Config cfg("OpiePlayer"); |
90 | cfg.setGroup("AudioWidget"); | 85 | cfg.setGroup("AudioWidget"); |
91 | 86 | ||
92 | QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; | 87 | QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; |
93 | backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); | 88 | backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); |
94 | buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll"); | 89 | buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll"); |
95 | buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig"); | 90 | buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig"); |
96 | controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls"); | 91 | controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls"); |
97 | 92 | ||
98 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); | 93 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); |
99 | pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) ); | 94 | pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) ); |
@@ -118,28 +113,26 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | |||
118 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 113 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
119 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 114 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
120 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 115 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
121 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 116 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
122 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 117 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
123 | 118 | ||
124 | // Intialise state | 119 | // Intialise state |
125 | setLength( mediaPlayerState->length() ); | 120 | setLength( mediaPlayerState->length() ); |
126 | setPosition( mediaPlayerState->position() ); | 121 | setPosition( mediaPlayerState->position() ); |
127 | setLooping( mediaPlayerState->fullscreen() ); | 122 | setLooping( mediaPlayerState->fullscreen() ); |
128 | setPaused( mediaPlayerState->paused() ); | 123 | setPaused( mediaPlayerState->paused() ); |
129 | setPlaying( mediaPlayerState->playing() ); | 124 | setPlaying( mediaPlayerState->playing() ); |
130 | |||
131 | } | 125 | } |
132 | 126 | ||
133 | |||
134 | AudioWidget::~AudioWidget() { | 127 | AudioWidget::~AudioWidget() { |
135 | mediaPlayerState->isStreaming = FALSE; | 128 | mediaPlayerState->isStreaming = FALSE; |
136 | for ( int i = 0; i < 3; i++ ) { | 129 | for ( int i = 0; i < 3; i++ ) { |
137 | delete pixmaps[i]; | 130 | delete pixmaps[i]; |
138 | } | 131 | } |
139 | } | 132 | } |
140 | 133 | ||
141 | 134 | ||
142 | static bool audioSliderBeingMoved = FALSE; | 135 | static bool audioSliderBeingMoved = FALSE; |
143 | 136 | ||
144 | 137 | ||
145 | void AudioWidget::sliderPressed() { | 138 | void AudioWidget::sliderPressed() { |
@@ -147,25 +140,24 @@ void AudioWidget::sliderPressed() { | |||
147 | } | 140 | } |
148 | 141 | ||
149 | 142 | ||
150 | void AudioWidget::sliderReleased() { | 143 | void AudioWidget::sliderReleased() { |
151 | audioSliderBeingMoved = FALSE; | 144 | audioSliderBeingMoved = FALSE; |
152 | if ( slider->width() == 0 ) { | 145 | if ( slider->width() == 0 ) { |
153 | return; | 146 | return; |
154 | } | 147 | } |
155 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 148 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
156 | mediaPlayerState->setPosition( val ); | 149 | mediaPlayerState->setPosition( val ); |
157 | } | 150 | } |
158 | 151 | ||
159 | |||
160 | void AudioWidget::setPosition( long i ) { | 152 | void AudioWidget::setPosition( long i ) { |
161 | // qDebug("set position %d",i); | 153 | // qDebug("set position %d",i); |
162 | updateSlider( i, mediaPlayerState->length() ); | 154 | updateSlider( i, mediaPlayerState->length() ); |
163 | } | 155 | } |
164 | 156 | ||
165 | 157 | ||
166 | void AudioWidget::setLength( long max ) { | 158 | void AudioWidget::setLength( long max ) { |
167 | updateSlider( mediaPlayerState->position(), max ); | 159 | updateSlider( mediaPlayerState->position(), max ); |
168 | } | 160 | } |
169 | 161 | ||
170 | 162 | ||
171 | void AudioWidget::setView( char view ) { | 163 | void AudioWidget::setView( char view ) { |