mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
fix: 任务栏插件参数缺失
之前用QTimer定时1秒钟后将插件的配置信息写入GSettings,但在配置比较差的机型上插件还没有加载完,导致往GSettings里写配置信息的时候漏了一两个插件。 改为当有插件被用户移动、移除或检测到新的插件时,直接调用更新GSettings中的插件配置信息。 Log: 修复自动化测试发现任务栏插件参数缺失的问题。 Bug: https://pms.uniontech.com/zentao/bug-view-59243.html Change-Id: I4dc37ad7f611fabf479375f100506ef84f3f78d3
This commit is contained in:
parent
8adb1f62c5
commit
3b3c303bf9
@ -32,7 +32,6 @@ DockItemManager *DockItemManager::INSTANCE = nullptr;
|
||||
|
||||
DockItemManager::DockItemManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_updatePluginsOrderTimer(new QTimer(this))
|
||||
, m_appInter(new DBusDock("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this))
|
||||
, m_pluginsInter(new DockPluginsController(this))
|
||||
{
|
||||
@ -55,11 +54,6 @@ DockItemManager::DockItemManager(QObject *parent)
|
||||
|
||||
// 托盘区域和插件区域 由DockPluginsController获取
|
||||
|
||||
// 更新插件顺序
|
||||
m_updatePluginsOrderTimer->setSingleShot(true);
|
||||
m_updatePluginsOrderTimer->setInterval(1000);
|
||||
connect(m_updatePluginsOrderTimer, &QTimer::timeout, this, &DockItemManager::updatePluginsItemOrderKey);
|
||||
|
||||
// 应用信号
|
||||
connect(m_appInter, &DBusDock::EntryAdded, this, &DockItemManager::appItemAdded);
|
||||
connect(m_appInter, &DBusDock::EntryRemoved, this, static_cast<void (DockItemManager::*)(const QString &)>(&DockItemManager::appItemRemoved), Qt::QueuedConnection);
|
||||
@ -73,9 +67,6 @@ DockItemManager::DockItemManager(QObject *parent)
|
||||
|
||||
// 刷新图标
|
||||
QMetaObject::invokeMethod(this, "refershItemsIcon", Qt::QueuedConnection);
|
||||
|
||||
// 启动的时候把插件名写入配置(自动化测试需要)
|
||||
m_updatePluginsOrderTimer->start();
|
||||
}
|
||||
|
||||
DockItemManager *DockItemManager::instance(QObject *parent)
|
||||
@ -116,10 +107,12 @@ void DockItemManager::refershItemsIcon()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 将插件的参数(Order, Visible, etc)写入gsettings
|
||||
* 自动化测试需要通过dbus(GetPluginSettings)获取这些参数
|
||||
*/
|
||||
void DockItemManager::updatePluginsItemOrderKey()
|
||||
{
|
||||
Q_ASSERT(sender() == m_updatePluginsOrderTimer);
|
||||
|
||||
int index = 0;
|
||||
for (auto item : m_itemList) {
|
||||
if (item.isNull() || item->itemType() != DockItem::Plugins)
|
||||
@ -161,9 +154,10 @@ 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::FixedPlugin || replaceType == DockItem::FixedPlugin)
|
||||
m_updatePluginsOrderTimer->start();
|
||||
|| moveType == DockItem::TrayPlugin || replaceType == DockItem::TrayPlugin
|
||||
|| moveType == DockItem::FixedPlugin || replaceType == DockItem::FixedPlugin) {
|
||||
updatePluginsItemOrderKey();
|
||||
}
|
||||
|
||||
// for app move, index 0 is launcher item, need to pass it.
|
||||
if (moveType == DockItem::App && replaceType == DockItem::App)
|
||||
@ -297,6 +291,7 @@ void DockItemManager::pluginItemInserted(PluginsItem *item)
|
||||
insertIndex ++;
|
||||
}
|
||||
|
||||
updatePluginsItemOrderKey();
|
||||
emit itemInserted(insertIndex - firstPluginPosition, item);
|
||||
}
|
||||
|
||||
@ -307,6 +302,8 @@ void DockItemManager::pluginItemRemoved(PluginsItem *item)
|
||||
emit itemRemoved(item);
|
||||
|
||||
m_itemList.removeOne(item);
|
||||
|
||||
updatePluginsItemOrderKey();
|
||||
}
|
||||
|
||||
void DockItemManager::reloadAppItems()
|
||||
|
@ -59,7 +59,6 @@ signals:
|
||||
public slots:
|
||||
void refershItemsIcon();
|
||||
void sortPluginItems();
|
||||
void updatePluginsItemOrderKey();
|
||||
void itemMoved(DockItem *const sourceItem, DockItem *const targetItem);
|
||||
void itemAdded(const QString &appDesktop, int idx);
|
||||
|
||||
@ -70,11 +69,11 @@ private:
|
||||
void appItemRemoved(AppItem *appItem);
|
||||
void pluginItemInserted(PluginsItem *item);
|
||||
void pluginItemRemoved(PluginsItem *item);
|
||||
void updatePluginsItemOrderKey();
|
||||
void reloadAppItems();
|
||||
void manageItem(DockItem *item);
|
||||
|
||||
private:
|
||||
QTimer *m_updatePluginsOrderTimer;
|
||||
DBusDock *m_appInter;
|
||||
DockPluginsController *m_pluginsInter;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user