summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 87e06ee..c148820 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -25,165 +25,163 @@
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#include <opie/oticker.h>
38 38
39#include <qwidget.h> 39#include <qwidget.h>
40#include <qpixmap.h> 40#include <qpixmap.h>
41#include <qbutton.h> 41#include <qbutton.h>
42#include <qpainter.h> 42#include <qpainter.h>
43#include <qframe.h> 43#include <qframe.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qdir.h> 45#include <qdir.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <stdio.h> 47#include <stdio.h>
48 48
49#include "audiowidget.h" 49#include "audiowidget.h"
50#include "mediaplayerstate.h" 50#include "mediaplayerstate.h"
51#include "playlistwidget.h" 51#include "playlistwidget.h"
52 52
53namespace 53namespace
54{ 54{
55 55
56const int xo = -2; // movable x offset 56const int xo = -2; // movable x offset
57const int yo = 22; // movable y offset 57const int yo = 22; // movable y offset
58 58
59const MediaWidget::SkinButtonInfo skinInfo[] = 59const MediaWidget::SkinButtonInfo skinInfo[] =
60{ 60{
61 { MediaWidget::Play, "play", MediaWidget::ToggleButton }, 61 { MediaWidget::Play, "play", MediaWidget::ToggleButton },
62 { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, 62 { MediaWidget::Stop, "stop", MediaWidget::NormalButton },
63 { MediaWidget::Next, "next", MediaWidget::NormalButton }, 63 { MediaWidget::Next, "next", MediaWidget::NormalButton },
64 { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, 64 { MediaWidget::Previous, "prev", MediaWidget::NormalButton },
65 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, 65 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
66 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, 66 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
67 { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, 67 { MediaWidget::Loop, "loop", MediaWidget::ToggleButton },
68 { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, 68 { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton },
69 { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, 69 { MediaWidget::Forward, "forward", MediaWidget::NormalButton },
70 { MediaWidget::Back, "back", MediaWidget::NormalButton } 70 { MediaWidget::Back, "back", MediaWidget::NormalButton }
71}; 71};
72 72
73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
74 74
75void changeTextColor( QWidget * w) { 75void changeTextColor( QWidget * w) {
76 QPalette p = w->palette(); 76 QPalette p = w->palette();
77 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 77 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
78 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 78 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
79 w->setPalette( p ); 79 w->setPalette( p );
80} 80}
81 81
82} 82}
83 83
84AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : 84AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
85 85
86 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), 86 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ),
87 audioSliderBeingMoved( false ) 87 audioSliderBeingMoved( false )
88{ 88{
89 for ( uint i = 0; i < buttonCount; ++i ) {
90 Button button;
91 button.type = skinInfo[ i ].type;
92 buttons.push_back( button );
93 }
94
95 setCaption( tr("OpiePlayer") ); 89 setCaption( tr("OpiePlayer") );
96 90
97 Config cfg("OpiePlayer"); 91 Config cfg("OpiePlayer");
98 cfg.setGroup("Options"); 92 cfg.setGroup("Options");
99 skin = cfg.readEntry("Skin","default"); 93 skin = cfg.readEntry("Skin","default");
100 //skin = "scaleTest"; 94 //skin = "scaleTest";
101 // color of background, frame, degree of transparency 95 // color of background, frame, degree of transparency
102 96
103 QString skinPath = "opieplayer2/skins/" + skin; 97 QString skinPath = "opieplayer2/skins/" + skin;
104 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 98 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
105 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 99 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
106 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 100 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
107 101
108 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 102 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
109 buttonMask.fill( 0 ); 103 buttonMask.fill( 0 );
110 104
111 for ( uint i = 0; i < buttons.size(); i++ ) { 105 for ( uint i = 0; i < buttonCount; i++ ) {
106 Button button;
107 button.type = skinInfo[ i ].type;
108
112 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" ); 109 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" );
113 buttons[ i ].mask =QBitmap( filename ); 110 button.mask =QBitmap( filename );
114 111
115 if ( !buttons[i].mask.isNull() ) { 112 if ( !button.mask.isNull() ) {
116 QImage imgMask = buttons[i].mask.convertToImage(); 113 QImage imgMask = button.mask.convertToImage();
117 uchar **dest = buttonMask.jumpTable(); 114 uchar **dest = buttonMask.jumpTable();
118 for ( int y = 0; y < imgUp.height(); y++ ) { 115 for ( int y = 0; y < imgUp.height(); y++ ) {
119 uchar *line = dest[y]; 116 uchar *line = dest[y];
120 for ( int x = 0; x < imgUp.width(); x++ ) 117 for ( int x = 0; x < imgUp.width(); x++ )
121 if ( !qRed( imgMask.pixel( x, y ) ) ) 118 if ( !qRed( imgMask.pixel( x, y ) ) )
122 line[x] = i + 1; 119 line[x] = i + 1;
123 } 120 }
124 } 121 }
125 122
123 buttons.push_back( button );
126 } 124 }
127 125
128 setBackgroundPixmap( pixBg ); 126 setBackgroundPixmap( pixBg );
129 127
130 songInfo.setFocusPolicy( QWidget::NoFocus ); 128 songInfo.setFocusPolicy( QWidget::NoFocus );
131// changeTextColor( &songInfo ); 129// changeTextColor( &songInfo );
132// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 130// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
133// songInfo.setFrameStyle( QFrame::NoFrame); 131// songInfo.setFrameStyle( QFrame::NoFrame);
134 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 132 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
135// songInfo.setForegroundColor(Qt::white); 133// songInfo.setForegroundColor(Qt::white);
136 134
137 slider.setFixedHeight( 20 ); 135 slider.setFixedHeight( 20 );
138 slider.setMinValue( 0 ); 136 slider.setMinValue( 0 );
139 slider.setMaxValue( 1 ); 137 slider.setMaxValue( 1 );
140 slider.setFocusPolicy( QWidget::NoFocus ); 138 slider.setFocusPolicy( QWidget::NoFocus );
141 slider.setBackgroundPixmap( pixBg ); 139 slider.setBackgroundPixmap( pixBg );
142 140
143// Config cofg("qpe"); 141// Config cofg("qpe");
144// cofg.setGroup("Appearance"); 142// cofg.setGroup("Appearance");
145// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 143// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
146 144
147 time.setFocusPolicy( QWidget::NoFocus ); 145 time.setFocusPolicy( QWidget::NoFocus );
148 time.setAlignment( Qt::AlignCenter ); 146 time.setAlignment( Qt::AlignCenter );
149 147
150// time.setFrame(FALSE); 148// time.setFrame(FALSE);
151// changeTextColor( &time ); 149// changeTextColor( &time );
152 150
153 resizeEvent( NULL ); 151 resizeEvent( NULL );
154 152
155 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 153 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
156 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 154 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
157 155
158 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 156 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
159 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 157 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
160 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 158 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
161 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 159 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
162 160
163 // Intialise state 161 // Intialise state
164 setLength( mediaPlayerState.length() ); 162 setLength( mediaPlayerState.length() );
165 setPosition( mediaPlayerState.position() ); 163 setPosition( mediaPlayerState.position() );
166 setLooping( mediaPlayerState.isFullscreen() ); 164 setLooping( mediaPlayerState.isFullscreen() );
167 // setPaused( mediaPlayerState->paused() ); 165 // setPaused( mediaPlayerState->paused() );
168 setPlaying( mediaPlayerState.isPlaying() ); 166 setPlaying( mediaPlayerState.isPlaying() );
169 167
170} 168}
171 169
172AudioWidget::~AudioWidget() { 170AudioWidget::~AudioWidget() {
173 171
174// mediaPlayerState->setPlaying(false); 172// mediaPlayerState->setPlaying(false);
175} 173}
176 174
177namespace { 175namespace {
178 176
179QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 177QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
180 QPixmap pix( img.width(), img.height() ); 178 QPixmap pix( img.width(), img.height() );
181 QPainter p( &pix ); 179 QPainter p( &pix );
182 p.drawTiledPixmap( pix.rect(), bg, offset ); 180 p.drawTiledPixmap( pix.rect(), bg, offset );
183 p.drawImage( 0, 0, img ); 181 p.drawImage( 0, 0, img );
184 return pix; 182 return pix;
185} 183}
186 184
187 185
188QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { 186QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) {
189 QPixmap pixmap( pix ); 187 QPixmap pixmap( pix );