diff --git a/CHANGELOG.md b/CHANGELOG.md index 79bca6a8..f3821a9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Bugfix: Fixed message contents being cleared when using the close button for replies. (#6145) - Bugfix: Handle CMD + BACKSPACE behavior explicitly in main chat dialog input for macOS. (#6111) - Bugfix: Fixed a small typo in the settings page. (#6134) +- Bugfix: Fixed an issue where Splits could get lost by dragging it onto your Recycle Bin. (#6147) - Bugfix: Fixed some Twitch commands not getting tab-completed correctly. (#6143) - Bugfix: Fixed shared chat badges displaying pixelated when Chatterino is scaled too much. (#6146) - Dev: Mini refactor of Split. (#6148) diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 1ecd55a5..3c762392 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -3,6 +3,7 @@ #include "Application.hpp" #include "common/Channel.hpp" #include "common/Common.hpp" +#include "common/QLogging.hpp" #include "controllers/hotkeys/HotkeyCategory.hpp" #include "controllers/hotkeys/HotkeyController.hpp" #include "singletons/Fonts.hpp" @@ -1000,12 +1001,42 @@ void NotebookTab::dragEnterEvent(QDragEnterEvent *event) return; } + event->acceptProposedAction(); + if (this->notebook_->getAllowUserTabManagement()) { this->notebook_->select(this->page); } } +void NotebookTab::dropEvent(QDropEvent *event) +{ + if (!event->mimeData()->hasFormat("chatterino/split")) + { + return; + } + + if (!isDraggingSplit()) + { + // Ensure dragging a split from a different Chatterino instance doesn't switch tabs around + return; + } + + auto *draggedSplit = dynamic_cast(event->source()); + if (!draggedSplit) + { + qCDebug(chatterinoWidget) + << "Dropped something that wasn't a split onto a notebook button"; + return; + } + + if (auto *container = dynamic_cast(this->page)) + { + event->acceptProposedAction(); + container->insertSplit(draggedSplit); + } +} + void NotebookTab::mouseMoveEvent(QMouseEvent *event) { if (getSettings()->showTabCloseButton && diff --git a/src/widgets/helper/NotebookTab.hpp b/src/widgets/helper/NotebookTab.hpp index 74c48586..15bfadeb 100644 --- a/src/widgets/helper/NotebookTab.hpp +++ b/src/widgets/helper/NotebookTab.hpp @@ -103,6 +103,7 @@ protected: void leaveEvent(QEvent *) override; void dragEnterEvent(QDragEnterEvent *event) override; + void dropEvent(QDropEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void wheelEvent(QWheelEvent *event) override; diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 13e0207e..eabe7a5c 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -1656,7 +1656,8 @@ void Split::drag() drag->setMimeData(mimeData); // drag->exec is a blocking action - if (drag->exec(Qt::MoveAction) == Qt::IgnoreAction) + auto dragRes = drag->exec(Qt::MoveAction); + if (dragRes != Qt::MoveAction || drag->target() == nullptr) { // The split wasn't dropped in a valid spot, return it to its original position container->insertSplit(this, {.position = originalLocation});