]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/selectiontoggle.cpp
Apply the cursor asynchronously. This fixes the issue that a pointing-hand cursor...
[dolphin.git] / src / views / selectiontoggle.cpp
index 3ab40ebdcebda2e868c4b70665efd289ebb12743..cbd273b11924f577db2a899a286775bc9987a782 100644 (file)
@@ -135,8 +135,16 @@ void SelectionToggle::enterEvent(QEvent* event)
     QAbstractButton::enterEvent(event);
 
     if (!m_appliedArrowCursor) {
-        QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
         m_appliedArrowCursor = true;
+        // Apply the arrow asynchronously. This is required for
+        // the following usecase:
+        // 1. Cursor is above the viewport left beside an item
+        // 2. Cursor is moved above the item, so that the selection-toggle
+        //    and the item are entered equally.
+        // In this situation it is not defined who gets the enter-event first.
+        // As the selection-toggle is above the item, it should overwrite possible
+        // cursor changes done by the item.
+        QTimer::singleShot(0, this, SLOT(applyArrowCursor()));
     }
 
     // if the mouse cursor is above the selection toggle, display
@@ -156,8 +164,10 @@ void SelectionToggle::leaveEvent(QEvent* event)
     QAbstractButton::leaveEvent(event);
 
     if (m_appliedArrowCursor) {
-        QApplication::restoreOverrideCursor();
+        // Reset the cursor asynchronously. See SelectionToggle::enterEvent()
+        // for a more information.
         m_appliedArrowCursor = false;
+        QTimer::singleShot(0, this, SLOT(restoreCursor()));
     }
 
     m_isHovered = false;
@@ -235,6 +245,16 @@ void SelectionToggle::refreshIcon()
     setIconOverlay(isChecked());
 }
 
+void SelectionToggle::applyArrowCursor()
+{
+    QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
+}
+
+void SelectionToggle::restoreCursor()
+{
+    QApplication::restoreOverrideCursor();
+}
+
 void SelectionToggle::startFading()
 {
     Q_ASSERT(m_fadingTimeLine == 0);