fix:Do not drag when dock icon is deleted

任务栏图标删除时取消拖拽状态       (task:13009)
This commit is contained in:
chenzhe 2019-12-30 11:10:36 +08:00
parent 2f866675cc
commit ba695a3fc5
4 changed files with 15 additions and 0 deletions

View File

@ -223,6 +223,10 @@ void DockItemManager::appItemRemoved(AppItem *appItem)
{ {
emit itemRemoved(appItem); emit itemRemoved(appItem);
m_itemList.removeOne(appItem); m_itemList.removeOne(appItem);
if (appItem->isDragging()) {
QDrag::cancel();
}
appItem->deleteLater(); appItem->deleteLater();
} }

View File

@ -25,6 +25,7 @@
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QDrag>
DockPluginsController::DockPluginsController(QObject *parent) DockPluginsController::DockPluginsController(QObject *parent)
: AbstractPluginsController(parent) : AbstractPluginsController(parent)
@ -85,6 +86,10 @@ void DockPluginsController::itemRemoved(PluginsItemInterface *const itemInter, c
// do not delete the itemWidget object(specified in the plugin interface) // do not delete the itemWidget object(specified in the plugin interface)
item->centralWidget()->setParent(nullptr); item->centralWidget()->setParent(nullptr);
if (item->isDragging()) {
QDrag::cancel();
}
// just delete our wrapper object(PluginsItem) // just delete our wrapper object(PluginsItem)
item->deleteLater(); item->deleteLater();
} }

View File

@ -432,3 +432,8 @@ void DockItem::hideNonModel()
if (m_popupShown && !PopupWindow->model()) if (m_popupShown && !PopupWindow->model())
hidePopup(); hidePopup();
} }
bool DockItem::isDragging()
{
return m_draging;
}

View File

@ -67,6 +67,7 @@ public slots:
void hidePopup(); void hidePopup();
virtual void setDraging(bool bDrag); virtual void setDraging(bool bDrag);
bool isDragging();
signals: signals:
void dragStarted() const; void dragStarted() const;
void itemDropped(QObject *destination, const QPoint &dropPoint) const; void itemDropped(QObject *destination, const QPoint &dropPoint) const;