]> cloud.milkyroute.net Git - dolphin.git/commitdiff
try to align the x-position of the tooltip to the mouse-cursor if the tooltip can...
authorPeter Penz <peter.penz19@gmail.com>
Mon, 22 Sep 2008 15:33:04 +0000 (15:33 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 22 Sep 2008 15:33:04 +0000 (15:33 +0000)
CCMAIL: kdedevel@etotheipiplusone.com

svn path=/trunk/KDE/kdebase/apps/; revision=863586

src/tooltipmanager.cpp

index c8b91519578a3e21e9ea14dde21df37056ca9d23..231f4db15fe39491f2c1a85d1f24a542928f9592 100644 (file)
@@ -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();