summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiemm/oimagescrollview.cpp16
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
@@ -148,25 +148,25 @@ void OImageScrollView::init()
_zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" );
connect(_zoomer, SIGNAL( zoomAreaRel(int,int)),
this, SLOT(scrollBy(int,int)) );
connect(_zoomer, SIGNAL( zoomArea(int,int)),
this, SLOT(center(int,int)) );
connect(this,SIGNAL(contentsMoving(int,int)),
_zoomer, (SLOT(setVisiblePoint(int,int))) );
connect(this,SIGNAL(imageSizeChanged(const QSize&)),
_zoomer, SLOT(setImageSize(const QSize&)) );
connect(this,SIGNAL(viewportSizeChanged(const QSize&)),
_zoomer, SLOT(setViewPortSize(const QSize&)) );
- viewport()->setBackgroundColor(white);
+ setBackgroundColor(white);
setFocusPolicy(QWidget::StrongFocus);
setImageScaledLoaded(false);
setImageIsJpeg(false);
if (FirstResizeDone()) {
m_last_rot = Rotate0;
generateImage();
} else if (_original_data.size().isValid()) {
if (image_fit_into(_original_data.size()) || !ShowZoomer()) _zoomer->hide();
resizeContents(_original_data.width(),_original_data.height());
}
}
@@ -342,66 +342,70 @@ void OImageScrollView::generateImage()
Rotation r = Rotate0;
_pdata = QPixmap();
if (_original_data.isNull()) {
emit imageSizeChanged( _image_data.size() );
if (_zoomer) _zoomer->setImage( _image_data );
return;
}
if (width()>height()&&_original_data.width()<_original_data.height() ||
width()<height()&&_original_data.width()>_original_data.height()) {
if (AutoRotate()) r = Rotate90;
}
-
+ int twidth,theight;
odebug << " r = " << r << oendl;
if (AutoScale() && (_original_data.width()>width() || _original_data.height() > height()) ) {
if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) {
odebug << "Rescaling data" << oendl;
if (r==Rotate0) {
_image_data = _original_data;
} else {
rotate_into_data(r);
}
}
rescaleImage(width(),height());
- resizeContents(_image_data.width(),_image_data.height());
} else if (!FirstResizeDone()||r!=m_last_rot||_image_data.width()==0) {
if (r==Rotate0) {
_image_data = _original_data;
} else {
rotate_into_data(r);
}
m_last_rot = r;
- resizeContents(_image_data.width(),_image_data.height());
}
_pdata.convertFromImage(_image_data);
+ twidth = _image_data.width();
+ theight = _image_data.height();
/*
* update the zoomer
*/
check_zoomer();
emit imageSizeChanged( _image_data.size() );
rescaleImage( 128, 128 );
+ resizeContents(twidth,theight);
/*
* move scrollbar
*/
if (_zoomer) {
_zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2,
_image_data.width()/2, _image_data.height()/2 );
_zoomer->setImage( _image_data );
}
/*
* invalidate
*/
_image_data=QImage();
+ if (isVisible()) {
+ updateContents(contentsX(),contentsY(),width(),height());
+ }
}
void OImageScrollView::resizeEvent(QResizeEvent * e)
{
odebug << "OImageScrollView resizeEvent" << oendl;
QScrollView::resizeEvent(e);
generateImage();
setFirstResizeDone(true);
emit viewportSizeChanged( viewport()->size() );
}
@@ -428,43 +432,43 @@ void OImageScrollView::keyPressEvent(QKeyEvent * e)
QScrollView::keyPressEvent(e);
}
void OImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph)
{
int w = clipw;
int h = cliph;
int x = clipx;
int y = clipy;
bool erase = false;
if (!_pdata.size().isValid()) {
- p->fillRect(clipx,clipy,clipw,cliph,white);
+ p->fillRect(clipx,clipy,clipw,cliph, backgroundColor());
return;
}
if (w>_pdata.width()) {
w=_pdata.width();
x = 0;
erase = true;
} else if (x+w>_pdata.width()){
x = _pdata.width()-w;
}
if (h>_pdata.height()) {
h=_pdata.height();
y = 0;
erase = true;
} else if (y+h>_pdata.height()){
y = _pdata.height()-h;
}
if (erase||_original_data.hasAlphaBuffer()) {
- p->fillRect(clipx,clipy,clipw,cliph,white);
+ p->fillRect(clipx,clipy,clipw,cliph, backgroundColor());
}
p->drawPixmap(clipx,clipy,_pdata,x,y,w,h);
}
/* using the real geometry points and not the translated points is wanted! */
void OImageScrollView::viewportMouseMoveEvent(QMouseEvent* e)
{
int mx, my;
mx = e->x();
my = e->y();
if (_mouseStartPosX!=-1 && _mouseStartPosY!=-1) {
int diffx = _mouseStartPosX-mx;