Diffstat (limited to 'kaddressbook/imagewidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/imagewidget.cpp | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index d0f52ea..eec5e08 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp | |||
@@ -188,125 +188,110 @@ KABC::Picture ImageWidget::photo() const | |||
188 | else | 188 | else |
189 | photo.setData( px->convertToImage().scaleWidth( 100 ) ); | 189 | photo.setData( px->convertToImage().scaleWidth( 100 ) ); |
190 | #else //KAB_EMBEDDED | 190 | #else //KAB_EMBEDDED |
191 | //US add teh nullcheck | 191 | //US add teh nullcheck |
192 | if (px->isNull() != true ) | 192 | if (px->isNull() != true ) |
193 | photo.setData( px->convertToImage() ); | 193 | photo.setData( px->convertToImage() ); |
194 | #endif //KAB_EMBEDDED | 194 | #endif //KAB_EMBEDDED |
195 | 195 | ||
196 | photo.setType( "PNG" ); | 196 | photo.setType( "PNG" ); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | return photo; | 200 | return photo; |
201 | } | 201 | } |
202 | 202 | ||
203 | void ImageWidget::setLogo( const KABC::Picture &logo ) | 203 | void ImageWidget::setLogo( const KABC::Picture &logo ) |
204 | { | 204 | { |
205 | bool blocked = signalsBlocked(); | 205 | bool blocked = signalsBlocked(); |
206 | blockSignals( true ); | 206 | blockSignals( true ); |
207 | 207 | ||
208 | if ( logo.isIntern() ) { | 208 | if ( logo.isIntern() ) { |
209 | //US | 209 | //US |
210 | //US mLogoLabel->setPixmap( logo.data() ); | 210 | //US mLogoLabel->setPixmap( logo.data() ); |
211 | if (logo.data().isNull() != true) | 211 | if (logo.data().isNull() != true) |
212 | { | 212 | { |
213 | QPixmap pm; | 213 | QPixmap pm; |
214 | pm.convertFromImage(logo.data()); | 214 | pm.convertFromImage(logo.data()); |
215 | mLogoLabel->setPixmap( pm ); | 215 | mLogoLabel->setPixmap( pm ); |
216 | } | 216 | } |
217 | mUseLogoUrl->setChecked( false ); | 217 | mUseLogoUrl->setChecked( false ); |
218 | } else { | 218 | } else { |
219 | mLogoUrl->setURL( logo.url() ); | 219 | mLogoUrl->setURL( logo.url() ); |
220 | if ( !logo.url().isEmpty() ) | 220 | if ( !logo.url().isEmpty() ) |
221 | mUseLogoUrl->setChecked( true ); | 221 | mUseLogoUrl->setChecked( true ); |
222 | loadLogo(); | 222 | loadLogo(); |
223 | } | 223 | } |
224 | 224 | ||
225 | blockSignals( blocked ); | 225 | blockSignals( blocked ); |
226 | } | 226 | } |
227 | 227 | ||
228 | KABC::Picture ImageWidget::logo() const | 228 | KABC::Picture ImageWidget::logo() const |
229 | { | 229 | { |
230 | KABC::Picture logo; | 230 | KABC::Picture logo; |
231 | 231 | ||
232 | if ( mUseLogoUrl->isChecked() ) | 232 | if ( mUseLogoUrl->isChecked() ) |
233 | logo.setUrl( mLogoUrl->url() ); | 233 | logo.setUrl( mLogoUrl->url() ); |
234 | else { | 234 | else { |
235 | QPixmap *px = mLogoLabel->pixmap(); | 235 | QPixmap *px = mLogoLabel->pixmap(); |
236 | if ( px ) { | 236 | if ( px ) { |
237 | #ifndef KAB_EMBEDDED | 237 | #ifndef KAB_EMBEDDED |
238 | if ( px->height() > px->width() ) | 238 | if ( px->height() > px->width() ) |
239 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); | 239 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); |
240 | else | 240 | else |
241 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); | 241 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); |
242 | #else //KAB_EMBEDDED | 242 | #else //KAB_EMBEDDED |
243 | if (px->isNull() != true ) | 243 | if (px->isNull() != true ) |
244 | logo.setData( px->convertToImage() ); | 244 | logo.setData( px->convertToImage() ); |
245 | #endif //KAB_EMBEDDED | 245 | #endif //KAB_EMBEDDED |
246 | 246 | ||
247 | logo.setType( "PNG" ); | 247 | logo.setType( "PNG" ); |
248 | 248 | ||
249 | } | 249 | } |
250 | } | 250 | } |
251 | return logo; | 251 | return logo; |
252 | } | 252 | } |
253 | void ImageWidget::removePhoto() | 253 | void ImageWidget::removePhoto() |
254 | { | 254 | { |
255 | setPhoto(KABC::Picture() ); | 255 | setPhoto(KABC::Picture() ); |
256 | } | 256 | } |
257 | 257 | ||
258 | void ImageWidget::removeLogo() | 258 | void ImageWidget::removeLogo() |
259 | { | 259 | { |
260 | setLogo(KABC::Picture() ); | 260 | setLogo(KABC::Picture() ); |
261 | } | 261 | } |
262 | 262 | ||
263 | void ImageWidget::loadPhoto() | 263 | void ImageWidget::loadPhoto() |
264 | { | 264 | { |
265 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); | 265 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); |
266 | } | 266 | } |
267 | 267 | ||
268 | void ImageWidget::loadLogo() | 268 | void ImageWidget::loadLogo() |
269 | { | 269 | { |
270 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); | 270 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); |
271 | } | 271 | } |
272 | 272 | ||
273 | void ImageWidget::updateGUI() | 273 | void ImageWidget::updateGUI() |
274 | { | 274 | { |
275 | KURLRequester *ptr = (KURLRequester*)sender(); | 275 | KURLRequester *ptr = (KURLRequester*)sender(); |
276 | 276 | ||
277 | 277 | ||
278 | if ( ptr == mPhotoUrl ) | 278 | if ( ptr == mPhotoUrl ) |
279 | mUsePhotoUrl->setEnabled( true ); | 279 | mUsePhotoUrl->setEnabled( true ); |
280 | else if ( ptr == mLogoUrl ) | 280 | else if ( ptr == mLogoUrl ) |
281 | mUseLogoUrl->setEnabled( true ); | 281 | mUseLogoUrl->setEnabled( true ); |
282 | } | 282 | } |
283 | 283 | ||
284 | QPixmap ImageWidget::loadPixmap( const KURL &url ) | 284 | QPixmap ImageWidget::loadPixmap( const QString &url ) |
285 | { | 285 | { |
286 | QString tempFile; | 286 | |
287 | QPixmap pixmap; | 287 | QPixmap pixmap; |
288 | 288 | ||
289 | if ( url.isEmpty() ) | 289 | if ( url.isEmpty() ) |
290 | return pixmap; | 290 | return pixmap; |
291 | 291 | pixmap.load( url ); | |
292 | if ( url.isLocalFile() ) | ||
293 | pixmap = QPixmap( url.path() ); | ||
294 | else | ||
295 | { | ||
296 | #ifndef KAB_EMBEDDED | ||
297 | if ( KIO::NetAccess::download( url, tempFile ) ) { | ||
298 | pixmap = QPixmap( tempFile ); | ||
299 | KIO::NetAccess::removeTempFile( tempFile ); | ||
300 | } | ||
301 | #else //KAB_EMBEDDED | ||
302 | qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); | ||
303 | #endif //KAB_EMBEDDED | ||
304 | |||
305 | } | ||
306 | |||
307 | return pixmap; | 292 | return pixmap; |
308 | } | 293 | } |
309 | 294 | ||
310 | #ifndef KAB_EMBEDDED | 295 | #ifndef KAB_EMBEDDED |
311 | #include "imagewidget.moc" | 296 | #include "imagewidget.moc" |
312 | #endif //KAB_EMBEDDED | 297 | #endif //KAB_EMBEDDED |