Diffstat (limited to 'noncore/graphics/opie-eye/gui/imagescrollview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp index ad19219..5b12258 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp +++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp @@ -55,16 +55,31 @@ void ImageScrollView::setImage( const QString& path ) { generateImage(); } } /* should be called every time the QImage changed it content */ void ImageScrollView::init() { odebug << "init " << oendl; + + /* + * create the zoomer + * and connect ther various signals + */ + _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" ); + connect(_zoomer, SIGNAL( zoomAreaRel(int,int)), + this, SLOT(scrollBy(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); setFocusPolicy(QWidget::StrongFocus); if (first_resize_done) { last_rot = Rotate0; generateImage(); odebug << "reinit display " << oendl; } else if (_original_data.size().isValid()) { resizeContents(_original_data.width(),_original_data.height()); @@ -246,25 +261,42 @@ void ImageScrollView::generateImage() _image_data = _original_data; } else { rotate_into_data(r); } last_rot = r; resizeContents(_image_data.width(),_image_data.height()); } _pdata.convertFromImage(_image_data); + + /* + * update the zoomer + */ + emit imageSizeChanged( _image_data.size() ); + rescaleImage( 128, 128 ); + _zoomer->setImage( _image_data ); + + /* + * invalidate + */ _image_data=QImage(); } void ImageScrollView::resizeEvent(QResizeEvent * e) { odebug << "ImageScrollView resizeEvent" << oendl; QScrollView::resizeEvent(e); generateImage(); first_resize_done = true; + emit viewportSizeChanged( viewport()->size() ); + + /* + * move scrollbar + */ + _zoomer->setGeometry( viewport()->width()-100, viewport()->height()-50, 100, 50 ); } void ImageScrollView::keyPressEvent(QKeyEvent * e) { if (!e) return; int dx = horizontalScrollBar()->lineStep(); int dy = verticalScrollBar()->lineStep(); if (e->key()==Qt::Key_Right) { @@ -315,16 +347,17 @@ void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw p->fillRect(clipx,clipy,clipw,cliph,white); } p->drawPixmap(clipx,clipy,_pdata,x,y,w,h); } /* using the real geometry points and not the translated points is wanted! */ void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) { + odebug << "Move X and Y " << e->x() << " " << e->y() << oendl; int mx, my; mx = e->x(); my = e->y(); if (_mouseStartPosX!=-1 && _mouseStartPosY!=-1) { int diffx = _mouseStartPosX-mx; int diffy = _mouseStartPosY-my; #if 0 QScrollBar*xbar = horizontalScrollBar(); @@ -341,18 +374,19 @@ void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) } #endif scrollBy(diffx,diffy); } _mouseStartPosX=mx; _mouseStartPosY=my; } -void ImageScrollView::contentsMousePressEvent ( QMouseEvent * ) +void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) { + odebug << " X and Y " << e->x() << " " << e->y() << oendl; /* this marks the beginning of a possible mouse move. Due internal reasons of QT the geometry values here may real differ from that set in MoveEvent (I don't know why). For getting them in real context, we use the first move-event to set the start position ;) */ _mouseStartPosX = -1; _mouseStartPosY = -1; } |