author | llornkcor <llornkcor> | 2002-11-10 17:43:03 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-10 17:43:03 (UTC) |
commit | 49e5bbbd35bef879faca0d680f1c4d64a61b7b32 (patch) (unidiff) | |
tree | 51feb6d756101caf755e2dabefdc707b133292c2 | |
parent | b84ab7a14a0efb50cd425a8614ff465081116420 (diff) | |
download | opie-49e5bbbd35bef879faca0d680f1c4d64a61b7b32.zip opie-49e5bbbd35bef879faca0d680f1c4d64a61b7b32.tar.gz opie-49e5bbbd35bef879faca0d680f1c4d64a61b7b32.tar.bz2 |
use users default colors for ticker
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 47 |
1 files changed, 6 insertions, 41 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index de91a59..e21b0b1 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -5,125 +5,86 @@ | |||
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 | #include <opie/oticker.h> | ||
37 | 38 | ||
38 | #include <qwidget.h> | 39 | #include <qwidget.h> |
39 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
40 | #include <qbutton.h> | 41 | #include <qbutton.h> |
41 | #include <qpainter.h> | 42 | #include <qpainter.h> |
42 | #include <qframe.h> | 43 | #include <qframe.h> |
43 | #include <qlayout.h> | 44 | #include <qlayout.h> |
44 | #include <qdir.h> | 45 | #include <qdir.h> |
45 | #include <stdlib.h> | 46 | #include <stdlib.h> |
46 | #include <stdio.h> | 47 | #include <stdio.h> |
47 | 48 | ||
48 | #include "audiowidget.h" | 49 | #include "audiowidget.h" |
49 | #include "mediaplayerstate.h" | 50 | #include "mediaplayerstate.h" |
50 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
51 | 52 | ||
52 | extern MediaPlayerState *mediaPlayerState; | 53 | extern MediaPlayerState *mediaPlayerState; |
53 | extern PlayListWidget *playList; | 54 | extern PlayListWidget *playList; |
54 | 55 | ||
55 | static const int xo = -2; // movable x offset | 56 | static const int xo = -2; // movable x offset |
56 | static const int yo = 22; // movable y offset | 57 | static const int yo = 22; // movable y offset |
57 | 58 | ||
58 | |||
59 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { | ||
60 | setFrameStyle( WinPanel | Sunken ); | ||
61 | //setText( "No Song" ); | ||
62 | } | ||
63 | |||
64 | Ticker::~Ticker() { | ||
65 | } | ||
66 | |||
67 | void Ticker::setText( const QString& text ) { | ||
68 | pos = 0; // reset it everytime the text is changed | ||
69 | scrollText = text; | ||
70 | pixelLen = fontMetrics().width( scrollText ); | ||
71 | killTimers(); | ||
72 | if ( pixelLen > width() ) { | ||
73 | startTimer( 50 ); | ||
74 | } | ||
75 | update(); | ||
76 | } | ||
77 | |||
78 | |||
79 | void Ticker::timerEvent( QTimerEvent * ) { | ||
80 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | ||
81 | scroll( -1, 0, contentsRect() ); | ||
82 | repaint( FALSE ); | ||
83 | } | ||
84 | |||
85 | void Ticker::drawContents( QPainter *p ) { | ||
86 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | ||
87 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | ||
88 | } | ||
89 | QPixmap pm( width(), height() ); | ||
90 | pm.fill( colorGroup().base() ); | ||
91 | QPainter pmp( &pm ); | ||
92 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | ||
93 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | ||
94 | } | ||
95 | p->drawPixmap( 0, 0, pm ); | ||
96 | } | ||
97 | |||
98 | struct MediaButton { | 59 | struct MediaButton { |
99 | bool isToggle, isHeld, isDown; | 60 | bool isToggle, isHeld, isDown; |
100 | }; | 61 | }; |
101 | 62 | ||
102 | //Layout information for the audioButtons (and if it is a toggle button or not) | 63 | //Layout information for the audioButtons (and if it is a toggle button or not) |
103 | MediaButton audioButtons[] = { | 64 | MediaButton audioButtons[] = { |
104 | { TRUE, FALSE, FALSE }, // play | 65 | { TRUE, FALSE, FALSE }, // play |
105 | { FALSE, FALSE, FALSE }, // stop | 66 | { FALSE, FALSE, FALSE }, // stop |
106 | { FALSE, FALSE, FALSE }, // next | 67 | { FALSE, FALSE, FALSE }, // next |
107 | { FALSE, FALSE, FALSE }, // previous | 68 | { FALSE, FALSE, FALSE }, // previous |
108 | { FALSE, FALSE, FALSE }, // volume up | 69 | { FALSE, FALSE, FALSE }, // volume up |
109 | { FALSE, FALSE, FALSE }, // volume down | 70 | { FALSE, FALSE, FALSE }, // volume down |
110 | { TRUE, FALSE, FALSE }, // repeat/loop | 71 | { TRUE, FALSE, FALSE }, // repeat/loop |
111 | { FALSE, FALSE, FALSE }, // playlist | 72 | { FALSE, FALSE, FALSE }, // playlist |
112 | { FALSE, FALSE, FALSE }, // forward | 73 | { FALSE, FALSE, FALSE }, // forward |
113 | { FALSE, FALSE, FALSE } // back | 74 | { FALSE, FALSE, FALSE } // back |
114 | }; | 75 | }; |
115 | 76 | ||
116 | const char *skin_mask_file_names[10] = { | 77 | const char *skin_mask_file_names[10] = { |
117 | "play", "stop", "next", "prev", "up", | 78 | "play", "stop", "next", "prev", "up", |
118 | "down", "loop", "playlist", "forward", "back" | 79 | "down", "loop", "playlist", "forward", "back" |
119 | }; | 80 | }; |
120 | 81 | ||
121 | 82 | ||
122 | static void changeTextColor( QWidget *w ) { | 83 | static void changeTextColor( QWidget *w ) { |
123 | QPalette p = w->palette(); | 84 | QPalette p = w->palette(); |
124 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 85 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
125 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 86 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
126 | w->setPalette( p ); | 87 | w->setPalette( p ); |
127 | } | 88 | } |
128 | 89 | ||
129 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 90 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
@@ -145,65 +106,69 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | |||
145 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 106 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
146 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 107 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
147 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 108 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
148 | 109 | ||
149 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 110 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
150 | imgButtonMask->fill( 0 ); | 111 | imgButtonMask->fill( 0 ); |
151 | 112 | ||
152 | for ( int i = 0; i < 10; i++ ) { | 113 | for ( int i = 0; i < 10; i++ ) { |
153 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 114 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); |
154 | masks[i] = new QBitmap( filename ); | 115 | masks[i] = new QBitmap( filename ); |
155 | 116 | ||
156 | if ( !masks[i]->isNull() ) { | 117 | if ( !masks[i]->isNull() ) { |
157 | QImage imgMask = masks[i]->convertToImage(); | 118 | QImage imgMask = masks[i]->convertToImage(); |
158 | uchar **dest = imgButtonMask->jumpTable(); | 119 | uchar **dest = imgButtonMask->jumpTable(); |
159 | for ( int y = 0; y < imgUp->height(); y++ ) { | 120 | for ( int y = 0; y < imgUp->height(); y++ ) { |
160 | uchar *line = dest[y]; | 121 | uchar *line = dest[y]; |
161 | for ( int x = 0; x < imgUp->width(); x++ ) | 122 | for ( int x = 0; x < imgUp->width(); x++ ) |
162 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 123 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
163 | line[x] = i + 1; | 124 | line[x] = i + 1; |
164 | } | 125 | } |
165 | } | 126 | } |
166 | 127 | ||
167 | } | 128 | } |
168 | 129 | ||
169 | for ( int i = 0; i < 10; i++ ) { | 130 | for ( int i = 0; i < 10; i++ ) { |
170 | buttonPixUp[i] = 0l; | 131 | buttonPixUp[i] = 0l; |
171 | buttonPixDown[i] = 0l; | 132 | buttonPixDown[i] = 0l; |
172 | } | 133 | } |
173 | 134 | ||
174 | setBackgroundPixmap( *pixBg ); | 135 | setBackgroundPixmap( *pixBg ); |
175 | 136 | ||
176 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 137 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
177 | changeTextColor( &songInfo ); | 138 | // changeTextColor( &songInfo ); |
139 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | ||
140 | // songInfo.setFrameStyle( QFrame::NoFrame); | ||
141 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | ||
142 | // songInfo.setForegroundColor(Qt::white); | ||
178 | 143 | ||
179 | slider.setFixedHeight( 20 ); | 144 | slider.setFixedHeight( 20 ); |
180 | slider.setMinValue( 0 ); | 145 | slider.setMinValue( 0 ); |
181 | slider.setMaxValue( 1 ); | 146 | slider.setMaxValue( 1 ); |
182 | slider.setFocusPolicy( QWidget::NoFocus ); | 147 | slider.setFocusPolicy( QWidget::NoFocus ); |
183 | slider.setBackgroundPixmap( *pixBg ); | 148 | slider.setBackgroundPixmap( *pixBg ); |
184 | 149 | ||
185 | time.setFocusPolicy( QWidget::NoFocus ); | 150 | time.setFocusPolicy( QWidget::NoFocus ); |
186 | time.setAlignment( Qt::AlignCenter ); | 151 | time.setAlignment( Qt::AlignCenter ); |
187 | time.setFrame(FALSE); | 152 | time.setFrame(FALSE); |
188 | changeTextColor( &time ); | 153 | changeTextColor( &time ); |
189 | 154 | ||
190 | resizeEvent( NULL ); | 155 | resizeEvent( NULL ); |
191 | 156 | ||
192 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 157 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
193 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 158 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
194 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 159 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
195 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 160 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
196 | connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); | 161 | connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); |
197 | 162 | ||
198 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 163 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
199 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 164 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
200 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 165 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
201 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 166 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
202 | 167 | ||
203 | // Intialise state | 168 | // Intialise state |
204 | setLength( mediaPlayerState->length() ); | 169 | setLength( mediaPlayerState->length() ); |
205 | setPosition( mediaPlayerState->position() ); | 170 | setPosition( mediaPlayerState->position() ); |
206 | setLooping( mediaPlayerState->fullscreen() ); | 171 | setLooping( mediaPlayerState->fullscreen() ); |
207 | // setPaused( mediaPlayerState->paused() ); | 172 | // setPaused( mediaPlayerState->paused() ); |
208 | setPlaying( mediaPlayerState->playing() ); | 173 | setPlaying( mediaPlayerState->playing() ); |
209 | 174 | ||