| 1 | // SPDX-FileCopyrightText: Nheko Contributors |
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #include "NhekoDropArea.h" |
| 6 | |
| 7 | #include <QMimeData> |
| 8 | |
| 9 | #include "ChatPage.h" |
| 10 | #include "timeline/InputBar.h" |
| 11 | #include "timeline/RoomlistModel.h" |
| 12 | #include "timeline/TimelineModel.h" |
| 13 | #include "timeline/TimelineViewManager.h" |
| 14 | |
| 15 | NhekoDropArea::NhekoDropArea(QQuickItem *parent) |
| 16 | : QQuickItem(parent) |
| 17 | { |
| 18 | setFlags(ItemAcceptsDrops); |
| 19 | } |
| 20 | |
| 21 | void |
| 22 | NhekoDropArea::dragEnterEvent(QDragEnterEvent *event) |
| 23 | { |
| 24 | event->acceptProposedAction(); |
| 25 | } |
| 26 | |
| 27 | void |
| 28 | NhekoDropArea::dragMoveEvent(QDragMoveEvent *event) |
| 29 | { |
| 30 | event->acceptProposedAction(); |
| 31 | } |
| 32 | |
| 33 | void |
| 34 | NhekoDropArea::dropEvent(QDropEvent *event) |
| 35 | { |
| 36 | if (event) { |
| 37 | auto model = ChatPage::instance()->timelineManager()->rooms()->getRoomById(roomid_); |
| 38 | if (model) { |
| 39 | model->input()->insertMimeData(event->mimeData()); |
| 40 | ChatPage::instance()->timelineManager()->focusMessageInput(); |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | #include "moc_NhekoDropArea.cpp" |