SVN commit 505183 by cgilles:
digiKam from trunk : widget to compare image with all colors correction tools : Add an utimate new preview rendering mode : when the mouse is over image area, target image is displayed, else original image !!! Thanks to Julien Narboux for this suggestion (:=))) CCMAIL: [hidden email], [hidden email] M +1 -1 imageplugins/pics/Makefile.am M +43 -18 libs/widgets/imageguidewidget.cpp M +4 -1 libs/widgets/imageguidewidget.h M +11 -0 libs/widgets/imagewidget.cpp --- trunk/extragear/graphics/digikam/imageplugins/pics/Makefile.am #505182:505183 @@ -4,4 +4,4 @@ bwgreen.png bwred.png bwyellow.png bworange.png autolevels.png normalize.png \ equalize.png stretchcontrast.png centerwidth.png centerheight.png target.png \ bothvert.png bothhorz.png curvefree.png curvemooth.png original.png \ - duplicatebothvert.png duplicatebothhorz.png + duplicatebothvert.png duplicatebothhorz.png tooglemouseover.png --- trunk/extragear/graphics/digikam/libs/widgets/imageguidewidget.cpp #505182:505183 @@ -54,27 +54,28 @@ ImageGuideWidgetPriv() { - pixmap = 0; - iface = 0; - flicker = 0; - timerID = 0; - focus = false; - renderingPreviewMode = ImageGuideWidget::NoPreviewMode; + pixmap = 0; + iface = 0; + flicker = 0; + timerID = 0; + focus = false; + onMouseMovePreviewToogled = false; + renderingPreviewMode = ImageGuideWidget::NoPreviewMode; } + bool sixteenBit; + bool focus; + bool spotVisible; + bool onMouseMovePreviewToogled; + int width; int height; - int timerID; int guideMode; int guideSize; int flicker; int renderingPreviewMode; - bool sixteenBit; - bool focus; - bool spotVisible; - // Current spot position in preview coordinates. QPoint spot; @@ -213,7 +214,8 @@ d->pixmap->fill(colorGroup().background()); - if (d->renderingPreviewMode == PreviewOriginalImage) + if (d->renderingPreviewMode == PreviewOriginalImage || + (d->renderingPreviewMode == PreviewToogleOnMouseOver && d->onMouseMovePreviewToogled == false )) { p.drawPixmap(d->rect, d->preview.convertToPixmap()); @@ -225,12 +227,13 @@ p.drawRect(textRect); p.drawText(textRect, Qt::AlignCenter, text); } - else if (d->renderingPreviewMode == PreviewTargetImage || d->renderingPreviewMode == NoPreviewMode) + else if (d->renderingPreviewMode == PreviewTargetImage || d->renderingPreviewMode == NoPreviewMode || + (d->renderingPreviewMode == PreviewToogleOnMouseOver && d->onMouseMovePreviewToogled == true )) { d->iface->paint(d->pixmap, d->rect.x(), d->rect.y(), d->rect.width(), d->rect.height()); - if (d->renderingPreviewMode == PreviewTargetImage) + if (d->renderingPreviewMode == PreviewTargetImage || d->renderingPreviewMode == PreviewToogleOnMouseOver) { text = i18n("Target"); fontRect = fontMt.boundingRect(0, 0, d->rect.width(), d->rect.height(), 0, text); @@ -545,17 +548,39 @@ { if ( d->rect.contains( e->x(), e->y() ) && !d->focus && d->spotVisible ) { - setCursor( KCursor::crossCursor() ); + setCursor( KCursor::crossCursor() ); } else if ( d->rect.contains( e->x(), e->y() ) && d->focus && d->spotVisible ) { - d->spot.setX(e->x()-d->rect.x()); - d->spot.setY(e->y()-d->rect.y()); + d->spot.setX(e->x()-d->rect.x()); + d->spot.setY(e->y()-d->rect.y()); } else - setCursor( KCursor::arrowCursor() ); + { + setCursor( KCursor::arrowCursor() ); + } } +void ImageGuideWidget::enterEvent( QEvent * ) +{ + if ( !d->focus && d->renderingPreviewMode == PreviewToogleOnMouseOver ) + { + d->onMouseMovePreviewToogled = true; + updatePixmap(); + repaint(false); + } +} + +void ImageGuideWidget::leaveEvent( QEvent * ) +{ + if ( !d->focus && d->renderingPreviewMode == PreviewToogleOnMouseOver ) + { + d->onMouseMovePreviewToogled = false; + updatePixmap(); + repaint(false); + } +} + } // NameSpace Digikam #include "imageguidewidget.moc" --- trunk/extragear/graphics/digikam/libs/widgets/imageguidewidget.h #505182:505183 @@ -62,6 +62,7 @@ PreviewBothImagesHorzCont, // Horizontal with original and target in contiguous. PreviewBothImagesVertCont, // Vertical with original and target in contiguous. PreviewTargetImage, // Target image only. + PreviewToogleOnMouseOver, // Target image if mouse is over image area, else original image. NoPreviewMode // Target image only without information displayed. }; @@ -108,7 +109,9 @@ void mousePressEvent( QMouseEvent * e ); void mouseReleaseEvent( QMouseEvent * e ); void mouseMoveEvent( QMouseEvent * e ); - + void enterEvent ( QEvent * e ); + void leaveEvent ( QEvent * e ); + private: void updatePixmap( void ); --- trunk/extragear/graphics/digikam/libs/widgets/imagewidget.cpp #505182:505183 @@ -136,6 +136,16 @@ QToolTip::add( previewtargetButton, i18n( "<p>If you enable this option, you will see " "the target image." ) ); + QPushButton *previewToogleMouseOverButton = new QPushButton( d->previewButtons ); + d->previewButtons->insert(previewToogleMouseOverButton, ImageGuideWidget::PreviewToogleOnMouseOver); + KGlobal::dirs()->addResourceType("tooglemouseover", KGlobal::dirs()->kde_default("data") + "digikam/data"); + directory = KGlobal::dirs()->findResourceDir("tooglemouseover", "tooglemouseover.png"); + previewToogleMouseOverButton->setPixmap( QPixmap( directory + "tooglemouseover.png" ) ); + previewToogleMouseOverButton->setToggleButton(true); + QToolTip::add( previewToogleMouseOverButton, i18n( "<p>If you enable this option, you will see " + "the target image when the mouse is over image area, " + "else the original image." ) ); + QFrame *frame = new QFrame(this); frame->setFrameStyle(QFrame::Panel|QFrame::Sunken); QVBoxLayout* l = new QVBoxLayout(frame, 5, 0); @@ -176,6 +186,7 @@ // ------------------------------------------------------------- + //setRenderingPreviewMode(ImageGuideWidget::PreviewBothImagesVertCont); setRenderingPreviewMode(ImageGuideWidget::PreviewBothImagesVertCont); } _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |