fix(search):修复搜索状态下,应用右键菜单始终为添加到收藏的问题

This commit is contained in:
qiqi49 2024-09-11 17:53:21 +08:00
parent f0396447a7
commit bb6861fd2f
1 changed files with 6 additions and 8 deletions

View File

@ -19,6 +19,7 @@
*/ */
#include "app-search-plugin.h" #include "app-search-plugin.h"
#include "data-entity.h" #include "data-entity.h"
#include "basic-app-model.h"
#include <UkuiSearchTask> #include <UkuiSearchTask>
#include <QThread> #include <QThread>
@ -60,9 +61,7 @@ AppSearchPluginPrivate::AppSearchPluginPrivate(QObject *parent) : QThread(parent
m_appSearchTask->setSearchOnlineApps(false); m_appSearchTask->setSearchOnlineApps(false);
UkuiSearch::SearchResultProperties searchResultProperties; UkuiSearch::SearchResultProperties searchResultProperties;
searchResultProperties << UkuiSearch::SearchProperty::SearchResultProperty::ApplicationDesktopPath searchResultProperties << UkuiSearch::SearchProperty::SearchResultProperty::ApplicationDesktopPath;
<< UkuiSearch::SearchProperty::SearchResultProperty::ApplicationLocalName
<< UkuiSearch::SearchProperty::SearchResultProperty::ApplicationIconName;
m_appSearchTask->setResultProperties(UkuiSearch::SearchProperty::SearchType::Application, searchResultProperties); m_appSearchTask->setResultProperties(UkuiSearch::SearchProperty::SearchType::Application, searchResultProperties);
m_timer = new QTimer; m_timer = new QTimer;
@ -101,11 +100,10 @@ void AppSearchPluginPrivate::run()
m_timer->stop(); m_timer->stop();
if (result.getSearchId() == m_searchId) { if (result.getSearchId() == m_searchId) {
DataEntity app; DataEntity app;
app.setType(DataType::Normal); QString id = result.getValue(UkuiSearch::SearchProperty::ApplicationDesktopPath).toString();
app.setId(result.getValue(UkuiSearch::SearchProperty::ApplicationDesktopPath).toString()); if (!BasicAppModel::instance()->getAppById(id, app)) {
app.setName(result.getValue(UkuiSearch::SearchProperty::ApplicationLocalName).toString()); BasicAppModel::instance()->databaseInterface()->getApp(id, app);
app.setIcon(result.getValue(UkuiSearch::SearchProperty::ApplicationIconName).toString()); };
Q_EMIT this->searchedOne(app); Q_EMIT this->searchedOne(app);
} }
} }