From 71a45e8ceae022591c56be07328f88d9a26f1698 Mon Sep 17 00:00:00 2001 From: shaojun Date: Wed, 4 Sep 2019 13:22:43 +0800 Subject: [PATCH] feat(fixedplugin):fixedplugin add remove sort --- frame/controller/dockitemmanager.cpp | 20 +++++++++++++++----- frame/panel/mainpanelcontrol.cpp | 9 ++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/frame/controller/dockitemmanager.cpp b/frame/controller/dockitemmanager.cpp index 7e437b52a..98fec7a9e 100644 --- a/frame/controller/dockitemmanager.cpp +++ b/frame/controller/dockitemmanager.cpp @@ -40,11 +40,8 @@ DockItemManager::DockItemManager(QObject *parent) , m_pluginsInter(new DockPluginsController(this)) , m_containerItem(new ContainerItem) { - //固定区域:启动器、显示桌面、多任务视图 + //固定区域:启动器 m_itemList.append(new LauncherItem); - // TODO - // m_itemList.append(new ShowDesktopItem); - // m_itemList.append(new MutableTaskItem) // 应用区域 for (auto entry : m_appInter->entries()) { @@ -139,6 +136,14 @@ void DockItemManager::updatePluginsItemOrderKey() continue; static_cast(item.data())->setItemSortKey(++index); } + + // 固定区域插件排序 + index = 0; + for (auto item : m_itemList) { + if (item.isNull() || item->itemType() != DockItem::FixedPlugin) + continue; + static_cast(item.data())->setItemSortKey(++index); + } } void DockItemManager::itemMoved(DockItem *const sourceItem, DockItem *const targetItem) @@ -169,7 +174,8 @@ void DockItemManager::itemMoved(DockItem *const sourceItem, DockItem *const targ // update plugins sort key if order changed if (moveType == DockItem::Plugins || replaceType == DockItem::Plugins - || moveType == DockItem::TrayPlugin || replaceType == DockItem::TrayPlugin) + || moveType == DockItem::TrayPlugin || replaceType == DockItem::TrayPlugin + || moveType == DockItem::FixedPlugin || replaceType == DockItem::FixedPlugin) m_updatePluginsOrderTimer->start(); // for app move, index 0 is launcher item, need to pass it. @@ -329,6 +335,10 @@ 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/panel/mainpanelcontrol.cpp b/frame/panel/mainpanelcontrol.cpp index a8c7f9c00..ab35dc4ae 100644 --- a/frame/panel/mainpanelcontrol.cpp +++ b/frame/panel/mainpanelcontrol.cpp @@ -240,6 +240,7 @@ void MainPanelControl::insertItem(int index, DockItem *item) switch (item->itemType()) { case DockItem::Launcher: + case DockItem::FixedPlugin: addFixedAreaItem(index, item); break; case DockItem::App: @@ -261,6 +262,7 @@ void MainPanelControl::removeItem(DockItem *item) { switch (item->itemType()) { case DockItem::Launcher: + case DockItem::FixedPlugin: removeFixedAreaItem(item); break; case DockItem::App: @@ -296,6 +298,8 @@ void MainPanelControl::moveItem(DockItem *sourceItem, DockItem *targetItem) idx = m_appAreaSonLayout->indexOf(targetItem); else if (targetItem->itemType() == DockItem::Plugins) idx = m_pluginLayout->indexOf(targetItem); + else if (targetItem->itemType() == DockItem::FixedPlugin) + idx = m_fixedAreaLayout->indexOf(targetItem); else return; @@ -476,7 +480,7 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event) if (!item) return false; - if (item->itemType() != DockItem::App && item->itemType() != DockItem::Plugins) + if (item->itemType() != DockItem::App && item->itemType() != DockItem::Plugins && item->itemType() != DockItem::FixedPlugin) return false; startDrag(item); @@ -533,6 +537,9 @@ DockItem *MainPanelControl::dropTargetItem(DockItem *sourceItem, QPoint point) case DockItem::Plugins: parentWidget = m_pluginAreaWidget; break; + case DockItem::FixedPlugin: + parentWidget = m_fixedAreaWidget; + break; default: break; }