diff options
| author | Jin Liu <[email protected]> | 2024-02-20 20:09:26 +0800 |
|---|---|---|
| committer | Jin Liu <[email protected]> | 2024-02-27 10:13:21 +0800 |
| commit | 0eed595268d2b0478eee1d5bf5ed6bbd100cdf4c (patch) | |
| tree | 9628a27efb898e1966cffd68701dc9ecf916d83d /src | |
| parent | f13f3c7a267e552cbc7aed4c3cfcd3ee70989446 (diff) | |
Fix: can't drop into remote dir
KFileItem::isDir() only works when it's created from listDir(),
or from a local QUrl. For a remote QUrl, isDir always returns
false, so we can't use that in supportsDropping().
As a workaround, now supportsDropping() always returns true in
remote dirs -- we don't check if a remote dir is writable when
dropping.
Diffstat (limited to 'src')
| -rw-r--r-- | src/views/draganddrophelper.cpp | 16 | ||||
| -rw-r--r-- | src/views/draganddrophelper.h | 9 |
2 files changed, 8 insertions, 17 deletions
diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp index efdec5b92..7b9949df4 100644 --- a/src/views/draganddrophelper.cpp +++ b/src/views/draganddrophelper.cpp @@ -52,7 +52,12 @@ KIO::DropJob *DragAndDropHelper::dropUrls(const QUrl &destUrl, QDropEvent *event return nullptr; } - if (supportsDropping(destUrl)) { + // TODO: remove this check once Qt is fixed so that it doesn't emit a QDropEvent on Wayland + // when we called QDragMoveEvent::ignore() + // https://codereview.qt-project.org/c/qt/qtwayland/+/541750 + KFileItem item(destUrl); + // KFileItem(QUrl) only stat local URLs, so we always allow dropping on non-local URLs + if (!item.isLocalFile() || supportsDropping(item)) { // Drop into a directory or a desktop-file KIO::DropJob *job = KIO::drop(event, destUrl); KJobWidgets::setWindow(job, window); @@ -63,12 +68,6 @@ KIO::DropJob *DragAndDropHelper::dropUrls(const QUrl &destUrl, QDropEvent *event return nullptr; } -bool DragAndDropHelper::supportsDropping(const QUrl &destUrl) -{ - KFileItem item(destUrl); - return supportsDropping(item); -} - bool DragAndDropHelper::supportsDropping(const KFileItem &destItem) { return (destItem.isDir() && destItem.isWritable()) || destItem.isDesktopFile(); @@ -80,7 +79,8 @@ void DragAndDropHelper::updateDropAction(QDropEvent *event, const QUrl &destUrl) event->setDropAction(Qt::IgnoreAction); event->ignore(); } - if (supportsDropping(destUrl)) { + KFileItem item(destUrl); + if (!item.isLocalFile() || supportsDropping(item)) { event->setDropAction(event->proposedAction()); event->accept(); } else { diff --git a/src/views/draganddrophelper.h b/src/views/draganddrophelper.h index 0eee34a3d..73043febc 100644 --- a/src/views/draganddrophelper.h +++ b/src/views/draganddrophelper.h @@ -45,15 +45,6 @@ public: /** * Checks if the destination supports dropping. * - * @param destUrl URL of the item destination. - * @return True if the destination is a directory and is writable, or it's a desktop file. - * False otherwise. - */ - static bool supportsDropping(const QUrl &destUrl); - - /** - * Checks if the destination supports dropping. - * * @param destItem The item destination. * @return True if the destination is a directory and is writable, or it's a desktop file. * False otherwise. |
