mirror of https://github.com/Nheko-Reborn/nheko
parent
0eb8d4126b
commit
c74077a41f
@ -0,0 +1,39 @@ |
||||
#include "NhekoDropArea.h" |
||||
|
||||
#include <QMimeData> |
||||
|
||||
#include "ChatPage.h" |
||||
#include "timeline/InputBar.h" |
||||
#include "timeline/TimelineModel.h" |
||||
#include "timeline/TimelineViewManager.h" |
||||
|
||||
#include "Logging.h" |
||||
|
||||
NhekoDropArea::NhekoDropArea(QQuickItem *parent) |
||||
: QQuickItem(parent) |
||||
{ |
||||
setFlags(ItemAcceptsDrops); |
||||
} |
||||
|
||||
void |
||||
NhekoDropArea::dragEnterEvent(QDragEnterEvent *event) |
||||
{ |
||||
event->acceptProposedAction(); |
||||
} |
||||
|
||||
void |
||||
NhekoDropArea::dragMoveEvent(QDragMoveEvent *event) |
||||
{ |
||||
event->acceptProposedAction(); |
||||
} |
||||
|
||||
void |
||||
NhekoDropArea::dropEvent(QDropEvent *event) |
||||
{ |
||||
if (event) { |
||||
auto model = ChatPage::instance()->timelineManager()->getHistoryView(roomid_); |
||||
if (model) { |
||||
model->input()->insertMimeData(event->mimeData()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,30 @@ |
||||
#include <QQuickItem> |
||||
|
||||
class NhekoDropArea : public QQuickItem |
||||
{ |
||||
Q_OBJECT |
||||
Q_PROPERTY(QString roomid READ roomid WRITE setRoomid NOTIFY roomidChanged) |
||||
public: |
||||
NhekoDropArea(QQuickItem *parent = nullptr); |
||||
|
||||
signals: |
||||
void roomidChanged(QString roomid); |
||||
|
||||
public slots: |
||||
void setRoomid(QString roomid) |
||||
{ |
||||
if (roomid_ != roomid) { |
||||
roomid_ = roomid; |
||||
emit roomidChanged(roomid); |
||||
} |
||||
} |
||||
QString roomid() const { return roomid_; } |
||||
|
||||
protected: |
||||
void dragEnterEvent(QDragEnterEvent *event) override; |
||||
void dragMoveEvent(QDragMoveEvent *event) override; |
||||
void dropEvent(QDropEvent *event) override; |
||||
|
||||
private: |
||||
QString roomid_; |
||||
}; |
Loading…
Reference in new issue