From e50f8a2128e5a42a43abfe7b066dbebcac020020 Mon Sep 17 00:00:00 2001 From: wangxuwen Date: Wed, 4 Dec 2019 09:27:11 +0800 Subject: [PATCH] feat(dde-dock):plugin index and prewindow display error for task 12385 --- frame/controller/dockitemmanager.cpp | 4 --- frame/item/dockitem.cpp | 42 +++++++++++++++++++++++----- frame/panel/mainpanelcontrol.cpp | 13 +++++++-- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/frame/controller/dockitemmanager.cpp b/frame/controller/dockitemmanager.cpp index c15275c12..bd2feb178 100644 --- a/frame/controller/dockitemmanager.cpp +++ b/frame/controller/dockitemmanager.cpp @@ -283,10 +283,6 @@ void DockItemManager::pluginItemInserted(PluginsItem *item) } } - if (item->itemType() == DockItem::FixedPlugin) { - insertIndex ++; - } - m_itemList.insert(insertIndex, item); emit itemInserted(insertIndex - firstPluginPosition, item); diff --git a/frame/item/dockitem.cpp b/frame/item/dockitem.cpp index 364978c56..afe393a7d 100644 --- a/frame/item/dockitem.cpp +++ b/frame/item/dockitem.cpp @@ -26,6 +26,8 @@ #include #include +#define PLUGIN_MARGEN 10 + Position DockItem::DockPosition = Position::Top; DisplayMode DockItem::DockDisplayMode = DisplayMode::Efficient; QPointer DockItem::PopupWindow(nullptr); @@ -44,7 +46,7 @@ DockItem::DockItem(QWidget *parent) if (PopupWindow.isNull()) { DockPopupWindow *arrowRectangle = new DockPopupWindow(nullptr); arrowRectangle->setShadowBlurRadius(20); - arrowRectangle->setRadius(6); + arrowRectangle->setRadius(18); arrowRectangle->setShadowYOffset(2); arrowRectangle->setShadowXOffset(0); arrowRectangle->setArrowWidth(18); @@ -348,14 +350,40 @@ const QPoint DockItem::popupMarkPoint() const QPoint p(topleftPoint()); const QRect r = rect(); - const int offset = 2; switch (DockPosition) { - case Top: p += QPoint(r.width() / 2, r.height() + offset); break; - case Bottom: p += QPoint(r.width() / 2, 0 - offset); break; - case Left: p += QPoint(r.width() + offset, r.height() / 2); break; - case Right: p += QPoint(0 - offset, r.height() / 2); break; + case Top: { + if (itemType() == Plugins) { + p += QPoint(r.width() / 2, r.height() + PLUGIN_MARGEN); + } else { + p += QPoint(r.width() / 2, r.height()); + } + break; + } + case Bottom: { + if (itemType() == Plugins) { + p += QPoint(r.width() / 2, 0 - PLUGIN_MARGEN); + } else { + p += QPoint(r.width() / 2, 0); + } + break; + } + case Left: { + if (itemType() == Plugins) { + p += QPoint(r.width() + PLUGIN_MARGEN, r.height() / 2); + } else { + p += QPoint(r.width(), r.height() / 2); + } + break; + } + case Right: { + if (itemType() == Plugins) { + p += QPoint(0 - PLUGIN_MARGEN, r.height() / 2); + } else { + p += QPoint(0, r.height() / 2); + } + break; + } } - return p; } diff --git a/frame/panel/mainpanelcontrol.cpp b/frame/panel/mainpanelcontrol.cpp index 0269d9d0a..aaa7728d9 100755 --- a/frame/panel/mainpanelcontrol.cpp +++ b/frame/panel/mainpanelcontrol.cpp @@ -243,7 +243,12 @@ void MainPanelControl::insertItem(int index, DockItem *item) switch (item->itemType()) { case DockItem::Launcher: + addFixedAreaItem(0, item); + break; case DockItem::FixedPlugin: + if (index == 0) { + index += 1; + } addFixedAreaItem(index, item); break; case DockItem::App: @@ -610,9 +615,13 @@ DockItem *MainPanelControl::dropTargetItem(DockItem *sourceItem, QPoint point) continue; QRect rect; - rect.setTopLeft(dockItem->pos()); - rect.setSize(dockItem->size()); + rect.setTopLeft(dockItem->pos()); + if ((m_position == Position::Top) || (m_position == Position::Bottom)) { + rect.setSize(QSize(PLUGIN_MAX_SIZE, height())); + } else { + rect.setSize(QSize(width(), PLUGIN_MAX_SIZE)); + } if (rect.contains(point)) { targetItem = dockItem; break;