┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-09-22 15:33:04 +0000
committerPeter Penz <[email protected]>2008-09-22 15:33:04 +0000
commit17bb43dea47335f4c20a84fed7255680089db745 (patch)
tree895ee46a43dc823294b8aa5582d85c9e790f1e29
parenta55558a4fec730dd4d69259618e65f8bbaaedcdf (diff)
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: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=863586
-rw-r--r--src/tooltipmanager.cpp24
1 files changed, 14 insertions, 10 deletions
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();