-rw-r--r-- | libopie2/opiemm/oimagescrollview.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libopie2/opiemm/oimagescrollview.cpp b/libopie2/opiemm/oimagescrollview.cpp index 61b2062..a8165a4 100644 --- a/libopie2/opiemm/oimagescrollview.cpp +++ b/libopie2/opiemm/oimagescrollview.cpp | |||
@@ -152,17 +152,17 @@ void OImageScrollView::init() | |||
152 | this, SLOT(center(int,int)) ); | 152 | this, SLOT(center(int,int)) ); |
153 | connect(this,SIGNAL(contentsMoving(int,int)), | 153 | connect(this,SIGNAL(contentsMoving(int,int)), |
154 | _zoomer, (SLOT(setVisiblePoint(int,int))) ); | 154 | _zoomer, (SLOT(setVisiblePoint(int,int))) ); |
155 | connect(this,SIGNAL(imageSizeChanged(const QSize&)), | 155 | connect(this,SIGNAL(imageSizeChanged(const QSize&)), |
156 | _zoomer, SLOT(setImageSize(const QSize&)) ); | 156 | _zoomer, SLOT(setImageSize(const QSize&)) ); |
157 | connect(this,SIGNAL(viewportSizeChanged(const QSize&)), | 157 | connect(this,SIGNAL(viewportSizeChanged(const QSize&)), |
158 | _zoomer, SLOT(setViewPortSize(const QSize&)) ); | 158 | _zoomer, SLOT(setViewPortSize(const QSize&)) ); |
159 | 159 | ||
160 | viewport()->setBackgroundColor(white); | 160 | setBackgroundColor(white); |
161 | setFocusPolicy(QWidget::StrongFocus); | 161 | setFocusPolicy(QWidget::StrongFocus); |
162 | setImageScaledLoaded(false); | 162 | setImageScaledLoaded(false); |
163 | setImageIsJpeg(false); | 163 | setImageIsJpeg(false); |
164 | if (FirstResizeDone()) { | 164 | if (FirstResizeDone()) { |
165 | m_last_rot = Rotate0; | 165 | m_last_rot = Rotate0; |
166 | generateImage(); | 166 | generateImage(); |
167 | } else if (_original_data.size().isValid()) { | 167 | } else if (_original_data.size().isValid()) { |
168 | if (image_fit_into(_original_data.size()) || !ShowZoomer()) _zoomer->hide(); | 168 | if (image_fit_into(_original_data.size()) || !ShowZoomer()) _zoomer->hide(); |
@@ -346,58 +346,62 @@ void OImageScrollView::generateImage() | |||
346 | if (_zoomer) _zoomer->setImage( _image_data ); | 346 | if (_zoomer) _zoomer->setImage( _image_data ); |
347 | return; | 347 | return; |
348 | } | 348 | } |
349 | if (width()>height()&&_original_data.width()<_original_data.height() || | 349 | if (width()>height()&&_original_data.width()<_original_data.height() || |
350 | width()<height()&&_original_data.width()>_original_data.height()) { | 350 | width()<height()&&_original_data.width()>_original_data.height()) { |
351 | if (AutoRotate()) r = Rotate90; | 351 | if (AutoRotate()) r = Rotate90; |
352 | } | 352 | } |
353 | 353 | ||
354 | 354 | int twidth,theight; | |
355 | odebug << " r = " << r << oendl; | 355 | odebug << " r = " << r << oendl; |
356 | if (AutoScale() && (_original_data.width()>width() || _original_data.height() > height()) ) { | 356 | if (AutoScale() && (_original_data.width()>width() || _original_data.height() > height()) ) { |
357 | if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { | 357 | if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { |
358 | odebug << "Rescaling data" << oendl; | 358 | odebug << "Rescaling data" << oendl; |
359 | if (r==Rotate0) { | 359 | if (r==Rotate0) { |
360 | _image_data = _original_data; | 360 | _image_data = _original_data; |
361 | } else { | 361 | } else { |
362 | rotate_into_data(r); | 362 | rotate_into_data(r); |
363 | } | 363 | } |
364 | } | 364 | } |
365 | rescaleImage(width(),height()); | 365 | rescaleImage(width(),height()); |
366 | resizeContents(_image_data.width(),_image_data.height()); | ||
367 | } else if (!FirstResizeDone()||r!=m_last_rot||_image_data.width()==0) { | 366 | } else if (!FirstResizeDone()||r!=m_last_rot||_image_data.width()==0) { |
368 | if (r==Rotate0) { | 367 | if (r==Rotate0) { |
369 | _image_data = _original_data; | 368 | _image_data = _original_data; |
370 | } else { | 369 | } else { |
371 | rotate_into_data(r); | 370 | rotate_into_data(r); |
372 | } | 371 | } |
373 | m_last_rot = r; | 372 | m_last_rot = r; |
374 | resizeContents(_image_data.width(),_image_data.height()); | ||
375 | } | 373 | } |
376 | _pdata.convertFromImage(_image_data); | 374 | _pdata.convertFromImage(_image_data); |
375 | twidth = _image_data.width(); | ||
376 | theight = _image_data.height(); | ||
377 | 377 | ||
378 | /* | 378 | /* |
379 | * update the zoomer | 379 | * update the zoomer |
380 | */ | 380 | */ |
381 | check_zoomer(); | 381 | check_zoomer(); |
382 | emit imageSizeChanged( _image_data.size() ); | 382 | emit imageSizeChanged( _image_data.size() ); |
383 | rescaleImage( 128, 128 ); | 383 | rescaleImage( 128, 128 ); |
384 | resizeContents(twidth,theight); | ||
384 | /* | 385 | /* |
385 | * move scrollbar | 386 | * move scrollbar |
386 | */ | 387 | */ |
387 | if (_zoomer) { | 388 | if (_zoomer) { |
388 | _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2, | 389 | _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2, |
389 | _image_data.width()/2, _image_data.height()/2 ); | 390 | _image_data.width()/2, _image_data.height()/2 ); |
390 | _zoomer->setImage( _image_data ); | 391 | _zoomer->setImage( _image_data ); |
391 | } | 392 | } |
392 | /* | 393 | /* |
393 | * invalidate | 394 | * invalidate |
394 | */ | 395 | */ |
395 | _image_data=QImage(); | 396 | _image_data=QImage(); |
397 | if (isVisible()) { | ||
398 | updateContents(contentsX(),contentsY(),width(),height()); | ||
399 | } | ||
396 | } | 400 | } |
397 | 401 | ||
398 | void OImageScrollView::resizeEvent(QResizeEvent * e) | 402 | void OImageScrollView::resizeEvent(QResizeEvent * e) |
399 | { | 403 | { |
400 | odebug << "OImageScrollView resizeEvent" << oendl; | 404 | odebug << "OImageScrollView resizeEvent" << oendl; |
401 | QScrollView::resizeEvent(e); | 405 | QScrollView::resizeEvent(e); |
402 | generateImage(); | 406 | generateImage(); |
403 | setFirstResizeDone(true); | 407 | setFirstResizeDone(true); |
@@ -432,17 +436,17 @@ void OImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clip | |||
432 | { | 436 | { |
433 | int w = clipw; | 437 | int w = clipw; |
434 | int h = cliph; | 438 | int h = cliph; |
435 | int x = clipx; | 439 | int x = clipx; |
436 | int y = clipy; | 440 | int y = clipy; |
437 | bool erase = false; | 441 | bool erase = false; |
438 | 442 | ||
439 | if (!_pdata.size().isValid()) { | 443 | if (!_pdata.size().isValid()) { |
440 | p->fillRect(clipx,clipy,clipw,cliph,white); | 444 | p->fillRect(clipx,clipy,clipw,cliph, backgroundColor()); |
441 | return; | 445 | return; |
442 | } | 446 | } |
443 | if (w>_pdata.width()) { | 447 | if (w>_pdata.width()) { |
444 | w=_pdata.width(); | 448 | w=_pdata.width(); |
445 | x = 0; | 449 | x = 0; |
446 | erase = true; | 450 | erase = true; |
447 | } else if (x+w>_pdata.width()){ | 451 | } else if (x+w>_pdata.width()){ |
448 | x = _pdata.width()-w; | 452 | x = _pdata.width()-w; |
@@ -450,17 +454,17 @@ void OImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clip | |||
450 | if (h>_pdata.height()) { | 454 | if (h>_pdata.height()) { |
451 | h=_pdata.height(); | 455 | h=_pdata.height(); |
452 | y = 0; | 456 | y = 0; |
453 | erase = true; | 457 | erase = true; |
454 | } else if (y+h>_pdata.height()){ | 458 | } else if (y+h>_pdata.height()){ |
455 | y = _pdata.height()-h; | 459 | y = _pdata.height()-h; |
456 | } | 460 | } |
457 | if (erase||_original_data.hasAlphaBuffer()) { | 461 | if (erase||_original_data.hasAlphaBuffer()) { |
458 | p->fillRect(clipx,clipy,clipw,cliph,white); | 462 | p->fillRect(clipx,clipy,clipw,cliph, backgroundColor()); |
459 | } | 463 | } |
460 | p->drawPixmap(clipx,clipy,_pdata,x,y,w,h); | 464 | p->drawPixmap(clipx,clipy,_pdata,x,y,w,h); |
461 | } | 465 | } |
462 | 466 | ||
463 | /* using the real geometry points and not the translated points is wanted! */ | 467 | /* using the real geometry points and not the translated points is wanted! */ |
464 | void OImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) | 468 | void OImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) |
465 | { | 469 | { |
466 | int mx, my; | 470 | int mx, my; |