From: Peter Penz Date: Mon, 22 Sep 2008 15:33:04 +0000 (+0000) Subject: try to align the x-position of the tooltip to the mouse-cursor if the tooltip can... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/17bb43dea47335f4c20a84fed7255680089db745 try to align the x-position of the tooltip to the mouse-cursor if the tooltip can be shown below or above the item (thanks to Simon St James for the patch) CCMAIL: kdedevel@etotheipiplusone.com svn path=/trunk/KDE/kdebase/apps/; revision=863586 --- diff --git a/src/tooltipmanager.cpp b/src/tooltipmanager.cpp index c8b915195..231f4db15 100644 --- a/src/tooltipmanager.cpp +++ b/src/tooltipmanager.cpp @@ -221,20 +221,24 @@ void ToolTipManager::showToolTip(KToolTipItem* tip) return; } - int x = 0; - if (hasRoomToLeft || hasRoomToRight) { - x = hasRoomToRight ? m_itemRect.right() : m_itemRect.left() - size.width(); - } else { - // Put the tooltip at the far right of the screen. The item will be overlapped - // horizontally, but the y-coordinate will be adjusted afterwards so that no overlapping - // occurs vertically. - x = desktop.right() - size.width(); - } - + int x = 0; int y = 0; if (hasRoomBelow || hasRoomAbove) { + x = QCursor::pos().x() + 16; // TODO: use mouse pointer width instead of the magic value of 16 + if (x + size.width() >= desktop.right()) { + x = desktop.right() - size.width(); + } y = hasRoomBelow ? m_itemRect.bottom() : m_itemRect.top() - size.height(); } else { + if (hasRoomToLeft || hasRoomToRight) { + x = hasRoomToRight ? m_itemRect.right() : m_itemRect.left() - size.width(); + } else { + // Put the tooltip at the far right of the screen. The item will be overlapped + // horizontally, but the y-coordinate will be adjusted afterwards so that no overlapping + // occurs vertically. + x = desktop.right() - size.width(); + } + // Put the tooltip at the bottom of the screen. The x-coordinate has already // been adjusted, so that no overlapping with m_itemRect occurs. y = desktop.bottom() - size.height();