]> cloud.milkyroute.net Git - dolphin.git/commitdiff
KItemListView: Don't allow starting role editing when animation is running
authorAkseli Lahtinen <akselmo@akselmo.dev>
Thu, 24 Jul 2025 09:56:50 +0000 (12:56 +0300)
committerMéven Car <meven@kde.org>
Thu, 24 Jul 2025 09:56:50 +0000 (09:56 +0000)
If user presses delete and then F2 in very quick succession, the
inline rename field will get stuck in place, due to the animation
moving the actual item in different place.

To avoid any confusion, disallow starting role editing while any
animations are running.

BUG: 497125

src/kitemviews/kitemlistview.cpp

index 3ed4df3e7bb13f9b410574a85c0fde6dcca7cdcc..75d85be358953e7897936800d303142b183ef9f5 100644 (file)
@@ -750,7 +750,11 @@ QPixmap KItemListView::createDragPixmap(const KItemSet &indexes) const
 void KItemListView::editRole(int index, const QByteArray &role)
 {
     KStandardItemListWidget *widget = qobject_cast<KStandardItemListWidget *>(m_visibleItems.value(index));
-    if (!widget || m_editingRole) {
+    if (!widget) {
+        return;
+    }
+    if (m_editingRole || m_animation->isStarted(widget)) {
+        Q_EMIT widget->roleEditingCanceled(index, role, QVariant());
         return;
     }
 
@@ -1916,6 +1920,9 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
 
         if (animate) {
             if (m_animation->isStarted(widget, KItemListViewAnimation::MovingAnimation)) {
+                if (m_editingRole) {
+                    Q_EMIT widget->roleEditingCanceled(widget->index(), QByteArray(), QVariant());
+                }
                 m_animation->start(widget, KItemListViewAnimation::MovingAnimation, newPos);
                 applyNewPos = false;
             }