diff --git a/frame/window/mainpanelcontrol.cpp b/frame/window/mainpanelcontrol.cpp index a36fcad0d..dbb1e720d 100755 --- a/frame/window/mainpanelcontrol.cpp +++ b/frame/window/mainpanelcontrol.cpp @@ -70,6 +70,7 @@ MainPanelControl::MainPanelControl(QWidget *parent) , m_dislayMode(Efficient) , m_isHover(false) , m_needRecoveryWin(false) + , m_trashItem(nullptr) { initUi(); updateMainPanelLayout(); @@ -226,6 +227,11 @@ void MainPanelControl::addPluginAreaItem(int index, QWidget *wdg) QBoxLayout * boxLayout = new QBoxLayout(QBoxLayout::LeftToRight); boxLayout->addWidget(wdg, 0, Qt::AlignCenter); m_pluginLayout->insertLayout(index, boxLayout, 0); + + // 保存垃圾箱插件指针 + PluginsItem *pluginsItem = qobject_cast(wdg); + if (pluginsItem && pluginsItem->pluginName() == "trash") + m_trashItem = pluginsItem; } void MainPanelControl::removeFixedAreaItem(QWidget *wdg) @@ -247,6 +253,11 @@ void MainPanelControl::removePluginAreaItem(QWidget *wdg) { //因为日期时间插件大小和其他插件有异,为了方便设置边距,各插件中增加一层布局 //因此remove插件图标时,需要从多的一层布局中取widget进行判断是否需要移除的插件 + // 清空保存的垃圾箱插件指针 + PluginsItem *pluginsItem = qobject_cast(wdg); + if (pluginsItem && pluginsItem->pluginName() == "trash") + m_trashItem = nullptr; + for (int i = 0; i < m_pluginLayout->count(); ++i) { QLayoutItem *layoutItem = m_pluginLayout->itemAt(i); QLayout *boxLayout = layoutItem->layout(); @@ -709,6 +720,15 @@ void MainPanelControl::startDrag(DockItem *dockItem) drag->setPixmap(pixmap); drag->setHotSpot(pixmap.rect().center() / pixmap.devicePixelRatioF()); } + + // isNeedBack 保存是否需要重置垃圾箱的AcceptDrops + // 设置垃圾箱插件AcceptDrops false + bool isNeedBack = false; + if (item->itemType() == DockItem::Plugins && m_trashItem && dockItem != m_trashItem) { + m_trashItem->centralWidget()->setAcceptDrops(false); + isNeedBack = true; + } + drag->setMimeData(new QMimeData); drag->exec(Qt::MoveAction); @@ -716,6 +736,10 @@ void MainPanelControl::startDrag(DockItem *dockItem) m_appDragWidget = nullptr; item->setDraging(false); item->update(); + + // isNeedBack是否需要设置垃圾箱插件AcceptDrops true + if (isNeedBack) + m_trashItem->centralWidget()->setAcceptDrops(true); } } diff --git a/frame/window/mainpanelcontrol.h b/frame/window/mainpanelcontrol.h index dff1ca2da..83baa975f 100755 --- a/frame/window/mainpanelcontrol.h +++ b/frame/window/mainpanelcontrol.h @@ -134,6 +134,8 @@ private: bool m_isHover; // 判断鼠标是否移到desktop区域 bool m_needRecoveryWin; // 判断鼠标移出desktop区域是否恢复之前窗口 int m_dragIndex = -1; // 记录应用区域被拖拽图标的位置 + + PluginsItem *m_trashItem; // 垃圾箱插件(需要特殊处理一下) }; #endif // MAINPANELCONTROL_H