mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
feat(fixedplugin):fixedplugin add remove sort
This commit is contained in:
parent
c672482453
commit
71a45e8cea
@ -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<PluginsItem *>(item.data())->setItemSortKey(++index);
|
||||
}
|
||||
|
||||
// 固定区域插件排序
|
||||
index = 0;
|
||||
for (auto item : m_itemList) {
|
||||
if (item.isNull() || item->itemType() != DockItem::FixedPlugin)
|
||||
continue;
|
||||
static_cast<PluginsItem *>(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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user