1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

allow drag&drop on GroupWidget

This commit is contained in:
krepa098 2014-10-16 15:48:40 +02:00
parent 5ae2afb5c6
commit 6b39184915
2 changed files with 25 additions and 0 deletions

View File

@ -21,9 +21,12 @@
#include "form/groupchatform.h"
#include "maskablepixmapwidget.h"
#include "src/misc/style.h"
#include "src/core.h"
#include <QPalette>
#include <QMenu>
#include <QContextMenuEvent>
#include <QMimeData>
#include <QDragEnterEvent>
#include "ui_mainwindow.h"
@ -39,6 +42,8 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
statusMessageLabel->setText(GroupWidget::tr("%1 users in chat").arg(g->peers.size()));
else
statusMessageLabel->setText(GroupWidget::tr("0 users in chat"));
setAcceptDrops(true);
}
void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
@ -102,3 +107,18 @@ void GroupWidget::resetEventFlags()
g->hasNewMessages = 0;
g->userWasMentioned = 0;
}
void GroupWidget::dragEnterEvent(QDragEnterEvent *ev)
{
if (ev->mimeData()->hasFormat("friend"))
ev->acceptProposedAction();
}
void GroupWidget::dropEvent(QDropEvent *ev)
{
if (ev->mimeData()->hasFormat("friend"))
{
int friendId = ev->mimeData()->data("friend").toInt();
Core::getInstance()->groupInviteFriend(friendId, groupId);
}
}

View File

@ -37,6 +37,11 @@ signals:
void groupWidgetClicked(GroupWidget* widget);
void removeGroup(int groupId);
protected:
// drag & drop
void dragEnterEvent(QDragEnterEvent* ev);
void dropEvent(QDropEvent* ev);
public:
int groupId;
};