2021-06-18 09:48:58 +08:00
|
|
|
#include <QProcess>
|
|
|
|
#include <QDomDocument>
|
|
|
|
#include <QProcessEnvironment>
|
2021-07-08 18:53:16 +08:00
|
|
|
#include <QWidget>
|
2022-05-10 13:49:54 +08:00
|
|
|
#include <QDBusReply>
|
2022-11-29 20:07:53 +08:00
|
|
|
#include <QDBusArgument>
|
2023-04-19 10:31:51 +08:00
|
|
|
#include <QFile>
|
2023-04-19 15:14:36 +08:00
|
|
|
#include <QDebug>
|
2021-06-18 09:48:58 +08:00
|
|
|
#include "settings-search-plugin.h"
|
|
|
|
#include "file-utils.h"
|
2021-11-30 17:21:06 +08:00
|
|
|
|
2021-12-14 14:43:35 +08:00
|
|
|
using namespace UkuiSearch;
|
2021-11-30 17:21:06 +08:00
|
|
|
static SettingsMatch * settingMatchClass = nullptr;
|
|
|
|
size_t SettingsSearchPlugin::m_uniqueSymbolForSettings = 0;
|
|
|
|
QMutex SettingsSearchPlugin::m_mutex;
|
2021-06-18 09:48:58 +08:00
|
|
|
|
|
|
|
SettingsSearchPlugin::SettingsSearchPlugin(QObject *parent) : QObject(parent)
|
|
|
|
{
|
|
|
|
SearchPluginIface::Actioninfo open { 0, tr("Open")};
|
|
|
|
m_actionInfo << open;
|
2021-11-30 17:21:06 +08:00
|
|
|
SettingsMatch::getInstance()->start();
|
|
|
|
m_pool.setMaxThreadCount(1);
|
|
|
|
m_pool.setExpiryTimeout(1000);
|
2021-07-31 16:12:04 +08:00
|
|
|
initDetailPage();
|
2021-06-18 09:48:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const QString SettingsSearchPlugin::name()
|
|
|
|
{
|
2021-10-27 11:37:55 +08:00
|
|
|
return "Settings Search";
|
2021-06-18 09:48:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const QString SettingsSearchPlugin::description()
|
|
|
|
{
|
|
|
|
return tr("Settings search.");
|
|
|
|
}
|
|
|
|
|
|
|
|
QString SettingsSearchPlugin::getPluginName()
|
|
|
|
{
|
|
|
|
return tr("Settings Search");
|
|
|
|
}
|
|
|
|
|
2021-12-14 14:43:35 +08:00
|
|
|
void UkuiSearch::SettingsSearchPlugin::KeywordSearch(QString keyword, DataQueue<ResultInfo> *searchResult)
|
2021-06-18 09:48:58 +08:00
|
|
|
{
|
2021-11-30 17:21:06 +08:00
|
|
|
m_mutex.lock();
|
|
|
|
++m_uniqueSymbolForSettings;
|
|
|
|
m_mutex.unlock();
|
|
|
|
SettingsSearch *settingSearch = new SettingsSearch(searchResult, keyword, m_uniqueSymbolForSettings);
|
|
|
|
m_pool.start(settingSearch);
|
2021-06-18 09:48:58 +08:00
|
|
|
}
|
|
|
|
|
2022-02-12 14:20:55 +08:00
|
|
|
void SettingsSearchPlugin::stopSearch()
|
|
|
|
{
|
|
|
|
m_mutex.lock();
|
|
|
|
++m_uniqueSymbolForSettings;
|
|
|
|
m_mutex.unlock();
|
|
|
|
}
|
|
|
|
|
2021-06-18 09:48:58 +08:00
|
|
|
QList<SearchPluginIface::Actioninfo> SettingsSearchPlugin::getActioninfo(int type)
|
|
|
|
{
|
2023-04-24 14:07:56 +08:00
|
|
|
Q_UNUSED(type)
|
2021-06-18 09:48:58 +08:00
|
|
|
return m_actionInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsSearchPlugin::openAction(int actionkey, QString key, int type)
|
|
|
|
{
|
2023-04-24 14:07:56 +08:00
|
|
|
Q_UNUSED(type)
|
2021-06-18 09:48:58 +08:00
|
|
|
//TODO add some return message here.
|
|
|
|
switch (actionkey) {
|
|
|
|
case 0:
|
2022-05-10 13:49:54 +08:00
|
|
|
{
|
|
|
|
bool res(false);
|
|
|
|
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
|
|
|
"/com/kylin/AppManager",
|
|
|
|
"com.kylin.AppManager",
|
|
|
|
QDBusConnection::sessionBus());
|
|
|
|
if(!appLaunchInterface->isValid()) {
|
|
|
|
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
|
|
|
res = false;
|
|
|
|
} else {
|
|
|
|
appLaunchInterface->setTimeout(10000);
|
|
|
|
QDBusReply<bool> reply = appLaunchInterface->call("LaunchAppWithArguments", "ukui-control-center.desktop", QStringList() << "-m" << key.toLower());
|
|
|
|
if(reply.isValid()) {
|
|
|
|
res = reply;
|
|
|
|
} else {
|
|
|
|
qWarning() << "SoftWareCenter dbus called failed!";
|
|
|
|
res = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(appLaunchInterface) {
|
|
|
|
delete appLaunchInterface;
|
|
|
|
}
|
|
|
|
appLaunchInterface = NULL;
|
|
|
|
if (res)
|
|
|
|
break;
|
2021-06-18 09:48:58 +08:00
|
|
|
//打开控制面板对应页面
|
2023-04-24 14:07:56 +08:00
|
|
|
QProcess::startDetached("ukui-control-center", {"-m", key.toLower()});
|
2021-06-18 09:48:58 +08:00
|
|
|
break;
|
2022-05-10 13:49:54 +08:00
|
|
|
}
|
2021-06-18 09:48:58 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-31 16:12:04 +08:00
|
|
|
QWidget *SettingsSearchPlugin::detailPage(const ResultInfo &ri)
|
2021-07-08 18:53:16 +08:00
|
|
|
{
|
2021-07-31 16:12:04 +08:00
|
|
|
m_currentActionKey = ri.actionKey;
|
|
|
|
m_iconLabel->setPixmap(ri.icon.pixmap(120, 120));
|
|
|
|
QFontMetrics fontMetrics = m_nameLabel->fontMetrics();
|
2021-08-10 17:50:50 +08:00
|
|
|
QString showname = fontMetrics.elidedText(ri.name, Qt::ElideRight, 215); //当字体长度超过215时显示为省略号
|
2021-12-17 17:39:37 +08:00
|
|
|
m_nameLabel->setText(FileUtils::setAllTextBold(showname));
|
2021-07-31 16:12:04 +08:00
|
|
|
if(QString::compare(showname, ri.name)) {
|
|
|
|
m_nameLabel->setToolTip(ri.name);
|
2022-02-16 17:12:48 +08:00
|
|
|
} else {
|
|
|
|
m_nameLabel->setToolTip("");
|
2021-07-31 16:12:04 +08:00
|
|
|
}
|
|
|
|
return m_detailPage;
|
2021-07-08 18:53:16 +08:00
|
|
|
}
|
|
|
|
|
2021-07-31 16:12:04 +08:00
|
|
|
//bool SettingsSearchPlugin::isPreviewEnable(QString key, int type)
|
|
|
|
//{
|
|
|
|
// return false;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//QWidget *SettingsSearchPlugin::previewPage(QString key, int type, QWidget *parent = nullptr)
|
|
|
|
//{
|
|
|
|
// return nullptr;
|
|
|
|
//}
|
2021-07-08 18:53:16 +08:00
|
|
|
|
2021-07-31 16:12:04 +08:00
|
|
|
void SettingsSearchPlugin::initDetailPage()
|
|
|
|
{
|
|
|
|
m_detailPage = new QWidget();
|
|
|
|
m_detailPage->setFixedWidth(360);
|
|
|
|
m_detailPage->setAttribute(Qt::WA_TranslucentBackground);
|
|
|
|
m_detailLyt = new QVBoxLayout(m_detailPage);
|
|
|
|
m_detailLyt->setContentsMargins(8, 0, 16, 0);
|
|
|
|
m_iconLabel = new QLabel(m_detailPage);
|
|
|
|
m_iconLabel->setAlignment(Qt::AlignCenter);
|
|
|
|
m_iconLabel->setFixedHeight(128);
|
|
|
|
|
|
|
|
m_nameFrame = new QFrame(m_detailPage);
|
|
|
|
m_nameFrameLyt = new QHBoxLayout(m_nameFrame);
|
|
|
|
m_nameFrame->setLayout(m_nameFrameLyt);
|
|
|
|
m_nameFrameLyt->setContentsMargins(8, 0, 0, 0);
|
|
|
|
m_nameLabel = new QLabel(m_nameFrame);
|
|
|
|
m_nameLabel->setMaximumWidth(280);
|
|
|
|
m_pluginLabel = new QLabel(m_nameFrame);
|
|
|
|
m_pluginLabel->setText(tr("Settings"));
|
|
|
|
m_pluginLabel->setEnabled(false);
|
|
|
|
m_nameFrameLyt->addWidget(m_nameLabel);
|
|
|
|
m_nameFrameLyt->addStretch();
|
|
|
|
m_nameFrameLyt->addWidget(m_pluginLabel);
|
|
|
|
|
2021-12-09 13:57:19 +08:00
|
|
|
m_line_1 = new SeparationLine(m_detailPage);
|
2021-07-31 16:12:04 +08:00
|
|
|
|
|
|
|
m_actionFrame = new QFrame(m_detailPage);
|
|
|
|
m_actionFrameLyt = new QVBoxLayout(m_actionFrame);
|
|
|
|
m_actionFrameLyt->setContentsMargins(8, 0, 0, 0);
|
|
|
|
m_actionLabel1 = new ActionLabel(tr("Open"), m_currentActionKey, m_actionFrame);
|
|
|
|
|
|
|
|
m_actionFrameLyt->addWidget(m_actionLabel1);;
|
|
|
|
m_actionFrame->setLayout(m_actionFrameLyt);
|
|
|
|
|
|
|
|
m_detailLyt->addSpacing(50);
|
|
|
|
m_detailLyt->addWidget(m_iconLabel);
|
|
|
|
m_detailLyt->addWidget(m_nameFrame);
|
|
|
|
m_detailLyt->addWidget(m_line_1);
|
|
|
|
m_detailLyt->addWidget(m_actionFrame);
|
|
|
|
m_detailPage->setLayout(m_detailLyt);
|
|
|
|
m_detailLyt->addStretch();
|
|
|
|
|
|
|
|
connect(m_actionLabel1, &ActionLabel::actionTriggered, [ & ](){
|
|
|
|
openAction(0, m_currentActionKey, 0);
|
|
|
|
});
|
|
|
|
}
|
2021-11-30 17:21:06 +08:00
|
|
|
|
|
|
|
SettingsSearch::SettingsSearch(DataQueue<SearchPluginIface::ResultInfo> *searchResult, const QString &keyword, size_t uniqueSymbol)
|
|
|
|
{
|
|
|
|
this->setAutoDelete(true);
|
|
|
|
this->m_searchResult = searchResult;
|
|
|
|
this->m_keyword = keyword;
|
|
|
|
this->m_uniqueSymbol = uniqueSymbol;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsSearch::run()
|
|
|
|
{
|
|
|
|
SettingsMatch::getInstance()->startSearch(m_keyword, m_uniqueSymbol, m_searchResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
SettingsMatch *SettingsMatch::getInstance()
|
|
|
|
{
|
|
|
|
if (!settingMatchClass) {
|
|
|
|
settingMatchClass = new SettingsMatch;
|
|
|
|
}
|
|
|
|
return settingMatchClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsMatch::run()
|
|
|
|
{
|
2022-11-29 20:07:53 +08:00
|
|
|
// this->initDataOfXml();
|
|
|
|
this->initData();
|
|
|
|
}
|
|
|
|
|
|
|
|
SettingsMatch::SettingsMatch()
|
|
|
|
{
|
|
|
|
m_interface = new QDBusInterface("org.ukui.ukcc.session",
|
|
|
|
"/",
|
|
|
|
"org.ukui.ukcc.session.interface", QDBusConnection::sessionBus(), this);
|
|
|
|
if (m_interface->isValid()) {
|
|
|
|
connect(m_interface, SIGNAL(searchItemsAdd(QVariantMap)), this, SLOT(addItem(QVariantMap)));
|
|
|
|
connect(m_interface, SIGNAL(searchItemsDelete(QVariantMap)), this, SLOT(removeItem(QVariantMap)));
|
|
|
|
} else {
|
|
|
|
qCritical() << "Ukcc interface error:" << m_interface->lastError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief SettingsMatch::initData
|
|
|
|
* 将控制面板的dbus接口的设置项信息读到内存
|
|
|
|
*/
|
|
|
|
|
|
|
|
void SettingsMatch::initData()
|
|
|
|
{
|
|
|
|
QDBusReply<QVariantMap> reply = m_interface->call("getSearchItems");
|
|
|
|
if (reply.isValid()) {
|
|
|
|
this->parsingArgsOfDbus(reply.value(), HandleType::Add);
|
|
|
|
} else {
|
|
|
|
qWarning() << "Fail to call ukcc's getSearchItems.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsMatch::parsingArgsOfDbus(QVariantMap replyMap, HandleTypes type)
|
|
|
|
{
|
|
|
|
for (std::pair<QString, QVariant> it : replyMap.toStdMap()) {
|
|
|
|
const QDBusArgument &dbusArgs = it.second.value<QDBusArgument>();
|
|
|
|
dbusArgs.beginArray();
|
|
|
|
while (!dbusArgs.atEnd()) {
|
|
|
|
QVariant tmp;
|
|
|
|
dbusArgs >> tmp;
|
|
|
|
const QDBusArgument &args = tmp.value<QDBusArgument>();
|
|
|
|
QVariantMap itemInfo;
|
|
|
|
args >> itemInfo;
|
|
|
|
this->handleData(itemInfo, type);
|
|
|
|
}
|
|
|
|
dbusArgs.endArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsMatch::handleData(const QVariantMap &itemInfo, HandleTypes type)
|
|
|
|
{
|
|
|
|
QString enNameOfModule = itemInfo.value("superordinate").toString();
|
|
|
|
QString enNameOfPlugin = itemInfo.value("plugin").toString();
|
|
|
|
QString enNameOfFunc = itemInfo.value("subEnglish").toString();
|
|
|
|
|
|
|
|
QString dataKey= enNameOfModule + "/" + enNameOfPlugin;
|
|
|
|
QString localName = itemInfo.value("plugin" + QLocale::system().name()).toString();
|
|
|
|
QStringList englishSearchResult = m_searchMap[enNameOfModule].value(enNameOfPlugin);
|
|
|
|
|
|
|
|
if (type == HandleType::Add) {
|
|
|
|
englishSearchResult.append(enNameOfFunc);
|
|
|
|
//二级目录
|
|
|
|
this->add2DataMap(dataKey, enNameOfPlugin, localName);
|
|
|
|
//三级目录
|
|
|
|
dataKey = dataKey + "/" + enNameOfFunc;
|
|
|
|
localName = itemInfo.value("sub" + QLocale::system().name()).toString();
|
|
|
|
this->add2DataMap(dataKey, enNameOfFunc, localName);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == HandleType::Delete) {
|
|
|
|
englishSearchResult.removeOne(enNameOfFunc);
|
|
|
|
m_dataMap.remove(dataKey + "/" + enNameOfFunc);
|
|
|
|
if (englishSearchResult.isEmpty()) {
|
|
|
|
m_dataMap.remove(dataKey);
|
|
|
|
m_searchMap[enNameOfModule].remove(enNameOfPlugin);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//update searchMap
|
|
|
|
m_searchMap[enNameOfModule].insert(enNameOfPlugin, englishSearchResult);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsMatch::add2DataMap(const QString &key, const QString &enName, const QString &localName)
|
|
|
|
{
|
|
|
|
if (m_dataMap.contains(key)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList aItemInfo{enName, localName};
|
|
|
|
if (QLocale::system().language() == QLocale::Chinese) {
|
|
|
|
aItemInfo << FileUtils::findMultiToneWords(localName);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_dataMap.insert(key, aItemInfo);
|
2021-11-30 17:21:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief SettingsMatch::initDataOfXml
|
|
|
|
* 将xml文件内容读到内存
|
|
|
|
*/
|
|
|
|
|
|
|
|
void SettingsMatch::initDataOfXml(){
|
|
|
|
QFile file(QString::fromLocal8Bit("/usr/share/ukui-control-center/shell/res/search.xml"));//xml文件所在路径
|
|
|
|
if(!file.open(QIODevice::ReadOnly)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QDomDocument doc;
|
|
|
|
doc.setContent(&file);
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
QDomElement root = doc.documentElement();
|
|
|
|
QDomNode node = root.previousSibling();
|
|
|
|
node = root.firstChild();
|
|
|
|
matchNodes(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SettingsMatch::matchCommonEnvironment(QDomNode childNode)
|
|
|
|
{
|
|
|
|
if (childNode.nodeName() == QString::fromLocal8Bit("Environment")) {
|
|
|
|
QString environment = QProcessEnvironment::systemEnvironment().value("XDG_SESSION_TYPE");
|
|
|
|
QString version = childNode.toElement().text();
|
|
|
|
if ((version == "v101" && environment == "wayland")
|
|
|
|
|| (version == "hw990" && environment == "x11")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsMatch::matchNodes(QDomNode node){
|
|
|
|
QString chineseIndex;
|
|
|
|
QString englishIndex;
|
|
|
|
QStringList englishSearchResult;
|
|
|
|
|
|
|
|
while (!node.isNull()) {
|
|
|
|
QDomElement element = node.toElement();
|
|
|
|
QDomNodeList list = element.childNodes();
|
|
|
|
|
|
|
|
QString enNameOfModule = element.attribute("name");
|
|
|
|
QString enNameOfPlugin = list.at(0).nextSiblingElement("EnglishFunc1").toElement().text();
|
|
|
|
QString enNameOfFunc = list.at(0).nextSiblingElement("EnglishFunc2").toElement().text();
|
|
|
|
|
|
|
|
englishSearchResult = m_searchMap[enNameOfModule].value(enNameOfPlugin);
|
|
|
|
|
|
|
|
for (int i = 0; i < list.count(); ++i) {
|
|
|
|
QDomNode childNode = list.at(i);
|
|
|
|
QStringList aItemInfo;
|
|
|
|
|
|
|
|
chineseIndex = childNode.toElement().text();
|
|
|
|
|
|
|
|
if (!matchCommonEnvironment(childNode)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//TODO: Refactoring this part of code.
|
|
|
|
if (childNode.nodeName() == QString::fromLocal8Bit("ChinesePlugin")) {
|
|
|
|
englishIndex = enNameOfModule;
|
|
|
|
aItemInfo << englishIndex << chineseIndex << FileUtils::findMultiToneWords(chineseIndex);
|
|
|
|
m_dataMap.insert(enNameOfModule, aItemInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (childNode.nodeName() == QString::fromLocal8Bit("ChineseFunc1")) {
|
|
|
|
englishIndex = enNameOfPlugin;
|
|
|
|
aItemInfo << englishIndex << chineseIndex << FileUtils::findMultiToneWords(chineseIndex);
|
|
|
|
m_dataMap.insert(enNameOfModule + "/" + enNameOfPlugin, aItemInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (childNode.nodeName() == QString::fromLocal8Bit("ChineseFunc2")) {
|
|
|
|
englishIndex = enNameOfFunc;
|
|
|
|
englishSearchResult.append(englishIndex);
|
|
|
|
aItemInfo << englishIndex << chineseIndex << FileUtils::findMultiToneWords(chineseIndex);
|
|
|
|
m_dataMap.insert(enNameOfModule + "/" + enNameOfPlugin+ "/" + englishIndex, aItemInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_searchMap[enNameOfModule].insert(enNameOfPlugin, englishSearchResult);
|
|
|
|
node = node.nextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsMatch::startSearch(QString &keyword, size_t uniqueSymbol, DataQueue<SearchPluginIface::ResultInfo> *searchResult)
|
|
|
|
{
|
|
|
|
if (keyword == "/") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//根据searchMap的对应关系匹配dataMap中的数据信息
|
|
|
|
for (auto i = m_searchMap.constBegin(); i != m_searchMap.constEnd(); ++i) {
|
|
|
|
QMap<QString, QStringList> regMatch = *i;
|
|
|
|
QString moduleName = i.key();
|
|
|
|
for (auto t = regMatch.begin(); t != regMatch.end(); ++t) {
|
|
|
|
//匹配二级菜单信息
|
|
|
|
QString pluginName = t.key();
|
|
|
|
QString keyOfSecondLv =QString("%1/%2").arg(moduleName, pluginName);
|
|
|
|
matchDataMap(keyOfSecondLv, keyword, uniqueSymbol, searchResult);
|
|
|
|
//匹配对应三级菜单信息
|
|
|
|
for (QString funcName: t.value()) {
|
|
|
|
QString keyOfThirdLv = keyOfSecondLv + QString("/%1").arg(funcName);
|
|
|
|
matchDataMap(keyOfThirdLv, keyword, uniqueSymbol, searchResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-29 20:07:53 +08:00
|
|
|
void SettingsMatch::addItem(QVariantMap replyMap)
|
|
|
|
{
|
|
|
|
this->parsingArgsOfDbus(replyMap, HandleType::Add);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsMatch::removeItem(QVariantMap replyMap)
|
|
|
|
{
|
|
|
|
this->parsingArgsOfDbus(replyMap, HandleType::Delete);
|
|
|
|
}
|
|
|
|
|
2021-11-30 17:21:06 +08:00
|
|
|
void SettingsMatch::matchDataMap(QString &key, QString &keyword, size_t uniqueSymbol, DataQueue<SearchPluginIface::ResultInfo> *searchResult)
|
|
|
|
{
|
|
|
|
SearchPluginIface::ResultInfo resultInfo;
|
|
|
|
resultInfo.type = 0;
|
|
|
|
for (int counter = 0; counter < m_dataMap.value(key).size(); ++counter) {
|
|
|
|
QString data = m_dataMap.value(key).at(counter);
|
|
|
|
//关键字为单字不搜拼音
|
|
|
|
if (keyword.size() < 2 and counter > 1 and counter % 2 == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (data.contains(keyword, Qt::CaseInsensitive)) {
|
|
|
|
createResultInfo(resultInfo, m_dataMap.value(key), key);
|
|
|
|
//判断是否为同一次搜索
|
2021-12-28 14:56:41 +08:00
|
|
|
SettingsSearchPlugin::m_mutex.lock();
|
2021-11-30 17:21:06 +08:00
|
|
|
if (uniqueSymbol == SettingsSearchPlugin::m_uniqueSymbolForSettings) {
|
|
|
|
searchResult->enqueue(resultInfo);
|
|
|
|
SettingsSearchPlugin::m_mutex.unlock();
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
SettingsSearchPlugin::m_mutex.unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsMatch::createResultInfo(SearchPluginIface::ResultInfo &resultInfo, const QStringList &itemInfo, const QString &path)
|
|
|
|
{
|
|
|
|
QLocale ql;
|
|
|
|
resultInfo.name = ql.language() == QLocale::English ? itemInfo.at(0) : itemInfo.at(1);
|
|
|
|
resultInfo.icon = FileUtils::getSettingIcon();
|
|
|
|
resultInfo.actionKey = path.section("/", 1, 1);
|
|
|
|
}
|