mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
bugfix: restore item immediately when drop in plugin-layout
Change-Id: Id401cbc26ea81979152a103a6825698be91d4611
This commit is contained in:
parent
109afd7687
commit
4fcd036bee
Notes:
Deepin Code Review
2016-06-14 07:19:47 +00:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: <mr.asianwang@gmail.com> Submitted-by: <mr.asianwang@gmail.com> Submitted-at: Mon, 14 Sep 2015 17:13:11 +0800 Reviewed-on: https://cr.deepin.io/7003 Project: dde/dde-dock Branch: refs/heads/master
@ -140,6 +140,10 @@ void Panel::initAppLayout()
|
||||
connect(m_appLayout, &DockLayout::startDrag, this, &Panel::onItemDragStarted);
|
||||
connect(m_appLayout, &DockLayout::itemDropped, this, &Panel::onItemDropped);
|
||||
connect(m_appLayout, &DockLayout::contentsWidthChange, this, &Panel::onLayoutContentsWidthChanged);
|
||||
|
||||
//for plugin layout mask
|
||||
connect(m_appLayout, &DockLayout::startDrag, this, &Panel::showPluginLayoutMask);
|
||||
connect(m_appLayout, &DockLayout::itemDropped, this, &Panel::hidePluginLayoutMask);
|
||||
}
|
||||
|
||||
void Panel::initAppManager()
|
||||
@ -177,6 +181,10 @@ void Panel::initScreenMask()
|
||||
connect(m_maskWidget, &ScreenMask::itemDropped, this, &Panel::onItemDropped);
|
||||
connect(m_maskWidget, &ScreenMask::itemEntered, m_appLayout, &DockLayout::removeSpacingItem);
|
||||
connect(m_maskWidget, &ScreenMask::itemMissing, m_appLayout, &DockLayout::restoreTmpItem);
|
||||
|
||||
//for plugin layout mask
|
||||
connect(m_maskWidget, &ScreenMask::itemDropped, this, &Panel::hidePluginLayoutMask);
|
||||
connect(m_maskWidget, &ScreenMask::itemMissing, this, &Panel::hidePluginLayoutMask);
|
||||
}
|
||||
|
||||
void Panel::onItemDropped()
|
||||
@ -329,6 +337,34 @@ void Panel::updateLeftReflection()
|
||||
m_appReflection->setFixedSize(m_appLayout->width(), 0);
|
||||
}
|
||||
|
||||
void Panel::showPluginLayoutMask()
|
||||
{
|
||||
if (!m_pluginLayoutMask){
|
||||
m_pluginLayoutMask = new LayoutDropMask(this);
|
||||
connect(m_pluginLayoutMask, &LayoutDropMask::itemDrop, [=]{
|
||||
m_pluginLayoutMask->hide();
|
||||
m_appLayout->restoreTmpItem();
|
||||
});
|
||||
connect(m_pluginLayoutMask, &LayoutDropMask::itemMove, [=]{
|
||||
//readjust position and size
|
||||
m_pluginLayoutMask->setFixedSize(m_pluginLayout->size());
|
||||
m_pluginLayoutMask->move(m_pluginLayout->pos());
|
||||
});
|
||||
connect(m_pluginLayoutMask, &LayoutDropMask::itemEnter, m_appLayout, &DockLayout::removeSpacingItem);
|
||||
}
|
||||
m_pluginLayoutMask->setFixedSize(m_pluginLayout->size());
|
||||
m_pluginLayoutMask->move(m_pluginLayout->pos());
|
||||
m_pluginLayoutMask->raise();
|
||||
m_pluginLayoutMask->show();
|
||||
}
|
||||
|
||||
void Panel::hidePluginLayoutMask()
|
||||
{
|
||||
if (m_pluginLayoutMask)
|
||||
m_pluginLayoutMask->hide();
|
||||
}
|
||||
|
||||
|
||||
void Panel::reloadStyleSheet()
|
||||
{
|
||||
m_isFashionMode = m_dockModeData->getDockMode() == Dock::FashionMode;
|
||||
@ -354,3 +390,27 @@ Panel::~Panel()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
LayoutDropMask::LayoutDropMask(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
void LayoutDropMask::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
emit itemEnter();
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void LayoutDropMask::dragMoveEvent(QDragMoveEvent *event)
|
||||
{
|
||||
emit itemMove();
|
||||
}
|
||||
|
||||
void LayoutDropMask::dropEvent(QDropEvent *event)
|
||||
{
|
||||
emit itemDrop();
|
||||
event->accept();
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "widgets/reflectioneffect.h"
|
||||
#include "panelmenu.h"
|
||||
|
||||
class LayoutDropMask;
|
||||
class Panel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -63,6 +64,8 @@ private:
|
||||
void reanchorsLayout(Dock::DockMode mode);
|
||||
void updateRightReflection();
|
||||
void updateLeftReflection();
|
||||
void showPluginLayoutMask();
|
||||
void hidePluginLayoutMask();
|
||||
void reloadStyleSheet();
|
||||
void showPanelMenu();
|
||||
void setY(int value); //for hide and show animation
|
||||
@ -77,6 +80,7 @@ private:
|
||||
ScreenMask * m_maskWidget = NULL;
|
||||
AppManager *m_appManager = NULL;
|
||||
QWidget *m_parentWidget = NULL;
|
||||
LayoutDropMask *m_pluginLayoutMask = NULL;
|
||||
DockLayout *m_appLayout = NULL;
|
||||
|
||||
bool m_containMouse = false;
|
||||
@ -89,4 +93,22 @@ private:
|
||||
const QEasingCurve SHOW_HIDE_EASINGCURVE = QEasingCurve::InSine;
|
||||
};
|
||||
|
||||
class LayoutDropMask : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LayoutDropMask(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
void itemMove();
|
||||
void itemEnter();
|
||||
void itemDrop();
|
||||
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dragMoveEvent(QDragMoveEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
|
||||
};
|
||||
|
||||
#endif // PANEL_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user