summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-01-18 05:58:46 (UTC)
committer llornkcor <llornkcor>2004-01-18 05:58:46 (UTC)
commita2a3aabf21655cc9c7df8e2ed0d420d2b208fd3d (patch) (unidiff)
tree6cb2840a838d24cd1500e5c86c54393234999f08
parenta5a10ccc4b39e9ec21b1774713745b31f47a5133 (diff)
downloadopie-a2a3aabf21655cc9c7df8e2ed0d420d2b208fd3d.zip
opie-a2a3aabf21655cc9c7df8e2ed0d420d2b208fd3d.tar.gz
opie-a2a3aabf21655cc9c7df8e2ed0d420d2b208fd3d.tar.bz2
scale background image if needed
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp13
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp26
2 files changed, 28 insertions, 11 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index b187cb4..44fbe48 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -76,111 +76,122 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
76 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) 76 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
77{ 77{
78 setCaption( tr("OpiePlayer") ); 78 setCaption( tr("OpiePlayer") );
79 // qDebug("<<<<<audioWidget"); 79 // qDebug("<<<<<audioWidget");
80 80
81 Config cfg("OpiePlayer"); 81 Config cfg("OpiePlayer");
82 cfg.setGroup("Options"); 82 cfg.setGroup("Options");
83 skin = cfg.readEntry("Skin","default"); 83 skin = cfg.readEntry("Skin","default");
84 //skin = "scaleTest"; 84 //skin = "scaleTest";
85// color of background, frame, degree of transparency 85// color of background, frame, degree of transparency
86 86
87// QString skinPath = "opieplayer/skins/" + skin; 87// QString skinPath = "opieplayer/skins/" + skin;
88 QString skinPath; 88 QString skinPath;
89 skinPath = "opieplayer2/skins/" + skin; 89 skinPath = "opieplayer2/skins/" + skin;
90 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) 90 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists())
91 skinPath = "opieplayer2/skins/default"; 91 skinPath = "opieplayer2/skins/default";
92 92
93 // qDebug("skin path " + skinPath); 93 // qDebug("skin path " + skinPath);
94 94
95 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 95 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
96 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 96 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
97 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 97 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
98 98
99 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 99 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
100 imgButtonMask->fill( 0 ); 100 imgButtonMask->fill( 0 );
101 101
102 for ( int i = 0; i < 10; i++ ) { 102 for ( int i = 0; i < 10; i++ ) {
103 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 103 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
104 masks[i] = new QBitmap( filename ); 104 masks[i] = new QBitmap( filename );
105 105
106 if ( !masks[i]->isNull() ) { 106 if ( !masks[i]->isNull() ) {
107 QImage imgMask = masks[i]->convertToImage(); 107 QImage imgMask = masks[i]->convertToImage();
108 uchar **dest = imgButtonMask->jumpTable(); 108 uchar **dest = imgButtonMask->jumpTable();
109 for ( int y = 0; y < imgUp->height(); y++ ) { 109 for ( int y = 0; y < imgUp->height(); y++ ) {
110 uchar *line = dest[y]; 110 uchar *line = dest[y];
111 for ( int x = 0; x < imgUp->width(); x++ ) 111 for ( int x = 0; x < imgUp->width(); x++ )
112 if ( !qRed( imgMask.pixel( x, y ) ) ) 112 if ( !qRed( imgMask.pixel( x, y ) ) )
113 line[x] = i + 1; 113 line[x] = i + 1;
114 } 114 }
115 } 115 }
116 116
117 } 117 }
118 118
119 for ( int i = 0; i < 11; i++ ) { 119 for ( int i = 0; i < 11; i++ ) {
120 buttonPixUp[i] = NULL; 120 buttonPixUp[i] = NULL;
121 buttonPixDown[i] = NULL; 121 buttonPixDown[i] = NULL;
122 } 122 }
123 123
124 setBackgroundPixmap( *pixBg ); 124 QWidget *d = QApplication::desktop();
125 int width = d->width();
126 int height = d->height();
127
128 if( (width != pixBg->width() ) || (height != pixBg->height() ) ) {
129 // qDebug("<<<<<<<< scale image >>>>>>>>>>>>");
130 QImage img;
131 img = pixBg->convertToImage();
132 pixBg->convertFromImage( img.smoothScale( width, height));
133 }
134 setBackgroundPixmap( *pixBg);
125 135
126 songInfo.setFocusPolicy( QWidget::NoFocus ); 136 songInfo.setFocusPolicy( QWidget::NoFocus );
127 137
128// changeTextColor( &songInfo ); 138// changeTextColor( &songInfo );
129// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 139// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
130// songInfo.setFrameStyle( QFrame::NoFrame); 140// songInfo.setFrameStyle( QFrame::NoFrame);
131// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 141// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
132 //NoFrame 142 //NoFrame
133// songInfo.setForegroundColor(Qt::white); 143// songInfo.setForegroundColor(Qt::white);
134 144
135 slider.setFixedHeight( 20 ); 145 slider.setFixedHeight( 20 );
136 slider.setMinValue( 0 ); 146 slider.setMinValue( 0 );
137 slider.setMaxValue( 1 ); 147 slider.setMaxValue( 1 );
138 slider.setFocusPolicy( QWidget::NoFocus ); 148 slider.setFocusPolicy( QWidget::NoFocus );
149
139 slider.setBackgroundPixmap( *pixBg ); 150 slider.setBackgroundPixmap( *pixBg );
140 151
141 time.setFocusPolicy( QWidget::NoFocus ); 152 time.setFocusPolicy( QWidget::NoFocus );
142 time.setAlignment( Qt::AlignCenter ); 153 time.setAlignment( Qt::AlignCenter );
143 time.setFrame(FALSE); 154 time.setFrame(FALSE);
144 changeTextColor( &time ); 155 changeTextColor( &time );
145 156
146 resizeEvent( NULL ); 157 resizeEvent( NULL );
147 158
148 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 159 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
149 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 160 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
150 161
151 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 162 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
152 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 163 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
153 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 164 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
154// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 165// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
155 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 166 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
156 167
157 // Intialise state 168 // Intialise state
158 setLength( mediaPlayerState->length() ); 169 setLength( mediaPlayerState->length() );
159 setPosition( mediaPlayerState->position() ); 170 setPosition( mediaPlayerState->position() );
160 setLooping( mediaPlayerState->fullscreen() ); 171 setLooping( mediaPlayerState->fullscreen() );
161// setPaused( mediaPlayerState->paused() ); 172// setPaused( mediaPlayerState->paused() );
162 setPlaying( mediaPlayerState->playing() ); 173 setPlaying( mediaPlayerState->playing() );
163this->setFocus(); 174this->setFocus();
164} 175}
165 176
166 177
167AudioWidget::~AudioWidget() { 178AudioWidget::~AudioWidget() {
168 // setPlaying( false); 179 // setPlaying( false);
169 180
170 for ( int i = 0; i < 10; i++ ) { 181 for ( int i = 0; i < 10; i++ ) {
171 if(buttonPixUp[i]) delete buttonPixUp[i]; 182 if(buttonPixUp[i]) delete buttonPixUp[i];
172 if(buttonPixDown[i]) delete buttonPixDown[i]; 183 if(buttonPixDown[i]) delete buttonPixDown[i];
173 } 184 }
174 if(pixBg) delete pixBg; 185 if(pixBg) delete pixBg;
175 if(imgUp) delete imgUp; 186 if(imgUp) delete imgUp;
176 if(imgDn) delete imgDn; 187 if(imgDn) delete imgDn;
177 if(imgButtonMask) delete imgButtonMask; 188 if(imgButtonMask) delete imgButtonMask;
178 for ( int i = 0; i < 10; i++ ) { 189 for ( int i = 0; i < 10; i++ ) {
179 if(masks[i]) delete masks[i]; 190 if(masks[i]) delete masks[i];
180 } 191 }
181} 192}
182 193
183 194
184QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 195QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
185 QPixmap pix( img.width(), img.height() ); 196 QPixmap pix( img.width(), img.height() );
186 QPainter p( &pix ); 197 QPainter p( &pix );
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index 02c8568..d9a9478 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -52,125 +52,131 @@ struct MediaButton {
52// int controlType; 52// int controlType;
53}; 53};
54 54
55 55
56// Layout information for the videoButtons (and if it is a toggle button or not) 56// Layout information for the videoButtons (and if it is a toggle button or not)
57MediaButton videoButtons[] = { 57MediaButton videoButtons[] = {
58 { FALSE, FALSE, FALSE }, // stop 58 { FALSE, FALSE, FALSE }, // stop
59 { FALSE, FALSE, FALSE }, // play 59 { FALSE, FALSE, FALSE }, // play
60 { FALSE, FALSE, FALSE }, // previous 60 { FALSE, FALSE, FALSE }, // previous
61 { FALSE, FALSE, FALSE }, // next 61 { FALSE, FALSE, FALSE }, // next
62 { FALSE, FALSE, FALSE }, // volUp 62 { FALSE, FALSE, FALSE }, // volUp
63 { FALSE, FALSE, FALSE }, // volDown 63 { FALSE, FALSE, FALSE }, // volDown
64 { TRUE, FALSE, FALSE } // fullscreen 64 { TRUE, FALSE, FALSE } // fullscreen
65}; 65};
66 66
67//static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 67//static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
68 68
69const char *skinV_mask_file_names[7] = { 69const char *skinV_mask_file_names[7] = {
70 "stop","play","back","fwd","up","down","full" 70 "stop","play","back","fwd","up","down","full"
71}; 71};
72 72
73static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 73static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
74 74
75VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 75VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
76 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) 76 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 )
77{ 77{
78 setCaption( tr("OpiePlayer") ); 78 setCaption( tr("OpiePlayer") );
79 Config cfg("OpiePlayer"); 79 Config cfg("OpiePlayer");
80 80
81 cfg.setGroup("Options"); 81 cfg.setGroup("Options");
82 skin = cfg.readEntry("Skin","default"); 82 skin = cfg.readEntry("Skin","default");
83 83
84 QString skinPath; 84 QString skinPath;
85 skinPath = "opieplayer2/skins/" + skin; 85 skinPath = "opieplayer2/skins/" + skin;
86 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) 86 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists())
87 skinPath = "opieplayer2/skins/default"; 87 skinPath = "opieplayer2/skins/default";
88 88
89 // qDebug("skin path " + skinPath); 89 // qDebug("skin path " + skinPath);
90 90
91// QString skinPath = "opieplayer2/skins/" + skin; 91// QString skinPath = "opieplayer2/skins/" + skin;
92 92
93 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 93 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
94 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 94 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
95 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 95 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
96 96
97 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 97 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
98 imgButtonMask->fill( 0 ); 98 imgButtonMask->fill( 0 );
99 99
100 for ( int i = 0; i < 7; i++ ) 100 for ( int i = 0; i < 7; i++ ) {
101 {
102 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + 101 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath +
103 "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 102 "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
104 // qDebug("loading "+filename); 103 // qDebug("loading "+filename);
105 masks[i] = new QBitmap( filename ); 104 masks[i] = new QBitmap( filename );
106 105
107 if ( !masks[i]->isNull() ) 106 if ( !masks[i]->isNull() ) {
108 {
109 QImage imgMask = masks[i]->convertToImage(); 107 QImage imgMask = masks[i]->convertToImage();
110 uchar **dest = imgButtonMask->jumpTable(); 108 uchar **dest = imgButtonMask->jumpTable();
111 for ( int y = 0; y < imgUp->height(); y++ ) 109 for ( int y = 0; y < imgUp->height(); y++ ) {
112 {
113 uchar *line = dest[y]; 110 uchar *line = dest[y];
114 for ( int x = 0; x < imgUp->width(); x++ ) 111 for ( int x = 0; x < imgUp->width(); x++ ) {
115 {
116 if ( !qRed( imgMask.pixel( x, y ) ) ) 112 if ( !qRed( imgMask.pixel( x, y ) ) )
117 line[x] = i + 1; 113 line[x] = i + 1;
118 } 114 }
119 } 115 }
120 } 116 }
121 } 117 }
122 // qDebug("finished loading first pics"); 118 // qDebug("finished loading first pics");
123 for ( int i = 0; i < 7; i++ ) 119 for ( int i = 0; i < 7; i++ ) {
124 {
125 buttonPixUp[i] = NULL; 120 buttonPixUp[i] = NULL;
126 buttonPixDown[i] = NULL; 121 buttonPixDown[i] = NULL;
127 } 122 }
128 123
124
125 QWidget *d = QApplication::desktop();
126 int width = d->width();
127 int height = d->height();
128
129 if( (width != pixBg->width() ) || (height != pixBg->height() ) ) {
130 // qDebug("<<<<<<<< scale image >>>>>>>>>>>>");
131 QImage img;
132 img = pixBg->convertToImage();
133 pixBg->convertFromImage( img.smoothScale( width, height));
134 }
129 setBackgroundPixmap( *pixBg ); 135 setBackgroundPixmap( *pixBg );
130 136
131 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 137 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
132 138
133 slider = new QSlider( Qt::Horizontal, this ); 139 slider = new QSlider( Qt::Horizontal, this );
134 slider->setMinValue( 0 ); 140 slider->setMinValue( 0 );
135 slider->setMaxValue( 1 ); 141 slider->setMaxValue( 1 );
136 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 142 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
137 slider->setFocusPolicy( QWidget::NoFocus ); 143 slider->setFocusPolicy( QWidget::NoFocus );
138// slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 144// slider->setGeometry( QRect( 7, 250, 220, 20 ) );
139 145
140 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 146 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
141 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 147 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
142 148
143 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 149 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
144 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 150 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
145 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 151 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
146 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 152 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
147// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 153// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
148 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 154 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
149 155
150 // Intialise state 156 // Intialise state
151 setLength( mediaPlayerState->length() ); 157 setLength( mediaPlayerState->length() );
152 setPosition( mediaPlayerState->position() ); 158 setPosition( mediaPlayerState->position() );
153 setFullscreen( mediaPlayerState->fullscreen() ); 159 setFullscreen( mediaPlayerState->fullscreen() );
154// setPaused( mediaPlayerState->paused() ); 160// setPaused( mediaPlayerState->paused() );
155 setPlaying( mediaPlayerState->playing() ); 161 setPlaying( mediaPlayerState->playing() );
156} 162}
157 163
158 164
159VideoWidget::~VideoWidget() { 165VideoWidget::~VideoWidget() {
160 166
161 for ( int i = 0; i < 7; i++ ) 167 for ( int i = 0; i < 7; i++ )
162 { 168 {
163 delete buttonPixUp[i]; 169 delete buttonPixUp[i];
164 delete buttonPixDown[i]; 170 delete buttonPixDown[i];
165 } 171 }
166 172
167 delete pixBg; 173 delete pixBg;
168 delete imgUp; 174 delete imgUp;
169 delete imgDn; 175 delete imgDn;
170 delete imgButtonMask; 176 delete imgButtonMask;
171 for ( int i = 0; i < 7; i++ ) 177 for ( int i = 0; i < 7; i++ )
172 { 178 {
173 delete masks[i]; 179 delete masks[i];
174 } 180 }
175 181
176// for ( int i = 0; i < 3; i++ ) 182// for ( int i = 0; i < 3; i++ )