[frameworks/kxmlgui] src: KEditToolBar: show no-drop cursor with "Available" list for own items

Friedrich W. H. Kossebau <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 304fca9f8bdaccaab794d2255c9c7f5ec8efbb22 by Friedrich W. H. Kossebau.
Committed on 02/08/2026 at 23:37.
Pushed by kossebau into branch 'master'.

KEditToolBar: show no-drop cursor with "Available" list for own items

Makes it more obvious to users that items in that list cannot be moved
around there, only dragged out.

M  +21   -0    src/kedittoolbar.cpp
M  +2    -0    src/kedittoolbar_p.h

https://invent.kde.org/frameworks/kxmlgui/-/commit/304fca9f8bdaccaab794d2255c9c7f5ec8efbb22

diff --git a/src/kedittoolbar.cpp b/src/kedittoolbar.cpp
index f38df8a8..7406da83 100644
--- a/src/kedittoolbar.cpp
+++ b/src/kedittoolbar.cpp
@@ -18,6 +18,8 @@
 #include <QDialogButtonBox>
 #include <QDir>
 #include <QDomDocument>
+#include <QDragEnterEvent>
+#include <QDragMoveEvent>
 #include <QFile>
 #include <QGridLayout>
 #include <QLabel>
@@ -326,6 +328,25 @@ ToolBarItem *ToolBarListWidget::currentItem() const
     return static_cast<ToolBarItem *>(QListWidget::currentItem());
 }
 
+void ToolBarListWidget::dragEnterEvent(QDragEnterEvent *event)
+{
+    // no internal drag in inactive list
+    if (!m_activeList && (event->source() == this)) {
+        event->ignore();
+        return;
+    }
+    QListWidget::dragEnterEvent(event);
+}
+void ToolBarListWidget::dragMoveEvent(QDragMoveEvent *event)
+{
+    // no internal drag in inactive list
+    if (!m_activeList && (event->source() == this)) {
+        event->ignore();
+        return;
+    }
+    QListWidget::dragMoveEvent(event);
+}
+
 IconTextEditDialog::IconTextEditDialog(QWidget *parent)
     : QDialog(parent)
 {
diff --git a/src/kedittoolbar_p.h b/src/kedittoolbar_p.h
index 6002f6f6..be7dc390 100644
--- a/src/kedittoolbar_p.h
+++ b/src/kedittoolbar_p.h
@@ -57,6 +57,8 @@ protected:
 
     bool dropMimeData(int index, const QMimeData *data, Qt::DropAction action) override;
 
+    void dragEnterEvent(QDragEnterEvent *event) override;
+    void dragMoveEvent(QDragMoveEvent *event) override;
     // Skip internal dnd handling in QListWidget ---- how is one supposed to figure this out
     // without reading the QListWidget code !?
     void dropEvent(QDropEvent *ev) override
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.