Adapt to the new version of XML file,add some restrictions.

This commit is contained in:
baijunjie 2021-11-11 10:50:33 +08:00
parent 311983d9b2
commit 905051dc98
1 changed files with 40 additions and 44 deletions

View File

@ -273,9 +273,6 @@ void SettingsSearchPlugin::openAction(int actionkey, QString key, int type)
switch (actionkey) {
case 0:
//打开控制面板对应页面
if (key.left(key.indexOf("/")).toLower() == "wallpaper")
process.startDetached(QString("ukui-control-center -m background"));
else
process.startDetached(QString("ukui-control-center -m %1").arg(key.left(key.indexOf("/")).toLower()));
break;
@ -332,6 +329,9 @@ void SettingsSearchPlugin::xmlElement() {
while (!node.isNull()) {
QDomElement element = node.toElement();
QDomNodeList list = element.childNodes();
//通过xml文件的子节点判断父节点是否有问题
if (list.count() >= 8 && (list.at(6).nodeName() == QString::fromLocal8Bit("EnglishFunc1"))) {
//直接获取二级菜单英文名
QString key = list.at(6).toElement().text();
chineseSearchResult = m_chineseSearchList.value(key);
englishSearchResult = m_englishSearchList.value(key);
@ -360,29 +360,25 @@ void SettingsSearchPlugin::xmlElement() {
if (chineseIndex.isEmpty()) {
continue;
}
if (chineseSearchResult.contains(chineseIndex)) {
continue;
} else {
chineseSearchResult.append(chineseIndex);
}
}
if (n.nodeName() == QString::fromLocal8Bit("EnglishFunc2")) {
englishIndex = /*QString::fromLocal8Bit("/") + */n.toElement().text();
if (englishIndex.isEmpty()) {
continue;
}
if (englishSearchResult.contains(englishIndex)) {
continue;
} else {
englishSearchResult.append(englishIndex);
}
}
}
m_chineseSearchList.insert(key, chineseSearchResult);
m_englishSearchList.insert(key, englishSearchResult);
node = node.nextSibling();
} else {
qWarning() << "There's something wrong with the xml file's item:" << element.attribute("name");
node = node.nextSibling();
}
}
file.close();
}