Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 3 |
1 files changed, 3 insertions, 0 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 | |||
@@ -83,96 +83,99 @@ void Ticker::timerEvent( QTimerEvent * ) { | |||
83 | void Ticker::drawContents( QPainter *p ) { | 83 | void 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 | ||
95 | struct MediaButton { | 95 | struct 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) |
100 | MediaButton audioButtons[] = { | 100 | MediaButton 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 | ||
113 | const char *skin_mask_file_names[10] = { | 113 | const 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 | ||
119 | static void changeTextColor( QWidget *w ) { | 119 | static 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 | ||
126 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 126 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
127 | 127 | ||
128 | 128 | ||
129 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 129 | AudioWidget::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 ); |