mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +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_pluginsInter(new DockPluginsController(this))
|
||||||
, m_containerItem(new ContainerItem)
|
, m_containerItem(new ContainerItem)
|
||||||
{
|
{
|
||||||
//固定区域:启动器、显示桌面、多任务视图
|
//固定区域:启动器
|
||||||
m_itemList.append(new LauncherItem);
|
m_itemList.append(new LauncherItem);
|
||||||
// TODO
|
|
||||||
// m_itemList.append(new ShowDesktopItem);
|
|
||||||
// m_itemList.append(new MutableTaskItem)
|
|
||||||
|
|
||||||
// 应用区域
|
// 应用区域
|
||||||
for (auto entry : m_appInter->entries()) {
|
for (auto entry : m_appInter->entries()) {
|
||||||
@ -139,6 +136,14 @@ void DockItemManager::updatePluginsItemOrderKey()
|
|||||||
continue;
|
continue;
|
||||||
static_cast<PluginsItem *>(item.data())->setItemSortKey(++index);
|
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)
|
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
|
// update plugins sort key if order changed
|
||||||
if (moveType == DockItem::Plugins || replaceType == DockItem::Plugins
|
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();
|
m_updatePluginsOrderTimer->start();
|
||||||
|
|
||||||
// for app move, index 0 is launcher item, need to pass it.
|
// 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);
|
m_itemList.insert(insertIndex, item);
|
||||||
emit itemInserted(insertIndex - firstPluginPosition, item);
|
emit itemInserted(insertIndex - firstPluginPosition, item);
|
||||||
|
|
||||||
|
@ -240,6 +240,7 @@ void MainPanelControl::insertItem(int index, DockItem *item)
|
|||||||
|
|
||||||
switch (item->itemType()) {
|
switch (item->itemType()) {
|
||||||
case DockItem::Launcher:
|
case DockItem::Launcher:
|
||||||
|
case DockItem::FixedPlugin:
|
||||||
addFixedAreaItem(index, item);
|
addFixedAreaItem(index, item);
|
||||||
break;
|
break;
|
||||||
case DockItem::App:
|
case DockItem::App:
|
||||||
@ -261,6 +262,7 @@ void MainPanelControl::removeItem(DockItem *item)
|
|||||||
{
|
{
|
||||||
switch (item->itemType()) {
|
switch (item->itemType()) {
|
||||||
case DockItem::Launcher:
|
case DockItem::Launcher:
|
||||||
|
case DockItem::FixedPlugin:
|
||||||
removeFixedAreaItem(item);
|
removeFixedAreaItem(item);
|
||||||
break;
|
break;
|
||||||
case DockItem::App:
|
case DockItem::App:
|
||||||
@ -296,6 +298,8 @@ void MainPanelControl::moveItem(DockItem *sourceItem, DockItem *targetItem)
|
|||||||
idx = m_appAreaSonLayout->indexOf(targetItem);
|
idx = m_appAreaSonLayout->indexOf(targetItem);
|
||||||
else if (targetItem->itemType() == DockItem::Plugins)
|
else if (targetItem->itemType() == DockItem::Plugins)
|
||||||
idx = m_pluginLayout->indexOf(targetItem);
|
idx = m_pluginLayout->indexOf(targetItem);
|
||||||
|
else if (targetItem->itemType() == DockItem::FixedPlugin)
|
||||||
|
idx = m_fixedAreaLayout->indexOf(targetItem);
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -476,7 +480,7 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
|
|||||||
if (!item)
|
if (!item)
|
||||||
return false;
|
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;
|
return false;
|
||||||
|
|
||||||
startDrag(item);
|
startDrag(item);
|
||||||
@ -533,6 +537,9 @@ DockItem *MainPanelControl::dropTargetItem(DockItem *sourceItem, QPoint point)
|
|||||||
case DockItem::Plugins:
|
case DockItem::Plugins:
|
||||||
parentWidget = m_pluginAreaWidget;
|
parentWidget = m_pluginAreaWidget;
|
||||||
break;
|
break;
|
||||||
|
case DockItem::FixedPlugin:
|
||||||
|
parentWidget = m_fixedAreaWidget;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user