mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
add drag & drop
Change-Id: I2921e9d443e470556e24115afed0146218de8c96
This commit is contained in:
parent
775271b6fd
commit
1331a43336
@ -19,7 +19,8 @@ uint AppItem::ActiveWindowId = 0;
|
|||||||
|
|
||||||
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||||
: DockItem(App, parent),
|
: DockItem(App, parent),
|
||||||
m_itemEntry(new DBusDockEntry(entry.path(), this))
|
m_itemEntry(new DBusDockEntry(entry.path(), this)),
|
||||||
|
m_draging(false)
|
||||||
{
|
{
|
||||||
initClientManager();
|
initClientManager();
|
||||||
|
|
||||||
@ -32,6 +33,9 @@ void AppItem::paintEvent(QPaintEvent *e)
|
|||||||
{
|
{
|
||||||
DockItem::paintEvent(e);
|
DockItem::paintEvent(e);
|
||||||
|
|
||||||
|
if (m_draging)
|
||||||
|
return;
|
||||||
|
|
||||||
const QRect itemRect = rect();
|
const QRect itemRect = rect();
|
||||||
const int iconSize = std::min(itemRect.width(), itemRect.height());
|
const int iconSize = std::min(itemRect.width(), itemRect.height());
|
||||||
|
|
||||||
@ -90,6 +94,9 @@ void AppItem::mouseMoveEvent(QMouseEvent *e)
|
|||||||
|
|
||||||
void AppItem::startDrag()
|
void AppItem::startDrag()
|
||||||
{
|
{
|
||||||
|
m_draging = true;
|
||||||
|
update();
|
||||||
|
|
||||||
QPixmap pixmap(25, 25);
|
QPixmap pixmap(25, 25);
|
||||||
pixmap.fill(Qt::red);
|
pixmap.fill(Qt::red);
|
||||||
|
|
||||||
@ -101,6 +108,9 @@ void AppItem::startDrag()
|
|||||||
const Qt::DropAction result = drag->exec(Qt::MoveAction);
|
const Qt::DropAction result = drag->exec(Qt::MoveAction);
|
||||||
|
|
||||||
qDebug() << result;
|
qDebug() << result;
|
||||||
|
|
||||||
|
m_draging = false;
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppItem::initClientManager()
|
void AppItem::initClientManager()
|
||||||
|
@ -25,6 +25,8 @@ private:
|
|||||||
private:
|
private:
|
||||||
DBusDockEntry *m_itemEntry;
|
DBusDockEntry *m_itemEntry;
|
||||||
|
|
||||||
|
bool m_draging;
|
||||||
|
|
||||||
QMap<QString, QString> m_data;
|
QMap<QString, QString> m_data;
|
||||||
QMap<uint, QString> m_windows;
|
QMap<uint, QString> m_windows;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "mainpanel.h"
|
#include "mainpanel.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
|
#include <QDragEnterEvent>
|
||||||
|
|
||||||
MainPanel::MainPanel(QWidget *parent)
|
MainPanel::MainPanel(QWidget *parent)
|
||||||
: QFrame(parent),
|
: QFrame(parent),
|
||||||
@ -8,6 +9,7 @@ MainPanel::MainPanel(QWidget *parent)
|
|||||||
|
|
||||||
m_itemController(DockItemController::instance(this))
|
m_itemController(DockItemController::instance(this))
|
||||||
{
|
{
|
||||||
|
setAcceptDrops(true);
|
||||||
setObjectName("MainPanel");
|
setObjectName("MainPanel");
|
||||||
setStyleSheet("QWidget #MainPanel {"
|
setStyleSheet("QWidget #MainPanel {"
|
||||||
"border:none;"
|
"border:none;"
|
||||||
@ -40,6 +42,22 @@ void MainPanel::resizeEvent(QResizeEvent *e)
|
|||||||
adjustItemSize();
|
adjustItemSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainPanel::dragEnterEvent(QDragEnterEvent *e)
|
||||||
|
{
|
||||||
|
// TODO: check
|
||||||
|
e->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainPanel::dragMoveEvent(QDragMoveEvent *e)
|
||||||
|
{
|
||||||
|
qDebug() << e;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainPanel::dropEvent(QDropEvent *e)
|
||||||
|
{
|
||||||
|
qDebug() << e;
|
||||||
|
}
|
||||||
|
|
||||||
void MainPanel::adjustItemSize()
|
void MainPanel::adjustItemSize()
|
||||||
{
|
{
|
||||||
const QList<DockItem *> itemList = m_itemController->itemList();
|
const QList<DockItem *> itemList = m_itemController->itemList();
|
||||||
|
@ -18,6 +18,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *e);
|
||||||
|
void dragEnterEvent(QDragEnterEvent *e);
|
||||||
|
void dragMoveEvent(QDragMoveEvent *e);
|
||||||
|
void dropEvent(QDropEvent *e);
|
||||||
|
|
||||||
void adjustItemSize();
|
void adjustItemSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user