diff --git a/frame/item/appitem.cpp b/frame/item/appitem.cpp index f6775bce8..d6ca1547b 100644 --- a/frame/item/appitem.cpp +++ b/frame/item/appitem.cpp @@ -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()); diff --git a/frame/item/appitem.h b/frame/item/appitem.h index afa9ae9c9..6495718b6 100644 --- a/frame/item/appitem.h +++ b/frame/item/appitem.h @@ -139,7 +139,6 @@ private: QPointer m_drag; - bool m_dragging; bool m_active; int m_retryTimes; bool m_iconValid; diff --git a/frame/window/mainpanelcontrol.cpp b/frame/window/mainpanelcontrol.cpp index b67544204..495e75a67 100755 --- a/frame/window/mainpanelcontrol.cpp +++ b/frame/window/mainpanelcontrol.cpp @@ -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(dockItem); @@ -848,9 +848,6 @@ void MainPanelControl::startDrag(DockItem *dockItem) connect(m_appDragWidget, &AppDragWidget::destroyed, this, [ = ] { m_appDragWidget = nullptr; - AppItem *appItem = static_cast(dockItem); - if (appItem->supportSplitWindow()) - return; if (!item.isNull() && qobject_cast(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(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();