mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
feat: 任务栏应用拖动到移除驻留
判断鼠标拖动的位置是否在回收站区域,如果在回收站区域,则执行移除驻留的功能 Log: 增加任务栏应用到回收站移除驻留的功能 Influence: 拖动任务栏应用到回收站,观察是否可以移除驻留 Bug: https://pms.uniontech.com/bug-view-147699.html Change-Id: Ib0a17f0f4647827b2c2a0e70d98a86c1b9135c11
This commit is contained in:
parent
56c3019a5c
commit
d6f0860fcf
@ -61,7 +61,6 @@ AppItem::AppItem(DockInter *dockInter, const QGSettings *appSettings, const QGSe
|
||||
, m_itemAnimation(nullptr)
|
||||
, m_wmHelper(DWindowManagerHelper::instance())
|
||||
, m_drag(nullptr)
|
||||
, m_dragging(false)
|
||||
, m_retryTimes(0)
|
||||
, m_iconValid(true)
|
||||
, m_lastclickTimes(0)
|
||||
@ -274,10 +273,8 @@ void AppItem::moveEvent(QMoveEvent *e)
|
||||
void AppItem::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
DockItem::paintEvent(e);
|
||||
if (m_draging)
|
||||
return;
|
||||
|
||||
if (m_dragging || (m_swingEffectView != nullptr && DockDisplayMode != Fashion))
|
||||
if (isDragging() || (m_swingEffectView != nullptr && DockDisplayMode != Fashion))
|
||||
return;
|
||||
|
||||
QPainter painter(this);
|
||||
@ -569,7 +566,7 @@ QWidget *AppItem::popupTips()
|
||||
if (checkGSettingsControl())
|
||||
return nullptr;
|
||||
|
||||
if (m_dragging)
|
||||
if (isDragging())
|
||||
return nullptr;
|
||||
|
||||
static TipsWidget appNameTips(topLevelWidget());
|
||||
|
@ -139,7 +139,6 @@ private:
|
||||
|
||||
QPointer<AppDrag> m_drag;
|
||||
|
||||
bool m_dragging;
|
||||
bool m_active;
|
||||
int m_retryTimes;
|
||||
bool m_iconValid;
|
||||
|
@ -380,8 +380,8 @@ void MainPanelControl::resetRadius()
|
||||
*/
|
||||
void MainPanelControl::dockRecentApp(DockItem *dockItem)
|
||||
{
|
||||
// 如果当前不是特效模式,则无需做驻留操作
|
||||
if (m_displayMode != Dock::DisplayMode::Fashion)
|
||||
// 如果不是插入或者当前不是特效模式,则无需做驻留操作
|
||||
if (m_dragIndex == -1 || m_displayMode != Dock::DisplayMode::Fashion)
|
||||
return;
|
||||
|
||||
AppItem *appItem = qobject_cast<AppItem *>(dockItem);
|
||||
@ -848,9 +848,6 @@ void MainPanelControl::startDrag(DockItem *dockItem)
|
||||
|
||||
connect(m_appDragWidget, &AppDragWidget::destroyed, this, [ = ] {
|
||||
m_appDragWidget = nullptr;
|
||||
AppItem *appItem = static_cast<AppItem *>(dockItem);
|
||||
if (appItem->supportSplitWindow())
|
||||
return;
|
||||
|
||||
if (!item.isNull() && qobject_cast<AppItem *>(item)->isValid()) {
|
||||
// 如果是从最近打开区域移动到应用区域的,则需要将其固定
|
||||
@ -861,7 +858,6 @@ void MainPanelControl::startDrag(DockItem *dockItem)
|
||||
}
|
||||
item->setDraging(false);
|
||||
item->update();
|
||||
|
||||
// 发送拖拽完成事件
|
||||
m_recentHelper->resetAppInfo();
|
||||
}
|
||||
@ -892,7 +888,6 @@ void MainPanelControl::startDrag(DockItem *dockItem)
|
||||
// 设置垃圾箱插件AcceptDrops false
|
||||
bool isNeedBack = false;
|
||||
PluginsItem *trashItem = m_toolHelper->trashPlugin();
|
||||
|
||||
if (item->itemType() == DockItem::Plugins && trashItem && dockItem != trashItem) {
|
||||
trashItem->centralWidget()->setAcceptDrops(false);
|
||||
isNeedBack = true;
|
||||
@ -906,7 +901,25 @@ void MainPanelControl::startDrag(DockItem *dockItem)
|
||||
m_appDragWidget->execFinished();
|
||||
}
|
||||
|
||||
if (item->itemType() != DockItem::App || m_dragIndex == -1) {
|
||||
if (item->itemType() == DockItem::App) {
|
||||
// 判断是否在回收站区域, 如果在回收站区域,则移除驻留
|
||||
PluginsItem *trashItem = m_toolHelper->trashPlugin();
|
||||
if (!trashItem)
|
||||
return;
|
||||
|
||||
QRect trashRect = trashItem->centralWidget()->geometry();
|
||||
QPoint pointMouse = trashItem->centralWidget()->mapFromGlobal(QCursor::pos());
|
||||
if (trashRect.contains(pointMouse)) {
|
||||
AppItem *appItem = qobject_cast<AppItem *>(dockItem);
|
||||
if (!appItem)
|
||||
return;
|
||||
|
||||
// 先让其设置m_dragIndex==-1,避免在后续放到任务栏
|
||||
m_dragIndex = -1;
|
||||
appItem->setDraging(false);
|
||||
appItem->undock();
|
||||
}
|
||||
} else if (m_dragIndex == -1) {
|
||||
m_appDragWidget = nullptr;
|
||||
item->setDraging(false);
|
||||
item->update();
|
||||
|
Loading…
x
Reference in New Issue
Block a user