[Digikam-devel] [Bug 147362] tool-tip for zoom indicator is below the screen if window is maximised

Gilles Caulier caulier.gilles at gmail.com
Wed Jul 4 07:16:34 BST 2007

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

------- Additional Comments From caulier.gilles gmail com  2007-07-04 08:16 -------
Fabien this can be a fast fix for this problem. This widget is always on the bottom of windows.

But, i prefert an advanced fix which include something like QToolTip do : check the position of the widget over the screen and adapt X and Y offset accordinly to be always readable.

See below the code from Qt3.5.7. It have been extracted from method "void QTipManager::showTip()" of qtooltip.cpp C++ file. It resume exactly what we need to compute the offset and it simple to understand :


    int scr;
    if ( QApplication::desktop()->isVirtualDesktop() )
	scr = QApplication::desktop()->screenNumber( widget->mapToGlobal( pos ) );
	scr = QApplication::desktop()->screenNumber( widget );


#ifdef Q_WS_MAC
    QRect screen = QApplication::desktop()->availableGeometry( scr );
    QRect screen = QApplication::desktop()->screenGeometry( scr );

    QPoint p;

    p = widget->mapToGlobal( t->geometry.topLeft() );
    if ( p.y() < screen.y() )
	p.setY( screen.y() );
    if ( p.x() + label->width() > screen.x() + screen.width() )
	p.setX( screen.x() + screen.width() - label->width() );
    if ( p.x() < screen.x() )
	p.setX( screen.x() );
    if ( p.y() + label->height() > screen.y() + screen.height() )
	p.setY( screen.y() + screen.height() - label->height() );
    if ( label->text().length() ) 
	label->move( p );

"pos" is the current position of the mouse over the screen.
"scr" is a reference to the screen object.
"screen" is the screen rectangle. It include xinerama case.
"label" is the qtooltip label displayed by Qt over the widget.
"p" is the left/top point of the tip label to display adjusted over the screen.

You can adapt this code to DCursorTracker::eventFilter() method easily...


More information about the Digikam-devel mailing list