fix: 桌面和多任务视图移除后重新添加没有按照添加顺序显示

将后插入的FixedPlugin类插件放置在已插入的FixedPlugin后面

Log: 修复桌面和多任务视图移除后重新添加没有按照添加顺序显示
Bug: https://pms.uniontech.com/zentao/bug-view-58711.html
Change-Id: I34108bf5f3a263d4d49162496dd5a2e0e0249282
This commit is contained in:
dongrui 2021-01-07 13:20:43 +08:00
parent 9d2d4855f5
commit 860b78cd5f

View File

@ -52,16 +52,35 @@ void AbstractPluginsController::saveValue(PluginsItemInterface *const itemInter,
{
// is it necessary?
// refreshPluginSettings();
int fixedPluginCount(0); // FixPlugin Counts
// save to local cache
QJsonObject localObject = m_pluginSettingsObject.value(itemInter->pluginName()).toObject();
localObject.insert(key, QJsonValue::fromVariant(value)); //Note: QVariant::toJsonValue() not work in Qt 5.7
m_pluginSettingsObject.insert(itemInter->pluginName(), localObject);
// save to daemon
QJsonObject remoteObject, remoteObjectInter;
remoteObjectInter.insert(key, QJsonValue::fromVariant(value)); //Note: QVariant::toJsonValue() not work in Qt 5.7
remoteObject.insert(itemInter->pluginName(), remoteObjectInter);
if (itemInter->type() == PluginsItemInterface::Fixed && key == "enable" && !value.toBool()) {
// 遍历FixPlugin插件个数
for (auto it(m_pluginsMap.begin()); it != m_pluginsMap.end();) {
if (it.key()->type() == PluginsItemInterface::Fixed) {
fixedPluginCount++;
}
++it;
}
// 修改插件的order值位置为队尾
QString name = localObject.keys().last();
localObject.insert(name, QJsonValue::fromVariant(fixedPluginCount)); //Note: QVariant::toJsonValue() not work in Qt 5.7
// daemon中同样修改
remoteObjectInter.insert(name, QJsonValue::fromVariant(fixedPluginCount)); //Note: QVariant::toJsonValue() not work in Qt 5.7
remoteObject.insert(itemInter->pluginName(), remoteObjectInter);
}
m_pluginSettingsObject.insert(itemInter->pluginName(), localObject);
m_dockDaemonInter->MergePluginSettings(QJsonDocument(remoteObject).toJson(QJsonDocument::JsonFormat::Compact));
}